/* ============================================================
   KÓDEM TCG — THEME SYSTEM
   Dark mode (default): Cosmic Night — deep indigo-blacks
   Light mode:          Ancient Parchment — warm cream tones
   Toggle: data-theme="light" on <html>
   ============================================================ */

:root {
    /* ---- Surfaces (Dark: Cosmic Night) ---- */
    --bg-darker: #0c0d10;
    --bg-dark:   #131520;
    --bg-card:   #1c1f2e;
    --bg-hover:  #252840;

    /* ---- Text ---- */
    --text-primary:   #e8e8ef;
    --text-secondary: #8b8fa8;

    /* ---- Borders ---- */
    --border: #2e3147;

    /* ---- Brand Accents (same in both modes) ---- */
    --accent-amber:   #f59e0b;
    --accent-teal:    #14b8a6;
    --accent-crimson: #dc2626;

    /* ---- Semantic ---- */
    --success: #10b981;
    --warning: #f59e0b;
    --danger:  #ef4444;

    /* ---- Theme toggle icon ---- */
    --theme-toggle-icon: "🌙";

    /* ---- Energy colors (same in both modes — they're identity colors) ---- */
    --atlica:    #3b82f6;
    --pirica:    #ef4444;
    --gelida:    #06b6d4;
    --litica:    #b45309;
    --chaaktica: #eab308;
    --huumica:   #a855f7;
    --demotica:  #9ca3af;
    --feral:     #22c55e;

    /* ---- Energy RGB values for rgba() glow effects ---- */
    --atlica-rgb:    59, 130, 246;
    --pirica-rgb:    239, 68, 68;
    --gelida-rgb:    6, 182, 212;
    --litica-rgb:    180, 83, 9;
    --chaaktica-rgb: 234, 179, 8;
    --huumica-rgb:   168, 85, 247;
    --demotica-rgb:  156, 163, 175;
    --feral-rgb:     34, 197, 94;
    --default-rgb:   245, 158, 11;
}

/* ============================================================
   LIGHT MODE — Ancient Parchment
   ============================================================ */
[data-theme="light"] {
    /* ---- Surfaces ---- */
    --bg-darker: #f0ede8;
    --bg-dark:   #e8e4dc;
    --bg-card:   #faf9f7;
    --bg-hover:  #ede9e0;

    /* ---- Text ---- */
    --text-primary:   #1a1820;
    --text-secondary: #5a566b;

    /* ---- Borders ---- */
    --border: #d4cfc4;

    /* ---- Accents stay the same (brand identity) ---- */
    --accent-amber:   #d97706;
    --accent-teal:    #0d9488;
    --accent-crimson: #b91c1c;

    /* ---- Semantic ---- */
    --success: #059669;
    --warning: #d97706;
    --danger:  #dc2626;

    --theme-toggle-icon: "☀️";
}

/* Smooth theme transitions - scoped to transitioning class to avoid perf issues */
.theme-transitioning, .theme-transitioning *, .theme-transitioning *::before, .theme-transitioning *::after {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* Override the broad transition above to not affect transforms (perf) */
.card-item,
.nav-btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.modal-nav-btn {
    transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================================
   THEME TOGGLE BUTTON
   ============================================================ */
#theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    border-radius: 6px;
    font-size: 1.1rem;
    min-height: 36px;
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

#theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--accent-amber);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.25);
}

/* Light mode adjustments for selects/inputs */
[data-theme="light"] input[type="text"],
[data-theme="light"] select {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border);
}

[data-theme="light"] .stats-bar {
    background: var(--bg-card);
    color: var(--text-primary);
}

