/* Rocketball: the shared look for splash, phone and TV. Jonathan's printed field (cream squares, black
   ink) on a dark pitch, a red-hot ball, North in blue and South in gold. No web fonts, no remote anything:
   the party rig is offline, so every asset is local (test/pages.test.ts fails on an external URL). */
:root {
  --night: #14110f; --night2: #221d19; --night3: #322a24; --line: #4a3f36;
  --ink: #f6efe2; --dim: #b8a996; --paper: #fbf4e2; --inkd: #1d1b19;
  --amber: #ff7a1a; --amber2: #d4520a; --storm: #3d8bfd; --storm2: #2a64c0;
  --north: #3d8bfd; --south: #f2b630;
  --good: #3fd17a; --bad: #ff5a4a;
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #3a2a1c 0%, #14110f 62%); --cs-end-fg: #f6efe2; --cs-end-dim: #b8a996;
  --cs-end-accent: #ff7a1a; --cs-end-win: #ff7a1a; --cs-end-loss: #3d8bfd;
  --display: "Arial Black", Impact, "Helvetica Neue", Arial, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); font: 500 16px/1.4 var(--body); background: var(--night) radial-gradient(ellipse at 50% -10%, var(--night3), var(--night) 70%) fixed;
  -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; }
h1 { color: var(--amber); font-size: 34px; line-height: 1.1; }
h2 { color: var(--paper); font-size: 20px; }
button { background: var(--night3); border: 1.5px solid var(--line); color: var(--ink); padding: 10px 14px; border-radius: 12px;
  font: inherit; font-weight: 700; cursor: pointer; }
button.primary { background: var(--amber); border-color: var(--amber); color: var(--inkd); }
button:disabled { opacity: .38; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--night2); color: var(--ink); border: 1.5px solid var(--line); }
a { color: var(--amber); }
.muted, .hint, .tagg { color: var(--dim); }
.tagg { font-size: 13px; margin-left: 6px; }
.av { border-radius: 50%; vertical-align: middle; margin-right: 4px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(160px); background: var(--paper); color: var(--inkd);
  padding: 10px 18px; border-radius: 10px; transition: transform .25s; z-index: 50; max-width: 92vw; font-weight: 700; }
#toast.show { transform: translateX(-50%) translateY(0); }
#conn { position: fixed; top: 8px; right: 8px; background: var(--bad); color: #fff; padding: 4px 10px; border-radius: 8px; font-size: 13px; display: none; z-index: 60; }
#conn.show { display: block; }

/* ---- kit phone shell: join + lobby ---- */
.join, .lobbyv { max-width: 480px; margin: 0 auto; padding: 24px 16px; display: grid; gap: 12px; }
.join input { font-size: 20px; padding: 12px; }
.join button, .lobbyv button { font-size: 17px; padding: 12px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.btnrow button { flex: 1 1 auto; }
.seat-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: #0006; border-radius: 10px; margin: 4px 0; }
.levers { display: grid; gap: 8px; }
.levers label { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--dim); font-weight: 700; }

