/* UpTower: the shared look for splash, phone and TV. A blueprint: deep drafting blue, chalk-white grid
   lines, and six bright building-block colours, one per piece. 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 {
  --sky: #0f2a47; --sky2: #15385c; --sky3: #1d4874; --line: #3a6896;
  --chalk: #eaf2ff; --dim: #a3bedb; --paper: #f6efe0; --inkd: #14202e;
  --gold: #f2b134; --brick: #e4572e; --teal: #29a3a3; --good: #6fd08c; --bad: #ff6f61;
  --p1: #f2b134; --p2: #e4572e; --p3: #2fb3b3; --p4: #f59a6a; --p5: #8cc63f; --p6: #b98ae6;
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #1d4874 0%, #0f2a47 62%); --cs-end-fg: #eaf2ff; --cs-end-dim: #a3bedb;
  --cs-end-accent: #f2b134; --cs-end-win: #f2b134; --cs-end-loss: #2fb3b3;
  --display: "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--chalk); font: 500 16px/1.4 var(--body);
  background-color: var(--sky);
  background-image: linear-gradient(#ffffff0a 1px, transparent 1px), linear-gradient(90deg, #ffffff0a 1px, transparent 1px);
  background-size: 24px 24px; background-attachment: fixed;
  -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; letter-spacing: .01em; }
h1 { color: var(--gold); font-size: 34px; line-height: 1.1; }
h2 { color: var(--paper); font-size: 20px; }
button { background: var(--sky3); border: 1.5px solid var(--line); color: var(--chalk); padding: 10px 14px; border-radius: 10px;
  font: inherit; font-weight: 700; cursor: pointer; }
button.primary { background: var(--gold); border-color: var(--gold); color: var(--inkd); }
button.go { background: var(--teal); border-color: var(--teal); color: #fff; }
button:disabled { opacity: .38; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--sky2); color: var(--chalk); border: 1.5px solid var(--line); }
a { color: var(--gold); }
.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; }

/* ---- shared pieces: the playfield, the piece sheet, the die ---- */
.p1 { fill: var(--p1); } .p2 { fill: var(--p2); } .p3 { fill: var(--p3); } .p4 { fill: var(--p4); } .p5 { fill: var(--p5); } .p6 { fill: var(--p6); }
.board { display: block; width: 100%; height: 100%; overflow: visible; }
.board .bd-bg { fill: #0a1f36; }
.board .bd-grid { stroke: #ffffff1f; stroke-width: .35; }
.board .bd-frame { fill: none; stroke: var(--dim); stroke-width: .6; }
.board .bd-best { fill: none; stroke: var(--gold); stroke-width: .7; }
.board .blk { stroke: #0006; stroke-width: .4; }
.board .blk.pend { opacity: .78; }
.board .blk.fresh { stroke: #fff; stroke-width: 1.1; }
.board .blk-will { fill: #fff; opacity: .9; }
.board .ol { fill: none; stroke: #0b1a2b; stroke-width: .9; }
.board .ol.last { stroke: #fff; stroke-width: .9; stroke-dasharray: 1.6 1; }
.board .bd-tick { fill: var(--good); }
.board .ghost.ok { fill: #6fd08cd0; stroke: #fff; stroke-width: .7; }
.board .ghost.no { fill: #ff6f6155; stroke: var(--bad); stroke-width: .7; stroke-dasharray: 1.4 1; }
.board .bd-lab { fill: #a3bedb99; font: 600 4.6px var(--body); }
.board .bd-val { fill: var(--chalk); font: 700 5.2px var(--body); }
.board .bd-lab.best, .board .bd-val.best { fill: var(--gold); }

.piece { display: block; overflow: visible; }
.piece .pc-blk { fill: #ffffff10; stroke: #ffffff66; stroke-width: .5; }
.piece .pc-blk.on { fill-opacity: .9; }
.piece .pc-blk.p1.on { fill: var(--p1); } .piece .pc-blk.p2.on { fill: var(--p2); } .piece .pc-blk.p3.on { fill: var(--p3); }
.piece .pc-blk.p4.on { fill: var(--p4); } .piece .pc-blk.p5.on { fill: var(--p5); } .piece .pc-blk.p6.on { fill: var(--p6); }
.piece .pc-blk:not(.on) { fill: none; }
.piece .pc-blk.p1 { stroke: var(--p1); } .piece .pc-blk.p2 { stroke: var(--p2); } .piece .pc-blk.p3 { stroke: var(--p3); }
.piece .pc-blk.p4 { stroke: var(--p4); } .piece .pc-blk.p5 { stroke: var(--p5); } .piece .pc-blk.p6 { stroke: var(--p6); }
.piece .pc-n { fill: var(--inkd); font: 800 5.6px var(--body); }
.piece .pc-num { fill: var(--chalk); font: 700 5.4px var(--body); }
.piece .pc-dot { fill: #9aa9ba; }
.piece .pc-will { fill: #c9d3de; stroke: #8b9bb0; stroke-width: 1.6; }
.piece .pc-will.used { fill: #fff; stroke: var(--gold); }
.piece .pc-wn { fill: var(--inkd); font: 800 5.6px var(--body); }
.piece .pc-over { fill: var(--bad); font: 800 5px var(--body); }

.die rect { fill: var(--paper); stroke: #0004; stroke-width: .4; } .die circle { fill: var(--inkd); }
.logo { width: 1.3em; height: 1.3em; vertical-align: middle; }
.logo rect { stroke: #0b1a2b; stroke-width: .8; }

/* ---- the phone: a fixed skeleton that never scrolls the page ---- */
.g { position: fixed; inset: 0; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto; 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: 8px; min-height: 40px; }
.g-title { font: 800 19px var(--display); color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-turnno { margin-left: auto; white-space: nowrap; font-weight: 700; color: var(--dim); display: inline-flex; align-items: center; gap: 6px; }
.g-turnno .die { width: 26px; height: 26px; }
.g-turnno .last { color: var(--bad); text-transform: uppercase; font-size: 12px; letter-spacing: .08em; }
.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(--gold); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #f2b13455; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--sky2); border-left: 4px solid var(--gold); border-radius: 6px 10px 10px 6px; padding: 7px 11px; font-size: 14.5px; line-height: 1.3; min-height: 52px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--line); color: var(--dim); }
.g-board { min-height: 0; display: flex; flex-direction: column; gap: 4px; cursor: crosshair; }
.g-field { flex: 1; min-height: 0; display: flex; justify-content: center; }
.g-field .board { width: auto; height: 100%; max-width: 100%; }
.g-score { text-align: center; font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-score b { color: var(--gold); font: 800 20px/1 var(--display); }
.g-pieces { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.pc { position: relative; padding: 4px 3px 2px; border-radius: 9px; display: grid; justify-items: center; gap: 1px; min-height: 78px; background: var(--sky2); border: 1.5px solid var(--line); }
.pc .piece { width: 100%; height: 50px; }
.pc .pc-tag { font-size: 10.5px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; min-height: 13px; }
.pc.rolled { border-color: var(--gold); background: #f2b1341f; } .pc.rolled .pc-tag { color: var(--gold); }
.pc.will .pc-tag { color: var(--chalk); }
.pc.sel { box-shadow: 0 0 0 3px var(--good); border-color: var(--good); }
.pc:disabled { opacity: .55; }
.g-btns { display: grid; grid-template-columns: 1fr 1.15fr 1fr 1fr; gap: 6px; }
.g-btns button { min-height: 46px; padding: 6px 4px; font-size: 15px; line-height: 1.1; }
.g-strip { display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: center; font-size: 13px; color: var(--dim); min-height: 18px; }
.g-strip .st b { color: var(--chalk); } .g-strip .st.me b { color: var(--gold); } .g-strip .st.out { opacity: .5; }
.g-strip .ok { color: var(--good); font-style: normal; } .g-strip .wait { color: var(--dim); font-style: normal; }

/* The kit's pill (Table / Sound) sits beside "?": its own corner is where Done lives. */
body.phone #cs-pill { top: max(8px, env(safe-area-inset-top)); bottom: auto; left: 58px; right: auto; height: 40px; width: 92px; padding: 0 6px;
  font-size: 13.5px; white-space: nowrap; text-align: center; }
.g-pillgap { flex: none; width: 92px; }

/* A rig panel or a phone on its side: the playfield on the left, everything else on the right. */
@media (min-width: 720px) and (max-height: 640px) {
  .g { max-width: none; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; column-gap: 16px; padding: 8px 16px 10px; }
  .g-head { grid-column: 1 / -1; grid-row: 1; }
  #cs-pres-slot { grid-column: 2; grid-row: 2; }
  .g-coach { grid-column: 2; grid-row: 3; }
  .g-board { grid-column: 1; grid-row: 2 / -1; }
  .g-pieces { grid-column: 2; grid-row: 4; grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: center; }
  .pc { min-height: 0; } .pc .piece { height: 58px; }
  .g-btns { grid-column: 2; grid-row: 5; }
  .g-strip { grid-column: 2; grid-row: 6; }
  body.phone #cs-pill { left: 64px; top: 8px; }
  .g-head .g-turnno { margin-right: 120px; }
  .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 towers on the kit's end screen (em: the end screen shrinks to fit by font size) */
.end-towers { display: flex; flex-wrap: wrap; gap: .6em; justify-content: center; }
.end-tower { margin: 0; width: 7.5em; text-align: center; }
.end-tower figcaption { font-size: .8em; font-weight: 700; color: var(--chalk); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.end-tower .board { width: 7.5em; height: 9.6em; }

/* ---- coach marks (table/client/coach.ts draws them; these are its classes) ---- */
.coach { position: fixed; inset: 0; z-index: 2300; color: var(--chalk); -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(4, 12, 24, .82); }
.cm-ring { fill: none; stroke: var(--gold); stroke-width: 2; }
.cm-ln { stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--gold); stroke: var(--inkd); stroke-width: 1.5; }
.cm-call { position: absolute; padding: 9px 12px 10px; border-radius: 12px; font-size: 14.5px; line-height: 1.33; background: var(--sky2); border: 1.5px solid var(--gold); 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(--gold); color: var(--inkd); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 800 16px/22px var(--display); 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: #0a1a2cf7; 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: 16px; border: 2px solid var(--gold); background: var(--sky2); 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(--gold); }
.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; }

/* ---- splash + help ---- */
.wrap { max-width: 860px; margin: 0 auto; padding: 28px 18px 60px; }
.hero { display: grid; grid-template-columns: auto 1fr; gap: 0 18px; align-items: center; }
.hero > :not(.hero-logo) { grid-column: 2; }
.hero-logo { grid-row: 1 / span 6; width: clamp(80px, 16vw, 140px); height: auto; align-self: start; }
.hero-logo rect { stroke: #0b1a2b; stroke-width: .8; }
.hero h1 { font-size: clamp(40px, 8vw, 68px); }
.tag { font-size: 1.15em; color: var(--dim); margin: 6px 0 4px; }
.credit { color: var(--paper); font-weight: 600; }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 12px; background: var(--gold); color: var(--inkd); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--sky3); color: var(--chalk); 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(--sky2); border-radius: 12px; padding: 12px 14px; border-top: 4px solid var(--p3); }
.how div:nth-child(2) { border-top-color: var(--p1); } .how div:nth-child(3) { border-top-color: var(--p2); } .how div:nth-child(4) { border-top-color: var(--p5); }
.how h3 { color: var(--gold); margin-bottom: 4px; font-size: 20px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--sky2); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.rooms .code { font-family: var(--display); color: var(--gold); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--sky2); border-left: 4px solid var(--gold); 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: 6px 0; } .helppage td, .helppage th { border: 1px solid var(--line); padding: 4px 10px; text-align: center; }