[data-theme="light"] .sort-by-select {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

/* Inline style override for sort select in light mode */
[data-theme="light"] #sort-by {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

/* Grid size buttons in light mode */
[data-theme="light"] .grid-size-btn {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

[data-theme="light"] .grid-size-btn:hover,
[data-theme="light"] .grid-size-btn.active {
    background: var(--accent-amber) !important;
    color: white !important;
    border-color: var(--accent-amber) !important;
}

/* Sync modal in light mode */
[data-theme="light"] .sync-modal {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Footer */
.site-footer {
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

/* Card image background in light mode */
[data-theme="light"] .card-item img {
    background: var(--bg-hover);
}

/* Modal backdrop in light mode */
[data-theme="light"] .modal {
    background: rgba(0, 0, 0, 0.65);
}

/* Body background uses var(--bg-darker) — already set in main body rule */

body {
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    background: var(--bg-darker);
    color: var(--text-primary);
    line-height: 1.6;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

header {
    background: var(--bg-dark);
    border-bottom: 3px solid var(--accent-amber);
    box-shadow: 0 2px 16px rgba(245, 158, 11, 0.15);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent-amber);
    font-family: 'Cinzel', 'Times New Roman', serif;
}

nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-family: 'Cinzel', 'Times New Roman', serif;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--accent-amber);
    color: var(--bg-dark);
    border-color: var(--accent-amber);
    border-bottom: 3px solid #d97706;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

main {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

input[type="text"],
select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

input[type="text"] {
    flex: 1;
    min-width: 200px;
}

select {
    min-width: 150px;
}

:focus-visible {
    outline: 2px solid var(--accent-amber);
    outline-offset: 2px;
}

input[type="text"]:focus,
select:focus {
    border-color: var(--accent-teal);
}

.stats-bar {
    background: var(--bg-card);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    border-left: 3px solid var(--accent-teal);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.card-grid.small, .card-grid.grid-small {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
}
.card-grid.grid-medium {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}
.card-grid.grid-large {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.card-item {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.card-item:hover {
    transform: translateY(-2px);
    border-color: var(--card-energy-color, var(--accent-amber));
    box-shadow: 0 4px 20px rgba(var(--card-energy-rgb, var(--default-rgb)), 0.3),
                0 8px 16px rgba(0, 0, 0, 0.4);
}

/* Rarity-tinted card borders */
.card-item[data-rarity="Comun"]             { border-left: 3px solid #9ca3af; }  /* gray */
.card-item[data-rarity="Poco Comun"]        { border-left: 3px solid #22c55e; }  /* green */
.card-item[data-rarity="Rara"]              { border-left: 3px solid #60a5fa; }  /* blue */
.card-item[data-rarity="Super Rara"]        { border-left: 3px solid #a78bfa; }  /* purple */
.card-item[data-rarity="Ultra Rara"]        { border-left: 3px solid #f59e0b; }  /* orange */
.card-item[data-rarity="Kosmica/Titanica"]  { border-left: 3px solid #f97316; }  /* deep orange */
.card-item[data-rarity="Secreta"]           { border-left: 3px solid #ec4899; }  /* pink */
.card-item[data-rarity="Full Art"]          { border-left: 3px solid #34d399; }  /* emerald */
.card-item[data-rarity="Evento"]            { border-left: 3px solid #facc15; }  /* yellow */

/* Owned button on card grid */
.card-owned-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
    opacity: 0.4;
}

.card-item:hover .card-owned-btn {
    opacity: 0.7;
}

.card-owned-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.card-owned-btn.active {
    opacity: 1;
    background: rgba(220, 38, 38, 0.75);
    color: white;
}

.card-item.in-deck::before {
    content: '✓';
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: var(--accent-teal);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    z-index: 1;
}

.card-item img {
    width: 100%;
    height: auto;
    display: block;
    background: #333;
}

.card-item .card-name {
    padding: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: 'Cinzel', 'Times New Roman', serif;
    text-align: center;
    border-top: 1px solid var(--border);
}

.collection-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    border: 2px solid var(--border);
}

.stat-card h3 {
    font-size: 2rem;
    color: var(--accent-amber);
    margin-bottom: 0.25rem;
}

.stat-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stats-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.stats-grid .stat-item {
    background: var(--bg-darker);
    padding: 0.75rem;
    border-radius: 4px;
    border-left: 3px solid var(--accent-teal);
}

.stats-grid .stat-item strong {
    display: block;
    margin-bottom: 0.25rem;
}

.deck-builder-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto auto;
    grid-template-areas:
        "sidebar workspace"
        "pool pool";
    gap: 1rem;
    min-height: 80vh;
    max-width: 100%;
    overflow-x: hidden;
}

.deck-list-sidebar { grid-area: sidebar; }
.deck-workspace { grid-area: workspace; }
.card-pool { grid-area: pool; }

.deck-list-sidebar {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid var(--border);
}

.deck-list-sidebar h3 {
    margin-bottom: 1rem;
    color: var(--accent-amber);
    font-family: 'Cinzel', 'Times New Roman', serif;
}

#saved-decks {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.deck-item {
    background: var(--bg-darker);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.deck-item-name {
    flex: 1;
    font-size: 0.85rem;
}

.deck-item-arrows {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.deck-order-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 22px;
    height: 20px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.55rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.deck-order-btn:hover:not(:disabled) {
    border-color: var(--accent-amber);
    color: var(--accent-amber);
}
.deck-order-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.deck-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-teal);
}

.deck-item.active {
    border-color: var(--accent-amber);
    background: var(--bg-hover);
}

.deck-workspace {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 8px;
    border: 2px solid var(--border);
}

.deck-header {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.deck-header input {
    flex: 1;
}

.deck-actions {
    display: flex;
    gap: 0.5rem;
}

.deck-validation {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-darker);
    border-radius: 4px;
}

.validation-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.validation-item.valid {
    color: var(--success);
}

.validation-item.invalid {
    color: var(--danger);
}

.validation-item .label {
    font-weight: 600;
}

.validation-item .count {
    color: var(--accent-amber);
    font-weight: bold;
}

.validation-item .requirement {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.deck-stats {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-darker);
    border-radius: 4px;
}

.deck-stats .stat strong {
    display: block;
    margin-bottom: 0.25rem;
}

#energy-distribution {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.energy-badge {
    background: var(--bg-card);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.deck-content {
    background: var(--bg-darker);
    border-radius: 4px;
    padding: 1rem;
    min-height: 300px;
}

.deck-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Tercia grid layout */
.deck-section-label {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--accent-amber);
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.deck-section-label:hover {
    background: var(--bg-hover, #1a1a2e);
}
.collapse-icon {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: auto;
    transition: transform 0.2s;
}
.deck-section-count {
    font-weight: normal;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 6px;
}

.tercia-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tercia-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: visible;
}

.tercia-label {
    display: none; /* replaced by tercia-header */
}

.tercia-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    min-width: 28px;
    gap: 2px;
    user-select: none;
    padding: 4px 2px;
    border-radius: 6px;
    transition: background 0.15s;
}
.tercia-header:hover {
    background: var(--bg-hover, #1a1a2e);
}

.tercia-label-text {
    font-size: 0.6rem;
    font-weight: bold;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.tercia-collapse-icon {
    font-size: 0.55rem;
    color: var(--text-secondary);
}

.tercia-body {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 8px;
}

.tercia-cards-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    flex: 1;
}
.tercia-cards-row .card-item {
    width: 100%;
    min-width: 0;
}

.tercia-card-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.card-reorder-btns {
    display: flex;
    gap: 2px;
}

.reorder-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 24px;
    height: 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.reorder-btn:hover:not(:disabled) {
    border-color: var(--accent-amber);
    color: var(--accent-amber);
}
.reorder-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.tercia-row-btns {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tercia-move-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.tercia-move-btn:hover:not(:disabled) {
    border-color: var(--accent-amber);
    background: var(--accent-amber)11;
}
.tercia-move-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

/* Support grid (Protector, Bio, Equips) — always 3 columns */
.support-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 50%;
}
.support-grid .card-item {
    width: 100%;
    min-width: 0;
}

/* ── Mobile overrides for tercia layout ── */
@media (max-width: 768px) {
    /* Tercia on mobile: compact everything */
    .tercia-header {
        min-width: 20px;
        padding: 2px 1px;
    }
    .tercia-label-text {
        font-size: 0.5rem;
    }

    .tercia-row {
        padding: 6px 4px;
        gap: 4px;
    }

    .tercia-body {
        gap: 4px;
    }

    .tercia-cards-row {
        gap: 4px;
    }

    .tercia-card-slot {
        gap: 2px;
    }

    .card-reorder-btns {
        gap: 1px;
    }

    .reorder-btn {
        width: 28px;
        height: 24px;
        font-size: 0.65rem;
    }

    .tercia-row-btns {
        gap: 2px;
    }

    .tercia-move-btn {
        width: 28px;
        height: 28px;
        font-size: 0.6rem;
    }

    /* Move tercia buttons below cards instead of right side */
    .tercia-body {
        flex-wrap: wrap;
    }
    .tercia-row-btns {
        flex-direction: row;
        width: 100%;
        justify-content: center;
    }

    /* Larger tap targets for reorder buttons */
    .reorder-btn {
        width: 44px;
        height: 44px;
        font-size: 0.85rem;
    }
    .tercia-move-btn {
        width: 44px;
        height: 44px;
    }

    /* Support grid: 3 columns filling full width on mobile */
    .support-grid {
        max-width: 100%;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
}

.support-type-badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    font-size: 0.7rem;
    background: rgba(0,0,0,0.7);
    border-radius: 4px;
    padding: 1px 4px;
}

.empty-state {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

/* Empty state for card grid — shown when no cards match filters */
.card-grid-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
    font-size: 1rem;
    gap: 0.5rem;
}

.card-grid-empty .empty-icon {
    font-size: 2.5rem;
    opacity: 0.7;
}

.card-grid-empty .empty-msg {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.card-grid-empty .empty-hint {
    font-size: 0.8rem;
    opacity: 0.6;
}

.card-pool {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid var(--border);
    overflow-y: auto;
    max-height: 70vh;
    position: relative;
}

.card-pool > .controls {
    position: sticky;
    top: 28px;
    z-index: 10;
    background: var(--bg-card);
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.card-pool h3 {
    margin-bottom: 0.5rem;
    color: var(--accent-teal);
    font-family: 'Cinzel', 'Times New Roman', serif;
    position: sticky;
    top: 0;
    z-index: 11;
    background: var(--bg-card);
    padding: 4px 0 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pool-filter-icon {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: system-ui, sans-serif;
    font-weight: normal;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-amber);
    color: #000;
}

.btn-primary:hover {
    background: #d97706;
}

.btn-secondary {
    background: var(--accent-teal);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--accent-teal);
    filter: brightness(0.85);
}

.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    max-width: 900px;
    width: 100%;
    position: relative;
    border: 2px solid var(--accent-amber);
    border-left-width: 5px;
    animation: modalSlideIn 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
}

@keyframes modalSlideIn {
    from { transform: translateY(-12px) scale(0.98); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--bg-darker);
    border: none;
    color: var(--text-primary);
    font-size: 1.6rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--accent-crimson);
    color: white;
}

/* ---- Modal actions + navigation rows ---- */
.modal-actions-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.modal-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.modal-nav-inline {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    flex-shrink: 0;
}

.modal-nav-inline:hover:not(:disabled) {
    background: var(--accent-amber);
    color: var(--bg-dark);
    border-color: var(--accent-amber);
}

.modal-nav-inline:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.modal-actions-row .btn-primary,
.modal-actions-row .btn-want {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
    padding: 8px 12px;
}

/* Legacy nav (hidden, replaced by inline) */
.modal-nav-btn {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.6);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.4rem;
    width: 40px;
    height: 56px;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s, color 0.2s;
    align-items: center;
    justify-content: center;
}

.modal-nav-prev {
    left: 10px;
    border-radius: 8px;
}

.modal-nav-next {
    right: 10px;
    border-radius: 8px;
}

.modal-nav-btn:hover:not(:disabled) {
    background: var(--accent-amber);
    color: var(--bg-dark);
}

.modal-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.modal-body {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
    padding: 1.75rem;
}

/* ---- Modal image section ---- */
.modal-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

/* Mobile nav arrows on image */
.modal-arrow {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    font-size: 2rem;
    width: 36px;
    height: 60px;
    cursor: pointer;
    z-index: 10;
    border-radius: 6px;
    transition: background 0.2s;
}

.modal-arrow:hover,
.modal-arrow:active {
    background: rgba(245, 158, 11, 0.8);
}

.modal-arrow:disabled {
    opacity: 0.2;
    pointer-events: none;
}

.modal-arrow-left { left: -4px; }
.modal-arrow-right { right: -4px; }

@media (max-width: 768px) {
    .modal-arrow { display: flex; align-items: center; justify-content: center; }
    .modal-nav-row { display: none; }
}

.modal-image img {
    width: 300px;
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 2px solid var(--border);
    box-shadow: 0 0 20px color-mix(in srgb, var(--modal-energy-color, var(--accent-amber)) 40%, transparent);
    transition: box-shadow 0.3s ease;
}

/* ---- Modal info section ---- */
.modal-info {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 80vh;
    min-width: 0;
}

.modal-info h2 {
    color: var(--accent-amber);
    font-size: 1.35rem;
    font-family: 'Cinzel', 'Times New Roman', serif;
    line-height: 1.3;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.modal-type,
.modal-energy,
.modal-species,
.modal-artist {
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.modal-type strong,
.modal-energy strong,
.modal-species strong,
.modal-artist strong {
    color: var(--text-primary);
}

.modal-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 1rem;
}

.modal-stats strong {
    color: var(--text-primary);
}

/* ---- Effect box ---- */
.modal-effect {
    background: var(--bg-darker);
    padding: 0.9rem 1rem;
    border-radius: 6px;
    border-left: 3px solid var(--accent-teal);
}

.modal-effect strong {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#modal-effect-text {
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--text-primary);
    margin: 0;
}

.modal-cost {
    background: rgba(245, 158, 11, 0.08);
    padding: 0.7rem 1rem;
    border-radius: 6px;
    border-left: 3px solid var(--accent-amber);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    line-height: 1.55;
}
.modal-cost strong {
    color: #f59e0b;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- Colored effect keywords ---- */
.effect-keyword {
    font-weight: 700;
}

.modal-flavor {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.88rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
}

@media (max-width: 1200px) {
    .deck-builder-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "sidebar"
            "workspace"
            "pool";
    }

    .deck-list-sidebar {
        max-height: 300px;
        overflow-y: auto;
    }
    .card-pool {
        max-height: 50vh;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    main {
        padding: 0.75rem;
    }

    header {
        padding: 0.5rem 0.75rem;
    }

    header h1 {
        font-size: 1rem;
    }

    /* Compact nav: 4 buttons in a row */
    header nav {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
        width: 100%;
    }

    .nav-btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
        min-height: 44px;
        justify-content: center;
        text-align: center;
    }

    /* Collapsible filters */
    .controls {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .controls select,
    .controls input[type="text"] {
        min-height: 44px;
        padding: 6px 10px;
        font-size: 0.8rem;
        flex: 1 1 48%;
    }

    .controls input[type="text"] {
        flex: 1 1 100%;
    }

    /* Compact buttons in collection */
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        min-height: 36px;
        padding: 6px 10px;
        font-size: 0.75rem;
        flex: 1 1 auto;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.5rem;
    }

    /* Modal: single column on mobile */
    .modal-content {
        max-width: 100%;
        margin: 0;
        max-height: none;
        border-radius: 0;
        border: none;
        border-left: 4px solid var(--accent-amber);
        min-height: 100%;
    }

    .modal-body {
        grid-template-columns: 1fr;
        padding: 1.25rem;
    }

    .modal-image img {
        width: 220px;
        margin: 0 auto;
    }

    /* Nav buttons: inside modal on mobile */
    .modal-nav-prev,
    .modal-nav-next {
        position: static;
        transform: none;
        border-radius: 8px;
        min-height: 44px;
        min-width: 60px;
    }

    .modal-nav-container {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem 1rem 1.5rem;
        gap: 1rem;
    }

    .modal.active {
        padding: 0;
        align-items: flex-start;
    }

    .modal-close {
        position: sticky;
        top: 0;
        right: 0;
        z-index: 20;
        margin-left: auto;
        margin-right: 0.5rem;
        margin-top: 0.5rem;
        width: 44px;
        height: 44px;
        font-size: 1.8rem;
    }

    .modal-image img {
        width: 240px;
    }

    .deck-stats {
        grid-template-columns: 1fr;
    }
}

/* Remove-from-deck button — always on top and tappable */
.remove-from-deck {
    z-index: 20;
    touch-action: manipulation;
}

/* Remove-from-deck button min touch target on mobile */
@media (max-width: 768px) {
    .remove-from-deck {
        min-width: 32px !important;
        min-height: 32px !important;
        width: 32px !important;
        height: 32px !important;
        font-size: 1rem !important;
    }
    /* Prevent support-grid cards from clipping the remove button */
    .support-grid .card-item {
        overflow: visible;
    }
    /* Touch targets for owned/want buttons */
    .card-owned-btn, .card-want-btn {
        width: 36px !important;
        height: 36px !important;
        opacity: 0.85 !important;
    }
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

img[loading="lazy"] {
    background: linear-gradient(90deg, var(--bg-darker) 25%, var(--bg-card) 50%, var(--bg-darker) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   COLLECTION DASHBOARD
   ============================================================ */

#collection-dashboard {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* ---- Hero Stats ---- */
.dashboard-hero {
    background: var(--bg-card);
    border: 2px solid var(--accent-amber);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 2.5rem;
    flex-wrap: wrap;
}

.hero-progress-ring {
    position: relative;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.progress-ring-svg {
    width: 120px;
    height: 120px;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 10;
}

.ring-fill {
    fill: none;
    stroke: var(--accent-amber);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 314.16; /* 2*pi*50 */
    stroke-dashoffset: 314.16;
    transition: stroke-dashoffset 0.8s ease;
}

.ring-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    line-height: 1.2;
}

.ring-label span {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-amber);
}

.ring-label small {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hero-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem 2rem;
    flex: 1;
    min-width: 220px;
}

.hero-stat-item {
    display: flex;
    flex-direction: column;
}

.hero-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.hero-stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.1rem;
}

/* ---- Quick Stats ---- */
.quick-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.quick-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem 1rem;
    text-align: center;
    transition: border-color 0.2s;
}

.quick-stat-card:hover {
    border-color: var(--accent-teal);
}

.qs-icon {
    font-size: 1.8rem;
    margin-bottom: 0.4rem;
}

.qs-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent-amber);
    word-break: break-word;
    line-height: 1.3;
}

.qs-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---- Dashboard Sections ---- */
.dashboard-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
}

.dashboard-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-teal);
    margin-bottom: 1.25rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: 'Cinzel', 'Times New Roman', serif;
}

/* ---- Set Completion Chart ---- */
.set-group-header {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 1rem 0 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.set-group-header:first-child {
    margin-top: 0;
}

.set-bar-row {
    display: grid;
    grid-template-columns: auto 1fr 55px;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}


.set-bar-name {
    font-size: 0.75rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}

.set-bar-track {
    background: var(--bg-darker);
    border-radius: 3px;
    height: 14px;
    overflow: hidden;
    position: relative;
}

.set-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
    min-width: 2px;
}

.set-bar-fill.complete {
    background: linear-gradient(90deg, #059669, #10b981);
}

.set-bar-fill.good {
    background: linear-gradient(90deg, #b45309, #f59e0b);
}

.set-bar-fill.poor {
    background: linear-gradient(90deg, #991b1b, #ef4444);
}

.set-bar-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
}

/* ---- Rarity Donut ---- */
.rarity-section .rarity-layout {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.rarity-donut-wrap {
    flex-shrink: 0;
}

.rarity-donut {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    position: relative;
    /* background set via conic-gradient in JS */
    background: var(--bg-darker);
}

.rarity-donut::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 66px;
    height: 66px;
    background: var(--bg-card);
    border-radius: 50%;
}

.rarity-legend {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex: 1;
    min-width: 160px;
}

.rarity-legend-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.88rem;
}

.rarity-legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rarity-legend-name {
    flex: 1;
    color: var(--text-primary);
}

.rarity-legend-count {
    font-weight: 700;
    color: var(--accent-amber);
}

/* ---- Dashboard Duo Row (side by side cards) ---- */
.dashboard-duo-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.duo-card {
    padding: 1rem;
    margin-bottom: 0;
}

.unique-layout {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.unique-donut-wrap {
    flex-shrink: 0;
}

.unique-donut {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    position: relative;
    background: var(--bg-darker);
}

.unique-donut::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 66px;
    height: 66px;
    background: var(--bg-card);
    border-radius: 50%;
}

.unique-legend {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.unique-big-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-amber);
}

.unique-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---- Missing Cards Accordion ---- */
.missing-set-section {
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.missing-set-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-darker);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.missing-set-header:hover {
    background: var(--bg-hover);
}

.missing-set-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.missing-set-badge {
    background: var(--accent-crimson);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    white-space: nowrap;
}

.missing-set-badge.zero {
    background: var(--success);
}

.missing-set-chevron {
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: transform 0.2s;
}

.missing-set-section.open .missing-set-chevron {
    transform: rotate(180deg);
}

.missing-set-body {
    display: none;
    padding: 1rem;
    background: var(--bg-card);
}

.missing-set-section.open .missing-set-body {
    display: block;
}

.missing-cards-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.missing-card-chip {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.missing-card-chip.clickable {
    cursor: pointer;
    transition: all 0.2s;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
}

.missing-card-chip.clickable:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-amber);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

/* Energy-colored borders on missing chips */
.missing-card-chip[data-energy="átlica"] { border-color: var(--atlica) }
.missing-card-chip[data-energy="pírica"] { border-color: var(--pirica) }
.missing-card-chip[data-energy="gélida"] { border-color: var(--gelida) }
.missing-card-chip[data-energy="lítica"] { border-color: var(--litica) }
.missing-card-chip[data-energy="cháaktica"] { border-color: var(--chaaktica) }
.missing-card-chip[data-energy="húumica"] { border-color: var(--huumica) }
.missing-card-chip[data-energy="demótica"] { border-color: var(--demotica) }
.missing-card-chip[data-energy="feral"] { border-color: var(--feral) }

.missing-empty {
    color: var(--success);
    font-size: 0.85rem;
}

/* ---- Responsive overrides ---- */
@media (max-width: 768px) {
    .dashboard-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .dashboard-duo-row {
        grid-template-columns: 1fr;
    }

    .set-bar-row {
        grid-template-columns: 130px 1fr 60px;
    }

    .rarity-layout,
    .unique-layout {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .set-bar-row {
        grid-template-columns: 100px 1fr 55px;
    }
    .hero-stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ==================== TOAST NOTIFICATIONS ==================== */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent-teal);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    font-size: 0.9rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: translateX(24px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: auto;
    max-width: 320px;
    word-break: break-word;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.info {
    border-left-color: var(--accent-teal);
}

/* ==================== DECK STATS SUMMARY BAR ==================== */
.deck-stats-summary {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
    background: linear-gradient(135deg, var(--bg-darker), var(--bg-card));
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent-amber);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
}

.dss-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 60px;
}

.dss-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.dss-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent-amber);
}

.dss-energy-dots {
    min-width: 80px;
}

#dss-energy-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.dss-energy-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(255,255,255,0.15);
}

/* ==================== DECK ENERGY CHART ==================== */
.deck-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-darker);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.deck-chart-section {
    min-width: 0;
}

.deck-chart-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-family: 'Cinzel', 'Times New Roman', serif;
}

