/* Abs-Trac-Toe: the shared look for splash, phone and TV. A sheet of cream paper on a dark desk,
   black ink, and two fat markers: vermilion for X, cobalt for O, with a yellow for whatever is
   being pointed at. Jonathan first called the game Picasso-Tac-Toe, so the boards are meant to end
   up looking like a 1970s print. Colour is never the only difference: every claimed territory
   carries its X or its O. 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: #1b1917; --desk2: #26231f; --desk3: #34302a; --edge: #50493e;
  --ink: #f4ecd8; --dim: #b3a78f; --paper: #efe5cc; --paper2: #fffaf0; --pen: #17140f;
  --x: #e2452a; --xd: #a82d17; --o: #2a5fd0; --od: #1b3f93; --sun: #f2b824; --cut: #0f9d7c;
  --good: #58c98a; --bad: #ff6b5e;
  --me: var(--x);
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #34302a 0%, #1b1917 62%); --cs-end-fg: #f4ecd8; --cs-end-dim: #b3a78f;
  --cs-end-accent: #f2b824; --cs-end-win: #f2b824; --cs-end-loss: #e2452a; --cs-end-panel: #26231f;
  --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(--desk) radial-gradient(ellipse at 50% -10%, var(--desk3), var(--desk) 70%) fixed; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; letter-spacing: .01em; }
h1 { color: var(--sun); font-size: 34px; line-height: 1.05; }
h2 { color: var(--ink); font-size: 20px; }
button { background: var(--desk3); 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(--sun); border-color: var(--sun); color: var(--pen); }
button:disabled { opacity: .42; cursor: default; }
button[hidden] { display: none; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--desk2); color: var(--ink); border: 1.5px solid var(--edge); }
a { color: var(--sun); }
.muted, .hint, .tagg { color: var(--dim); }
.tagg { font-size: 13px; margin-left: 6px; }
.av { border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.s0 { --c: var(--x); --cd: var(--xd); } .s1 { --c: var(--o); --cd: var(--od); }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(200px); background: var(--paper2); color: var(--pen);
  padding: 10px 18px; border-radius: 10px; transition: transform .25s; z-index: 50; width: max-content; max-width: 92vw; font-weight: 700; box-shadow: 0 8px 24px #000a; }
#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(--edge); 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: 68%; }

/* ---- the sheet (client/shared/board.ts) ---- */
.board { display: block; width: 100%; height: 100%; -webkit-user-select: none; user-select: none; }
.board .blank { fill: #ffffff26; font: 700 44px var(--display); text-anchor: middle; }
.board .ground { fill: var(--paper2); }
.board .f { stroke: none; }
.board .f.v { fill: var(--paper2); }
.board .f.s0 { fill: var(--x); } .board .f.s1 { fill: var(--o); }
.board .f.fresh { animation: at-claim .9s ease-out; }
@keyframes at-claim { 0% { fill: var(--sun); } 100% { } }
.board .ln { stroke: var(--pen); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.board .ln.bend.new { stroke: var(--cut); stroke-width: 9; }
.board .rim { fill: none; stroke: var(--pen); stroke-width: 14; stroke-linejoin: round; }
.board .num { fill: #a3987f; font-family: var(--display); font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.board .mk { fill: none; stroke: #fff8ea; stroke-linecap: round; pointer-events: none; }
.board .pip { fill: #fff8ea; stroke: var(--pen); stroke-width: 4; pointer-events: none; }
.board .sel { fill: var(--sun); fill-opacity: .55; stroke: var(--sun); stroke-width: 9; stroke-linejoin: round; pointer-events: none; animation: at-sel 1.1s ease-in-out infinite; }
.board .selring { fill: none; stroke: var(--pen); stroke-width: 5; stroke-dasharray: 10 9; pointer-events: none; }
@keyframes at-sel { 50% { fill-opacity: .28; } }
.board.still .sel, .board.still .f.fresh { animation: none; }
@media (prefers-reduced-motion: reduce) { .board .sel, .board .f.fresh { animation: none; } }

/* the score chips, one per player */
.chip { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 9px; align-items: center; padding: 6px 10px; border-radius: 12px;
  background: var(--desk2); border: 2px solid var(--edge); min-width: 0; }
.chip.up { border-color: var(--c); box-shadow: 0 0 0 2px var(--c) inset; }
.chip .c-mark { grid-row: 1 / 3; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--c); color: #fff8ea; font: 800 22px/1 var(--display); }
.chip .c-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .c-name i { font-style: normal; font-weight: 600; font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; margin-left: 3px; }
.chip .c-score { grid-row: 1 / 3; grid-column: 3; font: 800 30px/1 var(--display); color: var(--ink); }
.chip .c-held { font-size: 12px; color: var(--dim); white-space: nowrap; }

/* ---- 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; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom)); max-width: 620px; margin: 0 auto; overflow: hidden; }
.g-head { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.g-title { font: 800 19px var(--display); color: var(--sun); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.g-stage { 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(--sun); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #f2b82455; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-score { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.g-coach { background: var(--desk2); border-left: 4px solid var(--sun); border-radius: 6px 12px 12px 6px; padding: 8px 12px; font-size: 14.5px; line-height: 1.33; min-height: 58px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--edge); color: var(--dim); }
.g-mid { container-type: size; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.g-feed { flex: 1; min-height: 0; align-self: stretch; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; padding: 0 4px; font-size: 13.5px; line-height: 1.3; color: var(--dim); }
.g-feed div:last-child { color: var(--ink); }
.g-sheet { position: relative; flex: none; width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); border-radius: 16px; background: var(--paper); box-shadow: 0 6px 22px #0009, 0 0 0 1px #0004 inset; overflow: hidden; }
.g-board, .g-ink { position: absolute; inset: 0; width: 100%; height: 100%; }
.g-ink { touch-action: none; -webkit-user-select: none; user-select: none; }
.g.t-outline .g-ink, .g.t-line .g-ink, .g.t-cut .g-ink { cursor: crosshair; }
.g.t-claim .g-ink { cursor: pointer; }
.g-ink .d-stroke { fill: none; stroke: var(--pen); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.g-ink .d-stroke.bend { stroke: var(--cut); }
.g-ink .d-close { stroke: var(--pen); stroke-width: 5; stroke-dasharray: 6 14; stroke-linecap: round; opacity: .5; }
.g-ink .d-bad { stroke: var(--x); stroke-width: 7; stroke-dasharray: 14 14; stroke-linecap: round; }
.g-btns { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 8px; }
.g-btns[data-n="2"] { grid-template-columns: 1fr 1.25fr; }
.g-btns[data-n="1"] { grid-template-columns: 1fr; }
.g-btns button { min-height: 50px; padding: 6px 8px; font-size: 15.5px; line-height: 1.15; }
.g.t-claim #g-b1, .g.t-claim #g-b2 { font-size: 22px; }
.g.t-claim .g-btns { grid-template-columns: 64px 64px 1fr; }

/* 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 main 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: 400px) { .g-title { font-size: 17px; } }

/* A rig panel or a phone on its side: the sheet on the left at full height, everything you read
   or 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: minmax(0, calc(100vh - 20px)) minmax(260px, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto; column-gap: 16px; padding: 8px 16px 10px; }
  .g-mid { grid-column: 1; grid-row: 1 / -1; }
  .g-feed { display: none; }
  .g-head, .g-score, #cs-pres-slot, .g-coach, .g-btns { grid-column: 2; }
  .g-head { padding-left: 0; }
  .g-coach { align-self: start; font-size: 16px; }
  .g-score { grid-template-columns: 1fr; }
  .g-btns button { min-height: 56px; }
  /* the pill would sit on the sheet up there: it goes back to the bottom corner, under the buttons' column */
  body.phone #cs-pill { top: 8px; left: auto; right: 16px; bottom: auto; }
  .g-pillgap { display: none; }
  .g-head { padding-right: 108px; }
  .g-stage { margin-left: 0; }
  .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 finished sheet on the kit's end screen: sized in em, so its fit loop can shrink it ---- */
.end-board { width: min(100%, 13em); aspect-ratio: 1; margin: 4px auto; background: var(--paper); border-radius: .6em; overflow: hidden; }
.cs-end.ph .end-board { width: min(100%, 20em); }

/* ---- 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, 10, 8, .84); }
.cm-ring { fill: none; stroke: var(--sun); stroke-width: 2; }
.cm-ln { stroke: var(--paper2); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--sun); 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(--desk2); border: 1.5px solid var(--sun); 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(--sun); color: var(--pen); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 700 15.5px/22px var(--display); color: var(--paper2); }
.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: #14110ef7; 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(--sun); 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(--sun); }
.cm-lastin h2 { margin: 0 0 8px; text-align: center; font-size: 22px; 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: 860px; margin: 0 auto; padding: 28px 18px 60px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 22px; align-items: center; }
.hero > * { grid-column: 1; }
.hero .art { grid-column: 2; grid-row: 1 / span 5; width: clamp(130px, 28vw, 250px); height: auto; aspect-ratio: 1; background: var(--paper); border-radius: 18px; box-shadow: 0 8px 22px #0009; transform: rotate(3deg); }
.hero h1 { font-size: clamp(36px, 7vw, 60px); }
.tag { font-size: 1.2em; color: var(--dim); margin: 6px 0 4px; }
.by { color: var(--ink); font-weight: 700; margin: 2px 0 0; } .by a { font-weight: 600; }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 14px; background: var(--sun); color: var(--pen); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--desk3); 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(--desk2); border-radius: 14px; padding: 12px 14px; border-top: 5px solid var(--edge); } .how h3 { color: var(--sun); margin-bottom: 4px; }
.how div:nth-child(1) { border-top-color: var(--pen); } .how div:nth-child(2) { border-top-color: var(--cut); } .how div:nth-child(3) { border-top-color: var(--x); } .how div:nth-child(4) { border-top-color: var(--o); }
.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(--sun); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--desk2); border-left: 4px solid var(--sun); 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(--edge); display: block; }
.helppage figure.phone img { max-width: 300px; margin: 0 auto; }
.helppage figcaption { color: var(--dim); margin-top: 8px; font-size: .95em; }
@media (max-width: 520px) { .hero { grid-template-columns: 1fr; } .hero .art { grid-column: 1; grid-row: auto; width: 150px; } }
