/* Climb On!: the shared look for splash, phone and TV. Alpine dusk: a slate sky, granite ledges,
   chalk-white type and rope colours for the teams (orange, teal, yellow, violet). Dice are drawn
   in their own shapes (a d4 is a triangle, a d20 a hexagon). 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: #18212e; --sky2: #222e40; --sky3: #2e3c52; --line: #44546c;
  --chalk: #f3eee4; --dim: #a9b4c4; --ink: #1b1712;
  --rock: #6d645b; --rock2: #554d46; --rock3: #3f3934; --grass: #3d4a3a;
  --rope: #ff7a3d; --rope2: #d65a22;
  --t0: #ff7a3d; --t1: #3ec6b8; --t2: #f2c84b; --t3: #b49bff;
  --tw: #f4f1ea; --tb: #4f8dff; --tr: #e5484d;
  --good: #6fdc8c; --bad: #ff6b6b;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: linear-gradient(180deg, #2e3c52 0%, #18212e 70%); --cs-end-fg: #f3eee4; --cs-end-dim: #a9b4c4;
  --cs-end-accent: #ff7a3d; --cs-end-win: #ff7a3d; --cs-end-loss: #3ec6b8;
  --display: "Trebuchet MS", "Gill Sans", "Segoe UI", system-ui, 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: var(--sky) linear-gradient(180deg, var(--sky3) 0%, var(--sky) 60%) fixed;
  -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; letter-spacing: .01em; }
h1 { color: var(--rope); font-size: 34px; line-height: 1.1; }
h2 { color: var(--chalk); 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(--rope); border-color: var(--rope); color: var(--ink); }
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(--rope); }
.muted, .hint { color: var(--dim); }
.av { border-radius: 50%; vertical-align: middle; margin-right: 4px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(160px); background: var(--chalk); color: var(--ink);
  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: grid; gap: 3px; color: var(--dim); font-weight: 700; }
.levers select { width: 100%; }

/* ---- shared pieces: dice, tokens, the mountain, the roll ---- */
.t0 { --team: var(--t0); } .t1 { --team: var(--t1); } .t2 { --team: var(--t2); } .t3 { --team: var(--t3); }
.die { --s: var(--die, 34px); width: var(--s); height: var(--s); padding: 0; border: 0; border-radius: 0; background: none; display: inline-grid; place-items: stretch;
  cursor: default; flex: none; transition: transform .12s, filter .12s; }
.die > span { display: grid; place-items: center; background: var(--team); color: var(--ink); font: 800 calc(var(--s) * .36)/1 var(--body);
  clip-path: var(--shape); padding-top: var(--dy, 0); }
.die.d4 { --shape: polygon(50% 2%, 100% 94%, 0 94%); --dy: 28%; }
.die.d4 > span { font-size: calc(var(--s) * .32); }
.die.d6 > span { clip-path: none; border-radius: 16%; }
.die.d8 { --shape: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.die.d10 { --shape: polygon(50% 0, 100% 40%, 50% 100%, 0 40%); --dy: 0; }
.die.d12 { --shape: polygon(50% 0, 100% 37%, 82% 100%, 18% 100%, 0 37%); --dy: 12%; }
.die.d20 { --shape: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0 50%); }
.die.can { cursor: pointer; filter: drop-shadow(0 0 1.5px var(--chalk)) drop-shadow(0 0 3px var(--chalk)); }
.die.sel { transform: translateY(-12%) scale(1.12); filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 5px var(--good)) drop-shadow(0 0 7px var(--good)); }
.die.tgt { filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 5px var(--bad)) drop-shadow(0 0 6px var(--bad)); }
.die-n { display: inline-block; min-width: 2.6em; text-align: center; font-weight: 800; }

.tok { display: inline-grid; place-items: center; min-width: 1.55em; height: 1.55em; padding: 0 .3em; border-radius: 999px; font: 800 .82em/1 var(--body); color: var(--ink); }
.tok.w { background: var(--tw); } .tok.b { background: var(--tb); color: #fff; } .tok.r { background: var(--tr); color: #fff; }
.tok.none { opacity: .3; }

.mtn { display: flex; flex-direction: column; justify-content: space-evenly; height: 100%; gap: 2px; }
.lv { display: grid; grid-template-columns: var(--tagw, 3.6em) minmax(0, 1fr); align-items: center; flex: 1 1 0; min-height: 0; }
.lv-tag { display: grid; justify-items: start; line-height: 1.05; }
.lv-tag b { font: 800 1.25em/1 var(--display); color: var(--chalk); }
.lv-tag small { color: var(--dim); font-size: .72em; font-weight: 700; }
.lv0 .lv-tag b { color: var(--dim); }
.ledge { position: relative; justify-self: center; height: 100%; display: flex; align-items: center; justify-content: center;
  width: max(calc(var(--room) / var(--wide) * 100%), 36%); padding: 3px 4px 4px; }
.lv0 .ledge { width: 100%; }
.ledge::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, var(--rock) 0%, var(--rock2) 70%, var(--rock3) 100%);
  clip-path: polygon(6% 0, 94% 0, 100% 100%, 0 100%); border-top: 2px solid #ffffff22; }