/* Energy bar rows */
.energy-bar-row {
    display: grid;
    grid-template-columns: 80px 1fr 28px;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.energy-bar-label {
    font-size: 0.78rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.energy-bar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    height: 14px;
    overflow: hidden;
    position: relative;
}

.energy-bar-fill {
    height: 100%;
    border-radius: 3px;
    min-width: 2px;
    transition: width 0.4s ease;
}

.energy-bar-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: right;
}

/* Damage histogram bars */
.damage-bar-row {
    display: grid;
    grid-template-columns: 32px 1fr 28px;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.damage-bar-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: right;
    font-family: monospace;
}

.damage-bar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    height: 14px;
    overflow: hidden;
}

.damage-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #64748b, #94a3b8);
    transition: width 0.4s ease;
    min-width: 2px;
}

.damage-bar-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: right;
}

.deck-chart-empty {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-style: italic;
    padding: 0.5rem 0;
}

@media (max-width: 768px) {
    .deck-charts {
        grid-template-columns: 1fr;
    }
    .deck-stats-summary {
        gap: 1rem;
    }
}

/* ==================== CONFIRM / CHOICE DIALOGS ==================== */
.confirm-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlayFadeIn 0.15s ease;
}

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

.confirm-dialog {
    background: var(--bg-card);
    border: 2px solid var(--accent-amber);
    border-radius: 12px;
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
    animation: dialogSlideIn 0.2s ease;
}

