/* Cube Digger: the shared look for splash, phone and TV. Underground: dark earth, a lamp-yellow
   accent, and the two pawns the rules suggest, a penny (copper) and a nickel (pale silver-blue).
   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 {
  --pit: #15100a; --pit2: #221910; --pit3: #34271a; --line: #5d4832;
  --ink: #f7efde; --dim: #c2b196; --paper: #f7e7c4; --inkd: #1d1408;
  --lamp: #ffb347; --lamp2: #e08a1c;
  --c0: #ff8f4a; --c1: #9ad4ff;            /* the penny and the nickel */
  --dirt: #7b5634; --dirt2: #5f4128; --dug: #0d0905;
  --good: #7be08a; --bad: #ff5d4d; --gold: #ffd23f;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #3a2a18 0%, #15100a 62%); --cs-end-fg: #f7efde; --cs-end-dim: #c2b196;
  --cs-end-accent: #ffb347; --cs-end-win: #ffb347; --cs-end-loss: #9ad4ff;
  --display: "Arial Black", "Helvetica Neue", Impact, 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); background: var(--pit) radial-gradient(ellipse at 50% -10%, var(--pit3), var(--pit) 70%) fixed;
  -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); font-weight: 900; margin: 0; }
h1 { color: var(--lamp); font-size: 34px; line-height: 1.1; font-style: italic; text-transform: uppercase; letter-spacing: .02em; }
h2 { color: var(--paper); font-size: 20px; }
button { background: var(--pit3); 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(--lamp); border-color: var(--lamp); color: var(--inkd); }
button:disabled { opacity: .38; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--pit2); color: var(--ink); border: 1.5px solid var(--line); }
a { color: var(--lamp); }
.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; }
.levers { display: grid; gap: 8px; }
.levers label { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--dim); font-weight: 700; font-size: 14px; }
.levers label { min-width: 0; } .levers select { width: 62%; min-width: 0; font-size: 14px; }
.lobbyv > * { min-width: 0; }

