/* ── Variables ───────────────────────────────────────── */
:root {
    --bg: #040302;
    --bg2: #08070A;
    --bg3: #0D0C10;
    --bg4: #141218;
    --b1: #1C1A24;
    --b2: #2A2435;
    --b3: #3E3250;
    --orange: #E85500;
    --orange2: #FF7020;
    --amber: #B87C00;
    --amber2: #D4A030;
    --red: #C81000;
    --green: #10A030;
    --green2: #20DD50;
    --txt: #C8A858;
    --txt2: #9A7A40;
    /* brighter than before */
    --txt3: #604830;
    --font-h: 'Orbitron', monospace;
    --font-d: 'Share Tech Mono', monospace;
    --card-w: 84px;
    --card-h: 122px;
    --emz-h: var(--card-h);
    --side-w: 80px;
    --gap: 38px;
}

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

html,
body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--txt);
    font-family: var(--font-d);
    font-size: 12px;
}

img {
    display: block;
}

::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--b3);
    border-radius: 2px;
}

/* ── App Shell ──────────────────────────────────────── */
#app {
    display: flex;
    height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────── */
#sidebar {
    width: 190px;
    min-width: 190px;
    display: flex;
    flex-direction: column;
    background: var(--bg2);
    border-right: 1px solid var(--b2);
    flex-shrink: 0;
}

#app-brand {
    padding: 14px 12px 10px;
    border-bottom: 1px solid var(--b2);
}

.brand-title {
    font-family: var(--font-h);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    color: var(--orange);
}

.brand-sub {
    font-size: 8px;
    color: var(--txt3);
    letter-spacing: .1em;
    margin-top: 3px;
    text-transform: uppercase;
}

#ep-tools {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    padding: 8px 10px 8px;
    border-bottom: 1px solid var(--b2);
}

#ep-search {
    min-width: 0;
    height: 24px;
    background: var(--bg3);
    border: 1px solid var(--b2);
    color: var(--txt);
    border-radius: 2px;
    padding: 0 8px;
    font-family: var(--font-d);
    font-size: 10px;
}

#ep-search:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 1px rgba(232, 85, 0, .2);
}

#ep-search-clear {
    height: 24px;
    width: 24px;
    background: var(--bg4);
    border: 1px solid var(--b2);
    color: var(--txt2);
    border-radius: 2px;
    cursor: pointer;
    font-family: var(--font-h);
    font-size: 8px;
    letter-spacing: .06em;
}

#ep-search-clear:hover {
    border-color: var(--orange);
    color: var(--orange2);
}

#ep-count {
    grid-column: 1 / -1;
    font-family: var(--font-h);
    font-size: 8px;
    letter-spacing: .1em;
    color: var(--txt3);
    text-transform: uppercase;
}

#ep-list {
    flex: 1;
    overflow-y: auto;
}

.ep-grp-hdr {
    padding: 8px 12px 3px;
    font-size: 8px;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--amber2);
    border-top: 1px solid var(--b1);
    font-family: var(--font-h);
    margin-top: 2px;
}

.ep-grp-hdr:first-child {
    border-top: none;
    margin-top: 0;
}

.ep-item {
    padding: 6px 12px 6px 14px;
    cursor: pointer;
    color: var(--txt2);
    font-size: 10px;
    border-left: 2px solid transparent;
    transition: all .1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ep-item:hover {
    background: var(--bg3);
    color: var(--txt);
    border-left-color: var(--b3);
}

.ep-item.active {
    background: var(--bg4);
    color: var(--orange2);
    border-left-color: var(--orange);
}

.no-ep {
    padding: 12px;
    color: var(--txt3);
    font-size: 10px;
    line-height: 1.7;
}

/* ── Main ───────────────────────────────────────────── */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Meta bar */
#meta-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    background: var(--bg2);
    border-bottom: 1px solid var(--b2);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.m-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
}

.m-chip .lbl {
    color: var(--txt3);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-family: var(--font-h);
}

.m-chip .val {
    color: var(--amber2);
    font-weight: 600;
}