@keyframes dialogSlideIn {
    from { transform: translateY(-12px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

.confirm-dialog p {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 1rem;
}

.confirm-dialog-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.confirm-dialog-actions .btn-primary,
.confirm-dialog-actions .btn-secondary,
.confirm-dialog-actions .btn-danger {
    min-width: 120px;
}

/* ============================================================
   MESOAMERICAN VISUAL POLISH
   Subtle pyramid/stepped motifs throughout the UI
   ============================================================ */

/* Section divider — stepped pyramid pattern using CSS gradients */
.section-divider {
    position: relative;
    height: 12px;
    margin: 1.5rem 0;
    overflow: hidden;
}

.section-divider::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        /* Stepped pyramid silhouette using repeating linear gradients */
        repeating-linear-gradient(
            90deg,
            transparent 0px,
            transparent 8px,
            rgba(245, 158, 11, 0.12) 8px,
            rgba(245, 158, 11, 0.12) 10px
        ),
        linear-gradient(
            to bottom,
            transparent 0%,
            transparent 30%,
            rgba(245, 158, 11, 0.08) 30%,
            rgba(245, 158, 11, 0.08) 70%,
            transparent 70%
        );
}

/* Pyramid stepped border — used as a top decoration on section headers */
.section-divider::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(245, 158, 11, 0.15) 10%,
        rgba(245, 158, 11, 0.5) 30%,
        var(--accent-amber) 50%,
        rgba(245, 158, 11, 0.5) 70%,
        rgba(245, 158, 11, 0.15) 90%,
        transparent 100%
    );
    /* Stepped clip: pyramid shape */
    clip-path: polygon(
        0% 100%, 5% 100%, 5% 0%,
        10% 0%, 10% 40%, 15% 40%, 15% 0%,
        20% 0%, 20% 70%, 25% 70%, 25% 0%,
        30% 0%, 30% 100%,
        70% 100%, 70% 0%,
        75% 0%, 75% 70%, 80% 70%, 80% 0%,
        85% 0%, 85% 40%, 90% 40%, 90% 0%,
        95% 0%, 95% 100%, 100% 100%
    );
}