/* ---- the cube (client/shared/board.ts): one SVG per level, drawn in 10-unit squares ---- */
.s0 { color: var(--c0); } .s1 { color: var(--c1); }
.cube { display: grid; gap: 6px 8px; }
.cube .lvl { min-width: 0; min-height: 0; }
.cube svg { display: block; width: 100%; height: 100%; overflow: visible; }
.cube text { font-family: var(--body); text-anchor: middle; -webkit-user-select: none; user-select: none; }
.cube .lab { font-size: 3.5px; font-weight: 800; fill: var(--dim); }
.cube .roman { font-family: var(--display); font-style: italic; font-weight: 900; fill: #fff; opacity: .1; pointer-events: none; }
.cell .tile { fill: var(--dirt); stroke: var(--dirt2); stroke-width: .5; }
.cell.dug .tile { fill: var(--dug); stroke: var(--line); stroke-width: .35; }
.cell.home .tile { fill: #2c2114; stroke-width: .7; } .cell.h0 .tile { stroke: var(--c0); } .cell.h1 .tile { stroke: var(--c1); }
.i-house path { fill: currentColor; opacity: .9; } .i-house .door { fill: #2c2114; }
.i-bomb circle:first-child { fill: currentColor; stroke: #000; stroke-width: .5; }
.i-bomb .fuse { stroke: currentColor; stroke-width: .8; fill: none; stroke-linecap: round; } .i-bomb .glint { fill: var(--gold); }
.i-bomb.exposed circle:first-child { stroke: #fff; stroke-width: .7; stroke-dasharray: 1.1 .8; }
.i-chest path, .i-chest rect { fill: currentColor; stroke: #000; stroke-width: .45; } .i-chest .lock { fill: var(--gold); }
.i-crater path { fill: #6b2416; stroke: #ff8a5c; stroke-width: .35; }
.i-snip circle, .i-snip path { fill: none; stroke: var(--dim); stroke-width: .6; stroke-linecap: round; }
.tick { fill: none; stroke: currentColor; stroke-width: .85; stroke-linecap: round; stroke-linejoin: round; }
.cube .step { fill: currentColor; opacity: .85; }
.pawn circle { fill: currentColor; stroke: #000; stroke-width: .55; } .pawn .rim { fill: none; stroke: #0007; stroke-width: .35; }
.pawn text { font-size: 3.7px; font-weight: 900; fill: var(--inkd); text-anchor: middle; font-family: var(--body); }
.pawn .loot path, .pawn .loot rect { fill: var(--gold); stroke: #000; stroke-width: .7; }
.cube .ring { fill: none; stroke: var(--good); stroke-width: .9; pointer-events: none; }
.cell.r-can, .cell.r-aim, .cell.r-spot { cursor: pointer; }
.cell.r-aim .ring { stroke: #fff; stroke-width: 1.3; } .cell.r-aim .tile { fill: #3d5a34; }
.cell.r-spot .ring { stroke: var(--lamp); stroke-width: .5; stroke-dasharray: 1.3 1; opacity: .9; }
.cube .updown { fill: var(--good); stroke: #000; stroke-width: .35; pointer-events: none; opacity: .92; }
.cube .last { fill: none; stroke: #fff; stroke-width: .7; pointer-events: none; animation: lastpulse 1.4s ease-in-out infinite; }
.cube .last.k-blast { stroke: var(--bad); stroke-width: 1; } .cube .last.k-scan.hit { stroke: var(--bad); }
@keyframes lastpulse { 50% { opacity: .25; } }
.ico { width: 1.25em; height: 1.25em; vertical-align: -.25em; margin-right: .2em; overflow: visible; }
.lg { display: inline-flex; align-items: center; white-space: nowrap; }

/* ---- 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 minmax(0, 1fr) auto auto auto; gap: 7px;
  padding: max(8px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom)); max-width: 620px; margin: 0 auto; overflow: hidden; }
.g-head { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.g-title { font: italic 900 16px var(--display); text-transform: uppercase; color: var(--lamp); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-stat { margin-left: auto; display: flex; gap: 5px; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; padding: 3px 8px 3px 6px; border-radius: 99px; background: var(--pit2); border: 1px solid var(--line); font-weight: 800; font-size: 14px; }
.chip.got { background: var(--gold); color: var(--inkd); border-color: var(--gold); } .chip.lost { border-color: var(--bad); color: var(--bad); }
.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(--lamp); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #ffb34755; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--pit2); border-left: 4px solid var(--lamp); border-radius: 6px 12px 12px 6px; padding: 8px 12px; font-size: 15px; line-height: 1.33; min-height: 58px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--line); color: var(--dim); }
.g.me0 .g-title { color: var(--c0); } .g.me1 .g-title { color: var(--c1); }
.g-cube { min-height: 0; min-width: 0; container-type: size; display: grid; place-items: center; }
.g-cube .cube { --ar: 1.2; grid-template-columns: 1fr 1fr; width: min(100cqw, 100cqh * var(--ar)); aspect-ratio: var(--ar); }
.g-cube .cube.n5 { --ar: .7; }
.g-cube.asking .cell { cursor: pointer; }
.g-said { min-height: 38px; font-size: 13.5px; line-height: 1.3; color: var(--dim); display: flex; flex-direction: column; justify-content: center; }
.g-said b { color: var(--lamp); font-weight: 700; }
.g-legend { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 11.5px; color: var(--dim); }
.g-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.g-btns button { min-height: 50px; padding: 6px 8px; font-size: 16px; line-height: 1.15; }
.g.one-btn .g-btns { grid-template-columns: 0 0 1fr; gap: 0; }
.g.ph-setup .g-btns { grid-template-columns: 1.15fr .8fr 1.25fr; } .g.ph-setup .g-btns button { font-size: 15px; }

/* 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 Defuse lives, 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; } }

/* A rig panel or a phone on its side: every level in one row, as wide as the screen. 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: minmax(0, 1fr) 300px; grid-template-rows: auto auto auto minmax(0, 1fr) auto; column-gap: 14px; padding: 8px 16px 10px; }
  .g-head, #cs-pres-slot, .g-cube { grid-column: 1 / -1; }
  .g-coach { grid-column: 1 / -1; min-height: 40px; padding: 6px 12px; }
  .g-cube .cube { --ar: 4.9; grid-template-columns: repeat(4, 1fr); }
  .g-cube .cube.n5 { --ar: 5.1; grid-template-columns: repeat(5, 1fr); }
  .g-said { grid-column: 1; grid-row: 5; min-height: 0; }
  .g-legend { display: none; }
  .g-btns { grid-column: 2; grid-row: 5; } .g-btns button { min-height: 46px; }
  body.phone #cs-pill { left: 64px; top: 8px; }
  .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 kit's end screen: both maps, sized in em so its fit loop can shrink them ---- */
.end-board { width: min(100%, 44em); margin: .3em auto; padding: .5em; background: #0b0704; border: 1.5px solid var(--line); border-radius: .8em; }
.end-board .cube { grid-template-columns: repeat(4, 1fr); gap: .4em; }
.end-board .cube.n5 { grid-template-columns: repeat(5, 1fr); }
.cs-end.ph .end-board { width: min(100%, 24em); }
.cs-end.ph .end-board .cube, .cs-end.ph .end-board .cube.n5 { grid-template-columns: 1fr 1fr; }

/* ---- 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(8, 5, 2, .84); }
.cm-ring { fill: none; stroke: var(--lamp); stroke-width: 2; }
.cm-ln { stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--lamp); 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(--pit2); border: 1.5px solid var(--lamp); 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(--lamp); color: var(--inkd); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 800 15px/22px var(--body); 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: #120c06f7; 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(--lamp); background: var(--pit2); 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(--lamp); }
.cm-lastin h2 { margin: 0 0 8px; text-align: center; font-size: 20px; 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(40px, 9vw, 76px); letter-spacing: .01em; text-shadow: 0 4px 0 #0008; }
.hero .cubeart { float: right; width: min(34vw, 220px); margin: 0 0 10px 16px; }
.tag { font-size: 1.2em; color: var(--dim); margin: 6px 0 4px; }
.byline { color: var(--paper); font-weight: 700; margin: 2px 0 6px; } .byline a { font-weight: 500; }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 14px; background: var(--lamp); color: var(--inkd); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--pit3); 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; clear: both; }
.how div { background: var(--pit2); border-radius: 14px; padding: 12px 14px; border-top: 3px solid var(--dirt); } .how h3 { color: var(--lamp); margin-bottom: 4px; font-size: 16px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--pit2); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.rooms .code { font-family: var(--display); color: var(--lamp); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--pit2); border-left: 4px solid var(--lamp); 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; }