.type-badge {
    font-family: var(--font-h);
    font-size: 8px;
    padding: 2px 7px;
    border-radius: 2px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.type-ppo {
    background: #0A1820;
    color: #50B8E8;
    border: 1px solid #1A3850;
}

.type-dqn {
    background: #180A28;
    color: #B870F0;
    border: 1px solid #3A1860;
}

.type-dreamer {
    background: #081A08;
    color: #50D880;
    border: 1px solid #185018;
}

.prompt-tag {
    margin-left: auto;
    padding: 2px 9px;
    border-radius: 2px;
    background: var(--bg4);
    border: 1px solid var(--b2);
    color: var(--orange2);
    font-size: 9px;
    letter-spacing: .08em;
    font-family: var(--font-h);
}

/* ── Workspace ──────────────────────────────────────── */
#workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ── Field Section ──────────────────────────────────── */
#field-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    position: relative;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(232, 85, 0, .04) 0%, transparent 65%),
        var(--bg);
}

#field-section::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(232, 85, 0, .025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(232, 85, 0, .025) 1px, transparent 1px);
    background-size: 32px 32px;
    z-index: 0;
}

#field-scroll {
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 10px 6px;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: stretch;
}

/* ── Field Grid Wrapper ──────────────────────────────── */
/* Must be a flex child so height flows down to the grid */
#field-grid-wrap {
    flex: 1;
    display: flex;
    min-width: 0;
    min-height: 0;
}

/* ── Field Grid ─────────────────────────────────────── */
.field-grid {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(var(--card-h), 1fr) repeat(5, minmax(var(--card-w), 1fr)) minmax(var(--card-h), 1fr);
    grid-template-rows: repeat(3, minmax(var(--card-h), 1fr));
    gap: var(--gap);
    min-width: calc(var(--card-h) * 2 + var(--card-w) * 5 + var(--gap) * 6);
}

