:root {
  color-scheme: dark;
  --bg: #090b0d;
  --panel: rgba(14, 18, 21, 0.9);
  --panel-strong: rgba(18, 23, 27, 0.96);
  --line: rgba(209, 220, 220, 0.16);
  --text: #f0f0e9;
  --muted: #9ba7aa;
  --gold: #d8a84f;
  --red: #d65b57;
  --green: #4bb174;
  --violet: #8d7cf6;
  --cyan: #55b8c7;
  --player: #55b8c7;
  --void: #8d7cf6;
  --void-glow: rgba(141, 124, 246, 0.45);
  --rival-glow: rgba(214, 91, 87, 0.42);
  --player-glow: rgba(85, 184, 199, 0.42);
  --shadow: rgba(0, 0, 0, 0.5);
  --font-display: "Chakra Petch", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { min-width: 320px; min-height: 100dvh; margin: 0; color: var(--text); background: var(--bg); font-family: var(--font-body); }
button, input { font: inherit; }
button { min-height: 38px; border: 1px solid var(--line); border-radius: 7px; padding: 0.55rem 0.8rem; color: var(--text); background: rgba(255,255,255,.06); font-weight: 700; cursor: pointer; transition: transform .14s ease, border-color .14s ease, background .14s ease; }
button:hover:not(:disabled), button:focus-visible { border-color: rgba(216,168,79,.9); background: rgba(216,168,79,.14); outline: none; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .45; }
button.primary { border-color: rgba(216,168,79,.88); color: #120f09; background: linear-gradient(135deg, #b98234, var(--gold)); }
button.wide { width: 100%; }
input { min-height: 38px; min-width: 0; border: 1px solid var(--line); border-radius: 7px; padding: .55rem .7rem; color: var(--text); background: rgba(0,0,0,.3); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); clip-path: inset(50%); white-space: nowrap; }

#gl-board { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -3; opacity: .72; }
#app { min-height: 100dvh; padding: clamp(8px, 1.5vw, 20px); }
#app::before { position: fixed; inset: 0; z-index: -2; content: ""; pointer-events: none; background: radial-gradient(circle at 50% 46%, rgba(31,52,55,.28), transparent 47%), linear-gradient(115deg, rgba(5,8,10,.9), rgba(5,8,10,.5) 45%, rgba(6,8,10,.88)); }
.eyebrow, .label, .step-number { color: var(--gold); font-family: var(--font-display); font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }

/* Deal desk */
.deal-desk { width: min(980px, 100%); margin: clamp(3vh, 9vh, 100px) auto; padding: clamp(18px, 3vw, 36px); border: 1px solid rgba(216,168,79,.34); border-radius: 14px; background: linear-gradient(145deg, rgba(23,30,34,.93), rgba(10,13,16,.95)); box-shadow: 0 24px 80px var(--shadow), inset 0 0 0 1px rgba(85,184,199,.07); }
.deal-desk-head { max-width: 630px; margin-bottom: 28px; }
.site-home { display: inline-block; margin-bottom: 14px; font-family: var(--font-display); font-size: .75rem; letter-spacing: .18em; text-transform: uppercase; text-decoration: none; color: var(--muted); }
.site-home:hover { color: var(--gold); }
.deal-desk-head h1 { margin: 4px 0 8px; font-size: clamp(2rem, 6vw, 4rem); letter-spacing: .05em; }
.deal-desk-head p:last-child { color: var(--muted); }
.deal-desk-step { display: grid; grid-template-columns: auto minmax(150px, .45fr) minmax(0, 1fr); gap: 14px; align-items: start; margin-top: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); }
.deal-desk-step h2 { margin-bottom: 4px; font-size: 1rem; }
.deal-desk-step p { color: var(--muted); font-size: .88rem; }
.step-number { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid rgba(216,168,79,.6); border-radius: 50%; }
.mode-options, .online-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mode-options button.active, .operator-option.active { border-color: var(--cyan); background: rgba(85,184,199,.14); }
.operator-choice-row { display: grid; gap: 8px; }
.deal-desk-step > .operator-choice-row:nth-child(4) { grid-column: 3; }
.operator-options { display: flex; flex-wrap: wrap; gap: 8px; }
.operator-option { flex: 1 1 140px; min-height: 76px; text-align: left; }
.operator-option strong, .operator-option span { display: block; }
.operator-option span { margin-top: 5px; color: var(--muted); font-size: .75rem; font-weight: 400; }
.online-panel { grid-template-columns: auto minmax(150px, .45fr) minmax(0, 1fr); }
.online-room-code, .online-countdown, .online-status { grid-column: 3; margin: 0; }
.online-room-code { color: var(--gold); font-family: var(--font-display); font-weight: 700; }
.online-countdown { color: var(--cyan); font-family: var(--font-display); font-size: 1.1rem; }
.deal-desk > .primary { margin-top: 20px; min-height: 52px; }