/* View sections — add a subtle pyramid-inspired top border */
.view > h2,
.view > .section-title {
    position: relative;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.view > h2::after,
.view > .section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(
        90deg,
        var(--accent-amber) 0%,
        rgba(245, 158, 11, 0.3) 60%,
        transparent 100%
    );
}

/* Stats bar — Mesoamerican left accent treatment */
.stats-bar {
    border-left: 3px solid var(--accent-amber);
    position: relative;
}

.stats-bar::before {
    content: '';
    position: absolute;
    left: -3px;
    top: 0;
    width: 3px;
    height: 40%;
    background: #d97706;
}

/* Card grid empty state — Mesoamerican oracle feel */
#card-grid:empty::after {
    content: '🔮 No se encontraron cartas con esos filtros';
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: 1 / -1;
    width: 100%;
    padding: 3rem 2rem;
    color: var(--text-secondary);
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 0.95rem;
    opacity: 0.75;
    letter-spacing: 0.03em;
}

/* Active nav — gold underline accent (complements the amber bg) */
nav .nav-btn.active {
    position: relative;
}

nav .nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 10%;
    width: 80%;
    height: 2px;
    background: #d97706;
    border-radius: 1px;
}

/* Sync Modal */
.sync-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
}
.sync-modal {
    background: #1e1e1e;
    border: 1px solid #f59e0b;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
}

