/* Boardwalk — the BLACKTIDE COMMAND skin, shared by the lobby and both games.
   One stylesheet, no build. Every colour is a token here; the two force
   colours and hit red are the brief's and must not drift. Anything that
   moves is switched off under .reduce-motion (set from the settings, which
   follow prefers-reduced-motion until changed). */

:root {
  --bg: #0b1320;
  --bg-2: #0e1828;
  --panel: rgba(16, 28, 46, 0.86);
  --panel-solid: #101c2e;
  --line: rgba(120, 160, 200, 0.16);
  --line-strong: rgba(120, 160, 200, 0.34);
  --ink: #dde7f0;
  --ink-dim: #9fb0c3;
  --ink-faint: #8091a6;
  --teal: #2ec4b6;
  --amber: #ff9f1c;
  --hit: #e63946;
  --slate: #5c677d;
  --p0: var(--teal);
  --p1: var(--amber);
  --head: "Rajdhani", "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --tap: 44px;
  --gutter: 16px;
  --radius: 4px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  /* the plotting grid behind everything */
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(46, 196, 182, 0.07), transparent 60%),
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 100% 100%, 48px 48px, 48px 48px;
  background-attachment: fixed;
  color: var(--ink);
  font: 500 16px/1.45 var(--head);
  overflow-x: hidden;
}

/* Scanlines over the whole page, and a slow radar sweep under it. Neither
   takes input. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
}
.radar {
  position: fixed;
  width: 150vmax;
  height: 150vmax;
  left: 50%;
  top: 50%;
  margin: -75vmax 0 0 -75vmax;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  background: conic-gradient(from 0deg, rgba(46, 196, 182, 0.075), transparent 50deg, transparent 360deg);
  animation: sweep 9s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }

a { color: var(--teal); }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- header ---------- */

