/* Write and Roll: Powers 'n Points: the shared look for splash, phone and TV. A play sheet on a desk blotter:
   cream graph paper, graphite ink, a blue pencil for the first player and a red one for the second, and a yellow
   highlighter for what you may tap. 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 {
  --desk: #1f2b2a; --desk2: #283837; --desk3: #34484a; --line: #4a6163;
  --paper: #f6f1e3; --paper2: #ebe4d0; --grid: #c3d2e3; --ink: #26282b; --ink2: #5d6470; --faint: #a7adb6;
  --chalk: #eef1ea; --dim: #a9bab6;
  --blue: #2f5fd0; --red: #c8402c; --hi: #ffd54a; --hi2: #f2b632; --good: #3f9b5a;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #34484a 0%, #1f2b2a 62%); --cs-end-fg: #eef1ea; --cs-end-dim: #a9bab6;
  --cs-end-accent: #ffd54a; --cs-end-win: #ffd54a; --cs-end-loss: #c8402c;
  --hand: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Neue", cursive;
  --display: "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --c0: var(--blue); --c1: var(--red);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--chalk); font: 500 16px/1.4 var(--body); background: var(--desk) radial-gradient(ellipse at 50% -10%, var(--desk3), var(--desk) 70%) fixed;
  -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; }
h1 { color: var(--hi); font-size: 34px; line-height: 1.1; }
h2 { color: var(--paper); font-size: 20px; }
button { background: var(--desk3); border: 1.5px solid var(--line); color: var(--chalk); padding: 10px 14px; border-radius: 12px;
  font: inherit; font-weight: 700; cursor: pointer; }
button.primary { background: var(--hi); border-color: var(--hi2); color: #2a2205; }
button:disabled { opacity: .4; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--desk2); color: var(--chalk); border: 1.5px solid var(--line); }
a { color: var(--hi); }
.muted, .hint, .tagg { color: var(--dim); }
.av { border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.by0 { --pc: var(--c0); } .by1 { --pc: var(--c1); }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(160px); background: var(--paper); color: var(--ink);
  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(--red); 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; }

/* ---- the sheet: paper, boxes with their O, marks ---- */
.sheet { --bx: 34px; color: var(--ink); background: var(--paper); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 12px 12px; background-position: -1px -1px; border-radius: 10px; padding: 8px; display: grid; gap: 8px; box-shadow: 0 6px 18px #0007; }
.sheet.seat0 { --pc: var(--c0); } .sheet.seat1 { --pc: var(--c1); }
.bx { position: relative; display: grid; place-items: center; width: var(--bx); height: var(--bx); border: 1.5px solid #7d8898; border-radius: 7px; background: #fffdf6; }
.bx em { font-style: normal; color: var(--faint); font: 700 calc(var(--bx) * .42) / 1 var(--display); }
.bx.dev em { color: var(--ink); }
.bx.pt em { font-size: calc(var(--bx) * .46); }
.bx .o { position: absolute; top: calc(var(--bx) * -.16); right: calc(var(--bx) * -.16); width: calc(var(--bx) * .42); height: calc(var(--bx) * .42); border-radius: 50%;
  border: 1.5px solid #9aa3b0; background: var(--paper); display: grid; place-items: center; font: 700 calc(var(--bx) * .24) / 1 var(--hand); font-style: normal; color: #fff; z-index: 1; }
.bx .o.on { background: var(--pc); border-color: var(--pc); }
.bx .o.new { background: repeating-linear-gradient(45deg, var(--pc) 0 2px, #fff 2px 4px); border-color: var(--pc); }
.bx.dev { border-color: var(--ink2); background: #fff; }
.bx.fresh { box-shadow: 0 0 0 2px var(--pc); }
.mk { position: absolute; left: -3px; bottom: -4px; text-decoration: none; font: 800 calc(var(--bx) * .27) / 1 var(--display); padding: 1px 3px; border-radius: 4px; color: #fff; background: var(--pc, #333); z-index: 2; }
.mk.mk-X { background: #222; color: #fff; outline: 1.5px solid var(--pc); }
.wi { text-decoration: none; margin-left: 3px; padding: 0 3px; border-radius: 4px; background: #4b5a2a; color: #fff; font-size: .85em; }

.sh-powers { display: grid; gap: 4px; }
.pw-row { display: grid; grid-template-columns: 1.1em repeat(6, var(--bx)) minmax(0, 1fr); align-items: center; gap: 4px; padding: 2px 4px; border-radius: 8px; }
.pw-n { font: 800 calc(var(--bx) * .62) / 1 var(--display); text-align: center; }
.pw-name { min-width: 0; border-bottom: 1.5px solid var(--ink2); padding: 0 2px 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 700 calc(var(--bx) * .4) / 1.2 var(--hand); }
.pw-name small { margin-left: 4px; color: var(--ink2); font: 700 calc(var(--bx) * .32) / 1 var(--display); }
.pw-name.blank { color: var(--faint); }
.pw-row.fire { background: #ffe9a8; box-shadow: inset 0 0 0 2px var(--hi2); }
.pw-row.stopped .pw-name b { text-decoration: line-through; text-decoration-thickness: 2px; }

.sh-points { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.pt-col { display: grid; gap: 5px; justify-items: center; padding: 4px 2px 2px; border-radius: 8px; }
.pt-col .bx { width: min(100%, calc(var(--bx) * 1.25)); }
.pt-label { font: 800 calc(var(--bx) * .4) / 1.1 var(--display); white-space: nowrap; border-radius: 6px; padding: 1px 3px; }
.pt-col.scoring { background: #d9ecd3; box-shadow: inset 0 0 0 2px var(--good); }

.sh-track { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 1px; background: #c9cfd8; border: 1px solid #c9cfd8; }
.tk { position: relative; background: #fffdf6; text-align: center; font: 600 11px/1.9 var(--body); color: var(--ink2); }
.tk.past { color: var(--faint); }
.tk.here { background: var(--pc); color: #fff; font-weight: 800; }
.tk .mk { left: auto; right: 0; bottom: 0; font-size: 9px; padding: 0 2px; border-radius: 3px; }

/* what may be tapped (highlighter) and what is picked (a pencil ring) */
.can { cursor: pointer; }
.bx.can, .tk.can, .pt-label.can { background: var(--hi); }
.pw-row.can, .pt-col.can { background: #fff3c0; box-shadow: inset 0 0 0 2px var(--hi2); }
.pw-row.can .bx, .pt-col.can .bx { background: #fffbe8; }
.sel, .bx.sel, .tk.sel, .pt-label.sel { box-shadow: 0 0 0 3px var(--good) !important; }
.bx.sel { background: #c9f0d3; }
.pw-row.sel { background: #d9f3df; }

.dice { display: inline-flex; gap: 6px; vertical-align: middle; }
.die { --d: 22px; width: var(--d); height: var(--d); display: grid; grid-template-columns: repeat(3, 1fr); padding: calc(var(--d) * .12); gap: calc(var(--d) * .04); background: #fffdf6; border-radius: calc(var(--d) * .2); box-shadow: inset 0 -2px 0 #0002; }
.die i { border-radius: 50%; }
.die i.p { background: var(--ink); }
.dice.none .die { opacity: .25; }

/* ---- 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) auto auto; gap: 6px;
  padding: max(8px, env(safe-area-inset-top)) 10px max(8px, 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; }
.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(--hi); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #ffd54a55; } }
.g-pillgap { flex: none; width: 96px; }
.g-dice { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 12px; color: var(--dim); white-space: nowrap; }
.g-dice .rd { font-weight: 700; }
.g-dice .sum { color: var(--hi); font-size: 18px; }
.holder { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 99px; background: var(--hi); color: #2a2205; font-weight: 800; }
.g-scores { margin-left: auto; display: grid; justify-items: end; font-size: 12px; line-height: 1.15; white-space: nowrap; }
.g-scores .sc b { font-size: 16px; color: #fff; }
.g-scores .sc::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--pc); margin-right: 5px; }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--desk2); border-left: 4px solid var(--hi); border-radius: 6px 12px 12px 6px; padding: 7px 11px; font-size: 14.5px; line-height: 1.3; min-height: 48px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--line); color: var(--dim); }
.g-tabs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.g-tabs button { padding: 6px 4px; font-size: 13px; border-radius: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.g-tabs button.on { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.g-tabs button.hot::after { content: ''; position: absolute; top: 4px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--hi); box-shadow: 0 0 0 2px var(--desk); }
.g-board { min-height: 0; overflow: hidden; display: flex; align-items: flex-start; justify-content: center; }
.g-board .one { width: 100%; }
.g-board .sheet { --bx: min(8.4vw, 3.9vh, 40px); }
.tracks { width: 100%; display: grid; gap: 8px; }
.trk { color: var(--ink); background: var(--paper); border-radius: 10px; padding: 6px 8px 8px; }
.trk.seat0 { --pc: var(--c0); } .trk.seat1 { --pc: var(--c1); }
.trk h3 { font-size: 13px; margin: 0 0 4px; } .trk h3 b { color: var(--pc); }
.trk .tk { font-size: 12px; line-height: min(2.6vh, 24px); }
.g-panel { display: grid; gap: 6px; }
.g-panel.empty { display: none; }
.g-panel .say { font-size: 13px; color: var(--chalk); } .g-panel .say.muted { color: var(--dim); }
.devs { display: flex; flex-wrap: wrap; gap: 5px; min-height: 26px; align-items: center; font-size: 13px; }
.tag { padding: 3px 8px; border-radius: 99px; background: var(--paper); color: var(--ink); font-weight: 700; }
.pick-power { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.pick-power button { padding: 6px 2px; font-size: 12.5px; border-radius: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-power button b { color: var(--hi); margin-right: 2px; }
.chips, .modes, .targets, .bends { display: flex; flex-wrap: wrap; gap: 5px; }
.chips button, .modes button, .targets button, .bends button { padding: 6px 9px; font-size: 13px; border-radius: 99px; }
.chips button small, .targets button small { color: var(--dim); margin-left: 3px; font-weight: 600; }
.bends button { display: grid; justify-items: center; line-height: 1.1; border-radius: 10px; min-width: 52px; }
.bends button small { font-size: 10.5px; color: var(--dim); }
.chips .on, .modes .on, .targets .on, .bends .on { background: var(--paper); color: var(--ink); border-color: var(--hi2); box-shadow: 0 0 0 2px var(--hi2); }
.chips .on small, .bends .on small { color: var(--ink2); }
.g-btns { display: grid; grid-template-columns: 1fr 1.5fr; gap: 8px; }
.g-btns button { min-height: 48px; padding: 6px 8px; font-size: 15px; line-height: 1.15; }
.g-btns button[hidden] { display: none; }
.g-btns button[hidden] + button { grid-column: 1 / -1; }

/* The kit's pill (table-dock.ts) opens the sheet with what happened and the sound switches. Its own spot is the
   bottom right corner, which is where Lock in lives, so it is moved up beside "?" and the header keeps a gap. */
body.phone #cs-pill { top: max(8px, env(safe-area-inset-top)); bottom: auto; left: 58px; right: auto; height: 40px; width: 96px; padding: 0 6px;
  font-size: 13.5px; white-space: nowrap; text-align: center; }

/* A rig panel or a phone on its side: the sheet on the left (Powers beside Points), everything else on the 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, 1.75fr) minmax(300px, 1fr); grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "head head" "board pres" "board coach" "board tabs" "board panel" "board btns"; column-gap: 14px; padding: 8px 14px 10px; }
  .g-head { grid-area: head; } #cs-pres-slot { grid-area: pres; } .g-coach { grid-area: coach; } .g-tabs { grid-area: tabs; }
  .g-board { grid-area: board; align-items: center; } .g-panel { grid-area: panel; align-content: start; } .g-btns { grid-area: btns; }
  .g-panel.empty { display: grid; }
  body.phone #cs-pill { left: 62px; top: 8px; }
  .g-board .sheet { --bx: min(5.6vh, 3.4vw, 34px); grid-template-columns: auto minmax(0, 1fr); align-items: start; }
  .g-board .sh-points { align-self: start; }
  .tracks { grid-template-columns: 1fr 1fr; }
  .trk .tk { font-size: 11px; line-height: min(3.6vh, 22px); }
  .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(--chalk); -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(8, 14, 13, .84); }
.cm-ring { fill: none; stroke: var(--hi); stroke-width: 2; }
.cm-ln { stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--hi); stroke: #2a2205; 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(--desk2); border: 1.5px solid var(--hi); 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(--hi); color: #2a2205; 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: #141d1cf7; 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(--hi); background: var(--desk2); 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(--hi); }
.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(34px, 6.5vw, 58px); } .hero h1 span { color: var(--paper); }
.tag-line { font-size: 1.2em; color: var(--dim); margin: 6px 0 4px; }
.credit { color: var(--paper); margin: 4px 0; } .credit a { color: var(--hi); }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 14px; background: var(--hi); color: #2a2205; font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--desk3); color: var(--chalk); 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(--desk2); border-radius: 14px; padding: 12px 14px; } .how h3 { color: var(--hi); margin-bottom: 4px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--desk2); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.rooms .code { font-family: var(--display); color: var(--hi); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--desk2); border-left: 4px solid var(--hi); 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; }
.helppage table { border-collapse: collapse; width: 100%; font-size: .95em; } .helppage td, .helppage th { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left; vertical-align: top; }
.helppage th { color: var(--hi); }
.logo { display: inline-grid; grid-template-columns: repeat(3, 26px); gap: 4px; vertical-align: middle; margin-right: 12px; }
.logo i { width: 26px; height: 26px; border-radius: 6px; border: 2px solid var(--paper); position: relative; }
.logo i.on::after { content: ''; position: absolute; top: -7px; right: -7px; width: 11px; height: 11px; border-radius: 50%; background: var(--red); border: 2px solid var(--paper); }
.logo i.b.on::after { background: var(--blue); }
.url { word-break: break-all; color: var(--hi); font-size: .9em; }