.sync-textarea {
    width: 100%;
    height: 80px;
    background: var(--bg-dark);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    font-size: 0.75rem;
    resize: none;
}

/* Collapsible advanced filters */
.advanced-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
}
.advanced-filters select,
.advanced-filters input[type="text"] {
    flex: 1 1 48%;
    min-width: 0;
}

@media (max-width: 768px) {
    .advanced-filters {
        display: none;
    }
    .advanced-filters.show {
        display: flex;
    }
    .advanced-filters select,
    .advanced-filters input[type="text"] {
        flex: 1 1 100%;
    }
    /* Compact stats bar */
    .stats-bar {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    .stats-bar select {
        min-height: 36px;
        font-size: 0.8rem;
    }
    /* Grid size buttons smaller */
    .grid-size-btn {
        min-height: 36px !important;
        padding: 4px 8px !important;
    }
    /* Reset button compact */
    #reset-filters {
        width: auto;
        min-height: 36px;
    }
}

@media (min-width: 769px) {
    #toggle-filters {
        display: none;
    }
}

/* Modal nav container — always inside modal */
.modal-nav-container {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
}

.modal-nav-container .modal-nav-btn {
    position: static;
    transform: none;
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    min-height: 44px;
    transition: all 0.2s;
}

.modal-nav-container .modal-nav-btn:hover:not(:disabled) {
    background: var(--accent-amber);
    color: var(--bg-dark);
}

.modal-nav-container .modal-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Deck builder mobile improvements */
@media (max-width: 768px) {
    .deck-current-cards {
        max-height: 250px;
        overflow-y: auto;
    }
    
    .deck-pool .controls {
        display: none;
    }
    
    .deck-pool .controls.show {
        display: flex;
    }
    
    .deck-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .deck-actions button {
        font-size: 0.7rem;
        padding: 6px 10px;
        min-height: 36px;
    }
    
    #deck-pool-grid {
        max-height: 400px;
        overflow-y: auto;
    }
}

/* Pagination buttons */
.page-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    min-height: 44px;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: var(--accent-amber);
    color: #000;
    border-color: var(--accent-amber);
}

.page-btn.active {
    background: var(--accent-amber);
    color: #000;
    border-color: var(--accent-amber);
    font-weight: 700;
}

.page-btn:disabled,
.page-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-ellipsis {
    color: var(--text-secondary);
    padding: 0 0.25rem;
    align-self: center;
}

/* Grid size buttons — consistent with brand */
.grid-size-btn {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    cursor: pointer;
    min-height: 36px !important;
    transition: all 0.2s;
}

.grid-size-btn:hover {
    background: var(--bg-hover) !important;
}

.grid-size-btn.active {
    background: var(--accent-amber) !important;
    color: #000 !important;
    border-color: var(--accent-amber) !important;
}

/* Want list button on card items */
.card-want-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
    opacity: 0.4;
}

.card-item:hover .card-want-btn {
    opacity: 0.7;
}

.card-want-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.card-want-btn.active {
    opacity: 1;
    background: rgba(245, 158, 11, 0.75);
    color: #000;
}

/* Utility: mobile-only elements */
.mobile-only {
    display: none !important;
}
@media (max-width: 768px) {
    .mobile-only {
        display: inline-flex !important;
    }

    select, input[type="text"] {
        min-height: 44px;
    }
}

/* Deck builder mobile tabs */
.deck-mobile-tabs {
    display: none !important;
    gap: 0;
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .deck-mobile-tabs {
        display: flex !important;
    }
    
    .deck-tab-btn {
        flex: 1;
        padding: 10px;
        border: 1px solid var(--border);
        background: var(--bg-card);
        color: var(--text-secondary);
        font-family: 'Cinzel', 'Times New Roman', serif;
        font-size: 0.8rem;
        text-transform: uppercase;
        cursor: pointer;
        transition: all 0.2s;
        min-height: 44px;
    }
    
    .deck-tab-btn:first-child {
        border-radius: 8px 0 0 8px;
    }
    
    .deck-tab-btn:last-child {
        border-radius: 0 8px 8px 0;
    }
    
    .deck-tab-btn.active {
        background: var(--accent-amber);
        color: #000;
        border-color: var(--accent-amber);
    }
    
    /* Hide inactive tab content */
    .deck-builder-layout[data-active-tab="pool"] .deck-workspace,
    .deck-builder-layout[data-active-tab="pool"] .deck-list-sidebar {
        display: none;
    }
    
    .deck-builder-layout[data-active-tab="workspace"] .card-pool {
        display: none;
    }
    
    /* When pool is visible, give it full height and allow scrolling */
    .deck-builder-layout[data-active-tab="pool"] .card-pool {
        max-height: none;
        overflow-y: visible;
        overflow-x: hidden;
    }
    
    .deck-builder-layout[data-active-tab="workspace"] .deck-list-sidebar {
        max-height: 150px;
    }
    
    .deck-builder-layout[data-active-tab="workspace"] .deck-workspace {
        max-height: none;
    }
}

