/* Tricky Quest: Tactics: the shared look for splash, phone and TV. A torchlit dungeon: deep night blue, paper
   cards in parchment, amber torchlight, the monster in red. 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 {
  --night: #0e1420; --night2: #172033; --night3: #22304a; --line: #33456a;
  --ink: #f2f0e6; --dim: #9fb0cf; --paper: #fff4d6; --inkd: #2a1f0c;
  --amber: #ffb84a; --amber2: #e08a1c; --storm: #8a7dff; --storm2: #5b4fd6;
  --good: #58d68d; --bad: #ff6b6b;
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #22304a 0%, #0e1420 62%); --cs-end-fg: #f2f0e6; --cs-end-dim: #9fb0cf;
  --cs-end-accent: #ffb84a; --cs-end-win: #ffb84a; --cs-end-loss: #8a7dff;
  --display: Georgia, "Times New Roman", 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(--night) radial-gradient(ellipse at 50% -10%, var(--night3), var(--night) 70%) fixed;
  -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; }
h1 { color: var(--amber); font-size: 34px; line-height: 1.1; }
h2 { color: var(--paper); font-size: 20px; }
button { background: var(--night3); 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(--amber); border-color: var(--amber); color: var(--inkd); }
button:disabled { opacity: .38; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--night2); color: var(--ink); border: 1.5px solid var(--line); }
a { color: var(--amber); }
.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; }

/* ---- shared pieces: cards, the hex board, chips ---- */
.card { position: relative; display: inline-grid; grid-template-rows: auto auto auto 1fr; gap: 1px; width: 64px; height: 92px; padding: 5px 5px 4px; border-radius: 9px;
  background: var(--paper); color: #1d1a14; border: 2px solid #d9c9a0; font: 600 12px/1.1 var(--body); text-align: left; vertical-align: top; transition: transform .12s, box-shadow .12s, opacity .12s; }
.card.red { color: #b3122e; }
.card .c-top { display: flex; align-items: baseline; gap: 2px; }
.card .c-rank { font: 800 22px/1 var(--display); }
.card .c-suit { font-size: 19px; line-height: 1; }
.card .c-as { margin-left: auto; font-size: 10px; background: #1d1a14; color: var(--paper); border-radius: 6px; padding: 1px 3px; }
.card .c-pts { color: #6b5a2a; letter-spacing: 1px; font-size: 10px; }
.card .c-act { font-size: 10.5px; color: #4a4233; text-transform: uppercase; letter-spacing: .04em; }
.card .c-print { font-size: 10px; font-weight: 800; color: #7a4b00; background: #ffe08a; border-radius: 5px; padding: 1px 3px; justify-self: start; align-self: start; }
.card .c-stk { position: absolute; left: 3px; right: 3px; bottom: 3px; display: flex; flex-wrap: wrap; gap: 2px; }
.card .c-dun { position: absolute; right: 4px; bottom: 3px; font-size: 11px; opacity: .55; }
.card.small { width: 48px; height: 68px; padding: 3px 4px; border-radius: 7px; }
.card.small .c-rank { font-size: 17px; } .card.small .c-suit { font-size: 14px; } .card.small .c-act, .card.small .c-pts { font-size: 8.5px; } .card.small .c-print { font-size: 8px; }
.card.back { background: repeating-linear-gradient(45deg, #3b1f2a 0 6px, #52293a 6px 12px); border-color: #7a3b52; color: #ffd6e0; display: grid; place-items: center; font: 800 26px var(--display); }
.card.empty { background: transparent; border: 2px dashed var(--line); color: var(--dim); display: grid; place-items: center; font-size: 22px; }
.card.off { opacity: .78; }
.card.offsuit { box-shadow: 0 0 0 3px var(--bad); }
.chip { display: inline-block; font: 800 9px/1.2 var(--body); padding: 1px 3px; border-radius: 4px; background: #1d1a14; color: #fff; white-space: nowrap; }
.chip.flex { background: #2b6cb0; } .chip.rank { background: #6b46c1; } .chip.abil { background: #2f855a; } .chip.ab-poison { background: #5a8f2a; } .chip.ab-snare { background: #805ad5; } .chip.ab-mend { background: #c53070; } .chip.ab-cleave { background: #c05621; }
.suitbig { font: 800 26px/1 var(--display); color: var(--ink); } .suitbig.red { color: #ff5a6e; } .suitbig.dim { color: var(--dim); }
.cond { margin-left: 2px; } .gear { margin-right: 2px; } .gear.big { font-size: 26px; }
.dim { color: var(--dim); }

svg.board { width: 100%; height: 100%; display: block; }
svg.board .hx { stroke: #0b0f18; stroke-width: .7; }
svg.board .wall { fill: #2a2f3d; }
svg.board .floor.open { fill: #50473a; }
svg.board .floor.open.lair { fill: #5a3b3b; }
svg.board .floor.dark { fill: #1a1f2b; }
svg.board .door.shut { fill: #8a5a2b; }
svg.board .door.open { fill: #6b5844; }
svg.board .door-ico { font-size: 9px; pointer-events: none; }
svg.board .fog { font: 700 14px var(--display); fill: #ffffff44; pointer-events: none; }
svg.board polygon.hx.step { fill: #2f7d4f; cursor: pointer; }
svg.board polygon.hx.opendoor { fill: #e0a526; cursor: pointer; }
svg.board .foe .disc { fill: #2a0e14; stroke: #e0475b; stroke-width: 1.2; }
svg.board .foe.boss .disc { fill: #3a0d16; stroke: #ff6b6b; stroke-width: 1.8; }
svg.board .foe .ico, svg.board .hero .ico { font-size: 8px; pointer-events: none; }
svg.board .hero .ico { fill: var(--seat); font-weight: 900; }
svg.board .foe.boss .ico { font-size: 11px; }
svg.board .hpbar .bg { fill: #00000099; } svg.board .hpbar .fg { fill: #ff4d5e; }
svg.board .hp { font: 800 6px var(--body); fill: #fff; paint-order: stroke; stroke: #000; stroke-width: 1.4; }
svg.board .hp.small { font-size: 5px; }
svg.board .shield { font: 800 4.6px var(--body); fill: #9fd3ff; paint-order: stroke; stroke: #000; stroke-width: 1.2; }
svg.board .cnd { font-size: 5px; }
svg.board .hero .disc { fill: #10151f; stroke: var(--seat); stroke-width: 1.8; }
svg.board .hero.actor .disc { stroke-width: 2.6; filter: drop-shadow(0 0 2.5px var(--seat)); }
svg.board .hero.down .disc { fill: #2a2a2a; stroke-dasharray: 2 1.5; }
svg.board .hero .zz { font-size: 5px; }
svg.board .target .disc { stroke: #58d68d; stroke-width: 2.4; cursor: pointer; }
svg.board .tlabel { font: 900 6.2px var(--body); fill: #58d68d; paint-order: stroke; stroke: #000; stroke-width: 1.5; pointer-events: none; }

/* ---- the phone: a fixed skeleton that never scrolls the page (a rig panel is 960x540 with no scrollbar) ---- */
.g { position: fixed; inset: 0; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto 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 { font: 700 16px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-floor { margin-left: auto; white-space: nowrap; color: var(--dim); font-weight: 800; }
.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(--amber); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #ffb84a55; } }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--night2); border-left: 4px solid var(--amber); border-radius: 6px 12px 12px 6px; padding: 7px 10px; font-size: 14px; line-height: 1.3; min-height: 50px; display: flex; align-items: center; }
.g:not(.mine) .g-coach { border-left-color: var(--line); color: var(--dim); }
.g-stage { position: relative; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.g-stage > .g-map { flex: 1 1 0; }
.g-stage.rest { display: block; overflow-y: auto; overscroll-behavior: contain; }
.g-trick { display: flex; align-items: center; gap: 5px; min-height: 70px; overflow-x: auto; }
.g-trick .tp { border-bottom: 3px solid var(--seat, transparent); padding-bottom: 2px; }
.g-trick .tp.mon { margin-left: auto; border-bottom-color: #e0475b; }
.g-trick .peek { font-weight: 800; color: #c9b8ff; font-size: 13px; white-space: nowrap; }
.g-act { font-size: 13px; padding: 4px 8px; border-radius: 8px; background: var(--night2); border-left: 4px solid var(--seat); }
.g-act .pts { float: right; color: var(--amber); letter-spacing: 1px; }
.g-map { min-height: 0; border-radius: 12px; overflow: hidden; background: #0b0f18; }
.g-hand { display: flex; gap: 6px; justify-content: center; min-height: 96px; align-items: center; flex-wrap: nowrap; overflow-x: auto; }
.g-hand .card { cursor: pointer; flex: none; }
.g-hand .card.can { box-shadow: 0 0 0 2px var(--amber); }
.g.mine .g-hand .card:not(.can) { opacity: .5; }
.g-hand .card.picked { transform: translateY(-8px); box-shadow: 0 0 0 3px var(--good), 0 8px 18px #0008; opacity: 1; }
.g-none { color: var(--dim); }
.g-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.g-btns button { flex: 1 1 30%; min-height: 46px; padding: 6px 8px; font-size: 14px; line-height: 1.15; }
.g-btns button.on, .offer.on { border-color: var(--good); box-shadow: 0 0 0 2px var(--good); }
.g-btns .undo { font-size: 12.5px; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--night2); border: 1.5px solid var(--amber); border-radius: 12px; padding: 8px; font-size: 13px; z-index: 3; }
.sheet-cards { display: flex; gap: 5px; overflow-x: auto; margin: 6px 0; }
.rest h3 { font: 700 15px var(--display); color: var(--amber); margin: 8px 0 6px; }
.offers { display: grid; gap: 6px; }
.offer { display: flex; align-items: center; gap: 8px; text-align: left; font-size: 13.5px; }
.deckgrid { display: flex; flex-wrap: wrap; gap: 5px; }
.deckgrid .card { cursor: pointer; }
.passto { display: flex; gap: 6px; flex-wrap: wrap; } .passto button { border-color: var(--seat); }
.hint { color: var(--dim); font-size: 13px; margin: 4px 0; }
.cls-blurb { font-size: 13px; }

/* 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 End turn 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: 719px) { .g-lit .lit-pips { display: none; } }

/* A rig panel or a phone on its side: use the width. Lanterns left, your hand 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.25fr 1fr; grid-template-rows: auto auto auto minmax(0, 1fr) auto; column-gap: 14px; padding: 8px 14px 8px; }
  .g-head, .g-coach, #cs-pres-slot { grid-column: 1 / -1; }
  .g-stage { grid-column: 1; grid-row: 4 / span 2; }
  .g-hand { grid-column: 2; grid-row: 4; align-content: center; flex-wrap: wrap; }
  .g-btns { grid-column: 2; grid-row: 5; }
  body.phone #cs-pill { left: 64px; top: 8px; }
  .g-head .g-title { max-width: 190px; }
  .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(--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(4, 7, 14, .82); }
.cm-ring { fill: none; stroke: var(--amber); stroke-width: 2; }
.cm-ln { stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--amber); 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(--night2); border: 1.5px solid var(--amber); 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(--amber); 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: #0a0f1af7; 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(--amber); background: var(--night2); 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(--amber); }
.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(--amber); color: var(--inkd); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--night3); 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(--night2); border-radius: 14px; padding: 12px 14px; } .how h3 { color: var(--amber); margin-bottom: 4px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--night2); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.rooms .code { font-family: var(--display); color: var(--amber); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--night2); border-left: 4px solid var(--amber); 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; }

/* ---- /learn: the step-by-step tutorial (client/splash/learn.ts) ---- */
body.learn .wrap { max-width: 780px; padding-bottom: 110px; }
.ln-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.ln-home { font: 700 18px var(--display); text-decoration: none; } #ln-count { color: var(--dim); font-weight: 700; }
.ln-page h1 { font-size: clamp(26px, 5vw, 38px); margin: 6px 0 8px; }
.ln-text { font-size: 17px; line-height: 1.5; } .ln-text b { color: #fff; }
.ln-art { margin: 14px 0; display: grid; gap: 10px; justify-items: center; }
.ln-board { width: 100%; height: min(56vh, 420px); background: #0b0f18; border-radius: 14px; overflow: hidden; }
.ln-trick { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; justify-content: center; }
.ln-trick > div { display: grid; justify-items: center; gap: 4px; color: var(--dim); font-weight: 700; font-size: 13px; }
.ln-trick .mon { margin-left: 18px; }
.ln-order { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.ln-order .ord { padding: 3px 10px; border-radius: 99px; border: 2px solid var(--seat, #e0475b); white-space: nowrap; } .ln-order .arrow { font-style: normal; color: var(--dim); }
.ln-cards { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ln-chips { display: flex; gap: 6px; } .ln-chips .chip { font-size: 13px; padding: 3px 6px; }
.ln-big { font-size: 64px; }
.ln-heroes { display: grid; gap: 8px; width: 100%; } .ln-heroes > div { background: var(--night2); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.ln-heroes .ic { grid-row: span 2; font-size: 30px; } .ln-heroes b { color: var(--amber); } .ln-heroes span { color: var(--dim); }
.ln-go { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ln-nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 12px max(14px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-bottom)); background: #0a0f1af2; border-top: 1px solid var(--line); }
.ln-nav > button, .ln-next { min-width: 92px; }
.ln-next { margin-left: auto; background: var(--amber); color: var(--inkd); border: none; border-radius: 12px; padding: 10px 14px; font-weight: 800; text-decoration: none; text-align: center; }
.ln-dots { flex: 1; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.ln-dots button { width: 12px; height: 12px; padding: 0; border-radius: 50%; } .ln-dots button.on { background: var(--amber); border-color: var(--amber); }
