/* Bounce, Hop, & Crash: the shared look for splash, phone and TV. A roll-and-write: a printed play sheet on
   graph paper, felt-tip trails in the rules' six rider colours, and a hot pink for crashes. 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 {
  --paper: #f6f2e7; --paper2: #ece6d6; --paper3: #e2dac6; --grid: #ddd4bf; --rule: #c9bfa6;
  --ink: #23262e; --dim: #6b6862; --faint: #9a958a;
  --hex: #e7e4dd; --hexline: #8f8b82;
  --hot: #e0367a; --hot2: #b51d5a; --go: #1d7a42;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: #f6f2e7; --cs-end-fg: #23262e; --cs-end-dim: #6b6862; --cs-end-panel: #ece6d6;
  --cs-end-accent: #e0367a; --cs-end-win: #1d7a42; --cs-end-loss: #b51d5a;
  --display: "Avenir Next", "Avenir", "Trebuchet MS", "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(--ink); font: 500 16px/1.4 var(--body); -webkit-tap-highlight-color: transparent;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px; background-attachment: fixed; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; font-style: italic; margin: 0; letter-spacing: -.01em; }
h1 { color: var(--ink); font-size: 34px; line-height: 1.05; }
h2 { color: var(--ink); font-size: 20px; }
button { background: #fff; border: 2px solid var(--ink); color: var(--ink); padding: 10px 14px; border-radius: 10px;
  font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 2px 0 var(--ink); }
button:active { transform: translateY(2px); box-shadow: none; }
button.primary { background: var(--hot); border-color: var(--hot2); color: #fff; box-shadow: 0 2px 0 var(--hot2); }
button:disabled { opacity: .4; cursor: default; box-shadow: none; transform: none; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: #fff; color: var(--ink); border: 2px solid var(--ink); }
a { color: var(--hot2); }
.muted, .hint, .tagg { color: var(--dim); }
.tagg { font-size: 13px; margin-left: 6px; }
.av { border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.shp { vertical-align: -.15em; flex: none; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(160px); background: var(--ink); color: var(--paper);
  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(--hot); 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: #fff; border: 1.5px solid var(--rule); 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: 62%; }

/* ---- the sheet (shared/board.ts) ---- */
svg.sheet { display: block; width: 100%; height: 100%; }
.sheet .compass { font: italic 800 30px var(--display); fill: var(--faint); text-anchor: middle; }
.sheet .hx { fill: var(--hex); stroke: var(--hexline); stroke-width: 2; }
.sheet .hx.center { fill: #fff; stroke: var(--ink); stroke-width: 3; }
.sheet .hx.base { stroke-width: 4; }
.sheet .hx.base.idle { stroke-width: 2; opacity: .55; }
.sheet .hx.start { stroke: var(--ink); stroke-width: 3; stroke-dasharray: 6 5; }
.sheet .hx.inked { stroke: var(--hexline); }
.sheet .star { fill: none; stroke: var(--faint); stroke-width: 2; }
.sheet .lab { font: 600 15px var(--body); fill: var(--faint); text-anchor: middle; pointer-events: none; }
.sheet .lab.small { font-size: 11px; }
.sheet .rnd { font: 800 21px var(--display); text-anchor: middle; pointer-events: none; }
.sheet .trail { fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.sheet .trail.fresh { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1s ease-out forwards; stroke-width: 7; opacity: 1; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.sheet .chev { stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
.sheet .rshape { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.sheet .rider.fresh { animation: fadein .4s ease-out .8s both; }  /* opacity only: a CSS transform would replace the translate that places it */
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.sheet .wreck circle { stroke-width: 3; }
.sheet .wreck path { stroke-width: 6; stroke-linecap: round; fill: none; }
.sheet .wreck.fresh { animation: pop .4s ease-out .8s both; }
.sheet .ghost { opacity: .75; }
.sheet .plan { fill: none; stroke-width: 6; stroke-dasharray: 9 8; stroke-linecap: round; stroke-linejoin: round; }
.sheet .landing { fill: #ffffff99; stroke-width: 5; }
.sheet .landing.doom { fill: #e0367a33; stroke: var(--hot) !important; stroke-dasharray: 7 5; }
.sheet .scream circle { fill: none; stroke-width: 3; stroke-dasharray: 5 5; }
.sheet .scream.mine circle { stroke-width: 4; fill: #ffffff66; }
.sheet .scream.hit circle { stroke: var(--hot); stroke-width: 5; }
.sheet .burst line { stroke: var(--hot); stroke-width: 7; stroke-linecap: round; }
.sheet .burst { animation: pop .4s ease-out .7s both; transform-box: fill-box; transform-origin: center; }
@keyframes pop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
.sheet.still * { animation: none !important; }
.sheet .hit { fill: transparent; cursor: pointer; }

/* ---- the dice (shared/board.ts rollHtml) ---- */
.dz { display: grid; justify-items: center; gap: 1px; padding: 2px 0; position: relative; }
.dz .die { width: 40px; height: 40px; display: block; }
.dz .die polygon { fill: #fff; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.dz .die text { font: 800 19px var(--display); text-anchor: middle; fill: var(--ink); }
.dz span { font-size: 10.5px; font-weight: 700; color: var(--dim); white-space: nowrap; }
.dz.used .die polygon { fill: var(--paper3); stroke: var(--faint); }
.dz.used .die text { fill: var(--faint); }
.dz.used::after { content: ""; position: absolute; left: 12%; right: 12%; top: 46%; border-top: 3px solid var(--hot2); transform: rotate(-24deg); }
button.dz { background: transparent; border: 2px solid transparent; box-shadow: none; border-radius: 10px; padding: 3px 0 2px; min-width: 0; }
button.dz:not(:disabled) .die polygon { fill: #fff; }
button.dz.on { border-color: var(--hot); background: #e0367a1a; }
button.dz.on .die polygon { fill: var(--hot); stroke: var(--hot2); }
button.dz.on .die text { fill: #fff; }
button.dz:disabled { opacity: 1; }
button.dz:disabled:not(.used) .die polygon { fill: var(--paper2); }

/* ---- rider chips (shared/board.ts scoresHtml) ---- */
.sc { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 3px 7px; border-radius: 8px; background: #fff; border: 2px solid var(--c); font-size: 13.5px; }
.sc.me { box-shadow: inset 0 0 0 2px var(--c); background: color-mix(in srgb, var(--c) 14%, #fff); }
.sc.out { border-style: dashed; opacity: .78; }
.sc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.sc-team { font-style: normal; font-size: 10.5px; margin-left: 4px; color: var(--dim); }
.sc-st.ban { font-size: 10.5px; font-weight: 800; text-transform: uppercase; color: var(--ci); }
.sc-n { font: 800 16px var(--display); }
.sc-lock { width: 16px; text-align: center; color: var(--faint); font-weight: 800; }
.sc-lock.on { color: var(--go); }

/* ---- 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: 6px;
  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: 8px; min-height: 40px; }
.g-title { min-width: 0; font: italic 800 17px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-round { margin-left: auto; white-space: nowrap; font-weight: 800; font-size: 13.5px; color: var(--dim); }
.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(--hot); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #e0367a55; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-score { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.g-coach { background: #fff; border: 2px solid var(--ink); border-left-width: 6px; border-radius: 6px 10px 10px 6px; padding: 7px 10px; font-size: 14.5px; line-height: 1.3; min-height: 52px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-color: var(--rule); color: var(--dim); }
.g.banshee .g-coach { border-left-color: var(--hot); }
.g-board { min-height: 0; display: flex; justify-content: center; }
.g-board svg.sheet { width: auto; max-width: 100%; height: 100%; }
.g-ctl { display: grid; gap: 6px; }
.g-dice { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; min-height: 58px; align-items: center; }
.g-dice .dz .die { width: 36px; height: 36px; }
.g-face { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; min-height: 44px; }
.g-face.empty { display: flex; align-items: center; }
.fz { display: grid; justify-items: center; padding: 2px 0; font-size: 11px; line-height: 1; min-height: 44px; gap: 1px; box-shadow: 0 2px 0 var(--ink); }
.fz b { font-size: 19px; line-height: 1.1; }
.fz.on { background: var(--ink); color: var(--paper); }
.g-none { color: var(--dim); font-size: 13.5px; text-align: center; grid-column: 1 / -1; width: 100%; }
.g-btns { display: grid; grid-template-columns: 1fr 2.6fr; gap: 8px; }
.g-btns button { min-height: 48px; padding: 6px 8px; font-size: 15px; line-height: 1.15; }

/* The kit's pill sits up beside "?" (its own corner is where Lock in is). 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: 56px; right: auto; height: 40px; width: 92px; padding: 0 6px;
  font-size: 13px; white-space: nowrap; text-align: center; }
.g-pillgap { flex: none; width: 92px; }
@media (max-width: 380px) { .g-title { display: none; } }

/* A rig panel or a phone on its side: the sheet down the left, everything you press on the right. */
@media (min-width: 720px) and (max-height: 640px) {
  .g { max-width: none; grid-template-columns: minmax(0, 1fr) 430px; grid-template-rows: auto auto auto minmax(0, 1fr) auto; column-gap: 14px; padding: 8px 14px 10px; }
  .g-board { grid-column: 1; grid-row: 1 / -1; }
  .g-head, .g-score, #cs-pres-slot, .g-coach, .g-ctl { grid-column: 2; }
  .g-ctl { grid-row: 5; }
  body.phone #cs-pill { left: auto; right: 14px; top: 8px; }
  .g-head { padding-right: 100px; }
  .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: the finished sheet ---- */
.end-board svg { width: 19em; max-width: 100%; height: auto; display: block; margin: 0 auto; }

/* ---- 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(35, 38, 46, .78); }
.cm-ring { fill: none; stroke: var(--hot); stroke-width: 3; }
.cm-ln { stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--hot); stroke: #fff; 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(--paper); border: 2px solid var(--ink); box-shadow: 0 8px 24px #0006; }
.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(--hot); color: #fff; font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: italic 800 15.5px/22px var(--display); }
.cm-call .cm-b { margin-top: 3px; clear: both; }
.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: 14px; background: var(--paper); border: 2px solid var(--ink); box-shadow: 0 8px 26px #0006; }
.cm-pager button { min-height: 44px; padding: 0 16px; font-size: 16px; border-radius: 10px; }
.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(--ink); background: var(--paper); 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(--hot2); }
.cm-lastin h2 { margin: 0 0 8px; text-align: center; font-size: 22px; padding-bottom: 7px; border-bottom: 2px solid var(--ink); }
.cm-lastin ul { margin: 0; padding-left: 1.2em; } .cm-lastin li { margin: 0 0 6px; }

/* ---- splash + help ---- */
.wrap { max-width: 880px; margin: 0 auto; padding: 28px 18px 60px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; align-items: center; }
.hero h1 { font-size: clamp(38px, 7vw, 64px); }
.hero h1 i { color: var(--hot); }
.hero .mark svg { width: 100%; height: auto; display: block; }
@media (max-width: 620px) { .hero { grid-template-columns: 1fr; } .hero .mark { max-width: 220px; } }
.tag { font-size: 1.2em; color: var(--dim); margin: 8px 0 4px; }
.credit { font-weight: 700; margin: 4px 0; }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 12px; background: var(--hot); color: #fff; font-weight: 800; text-decoration: none; border: 2px solid var(--hot2); box-shadow: 0 3px 0 var(--hot2); }
.cta.alt { background: #fff; color: var(--ink); border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 26px; }
.how div { background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 12px 14px; } .how h3 { color: var(--hot2); margin-bottom: 4px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: #fff; border: 1.5px solid var(--rule); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.rooms .code { font-family: var(--display); color: var(--hot2); letter-spacing: 3px; font-size: 22px; font-weight: 800; }
#rejoin { display: none; background: #fff; border-left: 5px 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; }
.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: 2px solid var(--ink); 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: 8px 0; background: #fff; } .helppage td, .helppage th { border: 1.5px solid var(--rule); padding: 5px 10px; text-align: left; }
/* On the phone a toast drops from the top, under the header: the bottom is where Lock in is. */
body.phone #toast { top: 58px; bottom: auto; transform: translateX(-50%) translateY(-220px); }
body.phone #toast.show { transform: translateX(-50%) translateY(0); }