/* ── Zone Base ──────────────────────────────────────── */
.zone {
    position: relative;
    border-radius: 3px;
    overflow: hidden;
    background: var(--bg3);
    border: 1px solid var(--b2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.zone-empty {
    cursor: default;
}

.zone-num {
    font-family: var(--font-h);
    font-size: clamp(12px, 2vw, 22px);
    font-weight: 700;
    color: var(--b2);
    pointer-events: none;
    user-select: none;
}

.zone-lbl {
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: var(--font-h);
    font-size: clamp(5px, .7vw, 8px);
    letter-spacing: .1em;
    color: var(--txt3);
    text-transform: uppercase;
    pointer-events: none;
    z-index: 3;
}

/* EMZ row cells */
.zone-emz-empty {
    background: transparent;
    border: 1px dashed var(--b1);
    border-radius: 3px;
}

.zone-emz {
    background: var(--bg3);
    border: 1px solid var(--b2);
    border-radius: 3px;
}

.emz-label {
    font-family: var(--font-h);
    font-size: 7px;
    letter-spacing: .1em;
    color: var(--txt3);
    text-transform: uppercase;
    text-align: center;
    position: absolute;
    bottom: 3px;
    left: 0;
    right: 0;
}

/* Side zones (Extra Deck, GY, Deck) */
.zone-side {
    flex-direction: column;
    gap: 3px;
    background: var(--bg2);
    border: 1px solid var(--b2);
    cursor: default;
}

.zone-side.clickable {
    cursor: pointer;
}

.zone-side.clickable:hover {
    border-color: var(--b3);
    background: var(--bg3);
}

.side-count {
    font-family: var(--font-h);
    font-size: 14px;
    font-weight: 700;
    color: var(--amber2);
}

.side-label {
    font-family: var(--font-h);
    font-size: 6px;
    letter-spacing: .12em;
    color: var(--txt3);
    text-transform: uppercase;
}

.side-img {
    width: 52px;
    height: 76px;
    object-fit: cover;
    border-radius: 2px;
    opacity: .8;
}

.zone-side.has-card .side-img {
    opacity: 1;
}

.side-back {
    width: 52px;
    height: 76px;
    border-radius: 2px;
    flex-shrink: 0;
    background: linear-gradient(145deg, #0A0820 0%, #1C0C40 45%, #0A0820 100%);
    border: 1px solid #201040;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-h);
    font-size: 18px;
    color: #2A1848;
}

.zone-corner-label {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg2);
    border: 1px dashed var(--b1);
    border-radius: 3px;
}

.corner-txt {
    font-family: var(--font-h);
    font-size: 7px;
    letter-spacing: .1em;
    color: var(--b3);
    text-transform: uppercase;
    text-align: center;
    line-height: 1.5;
}

/* ── Zone Highlight States ──────────────────────────── */
/* Card/zone can be activated or selected */
.zone.legal {
    border-color: var(--orange) !important;
    box-shadow: 0 0 10px rgba(232, 85, 0, .4), inset 0 0 8px rgba(232, 85, 0, .1);
    background: rgba(232, 85, 0, .06) !important;
}

.zone.chosen {
    border-color: var(--green2) !important;
    box-shadow: 0 0 14px rgba(32, 221, 80, .55), inset 0 0 10px rgba(32, 221, 80, .12);
    background: rgba(32, 221, 80, .06) !important;
}

/* Empty zone is a valid placement destination */
.zone.place-legal {
    border-color: var(--amber) !important;
    box-shadow: 0 0 8px rgba(184, 124, 0, .45), inset 0 0 8px rgba(184, 124, 0, .1);
    background: rgba(184, 124, 0, .06) !important;
}

.zone.place-chosen {
    border-color: var(--green2) !important;
    box-shadow: 0 0 14px rgba(32, 221, 80, .55), inset 0 0 10px rgba(32, 221, 80, .12);
    background: rgba(32, 221, 80, .08) !important;
}

/* ── Card Content ───────────────────────────────────── */
.card-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px;
    display: block;
}

.card-back {
    width: 100%;
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(145deg, #0A0820 0%, #1C0C40 45%, #0A0820 100%);
    border: 1px solid #201040;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-h);
    font-size: 20px;
    color: #2A1848;
}

/* DEF position */
.zone.pos-def .card-wrap {
    transform: rotate(90deg);
}

.zone.pos-def {
    overflow: visible;
    z-index: 2;
}

/* Badges */
.card-badge {
    position: absolute;
    font-family: var(--font-h);
    font-size: 7px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 4;
    letter-spacing: .05em;
}

.badge-neg {
    top: 3px;
    right: 3px;
    background: var(--red);
    color: #fff;
}

.badge-mat {
    top: 3px;
    left: 3px;
    background: rgba(0, 0, 0, .75);
    color: var(--amber2);
    border: 1px solid var(--amber);
}

.badge-def {
    top: 3px;
    left: 3px;
    background: rgba(0, 0, 0, .75);
    color: #6090E8;
    border: 1px solid #304880;
}

.card-stats {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, .88));
    padding: 3px 4px 2px;
    font-family: var(--font-d);
    font-size: 8px;
    color: var(--amber2);
    text-align: center;
    pointer-events: none;
    z-index: 3;
}

/* ── Hand Area ──────────────────────────────────────── */
#hand-area {
    padding: 6px 10px 8px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    border-top: 2px solid transparent;
    border-image: repeating-linear-gradient(90deg, var(--orange) 0 6px, transparent 6px 12px) 1;
    background: rgba(4, 3, 2, .7);
}

.hand-label {
    font-family: var(--font-h);
    font-size: 7px;
    letter-spacing: .14em;
    color: var(--txt3);
    text-transform: uppercase;
    margin-bottom: 5px;
}

#hand-cards {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    align-items: flex-end;
    justify-content: center;
    /* Reserve full card box height (image height + borders) to avoid layout shift */
    min-height: calc(var(--card-h) + 2px);
}

.hand-card {
    flex-shrink: 0;
    width: var(--card-w);
    height: var(--card-h);
    position: relative;
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--b2);
    background: var(--bg3);
    transition: transform .15s, border-color .15s, box-shadow .15s;
}

.hand-card:hover {
    transform: translateY(-10px) scale(1.05);
    z-index: 10;
}

.hand-card.legal {
    border-color: var(--orange);
    box-shadow: 0 0 10px rgba(232, 85, 0, .5);
}

.hand-card.chosen {
    border-color: var(--green2);
    box-shadow: 0 0 14px rgba(32, 221, 80, .6);
}

.hand-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hand-card .card-back {
    width: 100%;
    height: 100%;
    font-size: 22px;
}

/* ── Stack Modal (GY / Extra / Deck) ────────────────── */
#gy-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .82);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

#gy-modal.hidden {
    display: none;
}

