/* 16 Memories: the shared look for splash, phone and TV. A dark plum table under a lamp, cream tiles with a
   black edge like the printed set, tile backs in a teal lattice, a coral pawn and coral for "you". Tiles use a
   plain serif, as the PDF does. No web fonts, no remote anything: the party rig is offline. */
:root {
  --bg: #17111f; --bg2: #21182c; --panel: #2a2037; --panel2: #352945; --line: #4a3b5e;
  --ink: #f6efe4; --dim: #b4a6c4; --paper: #fbf6ea; --inkd: #1a1320;
  --coral: #ff8a5c; --coral2: #e0643a; --teal: #3cc9b5; --teal2: #1f8f80; --gold: #ffd166;
  --good: #4fd18b; --bad: #ff5d6c;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #352945 0%, #17111f 62%); --cs-end-fg: #f6efe4; --cs-end-dim: #b4a6c4;
  --cs-end-accent: #ff8a5c; --cs-end-win: #ffd166; --cs-end-loss: #3cc9b5; --cs-end-panel: #2a2037;
  --serif: Georgia, "Times New Roman", Times, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --cs-end-font: var(--body);
}
* { 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%, #3a2b4d, var(--bg) 68%) fixed; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0; }
h1 { color: var(--coral); font-size: 34px; line-height: 1.1; }
h2 { color: var(--paper); font-size: 20px; }
button { background: var(--panel2); 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(--coral); border-color: var(--coral); color: var(--inkd); }
button:disabled { opacity: .38; 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(--coral); }
.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; }
.levers select { max-width: 64%; }
.levers .kidrule { justify-content: flex-start; font-weight: 600; } .levers .kidrule span { flex: 1; } .levers .kidrule input { width: 24px; height: 24px; }

