/* =============================================================================================
   S2C Web Play — interface styles.
   Dark arena UI. JHU blue #002D72 as the brand surface, #004EB3 as the brand link, both
   lightened where a dark background would make them unreadable (noted inline).
   Fonts: a LOCAL stack only. Work Sans / Roboto Slab are named first and used when the visitor
   has them; nothing is fetched at runtime, so the page has no third-party requests at all.
   ============================================================================================= */

:root {
  /* brand */
  --jhu-blue: #002d72;
  --jhu-link: #004eb3;
  --jhu-link-on-dark: #5aa0ff; /* #004EB3 fails contrast on #0A0F16; this is the same hue, lifted */

  /* surfaces */
  --bg: #080c12;
  --bg-2: #0d1320;
  --panel: rgba(16, 24, 38, 0.86);
  --panel-solid: #101826;
  --panel-edge: rgba(122, 156, 204, 0.16);
  --panel-edge-strong: rgba(122, 156, 204, 0.32);
  --tint-brand: rgba(0, 45, 114, 0.55);

  /* text */
  --ink: #e8eef7;
  --ink-2: #aebbcf;
  --ink-3: #74839a;

  /* sides (same values app/hud.js exports as SIDE_COLORS, DESIGN.md section 12) */
  --player: #1f6f8b;
  --player-bright: #4fc3e8;
  --ai: #b9afa2;
  --ai-bright: #e4d9c8;

  /* field palette (mjlab play markers, game_env_cfg.py:98-100) */
  --field-line: #ff4724;
  --field-zone: #1acc59;
  --field-surface: #293d54;
  --field-apron: #141f2b;

  /* state */
  --win: #3ddc84;
  --lose: #ff6b5e;
  --warn: #ffbf47;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  --gutter: 16px;

  --font-sans: 'Work Sans', 'Inter', 'Segoe UI Variable Text', 'Segoe UI', system-ui,
    -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-slab: 'Roboto Slab', 'Zilla Slab', 'Bitstream Vera Serif', Rockwell, Georgia, serif;
  --font-mono: ui-monospace, 'JetBrains Mono', 'SF Mono', 'DejaVu Sans Mono', Menlo, Consolas,
    monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 50% -12%, rgba(0, 45, 114, 0.5), transparent 62%),
    radial-gradient(900px 520px at 88% 8%, rgba(31, 111, 139, 0.18), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app,
.ui {
  position: relative;
  height: 100%;
  width: 100%;
}

a,
.link {
  color: var(--jhu-link-on-dark);
  text-decoration: none;
  border-bottom: 1px solid rgba(90, 160, 255, 0.35);
}
a:hover,
.link:hover {
  border-bottom-color: currentColor;
}

kbd.key {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 5px;
  border: 1px solid var(--panel-edge-strong);
  border-bottom-width: 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  font: 600 11px/1 var(--font-mono);
  color: var(--ink);
}
kbd.key-inline {
  margin-left: 8px;
  opacity: 0.7;
}

.mono {
  font-family: var(--font-mono);
  font-size: 11px;
}

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

.btn {
  appearance: none;
  border: 1px solid var(--panel-edge-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: 600 14px/1 var(--font-sans);
  letter-spacing: 0.01em;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(122, 156, 204, 0.5);
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 2px solid var(--player-bright);
  outline-offset: 2px;
}
.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(180deg, #0a4fb0, var(--jhu-blue));
  border-color: #1a63c8;
  box-shadow: 0 8px 22px rgba(0, 45, 114, 0.5);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #1160c9, #013a8f);
  border-color: #2d78dd;
}
.btn-ghost {
  background: transparent;
  border-color: var(--panel-edge);
  color: var(--ink-2);
}
.btn-small {
  padding: 7px 12px;
  font-size: 12.5px;
}
.btn-icon {
  padding: 0;
  width: 36px;
  height: 36px;
  justify-content: center;
  font-size: 15px;
  background: rgba(10, 16, 26, 0.72);
  backdrop-filter: blur(6px);
}
.btn-close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ink-2);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
}
.btn-close:hover {
  color: var(--ink);
}

/* ============================================================== stage + canvas */

.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #0b1220 0%, #070a10 100%);
}
.stage-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.stage:not(.stage-live) {
  opacity: 0;
  pointer-events: none;
}

.game-bar {
  position: absolute;
  top: calc(var(--gutter) + env(safe-area-inset-top, 0px));
  right: var(--gutter);
  display: flex;
  gap: 8px;
  z-index: 6;
}

