/* Thinking In Circles: the shared look for splash, phone and TV. A card table after dark: a plum
   room, the printed board on cream paper, copper pennies. The four shapes each have a colour AND an
   outline of their own, so colour is never the only signal. 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: #17111c; --bg2: #211827; --panel: #2a1f31; --panel2: #382a41; --line: #4d3b58; --edge: #6a5378;
  --ink: #f6efdf; --dim: #b9a8c2; --dark: #1d1712;
  --paper: #f3ead7; --paper2: #e6dabf; --pen: #2a2622; --loop: #b9b1a2;
  --copper: #e0903f; --copper2: #9a531b; --teal: #63cdbd;
  --circle: #1f5fc9; --triangle: #d1432a; --square: #1f8a4d; --pentagon: #7a3fc0;
  --good: #63cdbd; --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%, #382a41 0%, #17111c 62%); --cs-end-fg: #f6efdf; --cs-end-dim: #b9a8c2;
  --cs-end-accent: #e0903f; --cs-end-win: #63cdbd; --cs-end-loss: #ff6b6b; --cs-end-panel: #2a1f31;
  --display: Futura, "Century Gothic", "Avenir Next", "Trebuchet MS", "Gill Sans", system-ui, sans-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% -10%, #3a2a45, var(--bg) 70%) fixed; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: .12em; text-transform: uppercase; }
h1 { color: var(--copper); font-size: 32px; line-height: 1.1; }
h2 { color: var(--ink); font-size: 19px; }
button { background: var(--panel2); border: 1.5px solid var(--edge); color: var(--ink); padding: 10px 14px; border-radius: 12px;
  font: inherit; font-weight: 700; cursor: pointer; }
button.primary { background: var(--copper); border-color: var(--copper); color: var(--dark); }
button:disabled { opacity: .45; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--bg2); color: var(--ink); border: 1.5px solid var(--edge); }
a { color: var(--copper); }
.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(--dark);
  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: 1px solid var(--line); border-radius: 10px; margin: 4px 0; }
.levers { display: grid; gap: 6px; }
.levers label { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--dim); font-weight: 700; font-size: 14.5px; }
.levers select { max-width: 64%; padding: 6px; font-size: 14.5px; }

/* ---- the board (client/shared/board.ts) ---- */
.board { display: block; width: 100%; height: 100%; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.board .paper { fill: var(--paper); stroke: var(--paper2); stroke-width: 3; }
.board .loop { fill: none; stroke: var(--loop); stroke-width: 17; }
.board .track { fill: none; stroke: var(--pen); stroke-width: 5.5; }
.board .letter { fill: #2a262230; font: 700 50px var(--display); text-anchor: middle; }
.board .sp { fill: #fffaf0; stroke: var(--pen); stroke-width: 2.4; }
.board .sp.white { fill: #fff; stroke-width: 3.2; }
.board .sp.black { fill: var(--pen); }
.board .sp.neutral { stroke-width: 2.4; }
.sh { stroke: var(--pen); stroke-width: 1.6; stroke-linejoin: round; }
.sh.circle { fill: var(--circle); } .sh.triangle { fill: var(--triangle); } .sh.square { fill: var(--square); } .sh.pentagon { fill: var(--pentagon); }
.board .penny-edge { fill: none; stroke: #5a2f0c; stroke-width: 10; }
.board .penny { fill: none; stroke: var(--copper); stroke-width: 6.5; }
.board .ring.won .penny { stroke: #ffd24a; }
.board .token.shrug { animation: tic-shrug .5s .7s ease-in-out 2; transform-box: fill-box; transform-origin: center; }
@keyframes tic-shrug { 50% { scale: 1.18; } }
.board .halo { fill: #e0903f2e; stroke: var(--copper); stroke-width: 3; }
.board .legal { fill: #63cdbd1f; stroke: #14806f; stroke-width: 3.5; stroke-dasharray: 9 8; animation: tic-march 1.2s linear infinite; }
.board .legal.aimed { fill: #e0903f47; stroke: var(--copper2); stroke-dasharray: none; stroke-width: 5; animation: none; }
@keyframes tic-march { to { stroke-dashoffset: -34; } }
.board .reach { fill: none; stroke: var(--copper2); stroke-width: 2.6; stroke-dasharray: 4 5; }
.board .winarc { fill: none; stroke: #ffc21a; stroke-width: 30; stroke-linecap: round; opacity: .85; }
.board .nickel circle { fill: #c9ccd1; stroke: #6f747c; stroke-width: 4; } .board .nickel line { stroke: #6f747c; stroke-width: 7; stroke-linecap: round; }
.board .ring.blocked .track { stroke: #2a262255; }
.board .hit { fill: transparent; cursor: pointer; }
.board .mid-head { fill: #6b5a4a; font: 700 15px var(--display); letter-spacing: .14em; text-transform: uppercase; text-anchor: middle; }
.board .mid-name { fill: var(--pen); font: 700 16px var(--body); }
.board .mid-fist { fill: #6b5a4a; font: 800 13px var(--display); letter-spacing: .1em; text-transform: uppercase; text-anchor: middle; }
.board .mid-total { fill: var(--pen); font: 700 44px var(--display); text-anchor: middle; }
.board .mid-wait { fill: #6b5a4a; font: 600 15px var(--body); text-anchor: middle; }
.board .chip.white { fill: #fff; stroke: var(--pen); stroke-width: 2.4; } .board .chip.black { fill: var(--pen); stroke: var(--pen); stroke-width: 2.4; }
.board .bead.w { fill: #fff; stroke: var(--pen); stroke-width: 2.4; } .board .bead.b { fill: var(--pen); stroke: var(--pen); stroke-width: 2.4; }
.board .bead.q { fill: none; stroke: #2a262255; stroke-width: 2; stroke-dasharray: 3 3; }
.board .pop { animation: tic-pop .45s ease-out both; transform-box: fill-box; transform-origin: center; }
@keyframes tic-pop { from { scale: 0; } 70% { scale: 1.25; } }
.board.still * { animation: none !important; }
.board.settled .pop { animation: none; }
@media (prefers-reduced-motion: reduce) { .board .legal, .board .pop, .board .token.shrug { animation: none; } }

/* ---- the small pieces: a shape, a sequence, a hand of beads, a colour chip ---- */
.shape-ic { width: 1.5em; height: 1.5em; vertical-align: middle; flex: none; }
.goal { display: inline-flex; gap: .15em; padding: .12em .3em; border-radius: .5em; background: var(--paper); vertical-align: middle; }
.or { color: var(--dim); font-size: .8em; margin: 0 .3em; }
.beads { display: inline-flex; gap: .22em; vertical-align: middle; }
.bead { display: inline-block; width: .95em; height: .95em; border-radius: 50%; border: .12em solid var(--pen); }
.bead.w { background: #fff; } .bead.b { background: var(--pen); border-color: #d8cdb5; }
.chip { display: inline-block; width: 1em; height: 1em; border-radius: 50%; border: .13em solid #d8cdb5; vertical-align: -.14em; margin-right: .35em; }
.chip.white { background: #fff; } .chip.black { background: var(--pen); }
.nick { display: inline-block; width: 1em; height: 1em; border-radius: 50%; background: #c9ccd1; border: .13em solid #6f747c; vertical-align: -.14em; margin-right: .3em; }
.bot, .off { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; padding: 1px 6px; border-radius: 99px; background: var(--panel2); color: var(--dim); margin-left: 6px; vertical-align: middle; }
.off { background: #ff6b6b33; color: #ffc2c2; }

/* ---- 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 minmax(0, 1fr) auto 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); letter-spacing: .12em; text-transform: uppercase; color: var(--copper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-turn { margin-left: auto; white-space: nowrap; color: var(--dim); font-weight: 800; 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(--copper); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #e0903f55; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--panel); border-left: 4px solid var(--edge); border-radius: 6px 12px 12px 6px; padding: 7px 11px; font-size: 14.5px; line-height: 1.3; min-height: 52px; display: flex; align-items: center; color: var(--dim); }
.g.mine .g-coach { border-left-color: var(--copper); color: var(--ink); }
.g-board { min-height: 0; display: flex; justify-content: center; align-items: center; }
.g-board .board { width: auto; height: 100%; max-width: 100%; aspect-ratio: 1; }
.g-me { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; justify-content: space-between; padding: 6px 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 15px; min-height: 44px; }
.g-me small { color: var(--dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; margin-right: 6px; }
.g-me .m-goal { font-size: 15px; display: inline-flex; align-items: center; flex-wrap: wrap; }
.g-me .m-none { color: var(--dim); font-style: italic; }
.g-me .m-blk { white-space: nowrap; font-weight: 800; } .g-me .m-blk small { margin: 0 0 0 6px; }
.g-panel { min-height: 62px; display: grid; align-content: end; }
.p-wait { text-align: center; color: var(--dim); padding: 14px 8px; border: 1.5px dashed var(--line); border-radius: 12px; }
.p-btns { display: grid; grid-template-columns: 1fr; gap: 8px; }
.p-btns.two, .p-btns:has(#g-rewrite) { grid-template-columns: 1fr 1.5fr; }
.p-btns button { min-height: 50px; padding: 6px 8px; font-size: 16.5px; line-height: 1.15; }
.write { display: grid; gap: 7px; }
.w-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.w-slot { min-height: 50px; padding: 2px; background: var(--paper); border: 2px solid var(--paper2); border-radius: 12px; font-size: 22px; display: grid; place-items: center; }
.w-slot.at { border-color: var(--copper); box-shadow: 0 0 0 3px #e0903f66; }
.w-slot:disabled { opacity: 1; }
.w-q { color: #2a262260; font: 700 22px var(--display); }
.w-pal { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.w-pal button { display: grid; justify-items: center; gap: 0; padding: 5px 2px 3px; min-height: 52px; background: var(--paper); color: var(--dark); border-color: var(--paper2); font-size: 21px; }
.w-pal button span { font-size: 11px; letter-spacing: .04em; }
.write.n3 .w-slot { min-height: 38px; font-size: 17px; } .write.n2 .w-slot { min-height: 44px; font-size: 19px; }
.hands { display: grid; gap: 7px; }
.h-row { display: grid; grid-template-columns: 78px repeat(3, 1fr); gap: 7px; align-items: stretch; }
.h-lab { align-self: center; font: 700 13.5px var(--display); letter-spacing: .1em; text-transform: uppercase; line-height: 1.15; }
.h-lab small { color: var(--dim); font: 600 11px var(--body); letter-spacing: 0; text-transform: none; white-space: nowrap; }
.hand { min-height: 46px; padding: 4px; font-size: 21px; display: grid; place-items: center; background: #8d7a66; border-color: #b6a48f; }
.hand.held { background: var(--copper); border-color: #ffd9ae; box-shadow: 0 0 0 3px #e0903f66; }
.hand.closed { outline: 3px solid var(--teal); outline-offset: 1px; }

/* 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 the commit button 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: 430px) { .g-title { font-size: 13px; letter-spacing: .06em; } }

/* A rig panel, a phone on its side or a desktop window: the board on the left at full height, everything
   you read and press in a column on the right. Nothing a player presses is below the fold. */
@media (min-aspect-ratio: 5/4) {
  .g { max-width: none; grid-template-columns: auto minmax(280px, 1fr); grid-template-rows: auto auto auto auto minmax(0, 1fr); column-gap: 16px; padding: 8px 14px 10px; justify-content: center; }
  .g-board { grid-column: 1; grid-row: 1 / -1; width: min(calc(100dvh - 18px), 58vw); height: min(calc(100dvh - 18px), 58vw); align-self: center; }
  .g-head, #cs-pres-slot, .g-coach, .g-me, .g-panel { grid-column: 2; max-width: 520px; }
  .g-panel { align-content: start; }
  /* the kit's pill goes back to its own corner: down here that is empty table, not a button */
  body.phone #cs-pill { top: auto; left: auto; bottom: 10px; right: 14px; }
  .g-pillgap { display: none; }
  .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 pieces (server/debrief.ts). Sized in em: the kit fits its end screen by
   shrinking one font size, and a board in pixels would not shrink with it ---- */
.end-board { width: min(100%, 12.5em); aspect-ratio: 1; margin: 4px auto; }
.cs-end.ph .end-board { width: min(100%, 20em); }
.end-goals { display: grid; gap: .4em; }
.end-goals div { display: flex; align-items: center; gap: .5em; flex-wrap: wrap; }
.end-goals .goal { font-size: 1.1em; }

/* ---- 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, 7, 16, .84); }
.cm-ring { fill: none; stroke: var(--copper); stroke-width: 2; }
.cm-ln { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--copper); stroke: var(--dark); 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(--panel); border: 1.5px solid var(--copper); 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(--copper); color: var(--dark); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 700 14.5px/22px var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--ink); }
.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: #120c16f7; border: 1px solid var(--edge); 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(--copper); background: var(--panel); 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(--copper); }
.cm-lastin h2 { margin: 0 0 8px; text-align: center; font-size: 20px; padding-bottom: 7px; border-bottom: 1px solid var(--edge); }
.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: 900px; margin: 0 auto; padding: 28px 18px 60px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 24px; align-items: center; }
.hero > * { grid-column: 1; } .hero .emblem { grid-column: 2; grid-row: 1 / span 5; width: clamp(110px, 24vw, 220px); height: auto; }
.hero h1 { font-size: clamp(30px, 6.4vw, 60px); }
.byline { color: var(--ink); font-weight: 700; }
.tag { font-size: 1.15em; color: var(--dim); margin: 4px 0; }
.cta { display: inline-block; margin: 10px 10px 6px 0; padding: 12px 20px; border-radius: 14px; background: var(--copper); color: var(--dark); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--panel2); color: var(--ink); border: 1.5px solid var(--edge); }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 26px; }
.how div { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; } .how h3 { color: var(--copper); margin-bottom: 4px; font-size: 15px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--panel); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.rooms .code { font-family: var(--display); color: var(--copper); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--panel); border-left: 4px solid var(--copper); border-radius: 8px; padding: 12px 16px; margin-top: 18px; } #rejoin.show { display: block; }
footer { margin-top: 40px; color: var(--dim); font-size: .9em; }
.credit { margin-top: 26px; padding: 12px 14px; border-radius: 14px; border: 1px dashed var(--edge); color: var(--dim); }
.credit b { color: var(--ink); }
.helppage h2 { margin: 26px 0 6px; color: var(--copper); } .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(--edge); display: block; }
.helppage figure.phone img { max-width: 300px; margin: 0 auto; }
.helppage figcaption { color: var(--dim); margin-top: 8px; font-size: .95em; }
.helppage .legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 10px 14px; background: var(--paper); color: var(--dark); border-radius: 12px; font-weight: 700; }
.helppage .legend span { display: inline-flex; align-items: center; gap: 6px; }
