/* Blam!: the shared look for splash, phone and TV. A comic-book bang on a dark walnut chessboard:
   hot orange and yellow for the noise, four bright stashes (red, yellow, green, blue, the classic
   pyramid colours). Colour is never the only difference: every seat's pieces carry their own mark
   on the tip (dot, ring, diamond, cross). 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: #17100d; --bg2: #1f1612; --panel: #271b16; --panel2: #3a2921; --line: #6b4a3880; --edge: #6b4a38;
  --wood: #4c392e; --wood2: #3b2b23; --rim: #7a553f;
  --ink: #fff3e2; --dim: #d0b099; --dark: #17100d;
  --hot: #ff8a1f; --pop: #ffd23f;
  --c0: #ff5247; --c1: #ffd23f; --c2: #35d07f; --c3: #55a7ff;
  --good: #7df0a0; --bad: #ff6a5c;
  --me: var(--hot);
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #4a2a14 0%, #17100d 62%); --cs-end-fg: #fff3e2; --cs-end-dim: #d0b099;
  --cs-end-accent: #ff8a1f; --cs-end-win: #ffd23f; --cs-end-loss: #d0b099; --cs-end-panel: #271b16;
  --display: Impact, "Haettenschweiler", "Arial Narrow Bold", "Arial Black", 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%, #4a2a14, var(--bg) 70%) fixed; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: .03em; }
h1 { color: var(--hot); font-size: 36px; line-height: 1.05; font-style: italic; text-shadow: .06em .06em 0 #000; }
h2 { color: var(--ink); font-size: 21px; }
button { background: var(--panel2); border: 1.5px solid var(--edge); color: var(--ink); padding: 10px 14px; border-radius: 10px;
  font: inherit; font-weight: 700; cursor: pointer; }
button.primary { background: var(--hot); border-color: var(--hot); 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(--pop); }
.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(--c0); } .s1 { --c: var(--c1); } .s2 { --c: var(--c2); } .s3 { --c: var(--c3); }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(200px); background: var(--ink); 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: 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 pyramids (client/shared/board.ts): seen from above, lit from the top left ---- */
.pc .base { fill: var(--c); stroke: #0b0706; stroke-width: 2.5; }
.pc .fn { fill: #fff; opacity: .3; } .pc .fw { fill: #fff; opacity: .1; }
.pc .fe { fill: #000; opacity: .14; } .pc .fs { fill: #000; opacity: .3; }
.pc .pip { fill: #0b0706; opacity: .85; }
.pc .tip { fill: #0b0706; }
.pc .tip.hollow { fill: none; stroke: #0b0706; stroke-width: 3.5; stroke-linecap: round; }
.pyr { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -.25em; flex: none; }

/* ---- the board ---- */
.board { display: block; width: 100%; height: 100%; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.board .rim { fill: var(--rim); }
.board .sq { fill: var(--wood); }
.board .sq.alt { fill: var(--wood2); }
.board .lab { fill: var(--dim); font: 700 22px var(--body); text-anchor: middle; opacity: .8; }
.board .burst { fill: var(--pop); stroke: var(--hot); stroke-width: 5; stroke-linejoin: round; transform-box: fill-box; transform-origin: center; animation: bl-burst .45s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes bl-burst { from { transform: scale(.2) rotate(-25deg); opacity: 0; } to { transform: none; opacity: 1; } }
.board .trail { stroke: var(--c); stroke-width: 7; stroke-dasharray: 2 12; stroke-linecap: round; opacity: .7; }
.board .pc.shoved { animation: bl-slide .38s cubic-bezier(.2, .9, .3, 1.15); }
@keyframes bl-slide { from { transform: translate(var(--dx), var(--dy)); } to { transform: none; } }
.board .pc.new { transform-box: fill-box; transform-origin: center; animation: bl-drop .3s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes bl-drop { from { transform: scale(1.9); opacity: .2; } to { transform: none; opacity: 1; } }
.board .gone .pc { opacity: .55; }
.board .gain { fill: var(--pop); font: 400 30px var(--display); text-anchor: middle; paint-order: stroke; stroke: #0b0706; stroke-width: 6; stroke-linejoin: round; }
.board .gone.kept .gain, .board .gain.kept { fill: var(--ink); }
.board .legal { fill: var(--ink); opacity: .28; }
.board .aimring { fill: var(--c); fill-opacity: .2; stroke: var(--c); stroke-width: 5; }
.board .pc.ghost { opacity: .78; }
.board .arrow { stroke: var(--ink); stroke-width: 7; stroke-linecap: round; fill: none; opacity: .95; }
.board .arrow.out { stroke: var(--pop); }
.board .arrow.out.kept { stroke: var(--ink); stroke-dasharray: 9 9; }
.board .arrowhead { fill: context-stroke; }
.board .hit { fill: transparent; cursor: pointer; }
.board.still .burst, .board.still .pc.shoved, .board.still .pc.new { animation: none; }
@media (prefers-reduced-motion: reduce) { .board .burst, .board .pc.shoved, .board .pc.new { animation: none; } }

/* ---- the chips: one per player ---- */
.sc { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto; align-items: center; column-gap: 6px; padding: 5px 9px 6px; border-radius: 12px;
  background: var(--panel); border: 1.5px solid var(--line); border-left: 5px solid var(--c); min-width: 0; }
.sc.up { box-shadow: inset 0 0 0 1.5px var(--c); background: color-mix(in srgb, var(--c) 12%, var(--panel)); }
.sc-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sc-name .pyr { margin-right: 5px; }
.sc-n { grid-row: 1 / 3; grid-column: 2; font: 400 30px/1 var(--display); color: var(--c); text-align: center; display: grid; justify-items: center; }
.sc-n small { font: 700 10px/1.2 var(--body); color: var(--dim); letter-spacing: .04em; text-transform: uppercase; }
.sc-state { grid-column: 1; grid-row: 2; font-size: 12px; color: var(--dim); letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-state b { font-weight: 800; text-transform: uppercase; }
.sc-state b.on { color: var(--good); } .sc-state b.warn { color: var(--pop); }
.stash { display: flex; gap: 10px; align-items: center; }
.sc .stash { grid-column: 1 / -1; grid-row: 3; font-size: 13px; color: var(--ink); }
.stash .st { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; }
.stash .st.none { opacity: .35; }
.stash .st b { font-weight: 800; min-width: .7em; }
.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: 5px; vertical-align: middle; }
.off { background: #ff6a5c33; color: #ffc9c2; }

/* ---- 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.s0 { --me: var(--c0); } .g.s1 { --me: var(--c1); } .g.s2 { --me: var(--c2); } .g.s3 { --me: var(--c3); }
.g-head { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.g-title { font: italic 400 24px var(--display); color: var(--hot); white-space: nowrap; text-shadow: 2px 2px 0 #000; }
.g-move { 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(--pop); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #ffd23f55; } }
.g-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#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: 6px 11px; font-size: 14px; line-height: 1.3; min-height: 58px; display: flex; align-items: center; color: var(--dim); }
.g.mine .g-coach { border-left-color: var(--me); color: var(--ink); }
/* a square board. Its box keeps the SVG's shape. */
.g-board { justify-self: center; align-self: center; height: 100%; max-width: 100%; aspect-ratio: 1; min-height: 0; background: var(--bg2); border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.g-stash { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.sz { min-width: 0; }
.sz { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 50px; padding: 4px 6px; border-width: 2px; }
.sz .pyr { width: 34px; height: 34px; }
.sz-t { display: grid; text-align: left; line-height: 1.15; }
.sz-t b { font-size: 15px; } .sz-t small { font-size: 11px; color: var(--dim); font-weight: 600; white-space: nowrap; }
.sz.on { border-color: var(--me); background: color-mix(in srgb, var(--me) 22%, var(--panel2)); box-shadow: 0 0 0 2px var(--me); }
.g-btns { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.g-btns button { min-height: 50px; padding: 6px 10px; font-size: 17px; line-height: 1.15; }
.g-btns .primary { background: var(--me); border-color: var(--me); }
.g-btns .stop { min-width: 82px; font-size: 14.5px; color: var(--dim); }
.g-btns .stop.armed { border-color: var(--pop); color: var(--pop); }
.g-btns .stop.on { border-color: var(--pop); background: var(--pop); color: var(--dark); }

/* 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 buttons live, 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 { display: none; }
  .sz { gap: 5px; padding: 4px; } .sz .pyr { width: 26px; height: 26px; } .sz-t small { white-space: normal; } }

/* 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(300px, 480px); grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; column-gap: 16px; padding: 8px 14px 10px;
    justify-content: center; }
  .g-board { grid-column: 1; grid-row: 1 / -1; height: calc(100dvh - 18px); align-self: center; }
  .g-head, .g-chips, #cs-pres-slot, .g-coach, .g-stash, .g-btns { grid-column: 2; }
  .g-coach { align-self: start; min-height: 60px; font-size: 15px; }
  .g-title { display: inline; }
  /* the kit's pill goes back to a corner of its own, under the board's column edge */
  body.phone #cs-pill { top: max(8px, env(safe-area-inset-top)); left: auto; right: 14px; bottom: auto; }
  .g-pillgap { display: none; }
  .g-move { margin-right: 106px; }
  .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; }
}
@media (min-aspect-ratio: 5/4) and (max-height: 600px) {
  .g.n3 .sc, .g.n4 .sc { padding-top: 3px; padding-bottom: 3px; }
  .g.n3 .g-coach, .g.n4 .g-coach { font-size: 14px; min-height: 54px; }
}

/* ---- the end screen's board and chests (server/debrief.ts puts them in the reveal). 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%, 17em); aspect-ratio: 1; margin: .3em auto; background: var(--bg2); border: 1.5px solid var(--line); border-radius: .6em; overflow: hidden; }
.cs-end.ph .end-board { width: min(100%, 20em); }
.end-chest { display: flex; align-items: center; flex-wrap: wrap; gap: .1em .4em; font-size: .85em; line-height: 1.3; margin: .25em 0; padding-left: .5em; border-left: .3em solid var(--c); text-align: left; }
.end-chest b { color: var(--cs-end-fg); }
.end-chest .end-pts { font: 400 1.2em var(--display); color: var(--c); min-width: 1.4em; }
.end-chest .end-pcs { display: inline-flex; flex-wrap: wrap; gap: .1em; color: var(--cs-end-dim); }
.end-chest .pyr { width: 1.3em; height: 1.3em; }

/* ---- 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, 5, .86); }
.cm-ring { fill: none; stroke: var(--pop); stroke-width: 2; }
.cm-ln { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--pop); 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(--pop); 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(--pop); color: var(--dark); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 800 15.5px/22px var(--body); 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: #120b08f7; 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(--pop); 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(--pop); }
.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: 900px; margin: 0 auto; padding: 28px 18px 60px; }
/* the title in its own bang: a starburst cut out of a box, pure CSS */
.bang { display: inline-grid; place-items: center; padding: 34px 56px; margin: 0 0 6px -14px; background: var(--pop);
  clip-path: polygon(50% 0, 58% 17%, 72% 4%, 73% 22%, 91% 13%, 85% 31%, 100% 34%, 88% 48%, 100% 62%, 85% 66%, 92% 86%, 74% 79%, 72% 97%, 59% 84%, 50% 100%, 41% 84%, 27% 96%, 26% 79%, 8% 87%, 15% 67%, 0 62%, 12% 48%, 0 34%, 15% 31%, 9% 13%, 27% 22%, 28% 4%, 42% 17%); }
.bang h1 { font-size: clamp(46px, 13vw, 96px); color: #e0350b; transform: rotate(-5deg); text-shadow: .05em .05em 0 #17100d; letter-spacing: .02em; }
.tag { font-size: 1.2em; color: var(--dim); margin: 8px 0 4px; }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 12px; background: var(--hot); color: var(--dark); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--panel2); color: var(--ink); border: 1.5px solid var(--edge); }
/* a strip of board under the title, with a few pyramids on it: the same pieces as the game */
.strip { display: grid; grid-template-columns: repeat(8, 1fr); gap: 0; margin-top: 22px; border: 6px solid var(--rim); border-radius: 10px; overflow: hidden; max-width: 560px; }
.strip i { aspect-ratio: 1; background: var(--wood); display: grid; place-items: center; }
.strip i:nth-child(even) { background: var(--wood2); }
.strip .pyr { width: 78%; height: 78%; }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 22px; }
.how div { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; } .how h3 { color: var(--hot); margin-bottom: 4px; font-size: 19px; }
.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(--pop); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--panel); border-left: 4px solid var(--hot); 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(--pop); } .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; }