/* Modal redesign — action-first layout */
.modal-actions {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.modal-actions button {
    flex: 1;
    min-height: 44px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.btn-want {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-want:hover {
    border-color: var(--accent-amber);
}

.btn-want.active {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
    border-color: var(--accent-amber);
}

/* Compact game stats */
.modal-game-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
}

.modal-stat-row {
    display: flex;
    gap: 8px;
}

.stat-chip {
    flex: 1;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
}

/* Lore section — collapsible */
.modal-lore {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.modal-lore summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 4px 0;
    user-select: none;
}

.modal-lore summary:hover {
    color: var(--text-primary);
}

.modal-lore .modal-flavor,
.modal-lore .modal-species,
.modal-lore .modal-artist {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Modal nav inside info section */
.modal-info .modal-nav-container {
    padding: 0;
    border-top: none;
    margin: 8px 0;
}

/* Collection / Want List tabs */
.collection-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
}

.collection-tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 0.8rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.collection-tab-btn:first-child {
    border-radius: 8px 0 0 8px;
}

.collection-tab-btn:last-child {
    border-radius: 0 8px 8px 0;
}

.collection-tab-btn.active {
    background: var(--accent-amber);
    color: #000;
    border-color: var(--accent-amber);
}

.tab-count {
    background: rgba(0,0,0,0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
}

.collection-tab-btn.active .tab-count {
    background: rgba(0,0,0,0.3);
}

/* Deck builder — not-owned indicators */
.card-item.not-owned {
    border: 2px solid var(--accent-crimson) !important;
    opacity: 0.75;
}

.deck-not-owned-badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    font-size: 14px;
    background: rgba(0,0,0,0.7);
    border-radius: 4px;
    padding: 1px 4px;
    z-index: 1;
}

.validation-warning {
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid var(--accent-crimson);
    color: var(--accent-crimson);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-top: 8px;
}

/* Contact cards */
.contact-card:hover {
    border-color: var(--accent-amber) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}
   SINERGIAS-SPECIFIC STYLES
   Uses CSS vars from style.css for theme consistency
   ============================================================ */

.sinergias-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    max-width: 960px;
    margin: 0 auto;
}

.sinergias-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 12px;
    background: var(--bg-dark);
    padding: 6px 16px;
    border-radius: 20px;
    display: inline-block;
    border: 1px solid var(--border);
}

.map-wrap {
    position: relative;
    width: 100%;
    max-width: 900px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.map-wrap svg {
    width: 100%;
    height: auto;
    display: block;
}

/* SVG nodes */
.node-circle { cursor: pointer; transition: filter .2s }
.node-group:hover .node-circle,
.node-group.active .node-circle { filter: drop-shadow(0 0 18px currentColor) }
.node-label {
    font-family: 'Cinzel', 'Times New Roman', serif;
    fill: var(--text-primary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    pointer-events: none;
}
.node-role {
    font-family: 'Outfit', sans-serif;
    fill: var(--text-secondary);
    font-size: 9px;
    pointer-events: none;
}
.node-emoji { pointer-events: none; user-select: none }

/* SVG arrows */
.arrow-counter {
    fill: none;
    stroke-width: 3;
    opacity: 0.7;
    transition: opacity .2s;
    stroke-dasharray: 16 8;
    animation: dash 2s linear infinite;
}
.arrow-synergy {
    fill: none;
    stroke: var(--accent-amber);
    stroke-width: 2.5;
    stroke-dasharray: 10 6;
    opacity: 0.5;
    transition: opacity .2s;
}
.arrow-label {
    font-family: 'Outfit', sans-serif;
    font-size: 9px;
    fill: var(--text-primary);
    pointer-events: none;
    paint-order: stroke;
    stroke: var(--bg-card);
    stroke-width: 4px;
    stroke-linecap: round;
    stroke-linejoin: round;
    font-weight: 600;
}
.arrow-synergy-label {
    font-family: 'Outfit', sans-serif;
    font-size: 9px;
    fill: var(--accent-amber);
    pointer-events: none;
    paint-order: stroke;
    stroke: var(--bg-card);
    stroke-width: 4px;
    stroke-linecap: round;
    stroke-linejoin: round;
    font-weight: 600;
}

/* Highlight states */
.node-group.dimmed { opacity: 0.12 }
.arrow-counter.dimmed, .arrow-synergy.dimmed { opacity: 0.05 }
.arrow-counter.highlight { opacity: 1; stroke-width: 4 }
.arrow-synergy.highlight { opacity: 1; stroke-width: 3.5 }

/* Detail panel */
#detail-panel {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
    width: 100%;
    max-width: 900px;
}
#detail-panel.open { display: block }
#detail-panel h2 {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 1.1rem;
    margin-bottom: 8px;
}
#detail-panel .role {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 12px;
}
#detail-panel .desc {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 12px;
}
#detail-panel .connections { font-size: 0.85rem }
#detail-panel .conn-item {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
#detail-panel .conn-counter { color: var(--danger) }
#detail-panel .conn-synergy { color: var(--accent-amber) }

/* Legend */
.sinergias-legend {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.legend-line { width: 40px; height: 3px; border-radius: 2px }
.legend-counter { background: linear-gradient(90deg, var(--danger), var(--accent-amber)) }
.legend-synergy {
    background: repeating-linear-gradient(90deg, var(--accent-amber) 0, var(--accent-amber) 8px, transparent 8px, transparent 14px);
}

@keyframes dash { to { stroke-dashoffset: -32 } }

/* Responsive */
@media (max-width: 600px) {
    .node-label { font-size: 9px }
    .node-role { font-size: 7px }
    .arrow-label, .arrow-synergy-label { font-size: 7px }
    .sinergias-legend { gap: 12px }
}

/* ==================== GUIDE VIEW ==================== */
.guide-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 16px;
}