/* ============================================================== screens */

.screens {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 10;
}
.screen {
  min-height: 100%;
  padding: clamp(24px, 4vw, 56px) var(--gutter) 64px;
  max-width: 1280px;
  margin: 0 auto;
}

/* ---------------------------------------------------------------- hero */

.hero {
  margin-bottom: 34px;
}
.hero-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.hero-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--field-line);
  box-shadow: 0 0 16px rgba(255, 71, 36, 0.55);
}
.hero-rule {
  flex: 0 0 74px;
  height: 2px;
  background: linear-gradient(90deg, var(--jhu-link-on-dark), transparent);
}
.hero-title {
  font-family: var(--font-slab);
  font-size: clamp(34px, 6vw, 60px);
  line-height: 1;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
  font-weight: 700;
}
.hero-thin {
  font-weight: 300;
  color: var(--ink-2);
}
.hero-sub {
  margin: 0 0 10px;
  max-width: 62ch;
  color: var(--ink-2);
  font-size: 16px;
}
.hero-org {
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.dot-sep {
  margin: 0 8px;
  opacity: 0.6;
}

/* ---------------------------------------------------------------- setup grid */

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 306px;
  gap: 28px;
  align-items: start;
}
.setup-main {
  display: flex;
  flex-direction: column;
  gap: 26px;
  min-width: 0;
}
.setup-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
}

.setup-step {
  min-width: 0;
}
.step-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-family: var(--font-slab);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.step-n {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--tint-brand);
  border: 1px solid rgba(90, 160, 255, 0.35);
  color: #cfe0ff;
  font: 700 11px/1 var(--font-mono);
}
.step-note {
  margin: 10px 2px 0;
  font-size: 13px;
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- choices */

.choice-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.choice-row-games {
  flex-direction: column;
}
.choice-row-games > .choice {
  flex: 1 1 auto;
}
.opp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 12px;
}

.choice {
  appearance: none;
  text-align: left;
  font-family: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 15px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.choice:hover {
  border-color: var(--panel-edge-strong);
  background: rgba(22, 33, 52, 0.9);
}
.choice:focus-visible {
  outline: 2px solid var(--player-bright);
  outline-offset: 2px;
}
.choice.on {
  border-color: rgba(90, 160, 255, 0.72);
  background: linear-gradient(180deg, rgba(0, 45, 114, 0.42), rgba(16, 24, 38, 0.9));
  box-shadow: 0 0 0 1px rgba(90, 160, 255, 0.22), 0 14px 32px rgba(0, 0, 0, 0.35);
}
.choice-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.choice-name {
  font-family: var(--font-slab);
  font-size: 18px;
  font-weight: 600;
}
.choice-tag {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 2px 8px;
}
.tag-ours {
  color: #9fd2ff;
  border-color: rgba(90, 160, 255, 0.45);
  background: rgba(0, 45, 114, 0.5);
}
.choice-line {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}
.choice-detail {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-3);
}
.choice-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 11.5px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  margin-top: auto;
  padding-top: 4px;
}
.choice-opp .choice-facts span:first-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 128px;
  border-radius: 6px;
  background: var(--field-apron);
  border: 1px solid rgba(122, 156, 204, 0.12);
}

.fixed-seat {
  border: 1px dashed var(--panel-edge-strong);
  border-radius: var(--radius);
  padding: 13px 16px;
  background: rgba(16, 24, 38, 0.5);
  flex: 1 1 100%;
}
.fixed-seat-name {
  font-family: var(--font-slab);
  font-size: 15px;
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
}

.empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed rgba(255, 107, 94, 0.4);
  border-radius: var(--radius);
  color: var(--lose);
  font-size: 13px;
  grid-column: 1 / -1;
}

/* ---------------------------------------------------------------- options */