.hud-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px var(--gutter);
  padding-top: max(6px, env(safe-area-inset-top));
  background: rgba(11, 19, 32, 0.92);
  border-bottom: 1px solid var(--line-strong);
  backdrop-filter: blur(6px);
}
.hud-top .back {
  font: 600 15px/1 var(--head);
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  text-decoration: none;
  padding: 10px 8px 10px 0;
  white-space: nowrap;
}
.hud-top .back:hover { color: var(--ink); }
.hud-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  line-height: 1.05;
}
.hud-title b {
  display: block;
  font: 700 clamp(17px, 4.6vw, 22px)/1.05 var(--head);
  letter-spacing: 0.14em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-title a { color: inherit; text-decoration: none; }
.hud-title small {
  display: block;
  font: 500 10px/1.2 var(--mono);
  letter-spacing: 0.18em;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { color: var(--ink); border-color: var(--teal); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- layout ---------- */

main {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px var(--gutter) 40px;
}
.screen[hidden] { display: none !important; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
}
/* corner ticks, the HUD frame */
.panel::before, .panel::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--teal);
  opacity: 0.7;
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

h1, h2, h3 { font-family: var(--head); letter-spacing: 0.1em; text-transform: uppercase; margin: 0; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 600; color: var(--ink-dim); letter-spacing: 0.16em; }
.label {
  font: 500 11px/1.3 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- buttons ---------- */

.btn {
  min-height: var(--tap);
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(20, 34, 54, 0.9);
  color: var(--ink);
  font: 700 16px/1.1 var(--head);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  touch-action: manipulation;
}
.btn:hover:not(:disabled) { border-color: var(--teal); }
.btn:focus-visible, .icon-btn:focus-visible, .cell:focus-visible, .col-btn:focus-visible, .choice:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #04201d; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn.danger { background: var(--hit); border-color: var(--hit); color: #fff; }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.btn.armed { border-color: var(--amber); color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > .btn { flex: 1 1 auto; }

/* ---------- briefing (mode select) ---------- */

.brief { display: grid; gap: 14px; max-width: 640px; margin: 0 auto; }
.brief p { margin: 0; color: var(--ink-dim); }
.choices { display: grid; gap: 8px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(20, 34, 54, 0.7);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.choice:hover:not(:disabled) { border-color: var(--teal); }
.choice[aria-pressed="true"] { border-color: var(--teal); background: rgba(46, 196, 182, 0.12); }
.choice[aria-pressed="true"]::after {
  content: "SELECTED";
  margin-left: auto;
  font: 600 10px/1 var(--mono);
  letter-spacing: 0.14em;
  color: var(--teal);
}
.choice:disabled { opacity: 0.5; cursor: not-allowed; }
.choice b { font: 700 17px/1.1 var(--head); letter-spacing: 0.1em; display: block; }
.choice small { font: 400 12px/1.3 var(--mono); color: var(--ink-faint); display: block; }
.choice .glyph { width: 28px; height: 28px; flex: none; color: var(--teal); }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.levels .choice { justify-content: center; text-align: center; min-height: var(--tap); }
.levels .choice[aria-pressed="true"]::after { content: none; }

.toggles { display: grid; gap: 8px; }
.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.toggle input { width: 22px; height: 22px; accent-color: var(--teal); flex: none; margin: 0; }
.toggle b { display: block; font: 700 15px/1.1 var(--head); letter-spacing: 0.1em; }
.toggle small { display: block; font: 400 12px/1.35 var(--mono); color: var(--ink-faint); }

/* ---------- status line ---------- */

.statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--side, var(--slate));
  border-radius: var(--radius);
  background: var(--panel);
}
.statusbar .who {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 700 15px/1 var(--head);
  letter-spacing: 0.14em;
  color: var(--side, var(--ink));
  white-space: nowrap;
}
.statusbar .who svg { width: 20px; height: 20px; }
.statusbar .line {
  flex: 1;
  min-width: 0;
  font: 600 13px/1.3 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}
.statusbar .line::before { content: "› "; color: var(--ink-faint); }
.statusbar .line.hit { color: #ff6b75; }
.statusbar .line.miss { color: var(--ink-dim); }
.statusbar .line.win { color: #fff; }
.statusbar .count { font: 600 12px/1 var(--mono); color: var(--ink-dim); white-space: nowrap; }
.side-0 { --side: var(--p0); }
.side-1 { --side: var(--p1); }

/* ---------- cover (pass-and-play hand-over) ---------- */

.cover {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background: #070c15;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 32px 32px;
}
.cover[hidden] { display: none; }
.cover .card {
  max-width: 420px;
  width: 100%;
  text-align: center;
  display: grid;
  gap: 14px;
  justify-items: center;
}
.cover .card .badge { width: 72px; height: 72px; color: var(--side); }
.cover h2 { font-size: clamp(24px, 7vw, 32px); color: var(--side); }
.cover p { margin: 0; color: var(--ink-dim); font-family: var(--mono); font-size: 13px; letter-spacing: 0.06em; }
.cover .btn { min-width: 200px; }

/* ---------- result dialog ---------- */

dialog {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--ink);
  padding: 0;
  width: min(460px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 32px);
}
dialog::backdrop { background: rgba(4, 8, 14, 0.78); }
.dlg { padding: 18px; display: grid; gap: 14px; }
.dlg header { display: flex; align-items: center; gap: 10px; }
.dlg header h2 { flex: 1; }
.result-head { text-align: center; display: grid; gap: 6px; justify-items: center; }
.result-head .badge { width: 56px; height: 56px; color: var(--side, var(--slate)); }
.result-head h2 { font-size: clamp(24px, 7vw, 30px); color: var(--side, var(--ink)); }
.result-head p { margin: 0; font: 600 13px/1.3 var(--mono); letter-spacing: 0.1em; color: var(--ink-dim); }
.stats { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 13px; }
.stats th, .stats td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.stats th:first-child, .stats td:first-child { text-align: left; color: var(--ink-dim); }
.stats thead th { font-weight: 600; letter-spacing: 0.1em; }
.stats .c0 { color: var(--p0); }
.stats .c1 { color: var(--p1); }
.streak {
  display: flex;
  justify-content: space-around;
  text-align: center;
  font-family: var(--mono);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.streak b { display: block; font: 700 26px/1 var(--head); color: var(--ink); }
.streak span { font-size: 11px; letter-spacing: 0.14em; color: var(--ink-faint); }

/* ---------- lobby ---------- */

.lobby-head { text-align: center; padding: 18px 0 8px; display: grid; gap: 6px; }
.lobby-head h1 { font-size: clamp(30px, 9vw, 52px); font-weight: 700; letter-spacing: 0.16em; line-height: 1; }
.lobby-head p { margin: 0 auto; max-width: 560px; color: var(--ink-dim); }
.ticker {
  font: 500 12px/1.4 var(--mono);
  letter-spacing: 0.12em;
  color: var(--teal);
  text-transform: uppercase;
}
.games { display: grid; gap: 16px; margin-top: 18px; }
@media (min-width: 760px) { .games { grid-template-columns: 1fr 1fr; } }
.game-card { display: grid; gap: 12px; align-content: start; }
.game-card .art {
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #08101c;
  overflow: hidden;
}
.game-card .art svg { width: 100%; height: 100%; display: block; }
.game-card h2 { font-size: 26px; }
.game-card p { margin: 0; color: var(--ink-dim); }
.record { display: flex; gap: 14px; flex-wrap: wrap; font: 500 12px/1.3 var(--mono); color: var(--ink-faint); letter-spacing: 0.08em; }
.record b { color: var(--ink); font-weight: 600; }
.lobby-foot {
  margin-top: 28px;
  text-align: center;
  font: 400 12px/1.6 var(--mono);
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}
.lobby-foot a { color: var(--ink-dim); }

/* ---------- large tap ---------- */

.large-tap { --tap: 56px; --gutter: 10px; }
.large-tap .btn { font-size: 18px; }
.large-tap .statusbar .line { font-size: 14px; }

/* ---------- reduced motion ---------- */

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation: none !important;
  transition: none !important;
}
.reduce-motion .radar, .reduce-motion .water .sweep { display: none; }

/* lobby scenes reuse the drawn pods and vessels inside one SVG */
.pod-mini { overflow: visible; color: var(--c); --c: var(--p0); }
.pod-mini.p1 { --c: var(--p1); }
.pod-mini .pod-shell { fill: color-mix(in srgb, var(--c) 26%, #0a1422); stroke: var(--c); stroke-width: 5; }
.pod-mini .pod-rim { fill: none; stroke: color-mix(in srgb, var(--c) 55%, transparent); stroke-width: 2.5; }
.pod-mini .canopy { fill: color-mix(in srgb, var(--c) 30%, #0b1320); stroke: var(--c); stroke-width: 3; }
.pod-mini .shrouds { fill: none; stroke: var(--c); stroke-width: 1.5; }
.lobby-ship path, .lobby-ship rect, .lobby-ship circle { fill: none; stroke: #e63946; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.lobby-ship > path:first-child { stroke-dasharray: 4 3; }