/* Board */
.match-board { position: relative; min-height: calc(100dvh - 40px); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 12px; overflow: hidden; }
.match-board::before, .match-board::after { position: absolute; z-index: -1; content: ""; pointer-events: none; }
.match-board::before { inset: 0; border: 1px solid rgba(216,168,79,.34); border-radius: 14px; background: linear-gradient(135deg, rgba(30,36,36,.44), rgba(8,10,12,.8)); box-shadow: inset 0 0 42px rgba(0,0,0,.55), 0 20px 70px var(--shadow); }
.match-board::after { inset: 12px; border: 1px solid rgba(216,168,79,.18); border-radius: 8px; }
.match-header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 70px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.opponent-summary { min-width: 0; }
.opponent-summary strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-display); }
.opponent-summary p { color: var(--muted); font-size: .8rem; }
.resource-row { display: flex; flex-wrap: wrap; gap: 6px; }
.resource-chip { display: inline-flex; gap: 5px; align-items: baseline; padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; font-size: .73rem; }
.resource-chip strong { color: var(--gold); }
.resource-chip.resource-up { border-color: var(--green); }
.resource-chip.resource-down { border-color: var(--red); }
.queue-line { color: var(--muted); font-size: .75rem; }
.match-status { display: flex; gap: 8px; color: var(--gold); font-family: var(--font-display); font-weight: 700; }
.match-status span { padding: 6px 8px; border: 1px solid rgba(216,168,79,.35); border-radius: 6px; }