.gy-modal-inner {
    background: var(--bg2);
    border: 1px solid var(--b3);
    border-radius: 4px;
    padding: 16px;
    max-width: 680px;
    max-height: 82vh;
    overflow-y: auto;
}

.gy-modal-title {
    font-family: var(--font-h);
    font-size: 10px;
    letter-spacing: .14em;
    color: var(--amber2);
    margin-bottom: 10px;
    text-transform: uppercase;
}

.gy-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Each card in the modal */
.gy-card {
    width: 68px;
    height: 99px;
    border-radius: 2px;
    border: 1px solid var(--b2);
    position: relative;
    cursor: default;
    flex-shrink: 0;
}

/* Face-down card (Extra Deck / Deck) — back visible, front hidden until hover */
.gy-card.face-down .stack-back {
    opacity: 1;
    transition: opacity .18s;
}

.gy-card.face-down .stack-front {
    opacity: 0;
    transition: opacity .18s;
}

.gy-card.face-down:hover .stack-back {
    opacity: 0;
}

.gy-card.face-down:hover .stack-front {
    opacity: 1;
}

/* Face-up card (GY) — just show the image */
.gy-card.face-up .stack-front {
    opacity: 1;
}

.gy-card.face-up .stack-back {
    display: none;
}

.stack-front {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px;
}

.stack-back {
    position: absolute;
    inset: 0;
    border-radius: 2px;
    background: linear-gradient(145deg, #0A0820 0%, #1C0C40 45%, #0A0820 100%);
    border: 1px solid #201040;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-h);
    font-size: 20px;
    color: #2A1848;
    pointer-events: none;
}

/* ── Right Panel ────────────────────────────────────── */
#right-panel {
    width: 282px;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    background: var(--bg2);
    border-left: 1px solid var(--b2);
    flex-shrink: 0;
}

.panel-hdr {
    padding: 6px 10px 5px;
    font-family: var(--font-h);
    font-size: 8px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--txt3);
    border-bottom: 1px solid var(--b2);
    background: var(--bg2);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hdr-accent {
    width: 20px;
    height: 2px;
    background: repeating-linear-gradient(90deg, var(--orange) 0 3px, transparent 3px 6px);
}

/* Actions */
#actions-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-bottom: 1px solid var(--b2);
}

#actions-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
}

.action-row {
    display: flex;
    align-items: stretch;
    border-radius: 3px;
    border: 1px solid var(--b1);
    margin-bottom: 3px;
    background: var(--bg3);
    position: relative;
    cursor: default;
}

.action-row.chosen {
    border-color: var(--green);
    background: rgba(16, 160, 48, .07);
}

.action-row.finish-action {
    opacity: .6;
}

.action-fill {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    pointer-events: none;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(232, 85, 0, .07), transparent);
}

.action-row.chosen .action-fill {
    background: linear-gradient(90deg, rgba(16, 160, 48, .09), transparent);
}

.act-k {
    padding: 5px 6px;
    font-size: 8px;
    color: var(--txt3);
    min-width: 18px;
    border-right: 1px solid var(--b1);
    display: flex;
    align-items: center;
    font-family: var(--font-h);
    position: relative;
}

.act-body {
    flex: 1;
    padding: 4px 7px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.act-main {
    font-size: 10px;
    color: var(--txt);
    line-height: 1.3;
}

.act-sub {
    font-size: 8px;
    color: var(--txt3);
    margin-top: 1px;
    font-family: var(--font-d);
}

.act-score {
    padding: 4px 7px;
    font-family: var(--font-d);
    font-size: 10px;
    display: flex;
    align-items: center;
    gap: 3px;
    position: relative;
    white-space: nowrap;
}

.s-hi {
    color: var(--amber2);
}

.s-mid {
    color: var(--txt);
}

.s-lo {
    color: var(--txt3);
}

.star {
    color: var(--green2);
    font-size: 9px;
}

/* History */
#hist-wrap {
    height: 144px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-bottom: 1px solid var(--b2);
}

#hist-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 5px 8px;
}

.hist-row {
    display: flex;
    gap: 6px;
    align-items: baseline;
    padding: 2px 0;
    border-bottom: 1px solid var(--b1);
    font-size: 9px;
}

.h-ago {
    color: var(--txt3);
    min-width: 24px;
    font-size: 8px;
}

