:root {
    --bg-dark: #090c12;
    --card-bg: #121620;
    --card-border: #1e2433;
    --card-hover: #19202f;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;

    --amber: #ffb703;
    --amethyst: #9d4edd;
    --emerald: #2ec4b6;
    --ruby: #e63946;
    --sapphire: #0096c7;
    --steel: #8d99ae;
    --btn-grad: linear-gradient(135deg, #7b2cbf 0%, #b5179e 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

body.in-library {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ==========================================================================
   GLOBAL HEADER
   ========================================================================== */
.global-header {
    background: #0d1118;
    border-bottom: 1px solid var(--card-border);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 100;
    gap: 12px;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
}

.brand-logo-lore {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.brand-wrap:hover .brand-logo-lore {
    transform: scale(1.15);
}

.logo-clean {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.03em;
    line-height: 1;
}

.logo-dot-ink {
    color: #38bdf8;
    font-weight: 700;
}

.nav-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #070a0f;
    border: 1px solid var(--card-border);
    padding: 3px;
    border-radius: 10px;
}

.nav-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 6px 14px;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.nav-tab-btn:hover {
    color: #fff;
}

.nav-tab-btn.active {
    background: #1c2436;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.tab-text-short {
    display: none;
}

.tab-text-full {
    display: inline;
}

@media (max-width: 640px) {
    .global-header {
        flex-direction: column;
        align-items: stretch;
        padding: 8px 12px 10px;
        gap: 8px;
    }

    .brand-wrap {
        justify-content: center;
    }

    .logo-clean {
        font-size: 1.15rem;
    }

    .nav-tabs {
        width: 100%;
        display: flex;
        gap: 3px;
    }

    .nav-tab-btn {
        flex: 1;
        padding: 7px 4px;
        font-size: 0.78rem;
    }

    .tab-text-full {
        display: none;
    }

    .tab-text-short {
        display: inline;
    }
}

/* ==========================================================================
   HOME VIEW
   ========================================================================== */
.home-main {
    align-items: center;
    justify-content: center;
    padding: 36px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.home-container {
    max-width: 960px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    margin: auto 0;
}

.home-hero {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.home-hero h2 {
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(90deg, #fff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.home-hero p {
    color: var(--text-dim);
    font-size: 0.95rem;
    max-width: 580px;
    line-height: 1.6;
}

.home-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
}

@media (max-width: 720px) {
    .home-cards-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .home-hero h2 {
        font-size: 1.6rem;
    }

    .home-hero p {
        font-size: 0.88rem;
    }

    .home-main {
        padding: 24px 14px;
    }
}

.hub-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.hub-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.hub-card.card-lib::before {
    background: linear-gradient(90deg, var(--amber), var(--emerald));
}

.hub-card.card-sim::before {
    background: linear-gradient(90deg, var(--ruby), var(--amethyst));
}

.hub-card:hover {
    transform: translateY(-4px);
    border-color: #3b82f6;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.hub-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #090d14;
    border: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.hub-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
}

.hub-card p {
    color: var(--text-dim);
    font-size: 0.86rem;
    line-height: 1.6;
    flex: 1;
}

.hub-card-action {
    font-size: 0.84rem;
    font-weight: 700;
    color: #38bdf8;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

/* ==========================================================================
   LIBRARY VIEW
   ========================================================================== */
.icon-inline {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    display: inline-block;
    object-fit: contain;
    filter: brightness(0) invert(1);
    margin: 0 1px;
}

.icon-stat {
    width: 18px;
    height: 18px;
    vertical-align: -3px;
    display: inline-block;
    object-fit: contain;
    filter: brightness(0) invert(1);
    margin-left: 4px;
}

.icon-asset {
    width: 15px;
    height: 15px;
    vertical-align: -2px;
    display: inline-block;
    object-fit: contain;
    margin-right: 4px;
    flex-shrink: 0;
}

.icon-mono {
    display: inline-block;
    vertical-align: -2px;
    color: #ffffff;
    margin: 0 1px;
    flex-shrink: 0;
}

.lib-filter-header {
    background: #0d1118;
    border-bottom: 1px solid var(--card-border);
    padding: 10px 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.filter-bar-container {
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s ease;
}

.filter-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.filter-divider {
    width: 1px;
    height: 20px;
    background: #1f2737;
    flex-shrink: 0;
}

.btn-filter-ink {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #090c12;
    border: 1px solid #222a3a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.4;
    transition: all 0.15s ease;
    padding: 3px;
}

.btn-filter-ink img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.btn-filter-ink:hover {
    opacity: 0.75;
    transform: translateY(-1px);
}

.btn-filter-ink.active {
    opacity: 1;
    border-color: #6366f1;
    background: #151b27;
}

.btn-filter-ink.active.amber {
    border-color: var(--amber);
    box-shadow: 0 0 8px rgba(255, 183, 3, 0.4);
}

.btn-filter-ink.active.amethyst {
    border-color: var(--amethyst);
    box-shadow: 0 0 8px rgba(157, 78, 221, 0.4);
}

.btn-filter-ink.active.emerald {
    border-color: var(--emerald);
    box-shadow: 0 0 8px rgba(46, 196, 182, 0.4);
}

.btn-filter-ink.active.ruby {
    border-color: var(--ruby);
    box-shadow: 0 0 8px rgba(230, 57, 70, 0.4);
}

.btn-filter-ink.active.sapphire {
    border-color: var(--sapphire);
    box-shadow: 0 0 8px rgba(0, 150, 199, 0.4);
}

.btn-filter-ink.active.steel {
    border-color: var(--steel);
    box-shadow: 0 0 8px rgba(141, 153, 174, 0.4);
}

.btn-filter-cost {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #141924;
    border: 1px solid #222a3a;
    color: #94a3b8;
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.15s ease;
    user-select: none;
}

.btn-filter-cost:hover {
    opacity: 0.85;
    color: #fff;
}

.btn-filter-cost.active {
    opacity: 1;
    background: #2563eb;
    border-color: #3b82f6;
    color: #ffffff;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
}

.btn-filter-rarity {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.35;
    transition: all 0.15s ease;
    padding: 3px;
}

.btn-filter-rarity img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.btn-filter-rarity:hover {
    opacity: 0.75;
    transform: translateY(-1px);
}

.btn-filter-rarity.active {
    opacity: 1;
    border-color: #6366f1;
    background: #131824;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

.search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.search-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    background: #080a0f;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 9px 36px 9px 36px;
    color: var(--text-main);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.15s ease;
}

.search-input:focus {
    border-color: #6366f1;
}

.search-icon-svg {
    position: absolute;
    left: 11px;
    color: var(--text-dim);
    pointer-events: none;
}

.search-clear-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    cursor: pointer;
    display: none;
    padding: 2px 6px;
    border-radius: 4px;
}

.search-clear-btn:hover {
    color: #fff;
}

.btn-toggle-filters {
    display: none;
    align-items: center;
    gap: 6px;
    background: #141924;
    border: 1px solid var(--card-border);
    color: #cbd5e1;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-toggle-filters.has-active {
    border-color: #6366f1;
    color: #fff;
    background: #1a2236;
}

.filters-count-badge {
    background: #2563eb;
    color: #fff;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 9999px;
    display: none;
    font-family: 'Fira Code', monospace;
}

.mobile-nav-bar {
    display: none;
    background: #0f1420;
    border-bottom: 1px solid var(--card-border);
    padding: 10px 16px;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.mobile-back-btn {
    background: #1a2233;
    border: 1px solid var(--card-border);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mobile-card-title {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f1f5f9;
}

.main-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 360px 1fr;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

.cards-sidebar {
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    background: #0a0d14;
    overflow: hidden;
}

.sidebar-header {
    padding: 10px 16px;
    border-bottom: 1px solid var(--card-border);
    font-size: 0.8rem;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f131c;
    flex-shrink: 0;
}

.cards-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    -webkit-overflow-scrolling: touch;
}

.card-item {
    padding: 10px 14px;
    border-bottom: 1px solid #141924;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.12s ease;
}

.card-item:hover {
    background: var(--card-hover);
}

.card-item.selected {
    background: #171f30;
    border-left: 3px solid #6366f1;
}

.ink-pip {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.card-item-details {
    flex: 1;
    min-width: 0;
}

.card-item-name {
    font-size: 0.83rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.card-item-sub {
    font-size: 0.72rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.card-item-cost {
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    background: #07090e;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 2px 7px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'Fira Code', monospace;
}

.inspector-pane {
    overflow-y: auto;
    padding: 32px 24px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: var(--bg-dark);
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}

.inspector-empty {
    color: var(--text-dim);
    text-align: center;
    margin-top: 80px;
    font-size: 0.9rem;
    padding: 0 16px;
    max-width: 440px;
    line-height: 1.6;
}

.card-detail-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    max-width: 900px;
    width: 100%;
    display: grid;
    grid-template-columns: 310px 1fr;
    gap: 32px;
    padding: 28px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
    align-items: start;
    min-width: 0;
}

.image-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.card-image-box {
    width: 100%;
    max-width: 300px;
    aspect-ratio: 5/7;
    background: #07090e;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
    position: relative;
    touch-action: none;
    --foil-x: 50%;
    --foil-y: 50%;
}

.card-image-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: filter 0.3s ease;
}

.card-image-box .foil-rainbow-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(115deg, transparent 15%, rgba(255, 0, 128, 0.16) 26%, rgba(255, 170, 0, 0.20) 38%,
            rgba(0, 255, 180, 0.22) 50%, rgba(0, 160, 255, 0.22) 62%, rgba(180, 70, 255, 0.18) 74%, transparent 88%);
    background-size: 260% 260%;
    background-position: var(--foil-x) var(--foil-y);
    mix-blend-mode: color-dodge;
    transition: opacity 0.35s ease;
}

.card-image-box .foil-glare-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(circle at var(--foil-x) var(--foil-y), rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0.08) 25%, transparent 60%);
    mix-blend-mode: overlay;
    transition: opacity 0.35s ease;
}

@keyframes foilAmbientSweep {
    0% {
        background-position: 0% 0%;
    }

    50% {
        background-position: 100% 100%;
    }

    100% {
        background-position: 0% 0%;
    }
}

.card-image-box.is-foil .foil-rainbow-layer,
.card-image-box.is-foil .foil-glare-layer {
    opacity: 0.75;
}

.card-image-box.is-foil:not(:hover) .foil-rainbow-layer {
    animation: foilAmbientSweep 6s ease-in-out infinite;
}

.card-image-box.is-foil img {
    filter: contrast(1.06) saturate(1.08);
}

.finish-toggle-container {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: inline-flex;
    background: rgba(12, 16, 24, 0.82);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 9999px;
    padding: 3px;
    gap: 2px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

.btn-finish-opt {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 4px 14px;
    border-radius: 9999px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.15s ease;
    font-family: inherit;
    user-select: none;
}

.btn-finish-opt:hover {
    color: #fff;
}

.btn-finish-opt.active {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.info-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    width: 100%;
}

.top-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.pill {
    font-size: 0.74rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 6px;
    background: #090d14;
    border: 1px solid var(--card-border);
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'Fira Code', monospace;
}

.pill.core-legal {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.08);
    color: #4ade80;
}

.pill.core-not-legal {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
    color: #f87171;
}

.pill.infinity-legal {
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.08);
    color: #38bdf8;
}

.card-title-block h2 {
    font-size: 1.45rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.15;
}

.card-title-block .subtitle {
    font-size: 1.05rem;
    color: #94a3b8;
    font-weight: 500;
    margin-top: 2px;
}

.card-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid #182030;
    border-bottom: 1px solid #182030;
    text-align: center;
}

.card-stat-item .num {
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffffff;
    font-family: 'Fira Code', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.card-stat-item .lbl {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-top: 2px;
}

.classifications-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip-class {
    background: #0d121c;
    border: 1px solid #1c2436;
    color: #cbd5e1;
    padding: 3px 9px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.effects-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #0a0d14;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 14px;
}

.keyword-badge-row {
    background: rgba(30, 41, 59, 0.45);
    border: 1px solid #28354b;
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.84rem;
    line-height: 1.5;
}

.kw-tag {
    background: #2563eb;
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    margin-top: 1px;
}

.kw-desc {
    color: #cbd5e1;
    font-style: italic;
}

.ability-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ability-title {
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #ffffff;
}

.ability-body {
    font-size: 0.86rem;
    color: #cbd5e1;
    line-height: 1.6;
}

.market-box {
    background: #090c12;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-family: 'Fira Code', monospace;
}

.market-label {
    color: var(--text-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.market-prices {
    display: flex;
    gap: 14px;
}

.market-val {
    color: #e2e8f0;
    font-weight: 600;
}

.market-val.foil-val {
    color: #facc15;
}

@media (max-width: 768px) {
    .main-layout {
        display: block;
        position: relative;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .cards-sidebar {
        width: 100%;
        height: 100%;
        border-right: none;
    }

    .inspector-pane {
        display: none;
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        padding: 12px 10px 40px;
        background: var(--bg-dark);
        z-index: 10;
    }

    body.mobile-detail-open .cards-sidebar {
        display: none;
    }

    body.mobile-detail-open .inspector-pane {
        display: flex;
    }

    body.mobile-detail-open .mobile-nav-bar {
        display: flex;
    }

    .card-detail-card {
        grid-template-columns: 1fr;
        padding: 16px 12px;
        gap: 16px;
        border-radius: 12px;
    }

    .image-column {
        max-width: 240px;
        margin: 0 auto;
    }

    .btn-toggle-filters {
        display: inline-flex;
    }

    .filter-bar-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        width: 100%;
        background: #090c12;
        border: 1px solid var(--card-border);
        border-radius: 10px;
        padding: 10px 6px;
    }

    .filter-bar-container.collapsed {
        display: none;
    }

    .filter-group {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
    }

    .filter-divider {
        display: none;
    }
}

/* ==========================================================================
   SIMULATOR VIEW
   ========================================================================== */
.sim-main {
    width: 100%;
    align-items: center;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sim-wrapper {
    max-width: 1200px;
    width: 100%;
    padding: 24px 16px;
    margin: 0 auto;
}

.sim-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--card-border);
}

.sim-header-row h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: #fff;
}

.badge-status {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 9999px;
    background: #182234;
    color: #38bdf8;
    font-weight: 600;
    border: 1px solid #233554;
    font-family: 'Fira Code', monospace;
    white-space: nowrap;
}

.grid-decks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    width: 100%;
}

@media (max-width: 820px) {
    .grid-decks {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.deck-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.deck-card.deck-a {
    border-top: 4px solid var(--ruby);
}

.deck-card.deck-b {
    border-top: 4px solid var(--sapphire);
}

.deck-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.deck-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.deck-title-input {
    background: transparent;
    border: none;
    border-bottom: 1px dashed #334155;
    color: var(--text-main);
    font-weight: 700;
    font-size: 1.05rem;
    padding: 2px 4px;
    outline: none;
    width: 140px;
}

.deck-title-input:focus {
    border-bottom-color: #6366f1;
}

.btn-clear-deck {
    background: #141924;
    border: 1px solid var(--card-border);
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
    font-family: inherit;
}

.btn-clear-deck:hover {
    background: #201318;
    border-color: #7f1d1d;
    color: #f87171;
}

.archetype-select {
    background: #0f172a;
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.archetype-select:focus {
    border-color: #6366f1;
}

textarea.deck-input {
    width: 100%;
    height: 220px;
    background: #0b0f17;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: #e2e8f0;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    padding: 12px;
    resize: vertical;
    line-height: 1.5;
}

textarea.deck-input:focus {
    outline: none;
    border-color: #6366f1;
}

.deck-meta-info {
    font-size: 0.78rem;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Fira Code', monospace;
}

.legality-pill {
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.legality-pill.pending {
    background: #1e293b;
    border: 1px solid #334155;
    color: var(--text-dim);
}

.legality-pill.core {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #4ade80;
}

.legality-pill.infinity {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #38bdf8;
}

.legality-pill.illegal {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.sim-controls {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.runs-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.runs-group label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-dim);
}

.runs-group select {
    background: #0f172a;
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 600;
    outline: none;
}

button.btn-sim {
    background: var(--btn-grad);
    color: #fff;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button.btn-sim:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 18px rgba(181, 23, 158, 0.4);
}

button.btn-sim:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.status-text {
    width: 100%;
    font-size: 0.85rem;
    color: #38bdf8;
    font-family: 'Fira Code', monospace;
    display: none;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #1e293b;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
    display: none;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #818cf8, #c084fc);
    transition: width 0.1s ease;
}

.dashboard {
    display: none;
    flex-direction: column;
    gap: 24px;
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

@media (max-width: 640px) {
    .kpi-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .kpi-card {
        padding: 14px;
    }

    .kpi-card .value {
        font-size: 1.4rem;
    }
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kpi-card .label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
}

.kpi-card .value {
    font-size: 1.85rem;
    font-weight: 700;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 820px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 18px;
}

.chart-panel h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--text-dim);
    font-weight: 600;
}

.histogram-bar-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.turn-label {
    width: 65px;
    color: var(--text-dim);
    font-family: 'Fira Code', monospace;
}

.bar-bg {
    flex-grow: 1;
    height: 16px;
    background: #0f172a;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: #6366f1;
    border-radius: 4px;
}

.pct-label {
    width: 45px;
    text-align: right;
    font-weight: 600;
    font-family: 'Fira Code', monospace;
}

.log-panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 18px;
}

.log-panel h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-box {
    background: #090d16;
    border: 1px solid #1a2234;
    border-radius: 8px;
    padding: 16px;
    max-height: 380px;
    overflow-y: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    line-height: 1.7;
}

.log-turn {
    color: #facc15;
    font-weight: 700;
    margin-top: 8px;
    border-bottom: 1px dashed #334155;
    padding-bottom: 2px;
}

.log-action {
    color: #cbd5e1;
}

.log-win {
    color: #4ade80;
    font-weight: 700;
}

/* ==========================================================================
   UNIFIED FOOTER & MODAL LEGAL
   ========================================================================== */
.site-footer {
    background: #070a0f;
    border-top: 1px solid var(--card-border);
    padding: 20px;
    color: var(--text-dim);
    font-size: 0.78rem;
    line-height: 1.6;
    width: 100%;
    flex-shrink: 0;
    margin-top: auto;
}

.footer-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    text-align: center;
}

.footer-title {
    font-weight: 600;
    color: #cbd5e1;
    font-size: 0.84rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
}

.footer-links a,
.footer-links button {
    background: none;
    border: none;
    color: #94a3b8;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    padding: 0;
}

.footer-links a:hover,
.footer-links button:hover {
    color: #38bdf8;
    text-decoration: underline;
}

.footer-sep {
    color: #334155;
    user-select: none;
}

.footer-disclaimer {
    font-size: 0.72rem;
    color: #64748b;
    max-width: 860px;
    line-height: 1.5;
}

.footer-disclaimer a {
    color: #94a3b8;
    text-decoration: underline;
}

/* Modal Popup Flotante */
.legal-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 10, 0.85);
    backdrop-filter: blur(6px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.legal-modal-box {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    max-width: 680px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
}

#legalModalBody h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: 16px;
    letter-spacing: 0.02em;
}

#legalModalBody h4 {
    font-size: 0.95rem;
    color: #38bdf8;
    margin-top: 18px;
    margin-bottom: 8px;
    font-weight: 700;
}

#legalModalBody p {
    font-size: 0.86rem;
    color: #cbd5e1;
    line-height: 1.65;
    margin-bottom: 12px;
}

#legalModalBody ul {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.6;
}

.legal-modal-close-btn {
    align-self: flex-end;
    background: #1e2638;
    border: 1px solid #334155;
    color: #fff;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    margin-top: 14px;
    transition: background 0.15s ease;
}

.legal-modal-close-btn:hover {
    background: #2b354e;
}