/* ---- the board and its tiles (client/shared/ui.ts) ---- */
/* the board is the container a cell's own frame is measured against (a cell's cq units would be the page's) */
.board { container-type: inline-size; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2.4%; padding: 3%; aspect-ratio: 1; width: 100%;
  background: #d9d2c4; border-radius: 4%; box-shadow: 0 10px 30px #0008, inset 0 0 0 2px #fff6; }
.cell { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 13%; overflow: hidden; container-type: size; cursor: default;
  background: var(--paper); box-shadow: 0 0 0 max(2px, .5cqw) #111 inset; transition: transform .12s, box-shadow .15s; }
.cell .num { position: absolute; left: 7%; top: 4%; font: 700 13cqh/1 var(--body); color: #0008; pointer-events: none; z-index: 3; }
.cell.up .num { display: none; }
.cell .back { position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 max(2px, 2.2cqw) #111 inset;
  background: radial-gradient(circle at 50% 50%, #ffffff22 0 18%, transparent 19%) 0 0 / 25% 25%,
              repeating-linear-gradient(45deg, var(--teal2) 0 9%, #177367 9% 18%), var(--teal2); }
.cell.down .num { color: #ffffffb0; }
.cell.gone { background: transparent; box-shadow: none; }
.cell.gone .slot { position: absolute; inset: 4%; border: max(2px, 1.6cqw) dashed #8d8273; border-radius: 13%; }
.cell.gone .num { color: #6d6355; }
.cell.can { cursor: pointer; box-shadow: 0 0 0 max(2px, .5cqw) #111 inset, 0 0 0 3px var(--paper); }
.cell.can .back { outline: max(3px, 3cqw) solid #ffffffcc; outline-offset: -9cqw; }
.cell.picked { transform: translateY(-4%) scale(1.04); z-index: 2; box-shadow: 0 0 0 4px var(--coral), 0 8px 18px #0009; }
.cell.picked .back { outline-color: var(--coral); }
.cell.ok, .cell.only, .cell.bad, .cell.miss { box-shadow: 0 0 0 max(2px, .5cqw) #111 inset; }
.cell.ok::after, .cell.only::after, .cell.bad::after, .cell.miss::after { position: absolute; right: 5%; bottom: 3%; z-index: 4; font: 800 26cqh/1 var(--body); text-shadow: 0 0 4px #fff; }
.cell.ok::after { content: "✓"; color: #11924f; }
.cell.only::after { content: "★"; color: #c98a00; }
.cell.bad::after, .cell.miss::after { content: "✗"; color: #d3243a; }
.cell.ok { outline: max(3px, .7cqw) solid var(--good); outline-offset: -1px; }
.cell.only { outline: max(3px, .7cqw) solid var(--gold); outline-offset: -1px; }
.cell.bad { outline: max(3px, .7cqw) solid var(--bad); outline-offset: -1px; }
.cell.miss { opacity: .62; }
.cell.flip { animation: flip .5s ease-out; }
@keyframes flip { 0% { transform: rotateY(90deg); } 100% { transform: rotateY(0); } }
.cell .pawn { position: absolute; right: 6%; bottom: 6%; width: 38%; height: 38%; border-radius: 50%; z-index: 5; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #ffc3a8, var(--coral) 45%, var(--coral2)); border: max(2px, 2.4cqw) solid #fff; box-shadow: 0 3px 8px #000a; }
.cell .pencil { position: absolute; inset: 9%; border-radius: 10%; overflow: hidden; z-index: 2; opacity: .96; box-shadow: 0 0 0 2px #0006; }
@media (prefers-reduced-motion: reduce) { .cell.flip { animation: none; } }

/* a face: absolutely filling its tile or chip, sized from that container */
.tf { position: absolute; inset: 0; display: grid; place-items: center; background: var(--face, #fff); color: #111; text-align: center; line-height: 1; }
.tf-big { font: 400 min(66cqw, 66cqh)/1 var(--serif); }
.tf-big.two { font-size: min(50cqw, 56cqh); }
.tf-word { font: 600 min(21cqw, 40cqh)/1.05 var(--serif); padding: 0 4%; }
.tf-word.long { font-size: min(15cqw, 34cqh); }
.tf-nation b { display: block; max-width: 92%; padding: 3% 5%; border-radius: 8%; background: #fffffff0; color: #111; font: 700 min(14cqw, 26cqh)/1.05 var(--body); hyphens: manual; overflow-wrap: normal; }
.tf-shape svg { width: min(76cqw, 76cqh); height: min(76cqw, 76cqh); }

/* the palette: the names you may say, as chips that look like the tiles */
.palette { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: var(--chip-h, 46px); gap: 6px; }
.chip { position: relative; padding: 0; border: 0; border-radius: 10px; overflow: hidden; container-type: size; cursor: pointer;
  box-shadow: 0 0 0 2px #111 inset; background: var(--paper); }
.chip .tf { border-radius: 10px; }
.chip:disabled { opacity: .22; }
.chip.chosen { box-shadow: 0 0 0 4px var(--coral); transform: translateY(-2px); }

/* scores, one chip a player */
.g-scores, .t-players { display: flex; gap: 6px; }
.sc { flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 6px; padding: 4px 8px; border-radius: 10px;
  background: var(--panel); border: 1.5px solid var(--line); }
.sc.me { border-color: var(--coral); }
.sc.up { background: #ff8a5c26; border-color: var(--coral); }
.sc-name { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-n { grid-row: 1 / 3; grid-column: 2; font: 700 24px/1 var(--serif); color: var(--gold); text-align: right; }
.sc-n small { font: 700 10px var(--body); color: var(--dim); margin-left: 2px; }
.sc-st { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.2em; }
.sc-st.on { color: var(--teal); font-weight: 800; }
.bot, .off, .kid { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: 1px 5px; border-radius: 99px; background: var(--panel2); color: var(--dim); margin-right: 4px; vertical-align: middle; }
.off { background: #ff5d6c33; color: #ffb3bb; margin: 0 0 0 4px; } .kid { background: #ffd16633; color: var(--gold); }

/* option 1's calls, option 2's die */
.calls { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.calls li { display: flex; align-items: center; gap: 6px; padding: 3px 8px 3px 3px; border-radius: 9px; background: var(--panel); font-size: 13px; font-weight: 700; }
.mini { position: relative; display: inline-block; flex: none; width: 30px; height: 30px; border-radius: 6px; overflow: hidden; container-type: size; box-shadow: 0 0 0 1.5px #111; }
.calls li.ok { color: var(--good); } .calls li.bad { color: var(--bad); }
.die { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: var(--paper); color: var(--inkd); font: 800 22px var(--body); box-shadow: 0 2px 0 #b9ae9b; flex: none; }

/* ---- 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 minmax(0, 1fr); gap: 7px;
  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: 10px; min-height: 40px; }
.g-title { font: 700 18px var(--serif); color: var(--coral); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-clock { margin-left: auto; font: 700 22px var(--serif); color: var(--teal); font-variant-numeric: tabular-nums; }
.g-clock.low, .big-clock.low { color: var(--coral); }
.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(--coral); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #ff8a5c55; } }
.g-board { justify-self: center; width: min(100%, 42vh); }
.g-side { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); gap: 7px; min-height: 0; }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--bg2); border-left: 4px solid var(--coral); 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-act { display: flex; flex-direction: column; gap: 7px; min-height: 0; overflow: hidden; }
.act-note { margin: 0; color: var(--dim); font-size: 14.5px; text-align: center; } .act-note b { color: var(--ink); }
.big-clock { font: 700 64px/1 var(--serif); color: var(--teal); text-align: center; font-variant-numeric: tabular-nums; }
.bidpad { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.bidn { padding: 0; height: 46px; font: 700 20px var(--serif); border-radius: 10px; }
.bidn.chosen { background: var(--coral); border-color: var(--coral); color: var(--inkd); }
.say { min-height: 46px; font-size: 16px; }
.btn2 { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; } .btn2 button { min-height: 46px; padding: 6px 8px; }
.pawnline { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--dim); }
.legend { margin: 0; text-align: center; font-size: 13px; color: var(--dim); }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin: 0 4px 0 10px; vertical-align: -1px; }
.lg.ok { background: var(--good); } .lg.only { background: var(--gold); } .lg.miss { background: var(--bad); }
.g[data-phase="WRITE"] .palette, .g[data-phase="CALL"] .palette, .g[data-phase="TURN"] .palette { --chip-h: clamp(34px, 5.6vh, 50px); }
/* with the name palette on screen the board gives up a little height, so Pass / Say it stay whole */
.g.mine[data-phase="WRITE"] .g-board, .g.mine[data-phase="CALL"] .g-board, .g.mine[data-phase="TURN"] .g-board { width: min(100%, 36vh); }

/* The kit's pill ("Table", or "Sound") 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 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 minmax(0, 1fr); column-gap: 16px; padding: 8px 16px 10px; }
  .g-head { grid-column: 1 / -1; }
  body.phone #cs-pill { left: 64px; top: 8px; }
  .g-board { width: min(calc(100vh - 72px), 52vw); align-self: start; }
  .g.mine[data-phase] .g-board { width: min(calc(100vh - 72px), 52vw); }
  .g-coach { min-height: 42px; font-size: 14px; }
  .bidpad { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bidn { height: 44px; }
  .g[data-phase="WRITE"] .palette, .g[data-phase="CALL"] .palette, .g[data-phase="TURN"] .palette { --chip-h: clamp(30px, 8.4vh, 52px); }
  .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(12, 8, 18, .84); }
.cm-ring { fill: none; stroke: var(--coral); stroke-width: 2; }
.cm-ln { stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--coral); 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(--coral); 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(--coral); color: var(--inkd); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 700 15.5px/22px var(--serif); 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(--coral); 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(--coral); }
.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; }

/* ---- the end screen's board (server/debrief.ts reveal html) ---- */
.end-board { width: min(100%, 16em); margin: .3em auto; }
.end-board .board { box-shadow: none; }

/* ---- splash + help ---- */
.wrap { max-width: 860px; margin: 0 auto; padding: 28px 18px 60px; }
.hero h1 { font-size: clamp(36px, 7vw, 60px); }
.hero .mark { display: grid; grid-template-columns: repeat(4, 26px); gap: 4px; margin-bottom: 14px; }
.hero .mark i { width: 26px; height: 26px; border-radius: 5px; box-shadow: 0 0 0 2px #111 inset; }
.tag { font-size: 1.2em; color: var(--dim); margin: 6px 0 4px; }
.credit { color: var(--paper); margin: 4px 0 0; } .credit a { color: var(--teal); }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 14px; background: var(--coral); color: var(--inkd); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--panel2); 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(--coral); 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(--serif); color: var(--coral); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--bg2); border-left: 4px solid var(--coral); 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; }

/* The rules card lists all three options; once a game is on, only the one being played is shown. */
body[data-opt="1"] li[data-opt]:not([data-opt="1"]),
body[data-opt="2"] li[data-opt]:not([data-opt="2"]),
body[data-opt="3"] li[data-opt]:not([data-opt="3"]) { display: none; }
