/* Manic Minelayers: the shared look for splash, phone and TV. A sea chart at night: deep green water,
   iron mines, and two Minelayers in signal yellow and coral. The two colours stay apart for the
   common kinds of colour blindness (very different brightness), and each has its own shape too:
   round and diamond. 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: #04161b; --bg2: #082229; --panel: #0b2c34; --panel2: #123c46; --line: #2a626d80; --edge: #2a626d;
  --sea: #10434d; --sea2: #0c3740; --iron: #050d10; --horn: #9fb9b6;
  --ink: #eafaf6; --dim: #93bab6; --dark: #04161b;
  --c0: #ffd23f; --c0d: #a8860f; --c1: #ff6f91; --c1d: #a8324f;
  --good: #7df0c0; --bad: #ff5a4d;
  --me: var(--c0);
  /* the kit's shared end screen (client/endscreen.ts), in this game's colours */
  --cs-end-bg: radial-gradient(120% 90% at 50% -10%, #123c46 0%, #04161b 62%); --cs-end-fg: #eafaf6; --cs-end-dim: #93bab6;
  --cs-end-accent: #ffd23f; --cs-end-win: #7df0c0; --cs-end-loss: #ff6f91; --cs-end-panel: #0b2c34;
  --display: "Rockwell", "Roboto Slab", "Courier New", Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --cs-end-font: var(--body);
}
* { 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: var(--bg) radial-gradient(ellipse at 50% -10%, #123c46, var(--bg) 70%) fixed; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; letter-spacing: .01em; }
h1 { color: var(--c0); font-size: 34px; line-height: 1.05; }
h2 { color: var(--ink); font-size: 20px; }
button { background: var(--panel2); border: 1.5px solid var(--edge); color: var(--ink); padding: 10px 14px; border-radius: 10px;
  font: inherit; font-weight: 700; cursor: pointer; }
button.primary { background: var(--c0); border-color: var(--c0); color: var(--dark); }
button:disabled { opacity: .45; cursor: default; }
select, input { font: inherit; padding: 8px; border-radius: 8px; background: var(--bg2); color: var(--ink); border: 1.5px solid var(--edge); }
a { color: var(--c0); }
.muted, .hint, .tagg { color: var(--dim); }
.tagg { font-size: 13px; margin-left: 6px; }
.av { border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.s0 { --c: var(--c0); --cd: var(--c0d); } .s1 { --c: var(--c1); --cd: var(--c1d); }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(160px); background: var(--ink); color: var(--dark);
  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: 1px solid var(--line); 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: 68%; }

/* ---- the board (client/shared/board.ts) ---- */
.board { display: block; width: 100%; height: 100%; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.board .sq { fill: var(--sea); stroke: var(--bg); stroke-width: 3; }
.board .sq.alt { fill: var(--sea2); }
.board .sq.home.s0 { fill: color-mix(in srgb, var(--c0) 14%, var(--sea)); }
.board .sq.home.s1 { fill: color-mix(in srgb, var(--c1) 16%, var(--sea)); }
.board .lab { fill: var(--dim); font: 700 24px var(--body); text-anchor: middle; }
.board .mine line { stroke: var(--horn); stroke-width: 7; stroke-linecap: round; }
.board .mine .ball { fill: var(--iron); stroke: var(--horn); stroke-width: 3; }
.board .mine .stud { fill: var(--c); opacity: .85; }
.board .mine.fresh { transform-box: fill-box; transform-origin: center; animation: mm-drop .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes mm-drop { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.board .hop { stroke: var(--c); stroke-width: 5; stroke-dasharray: 3 13; stroke-linecap: round; opacity: .75; }
.board .ml .hull { fill: var(--c); stroke: var(--dark); stroke-width: 4; }
.board .ml .deck { fill: var(--dark); opacity: .8; }
.board .ml.ghost { opacity: .5; }
.board .ml.ghost.locked { opacity: .8; }
.board .ml.boxed .hull { stroke: var(--bad); stroke-width: 6; }
.board .here { fill: none; stroke: var(--c); stroke-width: 4; opacity: .9; transform-box: fill-box; transform-origin: center; animation: mm-here 1.8s ease-in-out infinite; }
@keyframes mm-here { 50% { transform: scale(1.1); opacity: .35; } }
.board .trap { fill: #ff5a4d2e; stroke: var(--bad); stroke-width: 5; stroke-dasharray: 9 8; }
.board .legal { fill: var(--c); fill-opacity: .1; stroke: var(--c); stroke-width: 4; stroke-dasharray: 7 7; }
.board .aim { stroke: var(--c); stroke-width: 6; stroke-dasharray: 12 10; stroke-linecap: round; fill: none; animation: mm-march .7s linear infinite; }
.board .aim.ring { stroke-dasharray: none; stroke-width: 7; fill: var(--c); fill-opacity: .28; animation: none; }
@keyframes mm-march { to { stroke-dashoffset: -22; } }
.board .hit { fill: transparent; cursor: pointer; }
.board.still .here, .board.still .mine.fresh { animation: none; }
@media (prefers-reduced-motion: reduce) { .board .here, .board .aim, .board .mine.fresh { animation: none; } }

/* ---- the chips: one per Minelayer ---- */
.sc { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; align-items: center; column-gap: 8px; padding: 6px 10px; border-radius: 12px;
  background: var(--panel); border: 1.5px solid var(--line); min-width: 0; }
.sc.me { border-color: var(--c); }
.sc.up { box-shadow: inset 0 0 0 1.5px var(--c); background: color-mix(in srgb, var(--c) 9%, var(--panel)); }
.sc-shape, .t-shape { width: 16px; height: 16px; background: var(--c); border-radius: 50%; flex: none; }
.s1 .sc-shape, .s1 .t-shape { border-radius: 2px; transform: rotate(45deg) scale(.82); }
.sc-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sc-name em { font-style: normal; color: var(--dim); font-weight: 600; font-size: .85em; }
.sc-n { grid-row: 1 / 3; grid-column: 3; font: 800 28px/1 var(--display); color: var(--c); text-align: center; display: grid; justify-items: center; }
.sc-n small { font: 600 10px/1.2 var(--body); color: var(--dim); letter-spacing: .03em; white-space: nowrap; }
.sc-state { grid-column: 1 / 3; grid-row: 2; font-size: 12px; color: var(--dim); letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-state b { font-weight: 600; }
.sc-state b.on { color: var(--good); font-weight: 800; text-transform: uppercase; }
.sc-state b.bad { color: var(--bad); font-weight: 800; text-transform: uppercase; }
.bot, .off { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; padding: 1px 6px; border-radius: 99px; background: var(--panel2); color: var(--dim); margin-right: 5px; vertical-align: middle; }
.off { background: #ff5a4d33; color: #ffc2bc; margin: 0 0 0 5px; }

/* ---- 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: 7px;
  padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; overflow: hidden; }
.g.s0 { --me: var(--c0); } .g.s1 { --me: var(--c1); }
.g-head { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.g-title { font: 800 18px var(--display); color: var(--c0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-move { margin-left: auto; white-space: nowrap; color: var(--dim); font-weight: 800; font-size: 14px; }
.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(--c0); }
@keyframes helppulse { 50% { box-shadow: 0 0 0 6px #ffd23f55; } }
.g-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#cs-pres-slot { display: flex; justify-content: center; min-height: 0; }
.g-coach { background: var(--panel); border-left: 4px solid var(--edge); border-radius: 6px 12px 12px 6px; padding: 7px 11px; font-size: 14.5px; line-height: 1.3; min-height: 52px; display: flex; align-items: center; color: var(--dim); }
.g.mine .g-coach { border-left-color: var(--me); color: var(--ink); }
/* a tall board: 5 squares wide, 10 long, your own end at the bottom. Its box keeps the SVG's shape. */
.g-board { justify-self: center; height: 100%; max-width: 100%; aspect-ratio: 546 / 1046; min-height: 0; background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.g-btns { display: grid; grid-template-columns: 1fr; gap: 8px; }
.g-btns button { min-height: 50px; padding: 6px 8px; font-size: 17px; line-height: 1.15; }
.g-btns .primary { background: var(--me); border-color: var(--me); }

/* 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 the Move button 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, a phone on its side or a desktop window: the board on the left at full height, everything
   you read and press in a column on the right. Nothing a player presses is below the fold. */
@media (min-aspect-ratio: 5/4) {
  .g { max-width: none; grid-template-columns: auto minmax(260px, 520px); grid-template-rows: auto auto auto auto auto minmax(0, 1fr); column-gap: 18px; padding: 8px 14px 10px;
    justify-content: center; }
  .g-board { grid-column: 1; grid-row: 1 / -1; height: calc(100dvh - 18px); align-self: center; }
  .g-head, .g-chips, #cs-pres-slot, .g-coach, .g-btns { grid-column: 2; }
  .g-title { display: inline; }
  .g-coach { min-height: 64px; font-size: 16px; }
  .g-btns button { min-height: 60px; font-size: 19px; }
  /* the kit's pill goes back to its own corner: nothing to press down there */
  body.phone #cs-pill { top: auto; left: auto; bottom: 10px; right: 14px; }
  .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's board and routes (server/debrief.ts puts them in the reveal). Sized in em: the kit
   fits its end screen by shrinking one font size, and a board in pixels would not shrink with it ---- */
.end-board { width: min(100%, 24em); aspect-ratio: 1046 / 546; margin: .3em auto; background: var(--bg); border: 1.5px solid var(--line); border-radius: .6em; overflow: hidden; }
.cs-end.ph .end-board { width: min(100%, 26em); }
.end-route { font-size: .8em; line-height: 1.35; margin: .25em 0; color: var(--cs-end-dim); overflow-wrap: anywhere; }
.end-route b { color: var(--cs-end-fg); margin-right: .4em; }

/* ---- 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(2, 10, 12, .84); }
.cm-ring { fill: none; stroke: var(--c0); stroke-width: 2; }
.cm-ln { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.cm-dot { fill: var(--c0); stroke: var(--dark); 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(--panel); border: 1.5px solid var(--c0); 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(--c0); color: var(--dark); font: 700 13px/1 var(--body); }
.cm-call .cm-t { font: 800 15.5px/22px var(--display); color: var(--ink); }
.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: #03100ff7; border: 1px solid var(--edge); 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(--c0); background: var(--panel); 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(--c0); }
.cm-lastin h2 { margin: 0 0 8px; text-align: center; font-size: 22px; padding-bottom: 7px; border-bottom: 1px solid var(--edge); }
.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: 900px; margin: 0 auto; padding: 28px 18px 60px; }
.hero h1 { font-size: clamp(38px, 9vw, 72px); }
.hero h1 span { color: var(--c1); }
.tag { font-size: 1.2em; color: var(--dim); margin: 8px 0 4px; }
.cta { display: inline-block; margin: 14px 10px 6px 0; padding: 12px 20px; border-radius: 12px; background: var(--c0); color: var(--dark); font-weight: 800; text-decoration: none; }
.cta.alt { background: var(--panel2); color: var(--ink); border: 1.5px solid var(--edge); }
/* a strip of sea under the title: pure CSS, the same pieces as the board */
.strip { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin-top: 22px; padding: 3px; background: var(--bg); border: 1px solid var(--edge); border-radius: 12px; }
.strip i { aspect-ratio: 1; background: var(--sea); border-radius: 3px; display: grid; place-items: center; }
.strip i:nth-child(even) { background: var(--sea2); }
.strip i.m::after { content: ""; width: 46%; aspect-ratio: 1; border-radius: 50%; background: var(--iron); border: 2px solid var(--horn); outline: 3px dotted var(--horn); outline-offset: 2px; }
.strip i.a::after { content: ""; width: 60%; aspect-ratio: 1; border-radius: 50%; background: var(--c0); border: 3px solid var(--dark); }
.strip i.b::after { content: ""; width: 50%; aspect-ratio: 1; border-radius: 3px; transform: rotate(45deg); background: var(--c1); border: 3px solid var(--dark); }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 22px; }
.how div { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; } .how h3 { color: var(--c0); margin-bottom: 4px; font-size: 17px; }
.rooms { margin-top: 30px; } .rooms .room { display: flex; justify-content: space-between; align-items: center; background: var(--panel); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.rooms .code { font-family: var(--display); color: var(--c0); letter-spacing: 3px; font-size: 22px; }
#rejoin { display: none; background: var(--panel); border-left: 4px solid var(--c0); border-radius: 8px; padding: 12px 16px; margin-top: 18px; } #rejoin.show { display: block; }
footer { margin-top: 40px; color: var(--dim); font-size: .9em; }
.credit { margin-top: 26px; padding: 12px 14px; border-radius: 14px; border: 1px dashed var(--edge); color: var(--dim); }
.credit b { color: var(--ink); }
.helppage h2 { margin: 26px 0 6px; color: var(--c1); } .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(--edge); display: block; }
.helppage figure.phone img { max-width: 300px; margin: 0 auto; }
.helppage figcaption { color: var(--dim); margin-top: 8px; font-size: .95em; }
