/* Waiting For The Game To Start: the shared look for splash, phone and TV. A game-store table at
   night: green felt, a cream play sheet in ballpoint blue, carried numbers in green and the Score line
   in orange (the colours of the worked example in Jonathan's rules), and a seven-die polyhedral set,
   one colour per die. No web fonts, no remote anything: the party rig is offline. */
:root {
  --felt: #173a36; --felt2: #1f4a45; --felt3: #29605a; --line: #3f7a72;
  --ink: #f4efe2; --dim: #b2cbc5; --gold: #f2b33d; --gold2: #c98a17;
  --paper: #f8f3e4; --paper2: #ebe2c9; --rule: #d9cfb3; --pen: #23264a;
  --blue: #2645a6; --green: #17803f; --orange: #cc5a12; --bad: #ff6b6b;
  --k-d4: #d9443e; --k-d6: #ea8423; --k-d8: #d9b21c; --k-d10a: #379e52; --k-d10b: #2595b0; --k-d12: #3d62c7; --k-d20: #8b4fcc;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #29605a 0%, #173a36 64%); --cs-end-fg: #f4efe2; --cs-end-dim: #b2cbc5;
  --cs-end-accent: #f2b33d; --cs-end-win: #f2b33d; --cs-end-loss: #8b4fcc;
  --display: "Trebuchet MS", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hand: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Neue", ui-rounded, system-ui, 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(--felt) radial-gradient(ellipse at 50% -10%, var(--felt3), var(--felt) 70%) fixed;
  -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; }
h1 { color: var(--gold); font-size: 34px; line-height: 1.1; }
h2 { color: var(--paper); font-size: 20px; }
button { background: var(--felt3); 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(--gold); border-color: var(--gold); color: #2a1d05; }
button:disabled { opacity: .38; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--felt2); color: var(--ink); border: 1.5px solid var(--line); }
a { color: var(--gold); }
.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(--pen);
  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 dice: one colour per die, the printed sheet's outlines ---- */
.k-d4 { --k: var(--k-d4); } .k-d6 { --k: var(--k-d6); } .k-d8 { --k: var(--k-d8); } .k-d10a { --k: var(--k-d10a); }
.k-d10b { --k: var(--k-d10b); } .k-d12 { --k: var(--k-d12); } .k-d20 { --k: var(--k-d20); }
.die { position: relative; display: grid; justify-items: center; align-content: start; gap: 2px; padding: 4px 1px 3px; min-width: 0;
  background: transparent; border: 2px solid transparent; border-radius: 12px; color: var(--ink); transition: transform .12s, background .12s, border-color .12s; }
