/* THE CUP — PREVIEW FEED. One sheet, one aesthetic: a late-night broadcast on a CRT
   nobody has adjusted since before the war. Scanlines + vignette are global layers;
   screens are CHANNELS; menus are what the aliens think a TV guide looks like.
   Touch targets ≥44px. No hover-DEPENDENT UI (hover only ever adds a preview). */

:root {
  --bg: #05060a;
  --panel: #10141d;
  --line: #232b3b;
  --ink: #e8e4d8;
  --dim: #8b93a7;
  --gold: #d8a531;
  --red: #d84a3a;
  --volt: #e8d44d;
  --chem: #a45ad6;
  --rad: #6fd657;
  --osd: #3dff7c;                     /* phosphor green: the TV's own voice */
  --hpc: #ff8c7a;
  /* board cards: scale with the screen, stay phone-safe.
     height budget: 2 lines (2.8w) + the tucked hand (~1w) + chrome ≈ 100dvh */
  --cardw: min(15vw, calc((100dvh - 180px) / 3.9), 210px);
  --handw: calc(var(--cardw) * 0.95);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
img { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* ^ kills iOS's long-press "Save Image" sheet so OUR long-press zoom owns the gesture */
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background:
    radial-gradient(ellipse at 50% 120%, #0e1420 0%, var(--bg) 55%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.35 ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  user-select: none;
}

/* ═══ the tube itself: scanlines, aperture grille, vignette, breath ═══ */
body::before {                        /* scanlines + faint RGB grille */
  content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.15) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255,0,60,.018) 0 1px, rgba(0,255,120,.014) 1px 2px, rgba(0,80,255,.018) 2px 3px);
  animation: hum 9s linear infinite;
}
body::after {                         /* curved-glass vignette */
  content: ""; position: fixed; inset: 0; z-index: 91; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,.42) 92%, rgba(0,0,0,.7) 100%);
}
@keyframes hum { 50% { opacity: .92; } }

/* phones: READABILITY OUTRANKS THE TUBE. The grille goes, scanlines drop to a whisper,
   the vignette loosens its grip — the theme lives on in the chrome, not over the text. */
@media (pointer: coarse) {
  body::before {
    background: repeating-linear-gradient(0deg, rgba(0,0,0,.05) 0 1px, transparent 1px 4px);
    animation: none;
  }
  body::after {
    background: radial-gradient(ellipse at center, transparent 72%, rgba(0,0,0,.16) 94%, rgba(0,0,0,.3) 100%);
  }
}

/* channel-change static */
#static-burst {
  position: fixed; inset: 0; z-index: 95; pointer-events: none; opacity: 0;
}
#static-burst.on {
  opacity: 1;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.14) 0 2px, rgba(0,0,0,.5) 2px 3px, rgba(255,255,255,.06) 3px 5px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.08) 0 1px, transparent 1px 4px);
  animation: staticjump .09s steps(2) infinite, staticfade .48s linear forwards;
}
@keyframes staticjump { 50% { background-position: 0 7px, 3px 0; } }
@keyframes staticfade { 0% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }

/* the TV's on-screen display */
#osd {
  position: fixed; top: 14px; right: 20px; z-index: 92; pointer-events: none;
  color: var(--osd); font-weight: 700; font-size: 20px; letter-spacing: .14em;
  text-shadow: 0 0 8px rgba(61,255,124,.75), 0 0 2px rgba(61,255,124,.9);
  display: flex; gap: 16px; align-items: baseline;
}
#osd-rec { font-size: 13px; animation: blink 1.4s steps(1) infinite; color: #ff5147; text-shadow: 0 0 8px rgba(255,81,71,.8); }
@keyframes blink { 50% { opacity: 0; } }
.osdtext {
  color: var(--osd); letter-spacing: .12em; font-size: 12px;
  text-shadow: 0 0 6px rgba(61,255,124,.5);
}

