:root {
    --bg-dark: #020617;
    --card-bg: rgba(15, 23, 42, 0.8);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    /* System Colors */
    --accent-p: #f43f5e; /* 社会 - Rose */
    --accent-r: #3b82f6; /* 経済 - Blue */
    --accent-l: #10b981; /* 環境 - Emerald */
    --accent-c: #8b5cf6; /* 外交 - Violet */
    --accent-t: #f59e0b; /* 技術 - Amber */
    
    /* Rarity Glows */
    --rarity-n: #64748b;
    --rarity-r: #0ea5e9;
    --rarity-sr: #f59e0b;
    --rarity-ur: #d946ef;
    --rarity-lr: #8b5cf6;
    
    /* Gradients */
    --lr-gradient: linear-gradient(45deg, #f06, #9f6, #06f, #f06);
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 0% 100%, rgba(244, 63, 94, 0.05) 0%, transparent 50%);
    color: var(--text-primary);
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    margin: 0;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(12px);
    overflow-y: auto;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: #0f172a;
    margin: 5vh auto;
    padding: 3rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: 85%;
    max-width: 1100px;
    height: auto;
    max-height: 85vh;
    border-radius: 24px;
    position: relative;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    transform: scale(0.95);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
    to { transform: scale(1); opacity: 1; }
}

.close-button {
    position: absolute;
    right: 2rem;
    top: 1.5rem;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 300;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    line-height: 1;
}

.close-button:hover {
    background: rgba(244, 63, 94, 0.2);
    color: var(--accent-p);
    transform: rotate(90deg);
}

header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    padding: 1.5rem 3rem;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.logo h1 {
    margin: 0;
    font-weight: 900;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2.5rem;
    padding: 3rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Card Style */
.card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 1.25rem;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    min-height: 480px;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.7);
}

/* Rarity Specific Card Frames */
.card.rarity-n { border-color: rgba(100, 116, 139, 0.2); }
.card.rarity-r { border-color: rgba(14, 165, 233, 0.4); box-shadow: 0 0 15px rgba(14, 165, 233, 0.1); }
.card.rarity-sr { border-color: rgba(245, 158, 11, 0.6); box-shadow: 0 0 20px rgba(245, 158, 11, 0.2); }
.card.rarity-ur { border-color: rgba(217, 70, 239, 0.8); box-shadow: 0 0 25px rgba(217, 70, 239, 0.3); }
.card.rarity-lr { 
    border-width: 2px;
    border-style: solid;
    border-image: var(--lr-gradient) 1;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.4);
    animation: border-flow 3s linear infinite;
}

@keyframes border-flow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

.card-image-area {
    width: 100%;
    height: 240px;
    background: #0f172a;
    border-radius: 14px;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-size: cover;
    background-position: center;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    cursor: pointer;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.card-image-area:hover {
    filter: brightness(1.2);
}

/* Rarity Badges */
.card-rarity {
    position: absolute;
    top: -12px;
    right: -12px;
    font-weight: 800;
    font-size: 1.2rem;
    z-index: 10;
    padding: 4px 12px;
    border-radius: 8px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    transform: rotate(5deg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.card-rarity.rarity-n { background: #475569; border: 1px solid #64748b; }
.card-rarity.rarity-r { background: linear-gradient(135deg, #0ea5e9, #0284c7); border: 1px solid #38bdf8; }
.card-rarity.rarity-sr { background: linear-gradient(135deg, #f59e0b, #d97706); border: 1px solid #fbbf24; }
.card-rarity.rarity-ur { background: linear-gradient(135deg, #d946ef, #c026d3); border: 1px solid #f5d0fe; }
.card-rarity.rarity-lr { 
    background: var(--lr-gradient);
    background-size: 200% 200%;
    border: 1px solid #fff;
    animation: rainbow 3s linear infinite, glow-lr 2s infinite alternate;
}

@keyframes rainbow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes glow-lr {
    from { filter: drop-shadow(0 0 2px var(--rarity-lr)); }
    to { filter: drop-shadow(0 0 15px var(--rarity-lr)); }
}

/* Card Meta - 新形式表示用 */
.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.card-no-badge {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.05);
}

.card-type-badge {
    padding: 2px 10px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 100px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 700;
    border: 1px solid rgba(255,255,255,0.1);
}

.card-name {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: #fff;
    letter-spacing: -0.02em;
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    flex-grow: 1;
    white-space: pre-wrap;
    background: rgba(0,0,0,0.2);
    padding: 0.75rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.card-cost {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--accent-r);
}

.stat {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
}

/* Modal Details */
.card-detail-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 3.5rem;
    align-items: start;
}

.detail-image {
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: transform 0.3s ease;
}

.detail-prompt {
    font-family: 'Fira Code', monospace;
    background: #020617;
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 1.5rem;
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Edit UI Styles */
.edit-input, .edit-textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
    box-sizing: border-box;
    margin-top: 0.4rem;
}

.edit-input:focus, .edit-textarea:focus {
    border-color: var(--accent-r);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.edit-textarea {
    resize: none;
}

.btn-action, .btn-save, .btn-cancel, .btn-delete, .btn-gemini {
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 0.9rem;
}

.btn-save { background: var(--accent-r); color: #fff; }
.btn-save:hover { background: #2563eb; transform: translateY(-2px); box-shadow: 0 5px 15px rgba(37, 99, 235, 0.4); }

.btn-cancel { background: rgba(255,255,255,0.05); color: var(--text-secondary); }
.btn-cancel:hover { background: rgba(255,255,255,0.1); color: #fff; }

.btn-delete { background: rgba(244, 63, 94, 0.1); color: var(--accent-p); border: 1px solid rgba(244, 63, 94, 0.2); }
.btn-delete:hover { background: var(--accent-p); color: #fff; }

.btn-gemini { 
    background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%); 
    color: #fff;
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
}
.btn-gemini:hover { transform: scale(1.05); box-shadow: 0 0 15px rgba(139, 92, 246, 0.4); }

.btn-action { background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.1); }
.btn-action:hover { background: rgba(255,255,255,0.2); }

/* Search Area */
.search-bar {
    background: rgba(15, 23, 42, 0.5) !important;
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}