/* Ziggurat: the shared look for splash, phone and TV. Baked clay at dusk: dark brick for the
   ground, limestone and sand for the dominoes, gold for the title and turquoise glaze for
   everything that can be tapped. 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 {
  --bg: #1a100b; --bg2: #2a1a12; --bg3: #3b2618; --line: #6a4a30;
  --ink: #f7ecd6; --dim: #c9ae8c; --inkd: #24150b;
  --gold: #f0c04e; --gold2: #c8922a; --turq: #35d0ba; --turq2: #1a8f80;
  --stone: #f6e7bd; --sand: #e0b56a; --brick: #b87f43; --brick2: #8c5a30; --brick3: #643c22;
  --good: #35d0ba; --bad: #ff7a66;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #4a2c18 0%, #1a100b 62%); --cs-end-fg: #f7ecd6; --cs-end-dim: #c9ae8c;
  --cs-end-accent: #f0c04e; --cs-end-win: #f0c04e; --cs-end-loss: #35d0ba; --cs-end-panel: #2a1a12;
  --display: "Copperplate", "Copperplate Gothic Bold", "Palatino Linotype", Palatino, Georgia, 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(--bg) radial-gradient(ellipse at 50% -10%, #4a2c18, var(--bg) 70%) fixed;
  -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: .04em; }
h1 { color: var(--gold); font-size: 34px; line-height: 1.1; text-transform: uppercase; }
h2 { color: var(--stone); font-size: 20px; }
button { background: var(--bg3); border: 1.5px solid var(--line); color: var(--ink); padding: 10px 14px; border-radius: 10px;
  font: inherit; font-weight: 700; cursor: pointer; }
button.primary { background: var(--turq); border-color: var(--turq); color: #05231f; }
button:disabled { opacity: .4; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--bg2); color: var(--ink); 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(--stone); 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; }

/* ---- the stack (shared/board.ts): d0 is the level being built, d1 the one under it, then deeper ---- */
.zig { display: block; width: 100%; height: 100%; }
.zig .bare { fill: #ffffff09; stroke: #ffffff26; stroke-width: 2; stroke-dasharray: 7 7; }
.dom .shade { fill: #000; opacity: .38; }
.dom .body { fill: var(--stone); stroke: #a8843f; stroke-width: 3; }
.dom .pip { fill: var(--inkd); } .dom .num { fill: var(--inkd); font: 800 56px var(--body); }
.dom .mid { stroke: var(--inkd); stroke-width: 4; stroke-linecap: round; opacity: .3; }
.dom.d1 .body { fill: var(--sand); stroke: #9a6f2c; }
.dom.d2 .body { fill: var(--brick); stroke: #7a4f24; }
.dom.d3 .body { fill: var(--brick2); stroke: #5a361a; } .dom.d3 .pip, .dom.d3 .num { fill: var(--stone); } .dom.d3 .mid { stroke: var(--stone); }
.dom.d4 .body { fill: var(--brick3); stroke: #432512; } .dom.d4 .pip, .dom.d4 .num { fill: #e3c996; } .dom.d4 .mid { stroke: #e3c996; }
.dom.last .body { stroke: var(--gold); stroke-width: 7; }
.dom.ghost .shade { display: none; }
.dom.ghost .body { fill: #35d0ba; fill-opacity: .82; stroke: #fff; stroke-width: 5; stroke-dasharray: 14 8; }
.dom.ghost .pip, .dom.ghost .num { fill: #05231f; } .dom.ghost .mid { stroke: #05231f; }
.zig .ring { fill: none; stroke: var(--turq); stroke-width: 7; animation: ringpulse 1.5s ease-in-out infinite; pointer-events: none; }
.zig .ring.aim { fill: #35d0ba77; stroke: #fff; animation: none; }
.zig .ring.far { opacity: .16; animation: none; }
@keyframes ringpulse { 50% { stroke-opacity: .45; } }
.zig .hit { fill: transparent; cursor: pointer; }

.tile { display: block; width: 100%; height: auto; }
.tile .body { fill: var(--stone); stroke: #a8843f; stroke-width: 4; }
.tile .pip, .tile .num { fill: var(--inkd); } .tile .num { font: 800 56px var(--body); }
.tile .mid { stroke: var(--inkd); stroke-width: 4; stroke-linecap: round; opacity: .3; }

/* the levels taken apart: one small plan each */
.layers { display: flex; gap: 8px; align-items: flex-end; justify-content: center; min-height: 0; }
.layer { display: grid; justify-items: center; gap: 2px; padding: 3px 5px; border-radius: 8px; border: 1.5px solid transparent; }
.layer svg { width: 30px; height: 30px; display: block; }
.layer span { font-size: 11px; font-weight: 700; color: var(--dim); white-space: nowrap; } .layer span b { color: var(--gold); margin-left: 3px; }
.layer.now { border-color: var(--turq); background: #35d0ba1a; }
.layer.more span { align-self: center; }
.layer .off { fill: #ffffff12; }
.layer .on { fill: var(--stone); } .layer .on.d1 { fill: var(--sand); } .layer .on.d2 { fill: var(--brick); } .layer .on.d3 { fill: var(--brick2); } .layer .on.d4 { fill: #7a4a2a; }

/* ---- 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)) 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: 700 17px var(--display); color: var(--gold); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-level { margin-left: auto; white-space: nowrap; color: var(--dim); font-weight: 700; font-size: 14px; } .g-level b { color: var(--gold); font-size: 1.2em; }
.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 #f0c04e55; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-seats { display: flex; gap: 6px; }
.chip { flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 6px; padding: 4px 8px 5px; border-radius: 10px; background: #0005; border: 1.5px solid var(--line); }
.chip .c-name { grid-column: 1 / -1; font-size: 12.5px; font-weight: 700; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .chip .c-name i { font-style: normal; font-size: 10px; opacity: .7; text-transform: uppercase; }
.chip .c-score { font: 700 22px/1 var(--display); color: var(--ink); }
.chip .c-left { font-size: 11.5px; color: var(--dim); white-space: nowrap; text-align: right; }
.chip.up { border-color: var(--gold); background: #f0c04e1c; } .chip.up .c-name { color: var(--gold); }
.chip.me .c-name::after { content: " (you)"; font-weight: 500; }
.g-coach { background: var(--bg2); border-left: 4px solid var(--turq); border-radius: 6px 12px 12px 6px; padding: 8px 12px; font-size: 14.5px; line-height: 1.33; min-height: 56px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--line); color: var(--dim); }
.g-board { min-height: 0; min-width: 0; display: grid; place-items: center; }
.g-board .zig { max-width: 100%; max-height: 100%; }
.g-mine { display: grid; gap: 8px; }
.g-hand { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; align-content: start; max-height: 150px; overflow-y: auto; padding: 4px 2px 2px; }
.g-hand.nl { grid-template-columns: repeat(6, minmax(0, 1fr)); } .g-hand.nxl { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.g-none { color: var(--dim); grid-column: 1 / -1; text-align: center; padding: 8px; }
.dz { padding: 0; border: 0; background: none; border-radius: 8px; transition: transform .12s; }
.g:not(.mine) .dz { opacity: .72; }
.dz.picked { transform: translateY(-4px); box-shadow: 0 0 0 3px var(--turq), 0 6px 14px #000a; opacity: 1; }
.g-btns { display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; }
.g-btns button { min-height: 46px; padding: 6px 8px; font-size: 15px; line-height: 1.15; }

/* 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 Place 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; }

/* A rig panel or a phone on its side: use the width. The stack on the left, everything you read
   and press on the right. Nothing 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: min(46vw, calc(100vh - 66px)) minmax(0, 1fr); grid-template-rows: auto auto auto auto auto minmax(0, 1fr); column-gap: 16px; padding: 8px 16px 10px;
    grid-template-areas: "head head" "board seats" "board pres" "board coach" "board layers" "board mine"; }
  .g-head { grid-area: head; } .g-seats { grid-area: seats; } #cs-pres-slot { grid-area: pres; } .g-coach { grid-area: coach; }
  .g-board { grid-area: board; } .g > .layers { grid-area: layers; } .g-mine { grid-area: mine; align-content: start; }
  body.phone #cs-pill { left: 64px; top: 8px; }
  .g-head .g-title { max-width: 190px; }
  .g-coach { min-height: 44px; }
  .g-hand { grid-template-columns: repeat(6, minmax(0, 1fr)); max-height: 168px; }
  .g-hand.nl, .g-hand.nxl { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .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's own pieces (sized in em: the kit shrinks the screen to fit by font size) ---- */
.end-board { width: min(100%, 12.5em); aspect-ratio: 1; margin: .3em auto; }
.cs-end.ph .end-board { width: min(100%, 17em); }
.end-hand { display: flex; align-items: center; gap: .6em; margin: .25em 0; } .end-hand b { min-width: 4.5em; text-align: left; }
.end-tiles { display: flex; flex-wrap: wrap; gap: .25em; } .end-tiles .tile { width: 2.9em; }
.end-none { color: var(--cs-end-dim); }

/* ---- 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(12, 6, 3, .84); }
.cm-ring { fill: none; stroke: var(--gold); stroke-width: 2; }
.cm-ln { stroke: var(--stone); 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: 14px; font-size: 14.5px; line-height: 1.33; background: var(--bg2); 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: 700 15.5px/22px var(--display); color: var(--stone); }
.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: #140b07f7; 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(--gold); background: var(--bg2); 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: 6px 22px; align-items: center; }
.hero .mark { width: clamp(84px, 20vw, 150px); height: auto; grid-row: span 2; }
.hero > :not(.mark):not(.hero-top) { grid-column: 1 / -1; }
.hero h1 { font-size: clamp(34px, 8vw, 64px); }
.byline { color: var(--stone); font-weight: 700; margin-top: 4px; } .byline a { font-weight: 500; }
.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(--turq); color: #05231f; font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--bg3); 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(--bg2); border-radius: 12px; padding: 12px 14px; border-bottom: 4px solid var(--brick2); } .how h3 { color: var(--gold); margin-bottom: 4px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--bg2); 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(--bg2); 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; }
