/* Pitter Pattern: the shared look for splash, phone and TV. A rainy evening and a box of dominoes:
   slate blue, ivory tiles, four bright piles of tokens. 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: #111c26; --bg2: #1a2935; --bg3: #253847; --line: #3b5468;
  --ink: #eef3f1; --dim: #9db3c1; --tile: #f4eedd; --tileline: #b9ae92; --tileink: #1c2731;
  --rain: #7fd6e8; --rain2: #3aa6c2; --inkd: #0c151c;
  --s0: #ff7d5c; --s1: #2fc4b2; --s2: #f4c542; --s3: #b693ff;
  --good: #7fd6e8; --bad: #ff6b6b;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #253847 0%, #111c26 62%); --cs-end-fg: #eef3f1; --cs-end-dim: #9db3c1;
  --cs-end-accent: #7fd6e8; --cs-end-win: #f4c542; --cs-end-loss: #9db3c1;
  --display: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
/* the rain: thin slanted strokes, very quiet, behind everything */
body { color: var(--ink); font: 500 16px/1.4 var(--body); -webkit-tap-highlight-color: transparent;
  background: repeating-linear-gradient(105deg, transparent 0 22px, #ffffff07 22px 23px, transparent 23px 61px), radial-gradient(ellipse at 50% -10%, var(--bg3), var(--bg) 70%) fixed var(--bg); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; }
h1 { color: var(--rain); font-size: 30px; line-height: 1.1; letter-spacing: .04em; text-transform: uppercase; }
h2 { color: var(--tile); font-size: 19px; }
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(--rain); border-color: var(--rain); color: var(--inkd); }
button:disabled { opacity: .4; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--bg2); color: var(--ink); border: 1.5px solid var(--line); }
a { color: var(--rain); }
.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(--tile); color: var(--tileink);
  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; }
.levers select { max-width: 62%; }

