/* Eight By Eight: the shared look for splash, phone and TV. The paper board as printed (cream, rounded
   squares, grey dots) laid on a late-evening plum, with four glossy pieces in the rules' spectrum: red,
   yellow, green, blue. 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 {
  --bg: #1d1726; --bg2: #2a2135; --bg3: #3a2f4a; --line: #54476a;
  --ink: #f6f0e4; --dim: #b6a9c8; --paper: #f7f0e1; --paper2: #e9dfca; --inkd: #231c2b;
  --red: #e8453c; --yellow: #f4c23d; --green: #3daa5c; --blue: #2f7fd8;
  --accent: #f4c23d; --good: #6fd08c; --bad: #ff7a6e;
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #3a2f4a 0%, #1d1726 62%); --cs-end-fg: #f6f0e4; --cs-end-dim: #b6a9c8;
  --cs-end-accent: #f4c23d; --cs-end-win: #f4c23d; --cs-end-loss: #b6a9c8;
  --display: "Avenir Next", "Futura", "Century Gothic", "Trebuchet MS", system-ui, 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); -webkit-tap-highlight-color: transparent;
  background: var(--bg) radial-gradient(ellipse at 50% -20%, var(--bg3), var(--bg) 70%) fixed; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; letter-spacing: .01em; }
h1 { color: var(--paper); font-size: 34px; line-height: 1.1; }
h2 { color: var(--paper); font-size: 20px; }
button { background: var(--bg3); 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(--accent); border-color: var(--accent); color: var(--inkd); }
button:disabled { opacity: .38; cursor: default; }
button[hidden] { display: none !important; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--bg2); color: var(--ink); border: 1.5px solid var(--line); }
a { color: var(--accent); }
.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; }

/* ---- the board (client/shared/board.ts draws it; the same SVG on TV, phone and end screen) ---- */
svg.board { display: block; width: 100%; height: 100%; }
.board .paper { fill: var(--paper); }
.board .band { fill: #f4c23d55; stroke: #d9a521; stroke-width: 2; }
.board .dot { fill: #c9c3cf; stroke: #5d5866; stroke-width: 3; }
.board .dot.now { stroke: var(--inkd); stroke-width: 5; }
.board .num { font: 800 46px var(--display); fill: var(--inkd); text-anchor: middle; }
.board .rnum { font: 700 30px var(--display); fill: #8f8698; text-anchor: middle; }
.board .rnum.now { fill: var(--inkd); }
.board .sq { fill: #fffdf8; stroke: #3a3340; stroke-width: 2.5; }
.board .sq.legal { fill: #fff7d6; stroke: #2a8a4a; stroke-width: 6; }
.board:not(.still) .sq.legal { animation: ringpulse 1.4s ease-in-out infinite; }
@keyframes ringpulse { 50% { stroke-width: 9; } }
.board .hit { fill: transparent; cursor: pointer; }
.pc .body { stroke: #0007; stroke-width: 2.5; }
.pc .shine { fill: #ffffff59; }
.pc .mk { fill: #0008; } .pc .mk.ring { fill: none; stroke: #0008; stroke-linecap: round; }
.pc.c0 .body { fill: var(--red); } .pc.c1 .body { fill: var(--yellow); } .pc.c2 .body { fill: var(--green); } .pc.c3 .body { fill: var(--blue); }
.pc.last .body { stroke: var(--inkd); stroke-width: 6; }
.board .run { stroke-width: 18; stroke-linecap: round; opacity: .55; }
.board .run.c0 { stroke: #8e1c15; } .board .run.c1 { stroke: #8a6400; } .board .run.c2 { stroke: #145c2b; } .board .run.c3 { stroke: #123f78; }

/* the eight-sided die */
.die { display: block; }
.die .d-body { fill: var(--paper); stroke: var(--inkd); stroke-width: 4; stroke-linejoin: round; }
.die .d-edge { fill: none; stroke: #0002; stroke-width: 2; }
.die .d-num { font: 800 44px var(--display); fill: var(--inkd); text-anchor: middle; paint-order: stroke; stroke: var(--paper); stroke-width: 8; }
.die.fresh { animation: tumble .45s ease-out; }
@keyframes tumble { 0% { transform: rotate(-70deg) scale(.6); } 70% { transform: rotate(12deg) scale(1.08); } 100% { transform: none; } }

/* a colour's strip */
.seat { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "pc name" "pc nums" "out out"; column-gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 12px; background: #0005; border: 2px solid transparent; min-width: 0; }
.seat.up { background: #f4c23d1f; border-color: var(--accent); }
.seat.me { outline: 2px dashed var(--paper); outline-offset: 1px; }
.seat-pc { grid-area: pc; width: 30px; height: 30px; }
.seat-name { grid-area: name; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.seat-nums { grid-area: nums; display: flex; flex-wrap: wrap; column-gap: 7px; row-gap: 0; color: var(--dim); font-size: 12.5px; white-space: nowrap; }
.seat-out { grid-area: out; display: flex; gap: 3px; min-height: 18px; margin-top: 3px; font-size: 12px; color: var(--dim); }
.seat-out b { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #c9c3cf; color: var(--inkd); font-size: 11.5px; }
.seat-out em { font-style: normal; opacity: .6; }
.tagb { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 1px 6px; border-radius: 99px; background: var(--bg3); color: var(--dim); vertical-align: middle; }

/* ---- 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: 7px;
  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: 10px; min-height: 40px; }
.g-title { font: 800 18px var(--display); color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-round { margin-left: auto; white-space: nowrap; color: var(--dim); font-weight: 700; font-size: 14px; }
.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(--accent); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #f4c23d55; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--bg2); border-left: 4px solid var(--accent); border-radius: 6px 12px 12px 6px; padding: 8px 12px; font-size: 15px; line-height: 1.32; min-height: 58px; 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 svg.board { width: auto; max-width: 100%; height: 100%; aspect-ratio: 872 / 966; filter: drop-shadow(0 6px 18px #0009); }
.g-side { display: grid; gap: 7px; }
.g-seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.g-seats:has(> :nth-child(3)) { grid-template-columns: 1fr 1fr; }
.g-ctl { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; }
.g-die { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.g-die .die { width: 54px; height: 64px; }
.g-prev { font-size: 12px; color: var(--dim); } .g-prev s { text-decoration-thickness: 2px; }
.g-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.g-btns button { min-height: 52px; padding: 6px 8px; font-size: 16px; line-height: 1.15; grid-column: 1 / -1; }
.g-btns #g-black:not([hidden]) ~ #g-pass:not([hidden]) { grid-column: auto; }
.g-btns #g-pass:not([hidden]) { grid-column: auto; }
.g-btns .black { background: #141016; border-color: #000; color: var(--paper); }
.g-btns .black b { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 50%; background: #c9c3cf; color: var(--inkd); margin: 0 2px; }
.g-btns .undo { font-size: 14px; background: var(--bg2); }

/* The kit's pill sits beside "?": its own corner is where the buttons live. */
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 board on the left at full height, everything else on the right. */
@media (min-width: 720px) and (max-height: 640px) {
  .g { max-width: none; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr); column-gap: 16px; padding: 8px 16px 10px; }
  .g-head { grid-column: 1 / -1; }
  .g-board { grid-column: 1; grid-row: 2 / span 3; }
  #cs-pres-slot { grid-column: 2; grid-row: 2; }
  .g-coach { grid-column: 2; grid-row: 3; min-height: 64px; }
  .g-side { grid-column: 2; grid-row: 4; align-content: end; }
  body.phone #cs-pill { left: 64px; top: 8px; }
  .g-seats { grid-template-columns: 1fr 1fr; }
  .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; }
}

/* ---- the end screen's board (the kit's end screen, sized in em so its fit loop can shrink it) ---- */
.end-board { width: 18em; max-width: 100%; margin: .3em auto; }
.end-board svg.board { height: auto; }

/* ---- 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(16, 11, 22, .84); }
.cm-ring { fill: none; stroke: var(--accent); stroke-width: 2; }
.cm-ln { stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--accent); 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(--bg2); border: 1.5px solid var(--accent); 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(--accent); color: var(--inkd); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 800 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: #150f1cf7; 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(--accent); background: var(--bg2); 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(--accent); }
.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 { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 20px; align-items: center; }
.hero h1 { font-size: clamp(36px, 7vw, 60px); }
.hero .mark { width: 100%; }
@media (max-width: 560px) { .hero { grid-template-columns: 1fr; } .hero .mark { width: 140px; order: -1; } }
.tag { font-size: 1.2em; color: var(--dim); margin: 6px 0 4px; }
.credit { color: var(--paper); margin: 4px 0; } .credit a { color: var(--accent); }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 14px; background: var(--accent); color: var(--inkd); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--bg3); 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(--bg2); border-radius: 14px; padding: 12px 14px; } .how h3 { color: var(--accent); margin-bottom: 4px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--bg2); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.rooms .code { font-family: var(--display); color: var(--accent); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--bg2); border-left: 4px solid var(--accent); 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; }