/* ---- shared pieces: the field (client/shared/field.ts), pips, the d4 ---- */
.field { display: block; width: 100%; height: 100%; }
.field .frame { fill: #efe4c8; stroke: #1d1b19; stroke-width: 6; }
.field .cell { fill: #fffaf0; stroke: #2b2724; stroke-width: 3.5; }
.field .cell.legal { fill: #effaef; cursor: pointer; }
.field .cell.sel { fill: #b9f0c8; stroke: #12813a; stroke-width: 9; }
.field .centre { fill: none; stroke: #2b2724; stroke-width: 4; pointer-events: none; }
.field .goal.aim rect { stroke: #12a14a; stroke-width: 12; filter: drop-shadow(0 0 10px #3fd17a); }
.field .goal-label { font: 800 26px var(--body); text-anchor: middle; fill: #1d1b19; }
.field .chip.turnable rect { stroke-dasharray: 14 7; }
.field .chip.turnable { cursor: pointer; }
.field .chip.sel rect { stroke: #12813a; stroke-width: 10; stroke-dasharray: none; }
.field .chip.ghost { opacity: .78; pointer-events: none; }
.field .chip.ghost rect { stroke: #12813a; stroke-dasharray: 8 6; }
.field .lock circle { fill: #1d1b19; } .field .lock path { stroke: #fbf4e2; stroke-width: 3; } .field .lock rect { fill: #fbf4e2; }
.field .ball { pointer-events: none; }
.field .ball .heat { animation: heat 1.1s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes heat { from { opacity: .75; transform: scale(.92); } to { opacity: 1; transform: scale(1.08); } }
.field .trail { stroke: #ff6a00; stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; opacity: .45; pointer-events: none; }
.field .page { fill: #f7efdc; stroke: #1d1b19; stroke-width: 3; }
.field .path { pointer-events: none; }
.field .path .pl { stroke: #6b5f55; stroke-width: 6; stroke-dasharray: 2 12; stroke-linecap: round; stroke-linejoin: round; }
.field .path .pl.tone-good { stroke: #12a14a; stroke-width: 8; } .field .path .pl.tone-bad { stroke: #e03a2c; stroke-width: 8; }
.field .path .pm rect { fill: #fffaf0; stroke: #6b5f55; stroke-width: 4; }
.field .path .pm text { font: 800 24px var(--body); text-anchor: middle; fill: #1d1b19; }
.field .path .pm.tone-good rect { fill: #12a14a; stroke: #0a5f2b; } .field .path .pm.tone-bad rect { fill: #e03a2c; stroke: #7d1a12; }
.field .path .pm.tone-good text, .field .path .pm.tone-bad text { fill: #fff; }
.pips { display: inline-flex; gap: 4px; vertical-align: middle; }
.pips i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--c); background: transparent; }
.pips i.on { background: var(--c); box-shadow: 0 0 6px var(--c); }
.d4 { position: relative; display: inline-grid; place-items: center; width: 2.2em; height: 2em; vertical-align: middle; }
.d4 svg { position: absolute; inset: 0; width: 100%; height: 100%; } .d4 path { fill: var(--paper); stroke: var(--inkd); stroke-width: 6; stroke-linejoin: round; }
.d4 b { position: relative; top: .22em; color: var(--inkd); font: 800 .9em/1 var(--body); }
.d4.sm { font-size: 18px; }

/* ---- the phone: a fixed skeleton that never scrolls the page (the rig's panels are 960x540 with
   no scrollbar: a control below the fold there is not a control) ---- */
.g { position: fixed; inset: 0; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; gap: 6px;
  padding: max(8px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; overflow: hidden; }
.g-head { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.g-score { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 13px; line-height: 1.1; min-width: 0; }
.g-score .sc { display: flex; align-items: center; gap: 6px; white-space: nowrap; max-width: 100%; }
.g-score .sc b { color: var(--c); overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.g-score .sc.me b::after { content: " (you)"; color: var(--dim); font-weight: 600; }
.help { flex: none; width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 20px; }
.help.pulse { animation: helppulse 1.6s ease-in-out infinite; border-color: var(--amber); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #ff7a1a55; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--night2); border-left: 4px solid var(--amber); border-radius: 6px 12px 12px 6px; padding: 7px 10px; font-size: 14px; line-height: 1.3; min-height: 52px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--line); color: var(--dim); }
.g-board { min-height: 0; display: flex; justify-content: center; }
.g-board .field { max-width: 100%; }
.g-mine { display: grid; gap: 6px; }
.g-act { min-height: 52px; display: grid; gap: 6px; align-content: center; }
.g-row { display: flex; gap: 6px; align-items: stretch; }
.g-row button { min-height: 48px; padding: 4px 8px; }
.g-row .primary { flex: 1; font-size: 15px; }
.dirb { width: 48px; font-size: 24px; line-height: 1; padding: 0 !important; flex: none; }
.dirb.drift { width: 46px; font-size: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dirb.drift small { font-size: 10px; font-weight: 700; line-height: 1; }
.rotb { flex: 1; }
.dirb.on, .rotb.on, .kindb.on { background: var(--good); border-color: var(--good); color: var(--inkd); }
.rotb { font-size: 15px; }
.kindb { flex: 1; font-size: 14px; }
.cancel { width: 44px; padding: 0 !important; flex: none; font-size: 18px; }
button.big { min-height: 54px; font-size: 18px; display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.g-hint, .g-wait { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--dim); font-size: 14px; text-align: center; }
.g-wait { flex-direction: row; justify-content: center; gap: 10px; }
.g-drawn b { color: var(--ink); }
.g-last { display: inline-flex; align-items: center; gap: 4px; }
.goalword { color: var(--amber); font: 900 22px var(--display); letter-spacing: .04em; }
.g-btns { display: grid; grid-template-columns: 1fr; }
.g-btns button { min-height: 40px; padding: 4px 8px; font-size: 13.5px; }

/* The kit's pill (table-dock.ts: "Table", or "Sound") opens the sheet with what happened, and the phone's
   sound switches. Its own spot is the bottom right corner, which is where End turn lives, so it is moved
   up beside "?" and the header keeps a gap for it (.g-pillgap). Off the top centre and the top right:
   the rig's launcher owns those on a panel. */
body.phone #cs-pill { top: max(8px, env(safe-area-inset-top)); bottom: auto; left: 60px; right: auto; height: 40px; width: 96px; padding: 0 6px;
  font-size: 13.5px; white-space: nowrap; text-align: center; }
.g-pillgap { flex: none; width: 96px; }

/* A rig panel or a phone on its side: the field left, everything else right. Nothing a player presses is
   below the fold, and the top centre stays clear for the launcher's own strip. */
@media (min-width: 720px) and (max-height: 640px) {
  .g { max-width: none; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; column-gap: 16px; padding: 8px 16px 10px; }
  .g-head { grid-column: 2; grid-row: 1; }
  #cs-pres-slot { grid-column: 2; grid-row: 2; }
  .g-board { grid-column: 1; grid-row: 1 / -1; width: min(42vw, calc((100vh - 18px) * 0.66)); }
  .g-coach { grid-column: 2; grid-row: 3; align-self: start; }
  .g-mine { grid-column: 2; grid-row: 4; }
  body.phone #cs-pill { left: auto; right: 16px; top: 8px; }
  .g-pillgap { display: none; }
  .g-head { padding-right: 110px; }
  .lobbyv { max-width: 900px; grid-template-columns: 1fr 1fr; align-items: start; padding: 44px 16px 10px; gap: 8px 16px; }
  .lobbyv h1 { grid-column: 1 / -1; font-size: 26px; }
  .lobbyv > div:nth-child(2) { grid-row: span 4; }
  .join { padding-top: 44px; }
}

/* ---- coach marks (table/client/coach.ts draws them; these are its classes) ---- */
.coach { position: fixed; inset: 0; z-index: 2300; color: var(--ink); -webkit-user-select: none; user-select: none; animation: cmin .18s ease-out; }
@keyframes cmin { from { opacity: 0; } to { opacity: 1; } }
.cm-svg { position: absolute; inset: 0; display: block; }
.cm-dim { fill: rgba(4, 7, 14, .82); }
.cm-ring { fill: none; stroke: var(--amber); stroke-width: 2; }
.cm-ln { stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--amber); stroke: var(--inkd); stroke-width: 1.5; }
.cm-call { position: absolute; padding: 9px 12px 10px; border-radius: 14px; font-size: 14.5px; line-height: 1.33; background: var(--night2); border: 1.5px solid var(--amber); box-shadow: 0 10px 28px #000a; }
.cm-call .cm-n { float: left; width: 22px; height: 22px; margin: 0 8px 0 0; border-radius: 50%; display: grid; place-items: center; background: var(--amber); color: var(--inkd); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 700 15.5px/22px var(--display); color: var(--paper); }
.cm-call .cm-b { margin-top: 3px; clear: both; } .cm-call .cm-b b { color: #fff; }
.cm-measure { visibility: hidden; left: -9999px; top: 0; pointer-events: none; }
.cm-none { text-align: center; }
.cm-pager { position: absolute; display: flex; align-items: center; gap: 8px; padding: 7px; border-radius: 16px; background: #0a0f1af7; border: 1px solid var(--line); box-shadow: 0 8px 26px #000a; }
.cm-pager button { min-height: 44px; padding: 0 16px; font-size: 16px; border-radius: 12px; }
.cm-pager .cm-close { width: 44px; padding: 0; font-size: 26px; line-height: 1; border-radius: 50%; flex: none; }
.cm-pager .cm-count { flex: 1; text-align: center; color: var(--dim); font-weight: 700; white-space: nowrap; }
.cm-last { position: absolute; left: 8px; right: 8px; display: flex; overflow: auto; overscroll-behavior: contain; }
.cm-lastin { margin: auto; width: 100%; max-width: 460px; max-height: 100%; overflow-y: auto; padding: 14px 16px 16px; border-radius: 18px; border: 2px solid var(--amber); background: var(--night2); font-size: 15px; line-height: 1.4; -webkit-user-select: text; user-select: text; }
.cm-lastin .cm-kick { text-align: center; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .16em; color: var(--amber); }
.cm-lastin h2 { margin: 0 0 8px; text-align: center; font-size: 22px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.cm-lastin ul { margin: 0; padding-left: 1.2em; } .cm-lastin li { margin: 0 0 6px; } .cm-lastin b { color: #fff; }

/* ---- splash + help ---- */
.wrap { max-width: 860px; margin: 0 auto; padding: 28px 18px 60px; }
.hero h1 { font-size: clamp(36px, 7vw, 60px); }
.tag { font-size: 1.2em; color: var(--dim); margin: 6px 0 4px; }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 14px; background: var(--amber); color: var(--inkd); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--night3); color: var(--ink); border: 1.5px solid var(--line); }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 26px; }
.how div { background: var(--night2); border-radius: 14px; padding: 12px 14px; } .how h3 { color: var(--amber); margin-bottom: 4px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--night2); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.rooms .code { font-family: var(--display); color: var(--amber); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--night2); border-left: 4px solid var(--amber); border-radius: 8px; padding: 12px 16px; margin-top: 18px; } #rejoin.show { display: block; }
footer { margin-top: 40px; color: var(--dim); font-size: .9em; }
.helppage h2 { margin: 26px 0 6px; } .helppage li { margin-bottom: 6px; } .helppage .back { text-decoration: none; font-weight: 700; }
.helppage figure { margin: 22px 0; } .helppage figure img { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); display: block; }
.helppage figure.phone img { max-width: 300px; margin: 0 auto; }
.helppage figcaption { color: var(--dim); margin-top: 8px; font-size: .95em; }

/* ---- splash hero ---- */
.splash .hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; }
.splash .hero h1 { font-family: var(--display); color: var(--amber); letter-spacing: .02em; }
.splash .credit { color: var(--dim); margin: 6px 0; font-size: .95em; }
.splash .mark { position: relative; width: 220px; height: 200px; }
.splash .mark .logo { position: absolute; inset: 0; width: 220px; filter: invert(1) sepia(1) saturate(4) hue-rotate(-20deg); }
.splash .mark .markball { position: absolute; left: 70px; top: 70px; width: 80px; filter: invert(1); background: radial-gradient(#ff9a1f 0 40%, transparent 70%); border-radius: 50%; }
@media (max-width: 640px) { .splash .hero { grid-template-columns: 1fr; } .splash .mark { display: none; } }

/* the debrief's field (server/debrief.ts): small, the trail of the winning goal on it */
.end-field { width: min(100%, 300px); aspect-ratio: 884 / 1300; margin: 0 auto; }
body.tvpage .end-field { width: auto; height: 40vh; }