.opt-row {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}
.opt {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.opt input[type='checkbox'] {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid var(--panel-edge-strong);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.opt input[type='checkbox']:checked {
  background: var(--jhu-blue);
  border-color: var(--jhu-link-on-dark);
}
.opt input[type='checkbox']:checked::after {
  content: '';
  width: 9px;
  height: 5px;
  border-left: 2px solid #eaf2ff;
  border-bottom: 2px solid #eaf2ff;
  transform: rotate(-45deg) translate(1px, -1px);
}
.opt input[type='checkbox']:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.no-filter .setup-step-options {
  opacity: 0.62;
}

.start-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.btn-start {
  font-size: 15.5px;
  padding: 14px 30px;
}
.start-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- side cards */

.card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 16px;
}
.card-title {
  margin: 0 0 12px;
  font-family: var(--font-slab);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.card-note {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}
.controls-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.controls-extra {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-edge);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.control-row {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.control-keys {
  display: flex;
  gap: 4px;
}
.control-range {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  white-space: nowrap;
}
.fact-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.fact-list li::marker {
  color: var(--jhu-link-on-dark);
}
.card-about .btn {
  margin-top: 14px;
}

/* ============================================================== loading */

.screen-loading {
  display: grid;
  place-items: center;
}
.load-card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.load-title {
  margin: 0 0 6px;
  font-family: var(--font-slab);
  font-size: 22px;
}
.load-label {
  margin: 0 0 16px;
  color: var(--ink-2);
  font-size: 13.5px;
}
.load-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  margin-bottom: 18px;
}
.load-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--jhu-blue), var(--jhu-link-on-dark));
  transition: width 0.25s ease;
}
.load-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.load-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-3);
}
.load-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--panel-edge-strong);
  justify-self: center;
}
.load-row[data-state='active'] {
  color: var(--ink);
}
.load-row[data-state='active'] .load-dot {
  background: var(--jhu-link-on-dark);
  border-color: var(--jhu-link-on-dark);
  animation: pulse 1.1s ease-in-out infinite;
}
.load-row[data-state='done'] {
  color: var(--ink-2);
}
.load-row[data-state='done'] .load-dot {
  background: var(--win);
  border-color: var(--win);
}
.load-row[data-state='fail'] .load-dot {
  background: var(--lose);
  border-color: var(--lose);
}
.load-detail {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}
.load-note {
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}
.load-error {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid rgba(255, 107, 94, 0.45);
  border-radius: var(--radius-sm);
  background: rgba(255, 107, 94, 0.08);
}
.load-error-msg {
  margin: 0 0 10px;
  font-size: 13px;
  color: #ffc9c3;
  font-family: var(--font-mono);
  word-break: break-word;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* ============================================================== HUD */

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  font-variant-numeric: tabular-nums;
}
.hud[hidden] {
  display: none;
}