.h-phase {
    color: var(--b3);
    min-width: 26px;
    font-size: 8px;
    text-transform: uppercase;
}

.h-act {
    color: var(--txt2);
    flex: 1;
}

.h-card {
    color: var(--amber);
    font-size: 8px;
}

/* Attention */
#attn-wrap {
    padding: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: 120px;
}

#attn-scroll {
    flex: 1;
    overflow: auto;
    padding: 5px 8px;
}

canvas#attn-cv {
    image-rendering: pixelated;
    display: block;
}

/* ── Step Nav ───────────────────────────────────────── */
#step-nav {
    padding: 7px 14px;
    background: var(--bg2);
    border-top: 1px solid var(--b2);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.nav-btn {
    background: var(--bg4);
    border: 1px solid var(--b2);
    color: var(--txt2);
    padding: 3px 10px;
    border-radius: 2px;
    cursor: pointer;
    font-family: var(--font-h);
    font-size: 9px;
    letter-spacing: .08em;
    transition: all .1s;
}

.nav-btn:hover:not(:disabled) {
    border-color: var(--orange);
    color: var(--orange);
}

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

#step-slider {
    flex: 1;
    accent-color: var(--orange);
    cursor: pointer;
}

#step-ctr {
    font-family: var(--font-d);
    font-size: 10px;
    color: var(--txt2);
    min-width: 64px;
    text-align: right;
    white-space: nowrap;
}

#step-metrics {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.rew-badge {
    font-family: var(--font-d);
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 2px;
    white-space: nowrap;
}

.r-pos {
    background: rgba(16, 160, 48, .15);
    color: var(--green2);
    border: 1px solid rgba(16, 160, 48, .4);
}

.r-neg {
    background: rgba(200, 16, 0, .12);
    color: #F06050;
    border: 1px solid rgba(200, 16, 0, .4);
}

.r-zero {
    background: var(--bg4);
    color: var(--txt3);
    border: 1px solid var(--b2);
}

.done-pill {
    padding: 2px 8px;
    border-radius: 10px;
    font-family: var(--font-h);
    font-size: 7px;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.done-true {
    background: rgba(16, 160, 48, .15);
    border: 1px solid rgba(16, 160, 48, .4);
    color: var(--green2);
}

.done-false {
    background: var(--bg4);
    border: 1px solid var(--b2);
    color: var(--txt3);
}

/* ── Tooltip ─────────────────────────────────────────── */
#card-tooltip {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    background: var(--bg2);
    border: 1px solid var(--b3);
    border-radius: 3px;
    padding: 8px;
    width: 180px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .85);
}

#card-tooltip.hidden {
    display: none;
}

#card-tooltip img {
    width: 164px;
    height: auto;
    border-radius: 2px;
    display: block;
    margin-bottom: 5px;
}

.tt-name {
    font-family: var(--font-h);
    font-size: 8px;
    color: var(--amber2);
    letter-spacing: .05em;
    line-height: 1.4;
}

.tt-type {
    font-size: 8px;
    color: var(--txt3);
    margin-top: 2px;
}

.tt-stats {
    font-size: 9px;
    color: var(--txt2);
    margin-top: 3px;
}

/* ── Loading ─────────────────────────────────────────── */
#loading {
    position: fixed;
    inset: 0;
    background: rgba(4, 3, 2, .93);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 800;
    backdrop-filter: blur(4px);
    gap: 12px;
}

#loading.hidden {
    display: none;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 2px solid var(--b3);
    border-top-color: var(--orange);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.loading-txt {
    font-family: var(--font-h);
    font-size: 9px;
    letter-spacing: .18em;
    color: var(--txt3);
    text-transform: uppercase;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty {
    color: var(--txt3);
    font-size: 9px;
    padding: 12px;
    text-align: center;
    font-family: var(--font-h);
    letter-spacing: .08em;
}

.hidden {
    display: none !important;
}

/* Face-down card back (Extra Deck, main Deck modal) */
.card-back-deck {
    width: 100%;
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(145deg, #0A0830 0%, #1C0C50 45%, #080620 100%);
    border: 1px solid #241060;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-h);
    font-size: clamp(14px, 2.5vw, 24px);
    color: #2A1060;
}