.lanes { min-height: 0; display: grid; grid-template-rows: repeat(3, minmax(142px, 1fr)); gap: 10px; padding: 0 12px; }
.lane { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 142px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; padding: 0; color: var(--text); background: rgba(5,8,11,.58); text-align: inherit; }
.lane:hover:not(:disabled) { transform: none; background: rgba(5,8,11,.68); }
.lane.selected { border-color: var(--cyan); box-shadow: inset 0 0 22px var(--player-glow); }
.lane.contested { border-color: rgba(141,124,246,.72); }
.lane.contested .lane-seam::before { box-shadow: 0 0 18px var(--void-glow); }
.lane-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,.07); }
.lane-head h2 { display: flex; gap: 9px; align-items: baseline; font-size: .92rem; }
.lane-head h2 span { color: var(--muted); font-family: var(--font-body); font-size: .68rem; font-weight: 500; text-transform: uppercase; }
.lane-scoreboard { display: flex; gap: 6px; }
.score-card { display: inline-flex; gap: 5px; align-items: center; padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; font-size: .68rem; }
.score-card strong { font-family: var(--font-display); font-size: .95rem; }
.rival-score.leading { color: var(--red); border-color: var(--red); }
.player-score.leading { color: var(--player); border-color: var(--player); }
.lane-cards { display: grid; grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr); min-height: 0; }
.lane-zone { position: relative; min-width: 0; padding: 8px 10px; }
.rival-zone { background: linear-gradient(90deg, rgba(214,91,87,.13), transparent); }
.player-zone { background: linear-gradient(270deg, rgba(85,184,199,.14), transparent); }
.zone-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: .64rem; text-transform: uppercase; }
.side-stack { display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-start; min-height: 54px; }
.lane-seam { position: relative; display: grid; place-items: center; }
.lane-seam::before { width: 2px; height: 100%; content: ""; background: var(--void); box-shadow: 0 0 8px var(--void-glow); }
.lane-seam-tag { position: absolute; z-index: 1; display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid var(--void); border-radius: 50%; color: var(--text); background: #11151b; font-family: var(--font-display); font-size: .68rem; }
.lane-footer { display: flex; justify-content: space-between; gap: 10px; padding: 5px 12px; border-top: 1px solid rgba(255,255,255,.07); color: var(--muted); font-size: .72rem; }

.card { position: relative; display: grid; grid-template-rows: 54px auto auto 1fr; width: 112px; min-height: 136px; overflow: hidden; border: 1px solid rgba(216,168,79,.45); border-radius: 7px; color: var(--text); background: #151a1b; box-shadow: 0 7px 12px rgba(0,0,0,.28); }
button.card { padding: 0; text-align: left; }
.card.alpha { border-color: rgba(85,184,199,.66); }
.card.bravo { border-color: rgba(214,91,87,.66); }
.card.selected { transform: translateY(-8px); border-color: var(--cyan); box-shadow: 0 0 16px var(--player-glow); }
.card.queued { border-style: dashed; }
.card.dragging { opacity: .45; }
.drop-target { outline: 2px solid var(--gold); outline-offset: -4px; }
.card-art { width: 100%; height: 54px; object-fit: cover; background: #20262a; }
.card-top { padding: 5px 6px 0; }
.card-name { overflow: hidden; font-family: var(--font-display); font-size: .68rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.card-badges { display: flex; gap: 3px; padding: 4px 6px; }
.card-badge { display: inline-flex; gap: 2px; align-items: baseline; font-size: .55rem; }
.card-badge strong { color: var(--gold); font-size: .72rem; }
.card-text { display: -webkit-box; overflow: hidden; padding: 0 6px 6px; color: var(--muted); font-size: .57rem; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }

.action-dock { position: relative; display: grid; gap: 8px; padding: 10px 14px 14px; border-top: 1px solid rgba(216,168,79,.34); background: rgba(9,12,14,.94); box-shadow: 0 -12px 30px rgba(0,0,0,.25); }
.selection-strip, .market-strip { display: flex; gap: 8px; align-items: center; }
.selection-strip { justify-content: space-between; }
.selection-strip strong { color: var(--cyan); font-family: var(--font-display); }
.market-strip { flex-wrap: wrap; }
.market-strip .raise-status { color: var(--muted); font-size: .75rem; }
.player-line { color: var(--muted); font-size: .8rem; }
.hand { display: flex; gap: 8px; overflow-x: auto; padding: 9px 3px 13px; overscroll-behavior-inline: contain; scroll-snap-type: inline mandatory; }
.hand > .card { flex: 0 0 128px; min-height: 160px; scroll-snap-align: center; }
#primary-action-button { min-height: 50px; font-size: 1rem; }
.match-result, .post-game, .email-cta { margin: 0 14px; }
.email-cta { display: block; padding: 12px; color: var(--gold); text-align: center; }

/* Sheets and utilities */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(2,4,6,.75); backdrop-filter: blur(8px); }
.sheet { width: min(680px, 100%); max-height: min(88dvh, 840px); overflow: auto; padding: 18px; border: 1px solid rgba(216,168,79,.45); border-radius: 12px; background: var(--panel-strong); box-shadow: 0 22px 80px var(--shadow); }
.sheet > header { display: flex; justify-content: space-between; gap: 16px; align-items: start; margin-bottom: 14px; }
.menu-sheet { width: min(760px, 100%); }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.handoff .sheet { width: min(420px, 100%); text-align: center; }
.handoff .sheet h2 { margin: 6px 0; }
.handoff .sheet p { margin-bottom: 18px; color: var(--muted); }
.undo-toast { position: fixed; right: 16px; bottom: 18px; z-index: 30; display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px); padding: 10px 12px; border: 1px solid var(--gold); border-radius: 8px; background: #1a1e20; box-shadow: 0 12px 34px var(--shadow); }
.onboarding-steps, .deck-browser-body { display: grid; gap: 10px; }
.onboarding-step, .deck-browser-section { padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.deck-browser-card { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.deck-browser-card:first-child { border-top: 0; }
.deck-browser-card-name { font-family: var(--font-display); }
.deck-browser-card-text, .coach-output, .lab-output, .diagnostics-export, .log { color: var(--muted); font-size: .82rem; }
.diagnostics-export { overflow: auto; white-space: pre-wrap; }
.log { max-height: 180px; overflow: auto; padding-left: 20px; }
.card-preview-panel { position: fixed; z-index: 35; width: min(320px, calc(100vw - 28px)); padding: 12px; border: 1px solid var(--gold); border-radius: 10px; background: #161b1d; box-shadow: 0 20px 50px var(--shadow); pointer-events: none; }
.card-preview-panel img { max-width: 100%; }

@keyframes contested-pulse { 50% { box-shadow: 0 0 28px var(--void-glow); } }
@media (prefers-reduced-motion: no-preference) { .lane.contested .lane-seam::before { animation: contested-pulse 2.4s ease-in-out infinite; } .card.enter { animation: card-enter .3s ease-out; } @keyframes card-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } } }
@media (max-width: 1024px) { body { overflow: auto; } .match-board { min-height: 100dvh; } .action-dock { position: sticky; bottom: 0; z-index: 4; } }
@media (min-width: 1025px) { .match-board { height: calc(100dvh - 40px); min-height: 0; } .match-header .label { display: none; } .lanes { min-height: 0; overflow-y: auto; grid-template-rows: repeat(3, minmax(105px, 1fr)); } .lane { min-height: 105px; } .action-dock { gap: 6px; padding: 8px 14px 10px; } .hand > .card { min-height: 116px; } }
@media (max-width: 768px) { #app { padding: 8px; } .deal-desk { margin: 10px auto; padding: 16px; } .deal-desk-step, .online-panel { grid-template-columns: auto 1fr; } .deal-desk-step > .mode-options, .deal-desk-step > .operator-choice-row, .online-panel > .online-actions, .online-panel > .online-room-code, .online-panel > .online-countdown, .online-panel > .online-status, .online-panel > #online-cancel-button { grid-column: 2; } .match-header { grid-template-columns: auto 1fr; } .match-status { grid-column: 1 / -1; } .lane-cards { grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr); } .card { width: 92px; min-height: 124px; } .hand > .card { flex-basis: 116px; } .zone-label { display: none; } .lane-scoreboard span span { display: none; } .menu-grid { grid-template-columns: 1fr; } }
