/* Whakka Mole: the shared look for splash, phone and TV. A back garden at dusk: dark soil, short green
   grass, brown moles in sunglasses (they wear them on Jonathan's play sheet), a red mallet and a yellow
   WHAKKA. System fonts only, no remote anything: the party rig is offline, so every asset is local
   (test/pages.test.ts fails on an external URL). */
:root {
  --soil: #24180f; --soil2: #342316; --soil3: #4a3321; --line: #6e4f35;
  --ink: #fbf3e4; --dim: #cfb99d; --paper: #fff6dc; --inkd: #24180f;
  --grass: #79c257; --grass2: #4c8f36; --grass3: #356b27;
  --mole: #8d5c3a; --mole2: #55341f; --nose: #f39db2;
  --sun: #ffd23f; --sun2: #e8a90f; --red: #e2462c; --red2: #a82a17;
  --good: #a6ea74; --bad: #ff8063;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #4a3321 0%, #24180f 64%); --cs-end-fg: #fbf3e4; --cs-end-dim: #cfb99d;
  --cs-end-accent: #ffd23f; --cs-end-win: #ffd23f; --cs-end-loss: #e2462c;
  --display: "Trebuchet MS", "Lucida Grande", Verdana, 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); background: var(--soil) radial-gradient(ellipse at 50% -20%, var(--soil3), var(--soil) 70%) fixed;
  -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; }
h1 { color: var(--sun); font-size: 34px; line-height: 1.1; letter-spacing: -.01em; }
h2 { color: var(--paper); font-size: 20px; }
button { background: var(--soil3); border: 1.5px solid var(--line); color: var(--ink); padding: 10px 14px; border-radius: 12px;
  font: inherit; font-weight: 700; cursor: pointer; }
button.primary { background: var(--sun); border-color: var(--sun2); color: var(--inkd); }
button:disabled { opacity: .45; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--soil2); color: var(--ink); border: 1.5px solid var(--line); }
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; }
.good { color: var(--good); } .bad { color: var(--bad); } .dim { color: var(--dim); font-weight: 600; }

#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(--red); 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: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--dim); font-weight: 700; }