/* ═══ SMPTE bars ═══ */
.bars { display: flex; width: 100%; }
.bars span { flex: 1; }
.bars.big { height: 34dvh; }
.bars.strip { height: 10px; }
.b-white   { background: #c9c9c9; }
.b-yellow  { background: #c9c927; }
.b-cyan    { background: #27c9c9; }
.b-green   { background: #27c927; }
.b-magenta { background: #c927c9; }
.b-red     { background: #c92727; }
.b-blue    { background: #2727c9; }

/* ═══ base atoms ═══ */
.hidden { display: none !important; }
.dim { color: var(--dim); }
.err { color: var(--red); font-size: 13px; letter-spacing: .08em; }
.row { display: flex; gap: 10px; justify-content: center; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; z-index: 10; }

input {
  background: #05070c; color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 12px; font-size: 16px; font-family: inherit; width: 100%;
  letter-spacing: .06em;
}
input:focus { outline: 1px solid var(--gold); }

.btn {
  background: linear-gradient(#1c2434, #121826);
  color: var(--ink);
  border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 5px;
  padding: 12px 18px; font: inherit; font-size: 14px; letter-spacing: .1em;
  cursor: pointer; min-height: 44px;
}
.btn:active { transform: translateY(1px); border-bottom-width: 1px; }
.btn:disabled { opacity: .38; cursor: default; }
.btn.primary { background: linear-gradient(#e8b83e, #c1901f); color: #17130a; border-color: #8a6a1a; font-weight: 700; }
.btn.primary.armed { background: linear-gradient(#59e87a, #2fae4e); border-color: #1c7a35; }
.btn.ghost { background: transparent; }
.btn.mini { min-height: 30px; padding: 3px 10px; font-size: 12px; }
.btn.action { border-color: var(--gold); color: var(--gold); font-weight: 700; }

/* ═══ CH ∅ · GATE ═══ */
#gate { background: #000 url(watermark.png) repeat; background-size: 430px; }
.gatelogo { width: min(150px, 26vw); filter: drop-shadow(0 0 24px rgba(216,165,49,.35)); }
.headlogo { width: 34px; vertical-align: -8px; margin-right: 4px; }
.gate-lower { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 20px; }
.standby {
  font-size: clamp(26px, 6vw, 54px); font-weight: 800; letter-spacing: .3em;
  color: var(--ink); text-shadow: 0 0 18px rgba(232,228,216,.35);
  animation: blink 2.2s steps(1) infinite;
  text-align: center;
}
.gate-lower p { text-align: center; }
.gate-form { display: flex; gap: 10px; width: min(400px, 88vw); flex-wrap: wrap; }
.gate-form .remember {
  flex-basis: 100%; display: flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: .08em; color: var(--ink); cursor: pointer;
}
.gate-form .remember input { accent-color: var(--green, #35c869); width: 15px; height: 15px; cursor: pointer; }
.gate-form .remember .dim { letter-spacing: .04em; }

/* ═══ CHANNEL GUIDE ═══ */
#guide { padding-bottom: env(safe-area-inset-bottom); background: var(--bg) url(watermark.png) repeat; background-size: 430px; }
.guide-inner { width: min(880px, 96vw); margin: 0 auto; flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.guide-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 18px 22px 8px; flex-wrap: wrap;
}
.guide-head h1 { margin: 0; font-size: 24px; letter-spacing: .2em; color: var(--gold); text-shadow: 0 0 14px rgba(216,165,49,.4); }
.guide-head .sub { color: var(--dim); font-size: 15px; letter-spacing: .12em; }
.guide-head-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.watching { letter-spacing: .06em; color: var(--osd); text-shadow: 0 0 8px rgba(61,255,124,.4); white-space: nowrap; }
.callsign { display: flex; align-items: center; gap: 10px; }
.lockedname {
  font-weight: 800; letter-spacing: .1em; color: var(--gold);
  border: 1px solid var(--line); border-radius: 4px; padding: 8px 14px;
  text-shadow: 0 0 8px rgba(216,165,49,.4);
}

/* the six match tables — a grid of square broadcast tiles. The whole guide scrolls as ONE
   page (guide-inner owns the scroll), so the top row never slides under a pinned pane. */
.guide-list {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px;
  padding: 12px 22px 4px; flex: none; overflow: visible; align-content: start;
}
.ch-tile {
  display: flex; flex-direction: column; gap: 5px;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 13px 10px; min-width: 0; min-height: 128px; overflow: hidden;
}
.ch-tile.live { border-color: #5c2019; box-shadow: 0 0 12px rgba(255,81,71,.18) inset; }
.tile-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.tile-actions { margin-top: auto; display: flex; gap: 6px; }
.tile-actions .btn { flex: 1; }
.tile-actions .btn.ghost { flex: 0 0 auto; padding: 8px 10px; }
/* the utility channels (HOUSE / RULES / COMPENDIUM / TEST PATTERN) — tiles too,
   so their descriptions wrap in full instead of truncating. Their own row below
   the match grid, natural height (not the scrolling flex:1 pane). */
.util-tiles {
  grid-template-columns: repeat(4, 1fr);
  flex: none; overflow: visible; padding-top: 0; padding-bottom: 16px;
}
/* the utility channels wear a warm amber accent so they read as a distinct band
   below the cool green match tiles */
.ch-tile.util {
  min-height: 118px;
  background: linear-gradient(180deg, #191308, #120d07);
  border-color: #5a441d;
}
.ch-tile.util .ch-no { color: var(--gold); text-shadow: 0 0 8px rgba(216,165,49,.5); }
.ch-tile.util .ch-name { color: #f0e2c4; }
.ch-tile.util .ch-sub { color: #cBA157; }
/* THE HOUSE — the commission's own; its own crimson standout among the amber utilities */
.ch-tile.util.house {
  background: linear-gradient(180deg, #1f0d0b, #160a09);
  border-color: #7a2a24;
}
.ch-tile.util.house .ch-no { color: #ff5147; text-shadow: 0 0 9px rgba(255,81,71,.6); }
.ch-tile.util.house .ch-sub { color: #e08a80; }
.ch-no { font-size: 20px; font-weight: 800; color: var(--osd); text-shadow: 0 0 8px rgba(61,255,124,.6); }
.ch-info { flex: 1; min-width: 0; }
.ch-name { font-size: 15px; font-weight: 700; letter-spacing: .08em; }
.ch-tile .ch-name { color: var(--ink); }
.ch-sub { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: pre-line; font-size: 12px; }
/* narrow screens: two match tiles per row so names + badges stay legible */
@media (max-width: 680px) {
  /* the whole guide scrolls as one page — no cramped inner window pinning the
     utility rows against a tiny tile viewport */
  .guide-inner { overflow-y: auto; min-height: 0; }
  .guide-list, .util-tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 12px 14px;
                flex: none; overflow: visible; }
  .util-tiles { padding-top: 0; padding-bottom: 16px; }
  .ch-tile { min-height: 132px; padding: 11px 11px 10px; }
  .ch-tile.util { min-height: 104px; }
  .ch-tile .ch-no { font-size: 18px; }
  .ch-tile .ch-name { font-size: 14px; letter-spacing: .04em; }
  .badge { font-size: 10px; padding: 2px 6px; }
}
.badge { font-size: 11px; padding: 2px 8px; border-radius: 3px; letter-spacing: .1em; vertical-align: 2px; }
.st-open { background: #143619; color: var(--osd); }
.st-wait { background: #3a2f10; color: var(--gold); }
.st-live { background: #43140f; color: #ff5147; animation: blink 1.4s steps(1) infinite; }
.st-post { background: #1c2434; color: var(--dim); }
.st-cup { background: #241a08; color: var(--gold); border: 1px solid #5a441d; margin-left: 4px; }
.stt-cup { color: var(--gold); font-size: 10px; font-weight: 800; margin-left: 6px; letter-spacing: .06em; }
.stt-bot { font-size: 11px; margin-left: 5px; opacity: .8; }
.stands-tile.cpu { border-color: #2b3447; opacity: .9; }
.stands-tile.cpu:hover { opacity: 1; }
.stands-tile.solo { border-color: #3a5a3a; box-shadow: inset 0 0 0 1px rgba(120,200,120,.15); }
#stands-cpu.off { border-color: var(--dim); color: var(--dim); opacity: .7; }
.guide-foot { text-align: center; padding: 8px 0 12px; }
/* THE STANDS entry tile — watch-cyan among the amber utilities */
.ch-tile.util.stands-entry { background: linear-gradient(180deg, #08171a, #061113); border-color: #1f5560; }
.ch-tile.util.stands-entry .ch-no { color: #3ed1c4; text-shadow: 0 0 8px rgba(62,209,196,.5); }
.ch-tile.util.stands-entry .ch-sub { color: #6bbcc4; }

/* ═══ CH·10 · THE STANDS — the wall of live tables ═══ */
#stands { background: var(--bg) url(watermark.png) repeat; background-size: 430px; }
.stands-inner { width: min(1100px, 96vw); margin: 0 auto; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.stands-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 10px; flex-wrap: wrap; }
.stands-head h1 { margin: 0; font-size: 22px; letter-spacing: .16em; color: var(--gold); display: flex; align-items: center; gap: 10px; text-shadow: 0 0 14px rgba(216,165,49,.4); }
.stands-head .headlogo { height: 26px; }
.stands-head .sub { color: var(--dim); font-size: 13px; letter-spacing: .12em; }
.stands-empty { text-align: center; padding: 46px 12px; }
.stands-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; padding: 8px 12px 24px; overflow-y: auto; flex: 1; align-content: start; }
.stands-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: pointer; transition: border-color .15s, transform .1s; }
.stands-tile:hover { border-color: var(--gold); transform: translateY(-2px); }
.stt-top { display: flex; justify-content: space-between; align-items: center; }
.stt-ch { color: var(--osd); font-weight: 800; font-size: 14px; text-shadow: 0 0 8px rgba(61,255,124,.5); }
.stt-t { color: var(--dim); font-size: 12px; }
.stt-name { font-size: 13px; font-weight: 700; letter-spacing: .03em; color: var(--ink); margin: 3px 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stt-name.bottom { color: var(--gold); margin-top: 6px; }
.stt-mini { background: #05070c; border: 1px solid var(--line); border-radius: 6px; padding: 7px; display: flex; flex-direction: column; gap: 6px; min-height: 92px; justify-content: center; }
.stt-wait { text-align: center; font-size: 11px; }
.stt-line { display: flex; gap: 5px; justify-content: center; }
.stt-slot { width: 30px; aspect-ratio: 5 / 7; border-radius: 3px; position: relative; }
.stt-slot.empty { border: 1px dashed #2b3447; opacity: .5; }
.stt-card { width: 100%; height: 100%; object-fit: cover; border-radius: 3px; display: block; }
.stt-card.fb { background: #1c2434; color: var(--ink); font-size: 7px; display: flex; align-items: center; justify-content: center; text-align: center; }
.stt-hp { position: absolute; bottom: -3px; right: -3px; background: rgba(5,7,12,.95); color: var(--hpc); font-size: 9px; font-weight: 800; border-radius: 6px; padding: 0 3px; border: 1px solid #6b2c24; }

/* ═══ CH·11 · THE GAUNTLET — the banner between the two channel sets ═══ */
.gaunt-banner { padding: 2px 12px 14px; }
.gaunt-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 20px; border-radius: 10px;
  background: linear-gradient(110deg, #1a1206 0%, #2a1c07 45%, #1a0f16 100%);
  border: 1px solid var(--gold);
  box-shadow: 0 0 22px rgba(216,165,49,.16), inset 0 0 30px rgba(216,165,49,.05);
  position: relative; overflow: hidden;
}
.gaunt-bar::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 22px, rgba(216,165,49,.05) 22px 24px);
  pointer-events: none;
}
.gaunt-copy { display: flex; flex-direction: column; gap: 2px; z-index: 1; }
.gaunt-no { color: var(--gold); font-size: 13px; letter-spacing: .18em; }
.gaunt-title { font-size: 26px; font-weight: 800; letter-spacing: .16em; color: #f6e2a8; text-shadow: 0 0 16px rgba(216,165,49,.5); }
.gaunt-sub { color: #c9a95e; font-size: 12px; letter-spacing: .06em; }
.gauntlet-cta {
  z-index: 1; flex: 0 0 auto; padding: 14px 22px; font-size: 15px; font-weight: 800;
  letter-spacing: .12em; color: #150d02; border: none; cursor: pointer; border-radius: 7px;
  background: linear-gradient(180deg, #f2cf6a, #d8a531); box-shadow: 0 0 18px rgba(216,165,49,.5);
  transition: transform .1s, box-shadow .15s;
}
.gauntlet-cta:hover { transform: translateY(-1px); box-shadow: 0 0 26px rgba(216,165,49,.75); }
.gaunt-ctas { display: flex; flex-direction: column; gap: 8px; z-index: 1; align-items: stretch; }
.gauntlet-board { padding: 9px 16px; font-size: 12px; font-weight: 700; letter-spacing: .1em; color: var(--gold); background: transparent; border: 1px solid #5a441d; border-radius: 7px; cursor: pointer; transition: border-color .12s, color .12s; }
.gauntlet-board:hover { border-color: var(--gold); color: #f6e2a8; }

/* ═══ CH·12 · THE STANDINGS — the leaderboard ═══ */
#leaderboard { background: var(--bg) url(watermark.png) repeat; background-size: 430px; }
.lb-inner { width: min(760px, 96vw); margin: 0 auto; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 10px; flex-wrap: wrap; }
.lb-head h1 { margin: 0; font-size: 22px; letter-spacing: .16em; color: var(--gold); display: flex; align-items: center; gap: 10px; text-shadow: 0 0 14px rgba(216,165,49,.4); }
.lb-head .headlogo { height: 26px; }
.lb-head .sub { color: var(--dim); font-size: 13px; letter-spacing: .12em; }
.lb-empty { text-align: center; padding: 46px 12px; line-height: 1.6; }
.lb-table { overflow-y: auto; padding: 4px 12px; flex: 1; }
.lb-row { display: grid; grid-template-columns: 40px 1fr 140px 70px 60px; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.lb-headrow { color: var(--dim); font-size: 11px; letter-spacing: .1em; border-bottom: 1px solid var(--gold); position: sticky; top: 0; background: var(--bg); }
.lb-row.me { background: rgba(61,255,124,.06); }
.lb-row.top { background: linear-gradient(90deg, rgba(216,165,49,.12), transparent); }
.lb-rank { color: var(--dim); font-weight: 800; text-align: center; }
.lb-row.top .lb-rank { color: var(--gold); }
.lb-name { font-weight: 700; letter-spacing: .03em; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row.me .lb-name { color: var(--osd); }
.lb-crown { color: var(--gold); }
.lb-medals { display: flex; gap: 6px; font-size: 14px; }
.lb-medal { white-space: nowrap; }
.lb-rec { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; }
.lb-pct { font-variant-numeric: tabular-nums; color: var(--dim); text-align: right; }
.lb-foot { text-align: center; padding: 10px 12px 16px; }
@media (max-width: 680px) {
  .lb-row { grid-template-columns: 30px 1fr 96px 56px; }
  .lb-pct { display: none; }
}
@media (max-width: 680px) {
  .gaunt-bar { flex-direction: column; align-items: stretch; text-align: center; gap: 12px; padding: 14px; }
  .gaunt-title { font-size: 22px; }
  .gauntlet-cta { width: 100%; }
}

/* ═══ CH·11 · THE QUALIFIERS — sign-up + bracket tree ═══ */
#qualifiers { background: var(--bg) url(watermark.png) repeat; background-size: 430px; }
.qual-inner { width: min(1180px, 96vw); margin: 0 auto; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.qual-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 10px; flex-wrap: wrap; }
.qual-head h1 { margin: 0; font-size: 22px; letter-spacing: .16em; color: var(--gold); display: flex; align-items: center; gap: 10px; text-shadow: 0 0 14px rgba(216,165,49,.4); }
.qual-head .headlogo { height: 26px; }
.qual-head .sub { color: var(--dim); font-size: 13px; letter-spacing: .12em; }
.qual-head .row { display: flex; gap: 8px; }

/* sign-up sheet */
.qual-signup { padding: 10px 14px 24px; overflow-y: auto; }
.qual-signup > p { margin: 4px 0 14px; }
.qual-entrants { min-height: 80px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 16px; }
.qual-none { line-height: 1.6; }
.ent-head { color: var(--gold); letter-spacing: .1em; margin-bottom: 10px; }
.ent-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ent-chip { padding: 6px 12px; border-radius: 20px; background: #141a26; border: 1px solid var(--line); color: var(--ink); font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.ent-chip.me { border-color: var(--osd); color: var(--osd); box-shadow: 0 0 10px rgba(61,255,124,.25); }
.qual-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sizepick { display: flex; align-items: center; gap: 6px; }
.sizepick .osdtext { margin-right: 4px; }
.size-opt { padding: 8px 14px; font-weight: 800; }
.size-opt.on { border-color: var(--gold); color: var(--gold); background: #241a08; }
.size-opt:disabled { opacity: .5; cursor: default; }
.btn.primary { border-color: var(--osd); color: #0a1a0e; font-weight: 800; }  /* dark text: readable on amber AND the green armed gradient */

/* sign-up preview — the opening round filling live as contestants enter */
.qual-preview { margin-top: 16px; }
.prev-head { color: var(--gold); letter-spacing: .12em; font-size: 12px; margin-bottom: 10px; }
.prev-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.prev-match { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; position: relative; }
.prev-lab { font-size: 10px; color: var(--dim); letter-spacing: .12em; margin-bottom: 5px; }
.prev-seat { padding: 6px 9px; border-radius: 5px; background: #0a0e16; margin-bottom: 4px; font-size: 13px; font-weight: 700; letter-spacing: .02em; color: var(--ink); }
.prev-seat:last-child { margin-bottom: 0; }
.prev-seat.me { color: var(--osd); border: 1px solid rgba(61,255,124,.4); }
.prev-seat.house { color: #8b93a7; font-weight: 600; font-style: italic; }

/* the bracket tree — columns per round, matches stacked */
.qual-bracket { flex: 1; overflow: auto; padding: 8px 12px 24px; }
.brk-cols { display: flex; gap: 22px; align-items: stretch; min-width: min-content; }
.brk-col { display: flex; flex-direction: column; gap: 14px; justify-content: space-around; min-width: 210px; }
.brk-col.bronze { justify-content: flex-start; }
.brk-coltitle { color: var(--gold); letter-spacing: .14em; text-align: center; padding-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.brk-match { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; position: relative; }
.brk-match.done { opacity: .82; }
.brk-match.live { border-color: #ff5147; box-shadow: 0 0 16px rgba(255,81,71,.25); }
.brk-match.mine { border-color: var(--osd); box-shadow: 0 0 16px rgba(61,255,124,.3); }
.brk-lab { font-size: 10px; color: var(--dim); letter-spacing: .12em; margin-bottom: 5px; }
.brk-side { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 8px; border-radius: 5px; background: #0a0e16; margin-bottom: 4px; }
.brk-side .brk-nm { font-size: 13px; font-weight: 700; letter-spacing: .02em; color: var(--ink); line-height: 1.2; word-break: break-word; }
.brk-side.won { background: #14210f; }
.brk-side.won .brk-nm { color: var(--rad); }
.brk-side.me .brk-nm { color: var(--osd); }
.brk-side.house .brk-nm { color: #e08a80; }
.brk-tick { color: var(--rad); font-weight: 800; }
.brk-foot { margin-top: 4px; text-align: right; }
.brk-tag { font-size: 10px; padding: 2px 7px; border-radius: 3px; letter-spacing: .09em; font-weight: 700; }
.brk-tag.on { background: #43140f; color: #ff5147; animation: blink 1.4s steps(1) infinite; }
.brk-tag.done { background: #1c2434; color: var(--dim); }
.brk-tag.ff { background: #2a1508; color: var(--gold); }
.brk-tag.wait { background: #10141d; color: var(--dim); border: 1px solid var(--line); }
.brk-play { width: 100%; margin-top: 8px; }
.brk-watch { width: 100%; margin-top: 8px; }

/* the podium — medals by callsign */
.qual-podium { padding: 20px 12px 30px; text-align: center; }
.pod-title { color: var(--gold); letter-spacing: .16em; font-size: 15px; margin-bottom: 18px; }
.pod-row { display: flex; justify-content: center; align-items: flex-end; gap: 18px; }
.pod-slot { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 18px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); min-width: 130px; }
.pod-slot .pod-medal { font-size: 40px; }
.pod-slot .pod-nm { font-size: 14px; font-weight: 800; letter-spacing: .04em; color: var(--ink); }
.pod-slot.gold { border-color: var(--gold); box-shadow: 0 0 22px rgba(216,165,49,.35); padding-bottom: 34px; order: 2; }
.pod-slot.gold .pod-nm { color: #f6e2a8; }
.pod-slot.silver { order: 1; padding-bottom: 20px; }
.pod-slot.bronze { order: 3; padding-bottom: 12px; }
@media (max-width: 680px) {
  .brk-cols { flex-direction: column; }
  .brk-col { min-width: 0; }
  .pod-row { gap: 10px; }
  .pod-slot { min-width: 92px; padding: 12px; }
}

/* ═══ STADIUM CHAT — global ephemeral chat + emotes, on every screen ═══ */
/* Bottom-LEFT, above the Discord badge — the turn controls own the bottom-RIGHT, and the chat used
   to sit right on top of them so taps for END TURN / attack landed on the dock (Mike's blocker).
   Collapsed it shrinks to a tiny pill that covers almost nothing; expanded it opens upward. */
#chatdock {
  position: fixed; left: 12px; right: auto; bottom: 56px; z-index: 50;
  width: min(330px, calc(100vw - 24px));
  background: rgba(9,12,19,.97); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); display: flex; flex-direction: column; overflow: hidden;
}
#chatdock.collapsed { width: auto; }
#chatdock.collapsed .cd-here { display: none; }   /* keep the collapsed pill tiny */
#chatdock.collapsed #chatdock-head { padding: 7px 10px; }
#chatdock-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer;
  background: linear-gradient(180deg, #141a26, #0d1119); border-bottom: 1px solid var(--line);
}
.cd-title { font-weight: 800; letter-spacing: .1em; font-size: 12px; color: var(--osd); text-shadow: 0 0 8px rgba(61,255,124,.4); }
.cd-here { color: var(--gold); font-size: 11px; letter-spacing: .06em; }
.cd-unread { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; border-radius: 10px; padding: 1px 7px; }
.cd-toggle { margin-left: auto; background: none; border: 1px solid var(--line); color: var(--ink); width: 24px; height: 22px; border-radius: 5px; cursor: pointer; font-size: 12px; }
.cd-unread + .cd-toggle { margin-left: 6px; }
#chatdock.collapsed #chatdock-body { display: none; }
#chatdock-body { display: flex; flex-direction: column; }
.cd-lines { height: 210px; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.cd-hello { text-align: center; padding: 20px 8px; line-height: 1.5; font-size: 11px; }
.cd-line { font-size: 13px; line-height: 1.35; word-break: break-word; }
.cd-tag { color: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.cd-from { color: var(--dim); font-weight: 800; margin: 0 4px 0 3px; }
.cd-from.me { color: var(--osd); }
.cd-body { color: var(--ink); }
.cd-emotebar { display: flex; gap: 3px; padding: 6px 8px; border-top: 1px solid var(--line); overflow-x: auto; }
.emote-btn { background: #0d1119; border: 1px solid var(--line); border-radius: 6px; font-size: 17px; line-height: 1; padding: 5px 6px; cursor: pointer; flex: 0 0 auto; transition: transform .08s, border-color .1s; }
.emote-btn:hover { transform: translateY(-2px) scale(1.12); border-color: var(--gold); }
.cd-inputrow { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); align-items: center; }
.cd-emoji { background: #0d1119; border: 1px solid var(--line); border-radius: 6px; font-size: 16px; padding: 6px 8px; cursor: pointer; }
#cd-msg { flex: 1; min-width: 0; background: #05070c; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
#cd-msg:focus { outline: 1px solid var(--gold); }
.cd-send { padding: 8px 12px; font-size: 12px; }
.cd-emojipick { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; padding: 8px; border-top: 1px solid var(--line); max-height: 132px; overflow-y: auto; }
.emoji-btn { background: none; border: 1px solid transparent; border-radius: 5px; font-size: 18px; padding: 3px; cursor: pointer; }
.emoji-btn:hover { border-color: var(--gold); background: #141a26; }

/* floating broadcast emotes — drift up over everything, seen by all */
#emote-float { position: fixed; inset: 0; z-index: 46; pointer-events: none; overflow: hidden; }
.emote-pop { position: absolute; bottom: 70px; display: flex; flex-direction: column; align-items: center; animation: emoteRise 2.6s ease-out forwards; }
.emote-pop .ep-glyph { font-size: 44px; filter: drop-shadow(0 0 10px rgba(0,0,0,.6)); }
.emote-pop .ep-who { font-size: 11px; font-weight: 800; letter-spacing: .06em; color: var(--gold); background: rgba(5,7,12,.8); border-radius: 8px; padding: 1px 7px; margin-top: 2px; }
@keyframes emoteRise {
  0%   { opacity: 0; transform: translateY(20px) scale(.6); }
  15%  { opacity: 1; transform: translateY(0) scale(1.1); }
  30%  { transform: scale(1); }
  100% { opacity: 0; transform: translateY(-46vh) scale(1); }
}

/* Discord — the spectator-role invite, persistent chrome, bottom-left */
#discord-badge {
  position: fixed; left: 16px; bottom: 14px; z-index: 49;
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px;
  background: #5865F2; color: #fff; border-radius: 8px; text-decoration: none;
  font-weight: 800; letter-spacing: .08em; font-size: 12px; box-shadow: 0 4px 16px rgba(88,101,242,.4);
  transition: transform .1s, box-shadow .15s;
}
#discord-badge:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(88,101,242,.6); }
#discord-badge svg { display: block; }

@media (max-width: 680px) {
  /* STADIUM CHAT tucks HARD into the bottom-left on phones and reads just "CHAT" so it never
     buries the hand (Tyler). Narrower, shorter feed, smaller type, more transparent. */
  #chatdock { left: 3px; right: auto; bottom: 40px; width: min(200px, calc(100vw - 12px)); background: rgba(9,12,19,.82); }
  #chatdock.collapsed { left: 3px; bottom: 6px; }        /* the collapsed pill sits in the very corner */
  #chatdock-head { padding: 5px 8px; }
  .cd-title { font-size: 10px; }
  .cd-stadium { display: none; }                          /* on phones the pill just reads "📣 CHAT" */
  .cd-lines { height: 90px; font-size: 11px; }
  #cd-msg { font-size: 12px; }
  /* the Discord badge is FULLY hidden on phones — it was crowding the bottom-left hand (Tyler) */
  #discord-badge { display: none !important; }
}

/* ═══ CH·07 · FIELD MANUAL ═══ */
#manual { background: var(--bg) url(watermark.png) repeat; background-size: 430px; }
.manual-inner { width: min(1020px, 96vw); margin: 0 auto; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.manual-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 8px 10px; flex-wrap: wrap; }
.manual-head h1 { margin: 0; font-size: 22px; letter-spacing: .18em; color: var(--gold); text-shadow: 0 0 14px rgba(216,165,49,.4); }
.tabbtn.on { border-color: var(--gold); color: var(--gold); font-weight: 800; }
.manual-pane { flex: 1; overflow-y: auto; padding: 4px 10px 30px; }
#manual-rules { max-width: 760px; margin: 0 auto; user-select: text; }
#manual-rules h2 { color: var(--gold); letter-spacing: .14em; font-size: 19px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
#manual-rules h3 { color: var(--osd); letter-spacing: .12em; font-size: 14px; margin: 22px 0 6px; text-shadow: 0 0 6px rgba(61,255,124,.4); }
#manual-rules p { color: #cfd6e4; font-size: 14px; line-height: 1.6; margin: 6px 0 10px; }
#manual-rules b { color: var(--ink); }
#manual-rules .cols { columns: 2 340px; column-gap: 36px; }   /* two columns when the glass allows */
#manual-rules section { break-inside: avoid; margin-bottom: 20px; }
#manual-rules section h3 { margin-top: 0; }
#manual-roster h2 { color: var(--gold); letter-spacing: .14em; font-size: 19px; }
.filters { flex-wrap: wrap; justify-content: flex-start; gap: 6px; align-items: center; padding: 4px 0 12px; }
#roster-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
.rostercard { cursor: pointer; transition: transform .12s; border-radius: 8px; }
.rosterflavor {
  font-size: 11px; font-style: italic; color: var(--dim);
  line-height: 1.45; padding: 6px 3px 2px; user-select: text;
}
.rostercard:hover { transform: translateY(-4px) scale(1.03); }
.rostercard img { width: 100%; border-radius: 8px; display: block; border: 1px solid #000; }
.rostercard.legendary { box-shadow: 0 0 14px rgba(216,165,49,.5); }
.rostercard.cryptid { box-shadow: 0 0 10px rgba(164,90,214,.4); }

/* 👁 the stands: read-only chrome */
body.watching .chatinput { display: none; }        /* the crowd reads, it doesn't heckle (yet) */
body.watching #turnctl { display: none; }
#btn-exit { border-color: #6b2c24; color: var(--hpc); }

/* 🐛 bug box */
#bugbox textarea {
  background: #05070c; color: var(--ink); border: 1px solid var(--line); border-radius: 4px;
  padding: 12px; font: inherit; font-size: 14px; width: 100%; resize: vertical;
}

/* ═══ TABLE LOBBY ═══ */
#lobby-view { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
/* ^ scrollable: on phones the recap runs tall and the chat SEND must stay reachable */
.lobby-panel {
  margin: 5dvh auto 0; width: min(660px, 94vw);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 26px 26px 22px; text-align: center;
  display: flex; flex-direction: column; gap: 18px;
}
.lobby-panel h2 { margin: 0; letter-spacing: .24em; color: var(--gold); font-size: 22px; }
.lobby-result {
  font-size: 17px; font-weight: 800; letter-spacing: .12em; color: var(--osd);
  text-shadow: 0 0 10px rgba(61,255,124,.6);
  border: 1px dashed #1c7a35; border-radius: 5px; padding: 10px;
}
.versus { display: flex; align-items: center; justify-content: center; gap: 26px; }
.fighter { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 170px; }
.fname { font-size: 17px; font-weight: 700; letter-spacing: .06em; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs { font-size: 15px; }
.lamp {
  width: 22px; height: 22px; border-radius: 50%;
  background: #1a2130; border: 2px solid var(--line);
}
.lamp.seated { background: #3a2f10; border-color: var(--gold); }
.lamp.lit { background: var(--osd); border-color: #1c7a35; box-shadow: 0 0 14px rgba(61,255,124,.8); }

.chatbox {
  margin: 16px auto 0; width: min(660px, 94vw); flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
#chatlines {
  flex: 1; overflow-y: auto; min-height: 70px; max-height: 30dvh;
  background: rgba(5, 7, 12, .8); border: 1px solid var(--line); border-radius: 6px 6px 0 0;
  padding: 8px 10px; font-size: 13px;
}
.chatline { padding: 2px 0; color: #cfd6e4; word-break: break-word; }
.chatfrom { color: var(--osd); }
.chatinput { display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 6px 6px; padding: 6px; }
.chatinput input { border: 0; background: transparent; padding: 8px; font-size: 14px; }

/* ═══ SURVIVOR SELECT (draft Tier 1) ═══ */
#pick-view { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.pick-inner {
  margin: 3dvh auto 0; width: min(1000px, 96vw);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 10px 10px calc(18px + env(safe-area-inset-bottom));
}
#pick-title { margin: 0; letter-spacing: .22em; color: var(--gold); font-size: 22px; text-align: center; }
#pick-sub { text-align: center; }
#pick-teams { display: flex; gap: 16px; justify-content: center; align-items: flex-start; flex-wrap: wrap; width: 100%; }
.pick-team { display: flex; flex-direction: column; gap: 10px; flex: 1 1 260px; max-width: 320px; min-width: 220px; }
.pick-team-h {
  text-align: center; letter-spacing: .16em; font-size: 12px; font-weight: 800;
  color: var(--osd); border-bottom: 1px solid var(--line); padding-bottom: 5px;
}
.pickcard {
  display: flex; gap: 10px; align-items: center; cursor: pointer;
  background: var(--panel); border: 2px solid var(--line); border-radius: 8px; padding: 8px;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.pickcard:hover { border-color: var(--gold); }
.pickcard.sel { border-color: var(--osd); box-shadow: 0 0 14px rgba(61,255,124,.5); transform: translateY(-1px); }
.pickcard.locked { border-color: var(--osd); box-shadow: 0 0 18px rgba(61,255,124,.7); }
.pickcard img { width: 62px; aspect-ratio: 5/7; object-fit: cover; border-radius: 5px; background: #05070c; flex: none; }
.pickcard .cardfallback { width: 62px; aspect-ratio: 5/7; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 9px; white-space: pre-line; color: var(--dim); border-radius: 5px; background: #05070c; flex: none; }
.pickcard-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pickcard-n { font-size: 12.5px; font-weight: 700; letter-spacing: .02em; color: var(--ink); line-height: 1.2; }
.pickcard-p { font-size: 10.5px; color: var(--dim); line-height: 1.25; }
#pick-foot {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: min(660px, 94vw); margin-top: 4px;
}
#pick-status { text-align: center; min-height: 18px; }
#pick-confirm { min-width: 200px; }
@media (max-width: 640px) {
  #pick-teams { gap: 10px; }
  .pick-team { flex-basis: 100%; max-width: 96vw; min-width: 0; }
  .pickcard img, .pickcard .cardfallback { width: 52px; }
  #pick-title { font-size: 18px; }
}

/* ═══ THE MATCH ═══ */
#match-view { display: flex; flex-direction: column; height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
@media (orientation: landscape) {
  #match-view.railopen #board,
  #match-view.railopen #topbar,
  #match-view.railopen #bottombar { margin-right: min(300px, 78vw); }
}
#topbar, #bottombar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; }
.pname {
  font-weight: 700; color: var(--gold); letter-spacing: .06em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 38vw; flex: 0 1 auto;
}
#topbar .zones { flex: 1; min-width: 0; }
.zones { display: flex; gap: 12px; font-size: 13px; color: var(--dim); overflow: hidden; white-space: nowrap; }
.zone { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
.zone.surv { color: var(--gold); font-weight: 700; }
/* the pit catches a fallen creature — a quick pulse as the body lands */
.zone.pitcatch { animation: pitcatch .5s ease-out; display: inline-block; }
@keyframes pitcatch { 0% { transform: scale(1); } 40% { transform: scale(1.4); color: var(--hpc); text-shadow: 0 0 10px var(--hpc); } 100% { transform: scale(1); } }
.choicecard.armed { border-color: var(--gold); color: var(--gold); }
#autoend { animation: blink 1s steps(1) infinite; }
#log-toggle { margin-left: auto; }

#board { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; min-height: 0; }
.line { display: flex; justify-content: center; gap: 2.6vw; align-items: flex-end; }
/* survivor passive — a slim always-on line above each side's creatures. Both
   players read what each coach's passive does; the full card is one tap away. */
.survpassive {
  align-self: center; max-width: min(700px, 94%);
  padding: 3px 13px; border-radius: 6px;
  background: rgba(216,165,49,.09); border: 1px solid rgba(216,165,49,.28);
  color: var(--gold); font-size: clamp(10px, 1.35vw, 13px); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; text-align: center; flex: 0 0 auto;
}
.survpassive:hover { background: rgba(216,165,49,.16); }
.cell {
  position: relative;
  width: var(--cardw);
  aspect-ratio: 5 / 7;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .15s;
}
.cell.podium { transform: translateY(-12px); }
.cell.podium::after {
  content: ""; position: absolute; left: 8%; right: 8%; bottom: -11px; height: 8px;
  background: linear-gradient(#3a4358, #232b3b);
  border-radius: 3px;
}
.line.enemy .cell.podium { transform: translateY(12px); }
.line.enemy .cell.podium::after { bottom: auto; top: -11px; }
.emptyslot { width: 100%; height: 100%; border: 2px dashed #2b3447; border-radius: 8px; opacity: .5; }
.boardcard, .cardfallback { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; display: block; }
.cardfallback {
  background: #1c2434; color: var(--ink);
  display: flex; align-items: center; justify-content: center; text-align: center;
  white-space: pre-line; font-size: 11px; padding: 4px; border: 1px solid var(--line);
}

.cell.sel { outline: 3px solid var(--gold); }
.cell.cand { outline: 3px dashed rgba(216, 165, 49, .75); }
.cell.pick1 { outline: 3px solid var(--gold); }
.cell.pick2 { outline: 3px solid var(--volt); }
.cell.atkflash { animation: atkflash .55s; }
.cell.beatflash { animation: beatflash .7s; }
@keyframes atkflash { 30% { transform: scale(1.07); filter: brightness(1.5); } }
@keyframes beatflash { 30% { filter: brightness(2) saturate(2); } }

/* ── live stat overlays, calibrated onto the PRINTED stat boxes (v1.3) ──
   geometry from the card renderer: ATK box x50 w168, HP box x228 w168, both
   y586 h52 in a 500×700 face → the % below. The box shares the print's brown
   so it reads as the same box, just showing the live number. */
.statbox {
  position: absolute; bottom: 8.86%; height: 8.6%;
  background: #3b2a1d; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; pointer-events: none; overflow: visible;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.statbox.atk { left: 10%;   width: 33.6%; }
.statbox.hp  { left: 45.6%; width: 33.6%; }
/* the ATK / HP label tucks into the box's top-left corner, freeing the middle
   for the live value (Tyler's call) */
.statbox .lbl {
  position: absolute; top: 8%; left: 8%;
  font-size: clamp(5px, calc(var(--cardw) * .04), 8px);
  letter-spacing: .08em; color: #f2e4c8; opacity: .78; font-weight: 700;
}
.statbox .sval {
  font-size: clamp(9px, calc(var(--cardw) * .08), 15px);
  font-weight: 800; color: var(--gold); white-space: nowrap;
  margin-top: 12%;   /* nudge below the corner label so they never collide */
}
.statbox .sval.hurt { color: var(--hpc); }
/* the grow/hurt delta badge — rides the top-right corner of its box */
.grow {
  position: absolute; top: -32%; right: -6%;
  font-size: clamp(7px, calc(var(--cardw) * .058), 11px); font-weight: 800;
  padding: 0 3px; border-radius: 6px; border: 1px solid #000;
}
.grow.up   { background: var(--osd); color: #08160c; box-shadow: 0 0 6px rgba(61,255,124,.7); }
.grow.down { background: var(--hpc); color: #240a06; box-shadow: 0 0 6px rgba(255,140,122,.6); }
/* the ATTACK ADDER — this-turn ATK buff, rides the top-LEFT so it never collides with the
   permanent-growth badge on the right. Volt-green with a swing tick so it reads as bonus damage. */
.grow.temp { left: -6%; right: auto; top: -32%; background: var(--volt); color: #1c1705; box-shadow: 0 0 7px rgba(232,212,77,.85); }
.grow.temp::before { content: "⚔"; margin-right: 1px; }
.grow.roped { left: -6%; right: auto; top: -32%; background: var(--hpc); color: #240a06; box-shadow: 0 0 7px rgba(255,140,122,.85); }
.grow.roped::before { content: "🪢"; margin-right: 1px; }

.chip {
  font-size: clamp(10px, calc(var(--cardw) * .088), 14px);
  font-weight: 800; padding: 1px 6px; border-radius: 4px;
  background: rgba(5, 7, 12, .92); border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.armor { color: #cfd6e4; }
.chip.corr  { color: var(--rad);   border-color: #2f5a20; }
.chip.att   { color: var(--gold);  border-color: #6a5215; }
/* armor + corrosion ride the guard strip just above the HP box */
.guardrow {
  position: absolute; right: 20.8%; bottom: 18.4%;
  display: flex; gap: 3px; align-items: flex-end;
}
/* extra stacking counters (Flock die, Jackalope) — ride just above the ATK box,
   mirroring the guard strip; clear of the printed variance pill (top-right) */
.attmarks {
  position: absolute; left: 10%; bottom: 18.4%;
  display: flex; gap: 3px; align-items: flex-end;
}

/* ── INFUSION COVERS: bold half-card markers. One infusion tints the top half; a second (a
   PAIR combo) tints the bottom half too. Semi-transparent so the art + live stats still read;
   pointer-events pass through EXCEPT the centered icon, which is the hover target for the effect. */
.infcover {
  position: absolute; left: 0; right: 0; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; overflow: hidden;
}
.infcover.top { top: 0;   height: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.15); }
.infcover.bot { top: 50%; height: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.15); }
.infcover.rad  { background: radial-gradient(rgba(111,214,87,.52), rgba(111,214,87,.26)); }
.infcover.volt { background: radial-gradient(rgba(232,212,77,.52), rgba(232,212,77,.26)); }
.infcover.chem { background: radial-gradient(rgba(164,90,214,.55), rgba(164,90,214,.30)); }
.infcover .inf-ico {
  pointer-events: auto; cursor: help;
  font-size: clamp(15px, calc(var(--cardw) * .26), 38px);
  filter: drop-shadow(0 1px 3px #000); opacity: .92; line-height: 1;
}
.inf-combo {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  text-align: center; pointer-events: auto; cursor: help;  /* tap the combo band to read its effect on touch */
  font-size: clamp(8px, calc(var(--cardw) * .1), 14px); font-weight: 900; letter-spacing: .08em;
  color: #fff; text-shadow: 0 1px 3px #000, 0 0 7px #000, 0 0 3px #000;
}
.marks { position: absolute; left: 4px; top: 4px; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; z-index: 2; }
.pip { width: 15px; height: 15px; border-radius: 50%; border: 1px solid #000; font-size: 9px; text-align: center; line-height: 14px; font-weight: 800; color: #10131a; }
.pip.rad { background: var(--rad); }
.pip.volt { background: var(--volt); }
.pip.chem { background: var(--chem); }
.pip.bond { background: #4dc3e8; width: auto; min-width: 15px; padding: 0 3px; border-radius: 8px; }
.pip.ult { background: #e8544d; width: auto; min-width: 15px; padding: 0 3px; border-radius: 8px; box-shadow: 0 0 6px #e8544d; }
.flagmark { font-size: 12px; background: rgba(5, 7, 12, .85); border-radius: 5px; padding: 0 3px; }

/* ══ KA UHI — Kealoha's ultimate: the unbreakable triple-bond, made unmistakable ══ */
.cell.kauhi { box-shadow: 0 0 0 2px #1a1020, 0 0 14px 3px rgba(255,110,40,.55), inset 0 0 22px rgba(20,10,30,.55); animation: kauhiPulse 1.7s ease-in-out infinite; z-index: 3; }
@keyframes kauhiPulse {
  0%, 100% { box-shadow: 0 0 0 2px #1a1020, 0 0 12px 2px rgba(255,110,40,.45), inset 0 0 18px rgba(20,10,30,.5); }
  50%      { box-shadow: 0 0 0 2px #2a1636, 0 0 22px 6px rgba(255,140,60,.85), inset 0 0 26px rgba(40,16,60,.7); }
}
.kauhi-aura { position: absolute; inset: 0; pointer-events: none; z-index: 2; border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(255,120,40,.0) 8%, rgba(255,120,40,.85) 50%, rgba(255,120,40,.0) 92%) center/100% 3px no-repeat,
    radial-gradient(120% 60% at 50% 100%, rgba(255,90,30,.35), rgba(60,20,80,.0) 70%);
  mix-blend-mode: screen; }
/* the thread bleeds past the edges so adjacent bonded cells read as ONE ink line across the three */
.kauhi-aura::before { content: ''; position: absolute; top: 50%; left: -12px; right: -12px; height: 3px; transform: translateY(-50%);
  background: linear-gradient(90deg, rgba(120,60,180,.9), rgba(255,130,50,.95), rgba(120,60,180,.9));
  box-shadow: 0 0 8px rgba(255,120,50,.9), 0 0 14px rgba(150,70,200,.7); }
.kauhi-emblem { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); z-index: 4; font-size: 15px;
  filter: drop-shadow(0 0 5px rgba(255,120,40,.95)); animation: kauhiPulse 1.7s ease-in-out infinite; pointer-events: auto; }

/* position:relative + z-index keeps CENTER STAGE (the rolling die) painting ABOVE the board
   cards. z-18 sits ABOVE the lunging attacker (z-12) — which was tying the old z-15 and, being
   later in the DOM, painting over the die mid-roll (Ash's report) — and BELOW the floaters (z-20)
   so damage numbers still pop over the die. */
#midbar { position: relative; z-index: 18; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 2px 10px; min-height: 46px; }
#turnchip { font-size: 13px; letter-spacing: .12em; color: var(--dim); }
#turnchip.live { color: var(--osd); font-weight: 800; text-shadow: 0 0 8px rgba(61,255,124,.5); }
#seatchip { font-size: 13px; border: 1px solid var(--line); border-radius: 5px; padding: 5px 9px; cursor: pointer; }

/* ── the hand: big, fanned, tucked into the bottom bezel; rises to meet you ── */
#bottombar { flex-direction: column; align-items: stretch; gap: 2px; overflow: visible; }
.pname.bottom { align-self: flex-start; max-width: 60vw; font-size: 14px; }
#hand {
  display: flex; justify-content: center; overflow: visible;
  align-items: flex-start;   /* NEVER stretch: stretch overrides aspect-ratio and squashes the cards */
  padding: 4px 10px 0;
  height: calc(var(--handw) * 1.12);            /* top ~80% visible at rest — bezel crop */
}
.handcard {
  flex: 0 0 auto; position: relative;
  width: var(--handw); aspect-ratio: 5 / 7;
  margin-left: calc(var(--handw) * -0.12);       /* a light fan — cards stay readable */
  cursor: pointer;
  transition: transform .14s;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.6));
}
.handcard:first-child { margin-left: 0; }
.handcard:hover, .handcard:active {
  transform: translateY(calc(var(--handw) * -0.42)) scale(1.05);
  z-index: 6;
}
.handimg { width: 100%; height: 100%; border-radius: 7px; display: block; border: 1px solid #000; }
.handcard.armed2play {   /* touch two-tap: armed and waiting for the commit */
  transform: translateY(calc(var(--handw) * -0.42)) scale(1.05);
  z-index: 6; outline: 3px solid var(--gold); border-radius: 8px;
}

/* ── log rail + in-match chat ── */
#lograil {
  position: fixed; right: 0; top: 42px; bottom: 0; width: min(300px, 78vw);
  background: rgba(6, 8, 13, .96); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 30;
  transition: transform .2s;
}
#lograil.collapsed { transform: translateX(100%); }
#lograil-head { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; font-size: 12px; letter-spacing: .16em; color: var(--osd); border-bottom: 1px solid var(--line); text-shadow: 0 0 6px rgba(61,255,124,.5); }
#loglines { flex: 1; overflow-y: auto; padding: 6px 10px; font-size: 11.5px; }
.logline { padding: 1.5px 0; color: #aeb6c8; word-break: break-word; }
.logline.diag { color: #7a6030; }
.logline.dim { opacity: .45; }
.logline.chat { color: var(--osd); }
.logline.feed { color: #ffd76a; font-size: 12.5px; font-weight: 700; padding: 3px 0; }
.chatinput.rail { border: 0; border-top: 1px solid var(--line); border-radius: 0; }

/* ── toasts ── */
#toasts { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 45; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(6, 9, 14, .95); border: 1px solid var(--line);
  border-radius: 4px; padding: 7px 16px; font-size: 14px; letter-spacing: .05em;
  transition: opacity .5s; max-width: 88vw;
}
.toast.bad { border-color: var(--red); color: #ffb0a5; }
.toast.beat { border-color: var(--gold); color: var(--gold); font-weight: 800; }
.toast.chat { border-color: #1c7a35; color: var(--osd); }
.toast.out { opacity: 0; }

/* ── floaters ── */
.floater {
  position: absolute; left: 50%; top: 38%;
  transform: translateX(-50%);
  font-size: 26px; font-weight: 900; z-index: 20; pointer-events: none;
  animation: floatup 1.3s ease-out forwards;
  text-shadow: 0 2px 4px #000;
}
.floater.dmg { color: var(--red); }
.floater.shield { color: #cfd6e4; font-size: 18px; top: 58%; }
.floater.ko { color: #fff; font-size: 36px; }
@keyframes floatup { to { transform: translateX(-50%) translateY(-40px); opacity: 0; } }

/* ── CENTER STAGE: the die lives here now — lands, lingers, ghosts ── */
#stage { display: flex; align-items: center; gap: 18px; }
#stage-die {
  --diecol: var(--gold);   /* set per-roll to the roller's survivor-deck colour */
  width: 84px; height: 84px; border-radius: 14px; flex: 0 0 auto;
  background: linear-gradient(145deg, #222b3e, #141a27);
  border: 2px solid var(--diecol);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity .8s, box-shadow .4s, border-color .3s;
}
#stage-die.idle { opacity: .18; box-shadow: none; }
#stage-die.rolling { opacity: 1; animation: wobble .5s linear infinite; box-shadow: 0 0 34px var(--diecol); }
#stage-die.landed { opacity: 1; animation: land .35s ease-out; box-shadow: 0 0 50px var(--diecol); }
#die-face { font-size: 34px; font-weight: 900; color: var(--diecol); line-height: 1; }

/* DESKTOP declutter (Tyler): survivor passives ride the LEFT edge (freeing the vertical
   bars the board was fighting), and the fading feed sits center, right of the tracker. */
@media (orientation: landscape) and (pointer: fine) {
  #board { position: relative; }
  .survpassive {
    position: absolute; left: 6px; max-width: 200px; z-index: 12;
    white-space: normal; text-align: left; line-height: 1.22;
    max-height: 34%; overflow: hidden;
  }
  #enemy-passive { top: 6px; }
  #your-passive  { bottom: 6px; }
  #toasts { top: 50%; left: 50%; transform: translate(-50%, -50%); align-items: center; }
}
#die-why { font-size: 9px; color: var(--dim); letter-spacing: .1em; text-transform: uppercase; max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes wobble { 25% { transform: rotate(3deg); } 75% { transform: rotate(-3deg); } }
@keyframes land { 0% { transform: scale(1.35); } }
#stage-info { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
#tracker { display: flex; gap: 8px; }
.trk {
  font-size: 11.5px; font-weight: 800; letter-spacing: .1em;
  border: 1px solid #1c7a35; color: var(--osd); border-radius: 4px; padding: 2px 8px;
  text-shadow: 0 0 6px rgba(61,255,124,.5);
}
.trk.spent { border-color: var(--line); color: #4a5162; text-shadow: none; text-decoration: line-through; }

/* turn controls: lower right, out of the way — and out from UNDER the rail */
#turnctl {
  position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 35; display: flex; gap: 8px;
}
@media (orientation: landscape) {
  #match-view.railopen ~ #turnctl,
  #match-view.railopen #turnctl { right: calc(24px + min(300px, 78vw)); }
}

/* attack drama */
/* tapping a play in the feed traces the creatures it touched */
.cell.trace { animation: trace 1.1s ease-out; }
@keyframes trace {
  0%, 100% { box-shadow: none; }
  15% { box-shadow: 0 0 0 3px var(--gold), 0 0 22px var(--gold); }
  60% { box-shadow: 0 0 0 3px var(--gold), 0 0 22px var(--gold); }
}
.logline.feed.clickable { cursor: pointer; border-left: 2px solid transparent; padding-left: 4px; }
.logline.feed.clickable:hover { border-left-color: var(--gold); background: rgba(216,165,49,.08); }
.cell.impact { animation: impact .32s ease-out; }
@keyframes impact {
  0% { transform: translate(0,0); filter: brightness(2.2); }
  30% { transform: translate(7px,-4px) rotate(2deg); }
  60% { transform: translate(-6px,3px) rotate(-2deg); }
}
.cell.dying { animation: dying .95s ease-in forwards; }
@keyframes dying {
  0% { filter: brightness(2.6) saturate(0); }
  25% { filter: brightness(1); transform: rotate(0); }
  100% { transform: rotate(10deg) translateY(26px) scale(.92); opacity: 0; }
}
.cell.autolock { outline: 3px solid var(--red); animation: lockpulse .45s ease-in-out; }
@keyframes lockpulse { 50% { outline-offset: 5px; filter: brightness(1.5); } }
.readydot {
  position: absolute; left: 50%; top: -7px; transform: translateX(-50%);
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gold); border: 1px solid #6a5215;
  box-shadow: 0 0 9px rgba(216,165,49,.9);
  animation: pulse 1.4s ease-in-out infinite;
}
.line.enemy .readydot { display: none; }

/* the matchup + the K.O. */
.matchup-inner { display: flex; align-items: center; gap: min(6vw, 60px); }
.mu-side { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.mu-side img { width: min(260px, 34vw); border-radius: 12px; box-shadow: 0 10px 60px #000; animation: land .5s ease-out; }
.mu-name { font-weight: 800; letter-spacing: .08em; color: var(--gold); font-size: 15px; text-align: center; }
.mu-vs { font-size: min(64px, 9vw); font-weight: 900; color: var(--osd); text-shadow: 0 0 30px rgba(61,255,124,.7); animation: pulse 1s infinite; }
#victory { flex-direction: column; gap: 10px; }
#victory-sub { font-size: 13px; letter-spacing: .14em; text-align: center; max-width: 88vw; color: var(--ink); }
#victory.celebrate #victory-ko { animation: land .4s ease-out, champpulse 1.1s ease-in-out .5s infinite; }
@keyframes champpulse { 50% { text-shadow: 0 0 110px rgba(216,165,49,1), 0 6px 0 #6a5215; transform: scale(1.04); } }
#victory-fx { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#victory-fx span { position: absolute; top: -4vh; width: 9px; height: 14px; opacity: .9; animation: confetti 3s linear infinite; }
@keyframes confetti { 0% { transform: translateY(0) rotate(0); } 100% { transform: translateY(110vh) rotate(540deg); } }
#victory-ko {
  font-size: min(160px, 24vw); font-weight: 900; color: var(--gold); letter-spacing: .1em;
  text-shadow: 0 0 60px rgba(216,165,49,.8), 0 6px 0 #6a5215;
  animation: land .4s ease-out;
}
#victory-name { font-size: 18px; letter-spacing: .2em; }
#victory .bars { position: absolute; top: 0; }

/* the recap */
.recap { display: flex; flex-direction: column; gap: 4px; }
.rc-head, .rc-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.rc-head { font-weight: 800; color: var(--gold); letter-spacing: .06em; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.rc-l { font-size: 11px; color: var(--dim); letter-spacing: .14em; }
.rc-v { font-size: 19px; font-weight: 900; color: var(--osd); text-shadow: 0 0 8px rgba(61,255,124,.4); }

/* ── choice sheet ── */
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 42;
  /* MORE transparent + lighter blur so your team's HP/ATK boxes read clearly THROUGH the play
     sheet while you aim a support (Tyler: "I want to see hp and atk when I'm using a support") */
  background: rgba(10, 14, 22, .42); backdrop-filter: blur(1.5px); -webkit-backdrop-filter: blur(1.5px);
  border-top: 2px solid var(--gold);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 9px; align-items: center;
}
#sheet-title { font-weight: 800; color: var(--gold); letter-spacing: .1em; }
#sheet-hint { font-size: 12.5px; text-align: center; }
/* ══ tournament "you're up next" banner ══ */
.qual-status { margin: 8px 0 4px; padding: 11px 14px; border-radius: 10px; text-align: center;
  background: rgba(20,26,38,.85); border: 1px solid #26324a; }
.qual-status.ready { border-color: var(--gold); background: rgba(42,34,10,.9); animation: qsPulse 1.5s ease-in-out infinite; }
@keyframes qsPulse { 0%,100% { box-shadow: 0 0 10px rgba(216,165,49,.35); } 50% { box-shadow: 0 0 22px rgba(216,165,49,.75); } }
.qs-wait { color: #9fb0c8; font-size: 13px; letter-spacing: .03em; }
.qs-podium { color: var(--gold); font-weight: 800; letter-spacing: .05em; }
.qs-play { font-size: 15px; }
.cell.destpick { box-shadow: inset 0 0 0 3px var(--gold), 0 0 12px rgba(216,165,49,.6); }

#sheet-card { display: flex; justify-content: center; margin: 2px 0 6px; }
.sheet-cardface { width: 128px; max-width: 42vw; border-radius: 9px; box-shadow: 0 5px 16px rgba(0,0,0,.55); }
.sheet-cardface.fb { padding: 22px 14px; background: #171b26; color: #cbd5e1; font-size: 12px; text-align: center; border-radius: 9px; }
#sheet-body { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-height: 32vh; overflow-y: auto; }
.choicecard { font-size: 13px; }

/* ── hover preview (desktop pointer only) ── */
#hoverprev {
  position: fixed; left: 0; top: 0;
  z-index: 55; pointer-events: none;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,.8));
}
#hoverprev img { width: min(340px, 30vw); border-radius: 12px; display: block; }

/* ── zoom ── */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .88);
}
#zoom-img { max-width: 92vw; max-height: 92dvh; border-radius: 14px; box-shadow: 0 8px 60px #000; }
#zoom-fallback { color: var(--ink); font-size: 20px; padding: 30px; }
#zoom-cap {
  position: fixed; left: 50%; bottom: 4dvh; transform: translateX(-50%);
  max-width: 90vw; text-align: center; color: var(--gold);
  background: rgba(8, 11, 17, .92); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; font-size: 14px; letter-spacing: .03em; line-height: 1.35; z-index: 61;
}

/* ── signal lost ── */
#conn {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--red); color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .1em;
  border-radius: 4px; padding: 5px 14px;
  animation: blink 1.2s steps(1) infinite;
}

/* ═══ portrait: stacked lines, drawer log, smaller guide ═══ */
@media (orientation: portrait) {
  :root {
    --cardw: min(27vw, calc((100dvh - 300px) / 2.9), 150px);
    --handw: min(24vw, 130px);
  }
  .line { gap: 3.5vw; }

  /* the OSD owns the top-right corner of the glass; the topbar cedes it */
  #osd { top: 8px; right: 10px; font-size: 13px; gap: 8px; }
  #osd-rec { font-size: 10px; }
  #topbar { padding-right: 112px; flex-wrap: wrap; row-gap: 2px; padding-top: 4px; padding-bottom: 4px; }
  .pname { max-width: 44vw; }
  #topbar .zones { order: 9; flex-basis: 100%; }   /* zones get their own row — names stop fighting buttons */
  .zones { gap: 8px; font-size: 12px; }
  .zone { max-width: 40vw; }

  /* center stage: smaller die, tighter ring — the tracker keeps one line */
  #stage { gap: 10px; }
  #stage-die { width: 62px; height: 62px; border-radius: 10px; }
  #die-face { font-size: 25px; }
  #die-why { font-size: 8px; max-width: 56px; }
  #midbar { gap: 10px; }

  /* stat chrome: tighter guard/counter chips so small cards keep their faces readable */
  .chip { font-size: clamp(9px, calc(var(--cardw) * .08), 12px); padding: 1px 4px; }
  .guardrow, .attmarks { gap: 2px; }
  .statbox .sval { font-size: clamp(9px, calc(var(--cardw) * .078), 13px); }
  .statbox .lbl { font-size: clamp(5px, calc(var(--cardw) * .04), 7px); }

  /* turn controls ride ABOVE the hand — never on a card */
  #turnctl { right: 10px; bottom: calc(var(--handw) * 1.12 + env(safe-area-inset-bottom) + 10px); }
  #turnctl .btn { min-height: 38px; padding: 8px 12px; font-size: 12.5px; }

  /* post-game lobby: tighter panel so recap + chat fit a phone; view scrolls regardless */
  .lobby-panel { margin-top: 2dvh; padding: 20px 16px 16px; gap: 14px; }
  #lograil { top: auto; height: 46dvh; width: 100vw; border-left: 0; border-top: 1px solid var(--line); }
  #lograil.collapsed { transform: translateY(100%); }
  .guide-head h1 { font-size: 19px; }
  .callsign { width: 100%; }
  .callsign input { flex: 1; }
  .ch-no { min-width: 64px; font-size: 18px; }
  .guide-row { padding: 12px 12px; gap: 10px; }
  .bars.big { height: 26dvh; }
  .versus { gap: 14px; }
  .fighter { min-width: 110px; }
}