.die .die-svg { width: 100%; max-width: 64px; height: auto; display: block; overflow: visible; }
.die .die-face { fill: var(--k); stroke: #0006; stroke-width: 3; stroke-linejoin: round; }
.die .die-num { fill: #fff; font: 800 40px var(--display); paint-order: stroke; stroke: #0007; stroke-width: 4px; }
.die .d-lab { font-size: 10px; line-height: 1.1; color: var(--dim); text-align: center; white-space: nowrap; max-width: 100%; overflow: hidden; }
.die .d-lab b { color: var(--ink); font-weight: 700; display: block; }
.die .d-carry { position: absolute; left: 50%; top: -9px; transform: translateX(-50%); background: var(--green); color: #fff; font-size: 10px; font-weight: 800;
  padding: 1px 6px; border-radius: 99px; white-space: nowrap; }
button.die:disabled { opacity: 1; }
button.die.can { cursor: pointer; background: #ffffff0d; border-color: #ffffff22; }
.die.kept { transform: translateY(-6px); border-color: var(--green); background: #17803f33; box-shadow: 0 0 0 2px #17803f88; }
.die.scoring { border-color: var(--gold); background: #f2b33d26; box-shadow: 0 0 12px #f2b33d77; }

/* ---- the play sheet: cream paper, blue ink, green carries, orange score ---- */
.sheet { width: 100%; border-collapse: collapse; table-layout: fixed; color: var(--pen); }
.sheet th, .sheet td { text-align: center; padding: 0; }
.sheet .sh-head th { font: 700 10.5px var(--body); color: var(--k, var(--pen)); padding-bottom: 2px; white-space: nowrap; overflow: hidden; }
.sheet .sh-head th:first-child, .sheet .sh-line th, .sheet .sh-score th { width: 13%; }
.sheet .sh-line th { font: 700 13px var(--body); color: #7a7360; text-align: left; padding-left: 4px; }
.sheet .sh-line td { font: 700 21px/1.25 var(--hand); color: var(--blue); border-bottom: 1px solid var(--rule); background: #00000008; }
.sheet .sh-line td:nth-child(even) { background: #0000000f; }
.sheet .sh-line td.carried { color: var(--green); }
.sheet .sh-line.empty td { color: transparent; }
.sheet .sh-arrows td { line-height: 1; height: 13px; }
.sheet .sh-arrows i { font-style: normal; font-size: 10px; color: #0000001f; }
.sheet .sh-arrows i.on { color: var(--green); font-size: 12px; }
.sheet .sh-arrows i.pending { opacity: .55; }
.sheet .sh-score th { font: 700 12px var(--body); color: #7a7360; text-align: left; padding: 4px 0 0 4px; vertical-align: top; }
.sheet .sh-score td { font: 700 14px/1.25 var(--hand); color: var(--orange); text-align: left; padding: 4px 4px 0; min-height: 20px; border-top: 1.5px dashed var(--rule); }
.rounds { display: flex; gap: 4px; }
.rounds .rb { flex: 1; min-width: 0; position: relative; border: 1.5px solid #00000033; border-radius: 8px; background: #fff; color: var(--orange);
  font: 700 17px/1 var(--hand); text-align: center; padding: 14px 2px 5px; min-height: 40px; }
.rounds .rb small { position: absolute; top: 2px; left: 0; right: 0; font: 700 9.5px var(--body); color: #7a7360; text-transform: uppercase; }
.rounds .rb em { position: absolute; bottom: -1px; left: 0; right: 0; font: 700 8.5px var(--body); color: #7a7360; font-style: normal; }
.rounds .rb.now { border-color: var(--gold2); box-shadow: 0 0 0 2px #f2b33d66; }
.rounds .rb.total { flex: 1.5; background: var(--pen); color: var(--paper); border-color: var(--pen); }
.rounds .rb.total small { color: var(--dim); }
.mini { display: inline-flex; gap: 3px; }
.mini i { font-style: normal; display: grid; place-items: center; min-width: 1.9em; padding: .12em 0; border-radius: .35em; background: #ffffff10; color: var(--ink); font-weight: 800;
  border-bottom: .18em solid var(--k); }
.mini i.carried { color: #8ff0b0; }
.mini i.keep { background: #17803f66; }

/* ---- 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-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto minmax(0, 1fr); gap: 8px;
  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 { min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 40px; }
.g-title { font: 700 17px var(--display); color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-total { margin-left: auto; white-space: nowrap; color: var(--dim); font-weight: 700; } .g-total b { color: var(--ink); font-size: 1.3em; }
.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(--gold); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #f2b33d55; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--felt2); border-left: 4px solid var(--line); border-radius: 6px 12px 12px 6px; padding: 8px 12px; font-size: 14.5px; line-height: 1.32; min-height: 54px; display: flex; align-items: center; color: var(--dim); }
.g.mine .g-coach { border-left-color: var(--gold); color: var(--ink); }
.g-play { display: grid; gap: 12px; }
.g-dice { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; padding-top: 6px; }
.g-act { display: grid; gap: 8px; min-height: 52px; }
.g-act button { min-height: 50px; font-size: 16px; padding: 6px 10px; }
.g-act button b { font-size: 1.2em; }
.g-act .junkbtn { background: var(--paper2); color: var(--pen); border-color: var(--paper2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; line-height: 1.15; }
.g-act .junkbtn small { font-weight: 600; opacity: .7; font-size: 12px; }
.g-act:has(#g-score) { grid-template-columns: 1fr 1fr; }
.g-act .locked { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--green); background: #ffffff0f; border-radius: 12px; min-height: 50px; padding: 4px 10px; text-align: center; }
.g-act .locked { color: #8ff0b0; } .g-act .locked.dim { color: var(--dim); } .g-act .locked.big { font-size: 20px; color: var(--gold); }
.g-act:has(#g-change) { grid-template-columns: 1fr auto; }
.g-paper { min-height: 0; overflow: hidden; display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 8px; align-content: start;
  background: var(--paper); color: var(--pen); border-radius: 10px; padding: 8px 8px 8px; box-shadow: 0 6px 20px #0006; }
.g-others { display: flex; flex-wrap: wrap; gap: 4px; align-content: start; overflow: hidden; }
.g-others .oc { font-size: 12.5px; padding: 2px 8px; border-radius: 99px; background: var(--paper2); color: var(--pen); white-space: nowrap; max-width: 48%; overflow: hidden; text-overflow: ellipsis; }
.g-others .oc.wait { box-shadow: inset 0 0 0 1.5px var(--gold2); }

/* The kit's pill (table-dock.ts: "Table", or "Sound") opens the sheet with what happened, and the phone's
   sound switches. 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: 58px; right: auto; height: 40px; width: 92px; padding: 0 6px;
  font-size: 13.5px; white-space: nowrap; text-align: center; }
.g-pillgap { flex: none; width: 92px; }

/* A rig panel or a phone on its side: use the width. Dice and buttons left, the sheet 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: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr); column-gap: 16px; padding: 8px 16px 10px; }
  .g-head, #cs-pres-slot { grid-column: 1 / -1; }
  .g-coach { grid-column: 1; }
  .g-play { grid-column: 1; grid-row: 4; align-content: start; }
  .g-paper { grid-column: 2; grid-row: 3 / span 2; }
  body.phone #cs-pill { left: 64px; top: 8px; }
  .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; }
}
@media (min-height: 760px) and (max-width: 719px) { .sheet .sh-line td { font-size: 25px; line-height: 1.55; } .sheet .sh-arrows td { height: 18px; } .g-paper { gap: 14px; padding: 12px 10px; } .die .d-lab { font-size: 11px; } }
@media (max-height: 700px) and (max-width: 719px) { .g-coach { min-height: 0; font-size: 13.5px; } .sheet .sh-line td { font-size: 18px; } }

/* ---- 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(6, 18, 17, .84); }
.cm-ring { fill: none; stroke: var(--gold); stroke-width: 2; }
.cm-ln { stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--gold); stroke: var(--pen); 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(--felt2); border: 1.5px solid var(--gold); 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(--gold); color: var(--pen); 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: #10292af7; 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(--gold); background: var(--felt2); 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(--gold); }
.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); }
.hero-dice svg { width: min(100%, 420px); height: auto; display: block; margin-bottom: 14px; }
.hero-dice polygon { fill: var(--k); stroke: #0006; stroke-width: 3; stroke-linejoin: round; }
.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(--gold); color: #2a1d05; font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--felt3); 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(--felt2); border-radius: 14px; padding: 12px 14px; } .how h3 { color: var(--gold); margin-bottom: 4px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--felt2); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.rooms .code { font-family: var(--display); color: var(--gold); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--felt2); border-left: 4px solid var(--gold); 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; }