/* ---- shared pieces: the board, the die, a pattern card, the player chips ---- */
.s0 { --c: var(--s0); } .s1 { --c: var(--s1); } .s2 { --c: var(--s2); } .s3 { --c: var(--s3); }
.board { display: block; width: 100%; height: 100%; -webkit-user-select: none; user-select: none; }
.board .tile { fill: var(--tile); stroke: var(--tileline); stroke-width: .3; }
.board .seam { stroke: var(--tileline); stroke-width: .4; stroke-linecap: round; fill: none; }
.board .num { font: 700 6.2px var(--display); fill: var(--tileink); text-anchor: middle; }
.board .blank { fill: #d9cfb4; }
.board .under { opacity: .3; }
.board .tok { fill: var(--c); stroke: var(--inkd); stroke-width: .4; }
.board .ini { font: 800 3.8px var(--body); fill: var(--inkd); opacity: .7; text-anchor: middle; pointer-events: none; }
.board .tok.last { stroke: #fff; stroke-width: .8; }
.board .legal { fill: #3aa6c238; stroke: var(--rain2); stroke-width: .8; animation: ring 1.4s ease-in-out infinite; }
.board .hint { fill: none; stroke: var(--rain2); stroke-width: .45; stroke-dasharray: 1.1 1; opacity: .8; }
.board .ghost { opacity: .7; stroke: var(--inkd); stroke-dasharray: 1.2 .8; }
.board .was { fill: none; stroke: var(--c); stroke-width: .55; stroke-dasharray: 1.3 1; }
.board .band { fill: none; stroke: var(--c); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; opacity: .5; }
.board .badge circle { fill: var(--c); stroke: var(--inkd); stroke-width: .3; }
.board .badge text { font: 800 3px var(--body); fill: var(--inkd); text-anchor: middle; }
.board .band.fresh { animation: bandin .7s ease-out; }
.board .badge.fresh { animation: badgein .7s ease-out; transform-box: fill-box; transform-origin: center; }
.board .tok.liftable { stroke: #fff; stroke-width: .7; }
.board .tok.picked { stroke: #fff; stroke-width: 1.3; filter: drop-shadow(0 0 1.2px #fff); }
.board .hit { fill: transparent; cursor: pointer; }
.board.still * { animation: none !important; }
@keyframes ring { 50% { stroke-width: 1.3; fill: #3aa6c258; } }
@keyframes bandin { from { opacity: 0; stroke-width: 7; } }
@keyframes badgein { from { opacity: 0; transform: scale(2.4); } }
/* while I am choosing what to lift, tokens that cannot be part of it step back */
.g.lifting.mine .board .tok:not(.liftable) { opacity: .4; }
.g.lifting.mine .board .tok:not(.liftable) + .ini { opacity: .3; }

.die { display: block; }
.die rect { fill: var(--tile); stroke: var(--tileline); stroke-width: .4; }
.die circle { fill: var(--tileink); }
.die text { font: 700 6px var(--display); fill: #9a8f74; text-anchor: middle; }
.pcard { display: block; }
.pcard rect { fill: var(--bg2); stroke: var(--line); stroke-width: .5; }
.pcard .tok { fill: var(--c, var(--tile)); stroke: var(--inkd); stroke-width: .25; }
.pcard.back rect { fill: var(--bg3); stroke-dasharray: 1 .7; }
.pcard.back text { font: 700 6px var(--display); fill: var(--dim); text-anchor: middle; }
.dot { display: inline-block; width: .8em; height: .8em; border-radius: 50%; background: var(--c); border: 1.5px solid var(--inkd); flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-width: 0; padding: 4px 9px; border-radius: 99px; background: #0005; border: 1.5px solid transparent; font-size: 13.5px; white-space: nowrap; }
.chip b { overflow: hidden; text-overflow: ellipsis; max-width: 7.5em; }
.chip em { font-style: normal; color: var(--dim); }
.chip.up { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); }

/* ---- 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 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: 700 16px var(--display); color: var(--rain); letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-count { margin-left: auto; white-space: nowrap; color: var(--dim); font-weight: 700; font-size: 13.5px; }
.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(--rain); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #7fd6e855; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.g-coach { background: var(--bg2); border-left: 4px solid var(--c, var(--rain)); border-radius: 6px 12px 12px 6px; padding: 8px 12px; font-size: 14.5px; line-height: 1.3; min-height: 54px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--line); color: var(--dim); }
.g-board { min-height: 0; min-width: 0; }
.g-mine { display: grid; gap: 8px; }
.g-info { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch; min-height: 66px; }
.g-card { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1.5px dashed var(--line); border-radius: 12px; padding: 6px 10px; min-width: 0; }
.g-card .pcard { width: 52px; height: 52px; flex: none; }
.g-card span { display: grid; min-width: 0; line-height: 1.2; }
.g-card em { font-style: normal; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.g-card b { font-size: 17px; color: var(--c); }
.g-card small { font-size: 12px; color: var(--dim); }
.g-die { display: grid; justify-items: center; align-content: center; gap: 2px; background: var(--bg2); border-radius: 12px; padding: 6px 10px; min-width: 92px; }
.g-die .die { width: 40px; height: 40px; }
.g-die em { font-style: normal; font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.g-die.stale .die { opacity: .4; }
.g-worth { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: center; }
.g-worth .w { display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 8px; background: var(--bg2); border-radius: 12px; padding: 5px 10px; min-width: 0; }
.g-worth .pcard { width: 42px; height: 42px; grid-row: span 2; }
.g-worth em { font-style: normal; font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 5.5em; align-self: end; }
.g-worth b { font-size: 19px; line-height: 1; align-self: start; }
.g-btns { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.g-btns button { min-height: 50px; padding: 6px 8px; font-size: 16px; line-height: 1.15; }
.g-btns #g-roll.must { background: var(--tile); border-color: var(--tile); color: var(--tileink); animation: helppulse 1.6s ease-in-out infinite; }

/* 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 Place 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; }
@media (max-width: 380px) { .g-title { display: none; } }

/* A rig panel or a phone on its side: use the width. The board on the left at full height, everything
   you read and press on the right. Nothing 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, 1.15fr); grid-template-rows: auto 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 / -1; }
  .g-chips, #cs-pres-slot, .g-coach, .g-mine { grid-column: 2; }
  .g-chips { justify-content: flex-start; }
  .g-mine { align-self: end; }
  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; }
}

/* ---- the kit's end screen: our two pieces of markup in it, sized in em so its fit loop can shrink them ---- */
.end-cards { display: flex; flex-wrap: wrap; gap: .8em 1.4em; justify-content: center; }
.end-card { display: grid; justify-items: center; gap: .15em; }
.end-card .pcard { width: 4.2em; height: 4.2em; }
.end-card em { font-style: normal; opacity: .75; font-size: .85em; }
.end-board { width: 15em; height: 17em; margin: 0 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(5, 10, 15, .84); }
.cm-ring { fill: none; stroke: var(--rain); stroke-width: 2; }
.cm-ln { stroke: var(--tile); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--rain); 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(--rain); 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(--rain); color: var(--inkd); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 700 15px/22px var(--display); color: var(--tile); }
.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: #0a1118f7; 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(--rain); 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(--rain); }
.cm-lastin h2 { margin: 0 0 8px; text-align: center; font-size: 20px; 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(30px, 7vw, 56px); }
.hero .by { color: var(--tile); margin-top: 6px; }
.tag { font-size: 1.15em; color: var(--dim); margin: 6px 0 4px; }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 14px; background: var(--rain); 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(--rain); margin-bottom: 4px; font-size: 16px; }
.deck { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.deck svg { width: 64px; height: 64px; }
.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(--rain); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--bg2); border-left: 4px solid var(--rain); 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; margin: 8px 0; } .helppage td, .helppage th { padding: 5px 14px 5px 0; text-align: left; border-bottom: 1px solid var(--line); }