.hud-top {
  position: absolute;
  top: calc(var(--gutter) + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 14px;
  width: min(880px, calc(100% - 2 * var(--gutter)));
}

.side-card {
  background: rgba(10, 16, 26, 0.72);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.side-ai {
  text-align: right;
}
.side-head {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.side-ai .side-head {
  flex-direction: row-reverse;
}
.side-chip {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}
.side-name {
  font: 700 11px/1 var(--font-sans);
  letter-spacing: 0.12em;
}
.side-you .side-name {
  color: var(--player-bright);
}
.side-ai .side-name {
  color: var(--ai-bright);
}
.side-seat,
.side-method {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-method {
  color: var(--ink-2);
  font-weight: 600;
}
.chip {
  font: 700 9.5px/1 var(--font-mono);
  letter-spacing: 0.1em;
  padding: 3px 6px;
  border-radius: 4px;
}
.chip-shield {
  background: rgba(61, 220, 132, 0.16);
  color: var(--win);
  border: 1px solid rgba(61, 220, 132, 0.4);
}
.side-dist {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.side-ai .side-dist {
  flex-direction: row-reverse;
}
.dist-num {
  font-family: var(--font-slab);
  font-size: 22px;
  line-height: 1;
  font-weight: 600;
}
.dist-unit {
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
.bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.1s linear;
}
.side-you .bar-fill {
  background: var(--player-bright);
}
.side-ai .bar-fill {
  background: var(--ai-bright);
  margin-left: auto;
}
.side-flag {
  font: 700 10px/1 var(--font-mono);
  letter-spacing: 0.08em;
  color: var(--ink-3);
  min-height: 10px;
}
.side-flag.flag-bad {
  color: var(--lose);
}

.hud-clock {
  text-align: center;
  background: rgba(10, 16, 26, 0.78);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  padding: 8px 18px 9px;
  backdrop-filter: blur(8px);
  min-width: 132px;
}
.clock-num {
  font-family: var(--font-slab);
  font-size: 30px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.clock-sub {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 2px;
}
.clock-bar {
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  margin: 7px 0 5px;
  overflow: hidden;
}
.clock-bar-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--jhu-link-on-dark);
  border-radius: 999px;
}
.clock-bar-fill.clock-low {
  background: var(--field-line);
}
.clock-steps {
  font: 400 10px/1 var(--font-mono);
  color: var(--ink-3);
}

.hud-legend {
  position: absolute;
  top: calc(var(--gutter) + 104px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(174, 187, 207, 0.62);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 2 * var(--gutter));
  text-align: center;
}

/*
 * 32 places in app/*.js hide an element by setting `hidden`. The UA sheet's
 * `[hidden] { display: none }` is the weakest possible rule, so ANY author
 * `display:` on the same element silently beats it and the element stays on
 * screen. That is how the countdown "1" kept sitting over the pitch for the
 * whole match: `.hud-center` sets `display: grid`, and `center.hidden = true`
 * did nothing. One rule, so no future `display:` can reintroduce it.
 */
[hidden] {
  display: none !important;
}

.hud-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.big-text {
  font-family: var(--font-slab);
  font-size: clamp(64px, 12vw, 132px);
  line-height: 1;
  font-weight: 700;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
  animation: pop 0.4s ease;
}
.big-go {
  color: var(--win);
}
.big-sub {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  letter-spacing: 0.05em;
}
@keyframes pop {
  from {
    transform: scale(1.35);
    opacity: 0;
  }
}

.hud-bottom {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(var(--gutter) + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}
.hud-bottom-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.hud-panel {
  background: rgba(10, 16, 26, 0.72);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  padding: 8px 9px 7px;
  backdrop-filter: blur(8px);
}
.panel-title {
  font: 700 9px/1 var(--font-mono);
  letter-spacing: 0.16em;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.hud-map {
  display: block;
  width: 206px;
  height: 116px;
  border-radius: 4px;
}
.map-scale {
  margin-top: 5px;
  font: 400 9.5px/1 var(--font-mono);
  color: var(--ink-3);
}
.hud-stick {
  display: block;
  width: 106px;
  height: 118px;
}
.cmd-nums {
  display: flex;
  gap: 9px;
  margin-top: 4px;
  font: 400 9.5px/1 var(--font-mono);
  color: var(--ink-3);
}
.cmd-nums b {
  color: var(--ink-2);
  font-weight: 600;
}
.hud-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font: 400 10.5px/1 var(--font-mono);
  color: var(--ink-3);
  background: rgba(10, 16, 26, 0.6);
  border-radius: 999px;
  padding: 5px 10px;
}
.meta-key {
  border: 1px solid var(--panel-edge-strong);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 9px;
}
.meta-cam {
  color: var(--ink-2);
}
.meta-sep {
  opacity: 0.4;
}

/* ============================================================== overlays */

.overlays {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 7, 12, 0.72);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  padding: var(--gutter);
}
.overlay[hidden] {
  display: none;
}
.overlay-card {
  width: min(520px, 100%);
  background: var(--panel-solid);
  border: 1px solid var(--panel-edge-strong);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  animation: rise 0.22s ease;
}
@keyframes rise {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
}
.overlay-title {
  margin: 0 0 8px;
  font-family: var(--font-slab);
  font-size: 25px;
  line-height: 1.2;
}
.overlay-sub {
  margin: 0 0 18px;
  color: var(--ink-2);
  font-size: 14px;
}
.overlay-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.result-tone {
  display: inline-block;
  font: 700 10.5px/1 var(--font-mono);
  letter-spacing: 0.18em;
  padding: 5px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.tone-win {
  color: var(--win);
  background: rgba(61, 220, 132, 0.12);
  border: 1px solid rgba(61, 220, 132, 0.4);
}
.tone-lose {
  color: var(--lose);
  background: rgba(255, 107, 94, 0.12);
  border: 1px solid rgba(255, 107, 94, 0.4);
}
.tone-draw {
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-edge-strong);
}
.result-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 14px;
  border-top: 1px solid var(--panel-edge);
}
.result-meta-label {
  font: 400 10px/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.result-term {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #9fd2ff;
  background: rgba(0, 45, 114, 0.45);
  border: 1px solid rgba(90, 160, 255, 0.28);
  border-radius: 5px;
  padding: 3px 8px;
}
.result-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 12px;
}
.result-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.result-stat span {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.result-stat b {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
}
.fatal-msg {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: #ffc9c3;
  word-break: break-word;
}

/* ---------------------------------------------------------------- panels */

.panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 7, 12, 0.72);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  padding: var(--gutter);
  z-index: 24;
}
.panel[hidden] {
  display: none;
}
.panel-card {
  width: min(520px, 100%);
  max-height: min(86vh, 760px);
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--panel-edge-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--panel-edge);
  background: var(--panel-solid);
}
.panel-title {
  margin: 0;
  font-family: var(--font-slab);
  font-size: 17px;
}
.panel-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.panel-lead {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.field-label {
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.field-hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-3);
}
.range-val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
}
.range {
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}
.range::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--jhu-link-on-dark);
  border: 2px solid #0b1220;
  cursor: pointer;
}
.range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--jhu-link-on-dark);
  border: 2px solid #0b1220;
  cursor: pointer;
}
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--panel-edge);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  flex-wrap: wrap;
}
.seg {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: 600 12.5px/1 var(--font-sans);
  padding: 8px 13px;
  border-radius: 7px;
  cursor: pointer;
}
.seg:hover {
  color: var(--ink);
}
.seg.on {
  background: var(--jhu-blue);
  color: #eaf2ff;
  box-shadow: inset 0 0 0 1px rgba(90, 160, 255, 0.35);
}

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: absolute;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 30;
}
.toast {
  pointer-events: none;
  background: rgba(10, 16, 26, 0.94);
  border: 1px solid var(--panel-edge-strong);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12.5px;
  color: var(--ink);
  box-shadow: var(--shadow);
  animation: rise 0.18s ease;
}
.toast-warn {
  border-color: rgba(255, 191, 71, 0.5);
  color: var(--warn);
}
.toast.out {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* ---------------------------------------------------------------- touch */

.touch-controls {
  position: absolute;
  inset: auto 0 0 0;
  padding: 0 var(--gutter) calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
}
.touch-controls[hidden] {
  display: none;
}
.touch-pad {
  pointer-events: auto;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: 1px solid var(--panel-edge-strong);
  background: rgba(10, 16, 26, 0.5);
  display: grid;
  place-items: center;
  touch-action: none;
}
.touch-knob {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(79, 195, 232, 0.5);
  border: 1px solid var(--player-bright);
}
.touch-turns {
  display: flex;
  gap: 10px;
}
.touch-turn {
  pointer-events: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--panel-edge-strong);
  background: rgba(10, 16, 26, 0.5);
  color: var(--ink);
  font-size: 20px;
  touch-action: none;
  cursor: pointer;
}