.guide-title {
    font-family: 'Cinzel', 'Times New Roman', serif;
    color: var(--accent-amber);
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.guide-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

.guide-section {
    margin-bottom: 28px;
}

.guide-section h3 {
    font-family: 'Cinzel', 'Times New Roman', serif;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* Board diagram */
.board-diagram {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.board-zone {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.zone-icon { font-size: 1.2rem; }
.zone-name { font-family: 'Cinzel', 'Times New Roman', serif; font-size: 0.85rem; color: var(--text-primary); font-weight: 700; }
.zone-desc { font-size: 0.75rem; color: var(--text-secondary); flex-basis: 100%; }

.zone-slots {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.slot {
    width: 40px;
    height: 56px;
    background: var(--bg-darker);
    border: 1px dashed var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.board-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.zone-principal { border-color: var(--accent-amber); }
.zone-protector { border-color: var(--atlica); }
.zone-extincion { border-color: var(--pirica); }

/* Turn flow */
.turn-flow {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.turn-phase {
    display: flex;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.phase-battle {
    border-color: var(--accent-amber);
    background: rgba(245, 158, 11, 0.05);
}

.phase-num {
    min-width: 28px;
    height: 28px;
    background: var(--accent-amber);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.phase-info strong {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.phase-info ul {
    margin: 4px 0 0 16px;
    padding: 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.phase-info li { margin-bottom: 2px; }

.turn-arrow {
    text-align: center;
    color: var(--accent-amber);
    font-size: 1rem;
    padding: 2px 0;
}

/* Card types grid */
.card-types-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.type-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.type-card strong { color: var(--text-primary); }
.type-icon { font-size: 1.2rem; display: block; margin-bottom: 4px; }

/* Energy guide */
.energy-guide-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.energy-chip {
    background: var(--bg-card);
    border: 1px solid;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.75rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.energy-chip span { font-size: 1.1rem; }

/* Marks */
.marks-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mark-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.mark-burn { border-left: 3px solid var(--pirica); }
.mark-poison { border-left: 3px solid #22c55e; }
.mark-abyss { border-left: 3px solid var(--gelida); }

.guide-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-style: italic;
}

/* Top rules */
.top-rules {
    padding-left: 20px;
    margin: 0;
}

.top-rules li {
    padding: 6px 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.top-rules li strong { color: var(--text-primary); }

/* Format grid */
.format-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.format-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.format-item strong { color: var(--accent-amber); }

.format-rule {
    border-color: var(--accent-amber);
    background: rgba(245, 158, 11, 0.05);
}

/* Guide desktop improvements */
@media (min-width: 769px) {
    .guide-container {
        max-width: 1100px;
        padding: 40px 48px;
    }

    .guide-title { font-size: 1.6rem; }

    /* More breathing room between sections */
    .guide-section {
        margin-bottom: 48px;
    }

    .guide-section h3 {
        margin-top: 8px;
        margin-bottom: 20px;
        padding-bottom: 10px;
        font-size: 1.1rem;
    }

    .board-diagram {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .board-row {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .board-zone {
        padding: 16px 20px;
    }

    .zone-slots {
        flex-direction: row;
    }

    /* Bigger card slots on desktop */
    .slot {
        width: 72px;
        height: 100px;
        font-size: 1.8rem;
        border-radius: 6px;
    }

    /* Turn flow: single column always */
    .turn-flow {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .turn-phase {
        padding: 20px;
        gap: 16px;
    }

    /* Larger phase number circles */
    .phase-num {
        min-width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .phase-info strong {
        font-size: 1rem;
    }

    .phase-info ul {
        font-size: 0.85rem;
        margin-top: 8px;
    }

    .phase-info li {
        margin-bottom: 5px;
    }

    /* Fase de Batalla stands out more */
    .phase-battle {
        grid-column: 1 / -1;
        border-width: 2px;
        border-color: var(--accent-amber);
        background: rgba(245, 158, 11, 0.08);
        box-shadow: 0 0 16px rgba(245, 158, 11, 0.18), inset 0 0 24px rgba(245, 158, 11, 0.04);
    }

    /* Card types: 4 columns */
    .card-types-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .type-card {
        padding: 16px;
    }

    /* Energy: 4 columns */
    .energy-guide-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Marks: horizontal */
    .marks-grid {
        flex-direction: row;
    }

    .mark-card { flex: 1; }

    /* Top rules: 2 columns */
    .top-rules {
        columns: 2;
        column-gap: 32px;
    }

    .top-rules li {
        break-inside: avoid;
        padding: 8px 0;
    }

    /* Format: 4 columns */
    .format-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .format-rule {
        grid-column: span 2;
    }
}

/* Fix mobile overflow — deck pool, filters, global */
@media (max-width: 768px) {
    body, html {
        overflow-x: hidden;
    }

    main {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .card-pool {
        overflow-x: hidden;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .card-pool .controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    
    .card-pool .controls input[type="text"] {
        grid-column: 1 / -1;
    }

    .card-pool select {
        width: 100%;
        min-width: 0;
        font-size: 0.8rem;
        padding: 0.4rem 0.5rem;
    }
    
    /* Deck builder overall */
    #deck-builder-view {
        overflow-x: hidden;
    }
    
    .deck-builder-layout {
        overflow-x: hidden;
    }
}

/* Fix deck pool controls overflow on ALL screen sizes */
.card-pool .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.card-pool .controls input[type="text"] {
    grid-column: 1 / -1;
}

.card-pool .controls .owned-toggle {
    grid-column: 1 / -1;
}

.card-pool .controls select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Desktop: filters in a single row when pool is full-width */
@media (min-width: 769px) {
    .card-pool .controls {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
    .card-pool .controls input[type="text"]:first-child {
        grid-column: 1 / -1;
    }
}

/* Deck builder: prevent horizontal overflow globally */
.deck-builder-layout,
.deck-workspace,
.card-pool {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Card grid in pool: prevent horizontal overflow only */
#deck-pool-grid {
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
}
/* cache-bust: 1773870311 */

/* ── Rarity badges ── */
.cost-badge {
    font-size: 0.7rem;
    margin-right: 2px;
    vertical-align: middle;
}

.rarity-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* ==================== VARIANTS ==================== */
.modal-variants {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.modal-variants strong {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary, #aaa);
}
.variants-grid {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}
.variant-thumb {
    flex: 0 0 auto;
    width: 64px;
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.15s;
    position: relative;
}
.variant-thumb:hover {
    border-color: var(--accent-amber, #f59e0b);
    transform: scale(1.08);
}
.variant-thumb.current {
    border-color: var(--accent-amber, #f59e0b);
    opacity: 0.6;
    pointer-events: none;
}
.variant-thumb.owned {
    border-color: #22c55e;
}
.variant-thumb img {
    width: 100%;
    display: block;
    aspect-ratio: 5/7;
    object-fit: cover;
    background: #1a1a2e;
}
.variant-thumb .variant-folio {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 0.55rem;
    text-align: center;
    padding: 1px 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Unique cards highlight */
.hero-stat-item.highlight .hero-stat-value {
    color: #f59e0b;
    font-weight: 700;
}
.hero-stat-item.highlight .hero-stat-label {
    color: #f59e0b;
    opacity: 0.85;
}

/* Collapsible dashboard sections */
.dashboard-section-title.collapsible {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.dashboard-section-title.collapsible:hover {
    opacity: 0.8;
}
.section-chevron {
    font-size: 0.8em;
    transition: transform 0.2s;
}
.collapsible-body.collapsed {
    display: none;
}