/* ---- the play sheet (client/shared/ui.ts sheetSvg): phone, TV and end screen ---- */
.sheet { display: block; width: 100%; height: 100%; overflow: visible; }
.sheet .s-bg { fill: var(--grass2); stroke: var(--grass3); stroke-width: 1.2; }
.sheet .h-hit { fill: transparent; stroke: none; }
.sheet .h-mound { fill: #6f4b2d; }
.sheet .h-pit { fill: #170f09; }
.sheet .h-num { fill: var(--paper); font: 800 7.5px var(--display); text-anchor: middle; paint-order: stroke; stroke: var(--grass3); stroke-width: 2.2px; }
.sheet .m-body { fill: var(--mole); stroke: var(--mole2); stroke-width: 1; }
.sheet .m-shade { fill: #120c08; } .sheet .m-shade-l { stroke: #120c08; stroke-width: 1; }
.sheet .m-nose { fill: var(--nose); }
.sheet .m-badge circle { fill: var(--sun); stroke: var(--inkd); stroke-width: .8; }
.sheet .m-badge text { fill: var(--inkd); font: 800 8px var(--body); text-anchor: middle; }
.sheet .mole.ghost:not(.up) .m-body { fill: #8d5c3a66; stroke: var(--paper); stroke-dasharray: 2.5 2; }
.sheet .mole.ghost:not(.up) .m-shade, .sheet .mole.ghost:not(.up) .m-nose { opacity: .55; }
.sheet .mole.up.ghost .m-body { stroke: var(--sun); stroke-width: 1.8; }
.sheet.tap-pop .hole, .sheet.tap-whack .hole { cursor: pointer; }
.sheet.tap-pop .h-hit { stroke: #ffffff40; stroke-width: 1; stroke-dasharray: 3 3; }
.sheet.tap-pop .hole.picked .h-hit { stroke: var(--sun); stroke-width: 2; stroke-dasharray: none; fill: #ffd23f22; }
.sheet.tap-whack .h-hit { stroke: #ffffff40; stroke-width: 1; stroke-dasharray: 3 3; }
.sheet .hole.aimed .h-hit { stroke: var(--red); stroke-width: 2.2; stroke-dasharray: none; fill: #e2462c26; }
.sheet.off .hole { opacity: .55; }
.sheet .mallet .ml-head { fill: var(--red); stroke: var(--red2); stroke-width: 1; }
.sheet .mallet .ml-handle { fill: #d9b27a; stroke: #8a6a3e; stroke-width: .6; }
.sheet .pow { fill: var(--sun); stroke: var(--inkd); stroke-width: 2.2px; paint-order: stroke; font: 900 12px var(--display); text-anchor: middle; transform-box: fill-box; transform-origin: center; animation: pow .5s ease-out both; }
.sheet .hole.fresh .mole { animation: popup .45s cubic-bezier(.3, 1.6, .5, 1) both; }
.sheet .hole.hit .mallet { animation: whack .35s ease-in both; transform-box: fill-box; }
/* a WHAKKA clears the whole sheet, not just the hole that was hit: every mole on it goes down */
.sheet.wiped .hole .mole, .sheet .hole.hit .mole { animation: squash .5s .25s ease-in both; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes popup { from { transform: translateY(8px); opacity: 0; } }
@keyframes pow { from { opacity: 0; transform: scale(.4); } }
@keyframes squash { to { transform: scaleY(.35); opacity: .35; } }
@keyframes whack { from { opacity: 0; } }

/* the score chips: a race to the target, with who has locked in */
.g-scores { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { position: relative; flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 10px; overflow: hidden;
  background: linear-gradient(90deg, #79c25744 var(--fill, 0%), var(--soil2) var(--fill, 0%)); border: 1.5px solid var(--line); font-size: 13.5px; }
.chip .c-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--dim); font-weight: 700; }
.chip .c-score { font: 800 17px var(--display); color: var(--ink); }
.chip .c-lock { width: 18px; text-align: center; color: var(--dim); font-weight: 800; }
.chip.locked .c-lock { color: var(--good); }
.chip.me { border-color: var(--sun); } .chip.me .c-name { color: var(--sun); }
.chip.tgt { border-color: var(--red); }
.chip.lead .c-score { color: var(--sun); }

/* ---- 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; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px 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 18px var(--display); color: var(--sun); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-turn { 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 #ffd23f55; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--soil2); border-left: 4px solid var(--sun); border-radius: 6px 12px 12px 6px; padding: 8px 12px; font-size: 15px; line-height: 1.32; min-height: 58px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--line); }
.g.reveal .g-coach { border-left-color: var(--red); color: var(--ink); font-weight: 600; }
.g-sheets { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; min-height: 0; }
.g-sheet { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 3px; min-height: 0; }
.g-cap { font-weight: 800; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.g-cap .dim { font-size: 13.5px; }
.g-svg { min-height: 0; display: flex; justify-content: center; }
.g-svg .sheet { width: auto; max-width: 100%; aspect-ratio: 1; }
.g-btns { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.g-btns button { min-height: 50px; padding: 6px 8px; font-size: 16px; line-height: 1.15; }

/* The kit's pill (table-dock.ts) opens the sheet with what happened and the phone's sound switches. Its own
   spot is the bottom right corner, which is where Lock in lives, 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 two sheets side by side, everything on one screen. */
@media (min-width: 720px) and (max-height: 640px) {
  .g { max-width: none; grid-template-rows: auto auto auto minmax(0, 1fr) auto; padding: 8px 16px 10px; gap: 6px; }
  #cs-pres-slot { position: fixed; right: 16px; top: 8px; }
  body.phone #cs-pill { left: 64px; top: 8px; }
  .g-head .g-title { max-width: 190px; }
  .g-coach { min-height: 40px; padding: 6px 12px; }
  .g-sheets { grid-template-rows: minmax(0, 1fr); grid-template-columns: 1fr 1fr; gap: 16px; }
  .g-btns { max-width: 560px; width: 100%; margin: 0 auto; }
  .g-btns button { 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(--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(14, 9, 5, .84); }
.cm-ring { fill: none; stroke: var(--sun); stroke-width: 2; }
.cm-ln { stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--sun); stroke: var(--inkd); 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(--soil2); 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(--inkd); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 700 15.5px/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: #1a110af7; 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(--sun); background: var(--soil2); 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(--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 h1 { font-size: clamp(36px, 7vw, 60px); }
.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: 14px; background: var(--sun); color: var(--inkd); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--soil3); color: var(--ink); 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(--soil2); border-radius: 14px; padding: 12px 14px; } .how h3 { color: var(--sun); margin-bottom: 4px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--soil2); 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(--soil2); 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(--line); display: block; }
.helppage figure.phone img { max-width: 300px; margin: 0 auto; }
.helppage figcaption { color: var(--dim); margin-top: 8px; font-size: .95em; }
.hero .mascot { width: 120px; height: 120px; float: right; margin: 0 0 10px 16px; }
.credit { margin-top: 10px; color: var(--dim); }