/* ---------------------------------------------------------------- boot error */

.boot-error {
  max-width: 760px;
  margin: 12vh auto;
  padding: 26px;
  background: var(--panel-solid);
  border: 1px solid rgba(255, 107, 94, 0.45);
  border-radius: var(--radius);
}
.boot-error h1 {
  margin: 0 0 10px;
  font-family: var(--font-slab);
  font-size: 22px;
}
.boot-error pre {
  overflow-x: auto;
  font-size: 12px;
  color: #ffc9c3;
  background: rgba(0, 0, 0, 0.35);
  padding: 12px;
  border-radius: 8px;
}

/* ============================================================== responsive */

@media (max-width: 1040px) {
  .setup-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .setup-side {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .setup-side > .card {
    flex: 1 1 280px;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 14.5px;
  }
  .screen {
    padding-top: 22px;
  }
  .hud-top {
    grid-template-columns: 1fr auto 1fr;
    gap: 7px;
    top: calc(8px + env(safe-area-inset-top, 0px));
  }
  .side-card {
    padding: 7px 9px;
  }
  .dist-num {
    font-size: 17px;
  }
  .clock-num {
    font-size: 24px;
  }
  .hud-clock {
    min-width: 96px;
    padding: 6px 11px 7px;
  }
  .side-method,
  .side-seat {
    display: none;
  }
  .hud-legend {
    display: none;
  }
  .hud-map {
    width: 148px;
    height: 84px;
  }
  .hud-stick {
    width: 84px;
    height: 94px;
  }
  .hud-bottom {
    bottom: calc(150px + env(safe-area-inset-bottom, 0px));
  }
  .opp-grid {
    grid-template-columns: 1fr;
  }
  .choice-row-games > .choice {
    flex: 1 1 100%;
  }
  .overlay-card,
  .panel-card {
    padding: 20px;
  }
  .overlay-title {
    font-size: 21px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* Error mirror (index.html): invisible until something throws. */
.boot-log {
  position: fixed;
  left: 8px;
  bottom: 8px;
  right: 8px;
  max-height: 40vh;
  overflow: auto;
  margin: 0;
  padding: 0;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #ff9c8a;
  background: rgba(10, 15, 22, 0.92);
  border-radius: 6px;
  white-space: pre-wrap;
  z-index: 9999;
  display: none;
}
.boot-log.is-visible { display: block; padding: 8px 10px; }