.lv4 .ledge::before { clip-path: polygon(30% 0, 70% 0, 100% 100%, 0 100%); background: linear-gradient(180deg, #e9edf2 0%, #a9b2bb 35%, var(--rock2) 100%); }
.lv0 .ledge::before { clip-path: none; border-radius: 6px; background: linear-gradient(180deg, var(--grass), #2a3329); }
.slots { position: relative; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 4px; }
.slot { width: var(--die, 34px); height: var(--die, 34px); border-radius: 50%; border: 2px dashed #ffffff40; flex: none; transform: scale(.7); }
.slots em { color: #ffffff88; font-size: .8em; }

.r-none { color: var(--dim); }
.r-who { font-weight: 800; }
.r-die { display: inline-flex; align-items: center; gap: .25em; }
.r-die b { font: 800 1.5em/1 var(--display); min-width: 1.1em; text-align: center; }
.r-verb { color: var(--dim); font-size: .9em; }
.r-out { margin-left: auto; padding: .15em .6em; border-radius: 999px; font-weight: 800; font-size: .9em; white-space: nowrap; }
.r-out.ok { background: var(--good); color: var(--ink); } .r-out.no { background: var(--sky3); color: var(--dim); } .r-out.wait { background: var(--rope); color: var(--ink); }

/* ---- 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 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: 800 19px var(--display); color: var(--rope); white-space: nowrap; margin-left: auto; }
.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(--rope); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #ff7a3d55; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-score { display: flex; gap: 6px; }
.sc { flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; align-items: center; column-gap: 6px;
  padding: 5px 8px; border-radius: 10px; background: var(--sky2); border: 2px solid transparent; }
.sc.up { border-color: var(--team); }
.sc .sw { width: 12px; height: 12px; border-radius: 3px; background: var(--team); }
.sc-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc b { font: 800 20px/1 var(--display); color: var(--team); }
.sc .toks { grid-column: 1 / -1; display: flex; gap: 3px; font-size: 13px; margin-top: 3px; }
.g-coach { background: var(--sky2); border-left: 4px solid var(--rope); border-radius: 6px 12px 12px 6px; padding: 8px 11px; font-size: 14.5px; line-height: 1.32; min-height: 54px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--line); color: var(--dim); }
.g-mtn { min-height: 0; --die: 33px; font-size: 15px; }
.g-roll { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 10px; border-radius: 10px; background: #0003; --die: 28px; }
.g-roll:empty { display: none; }
.g-acts { display: grid; gap: 6px; max-height: 34vh; overflow-y: auto; overscroll-behavior: contain; align-content: start; }
.g-acts:empty { display: none; }
.act { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 10px; background: var(--sky2); }
.a-what { font-size: 14px; line-height: 1.25; }
.a-pay { display: flex; gap: 5px; }
.pay { min-width: 48px; min-height: 44px; padding: 4px 8px; font-size: 13px; border-radius: 999px; border: 0; }
.pay.w { background: var(--tw); color: var(--ink); } .pay.b { background: var(--tb); color: #fff; } .pay.r { background: var(--tr); color: #fff; }
.save { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.spend { display: flex; align-items: center; gap: 4px; min-height: 48px; font-size: 14px; }
.spend span:last-child { margin-left: auto; }
#g-keep { min-height: 48px; }
.team { display: grid; gap: 5px; }
.t-row { display: grid; grid-template-columns: 3em 1fr 44px 2em 44px; align-items: center; gap: 6px; }
.t-row small { color: var(--dim); }
.t-row b { text-align: center; font-size: 18px; }
.t-row button { min-height: 38px; padding: 0; font-size: 20px; }
.t-picked { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; font-size: 18px; }
.team button.primary, #g-unteam { min-height: 46px; }
.g.picking .g-acts { max-height: none; }

/* 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 actions live, so it is moved
   up beside "?" and the header keeps a gap for it (.g-pillgap). */
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 mountain on the left, everything you press on the right. Nothing a
   player presses is below the fold, and the top centre stays clear for the launcher's own strip. */
@media (min-width: 720px) and (max-height: 640px) {
  .g { max-width: none; grid-template-columns: 1.1fr 1fr; grid-template-rows: auto auto auto auto auto minmax(0, 1fr); column-gap: 16px; padding: 8px 16px 10px; }
  .g-head { grid-column: 1 / -1; }
  .g-mtn { grid-column: 1; grid-row: 2 / -1; --die: 38px; }
  .g-score, #cs-pres-slot, .g-coach, .g-roll, .g-acts { grid-column: 2; }
  .g-score { grid-row: 2; } #cs-pres-slot { grid-row: 3; } .g-coach { grid-row: 4; } .g-roll { grid-row: 5; } .g-acts { grid-row: 6; }
  .g-acts { max-height: none; min-height: 0; }
  body.phone #cs-pill { left: 64px; top: 8px; }
  .g-coach { min-height: 44px; }
  .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(--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(10, 14, 20, .84); }
.cm-ring { fill: none; stroke: var(--rope); stroke-width: 2; }
.cm-ln { stroke: var(--chalk); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--rope); stroke: var(--ink); 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(--sky2); border: 1.5px solid var(--rope); 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(--rope); color: var(--ink); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 800 15.5px/22px var(--display); color: var(--chalk); }
.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: #111823f7; 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(--rope); 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(--rope); }
.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 { position: relative; }
.hero h1 { font-size: clamp(40px, 8vw, 68px); }
.peak { display: block; width: min(100%, 520px); height: auto; margin: 8px 0 4px; }
.tag { font-size: 1.2em; color: var(--dim); margin: 6px 0 4px; }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 12px; background: var(--rope); color: var(--ink); 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: 3px solid var(--rock); } .how h3 { color: var(--rope); margin-bottom: 4px; }
.board-table { border-collapse: collapse; margin: 10px 0; } .board-table th, .board-table td { border: 1px solid var(--line); padding: 4px 14px; text-align: center; }
.board-table th { color: var(--dim); font-weight: 700; }
.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(--rope); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--sky2); border-left: 4px solid var(--rope); border-radius: 8px; padding: 12px 16px; margin-top: 18px; } #rejoin.show { display: block; }
.credit { margin-top: 30px; color: var(--dim); }
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; }
