/*
  MYTHSTRIKE component stylesheet — styles for the Phase 1 DOM kit.

  Imports the token layer first; every rule below references ONLY tokens
  (plus the spec-documented chrome exceptions: focus rings 2px/2px, crosshair
  1px outline, banner gold border 2px). No layout pixel values that are not
  tokens. Class prefix: ms-.
*/
@import './tokens.css';

/* ------------------------------------------------------------------ */
/* Kit base                                                             */
/* ------------------------------------------------------------------ */

.ms-ui,
.ms-ui * {
  box-sizing: border-box;
}

/* Gold focus ring — reserved use 3: always visible on every interactive
   element, never removed (Phase 1 a11y baseline). Chrome exception values
   per spec: 2px solid ring, 2px offset. */
.ms-ui :focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Motion-aware visibility utility (150ms panel fade in / out). */
.ms-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Icons: 24×24 viewBox rendered at 16px, inherit currentColor. */
.ms-icon {
  width: var(--icon-size);
  height: var(--icon-size);
  display: block;
  flex: none;
}

/* ------------------------------------------------------------------ */
/* Typography utilities (4 sizes / 2 weights + mono readouts)           */
/* ------------------------------------------------------------------ */

.ms-body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-body-size);
  line-height: var(--text-body-lh);
  font-weight: var(--weight-regular);
  color: var(--paper);
}

.ms-label {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-label-size);
  line-height: var(--text-label-lh);
  font-weight: var(--weight-regular);
  color: var(--muted);
}

.ms-label--eyebrow {
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
}

.ms-heading {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-lh);
  font-weight: var(--weight-semibold);
  color: var(--paper);
}

/* Mono readouts (SIM/PLAYER values, timers) — tabular figures so columns
   of changing numbers never jitter. */
.ms-mono {
  font-family: var(--font-mono);
  font-size: var(--text-label-size);
  line-height: var(--text-label-lh);
  font-weight: var(--weight-regular);
}

.ms-tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ */
/* Button (component #6) — 44px target, press physics, variants         */
/* ------------------------------------------------------------------ */

.ms-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  font-family: var(--font-ui);
  font-size: var(--text-body-size);
  line-height: var(--text-body-lh);
  font-weight: var(--weight-semibold);
  min-width: var(--hit-target);
  min-height: var(--hit-target);
  padding: var(--btn-pad-y) var(--sp-lg); /* 12px/24px per spec */
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    transform var(--dur-press) var(--ease-out),
    box-shadow var(--dur-press) var(--ease-out);
}

.ms-btn[hidden] {
  display: none !important; /* #286: a hidden button stays hidden */
}

.ms-btn:disabled {
  opacity: 0.4; /* disabled CTA rest state per spec */
  cursor: default;
  transform: none;
  box-shadow: none;
}

.ms-btn--primary {
  background: var(--gold);
  color: var(--ink);
  border: var(--border-comic);
  box-shadow: var(--shadow-comic);
}

@media (hover: hover) {
  .ms-btn--primary:not(:disabled):hover {
    transform: translateY(var(--lift-hover));
    box-shadow: var(--shadow-comic-lift);
  }
}

.ms-btn--primary:not(:disabled):active {
  transform: translateY(var(--lift-press));
  box-shadow: var(--shadow-comic-pressed);
}

.ms-btn--ghost {
  background: transparent;
  color: var(--paper);
  border: var(--border-line);
  box-shadow: none;
}

@media (hover: hover) {
  .ms-btn--ghost:not(:disabled):hover {
    transform: translateY(var(--lift-hover));
  }
}

.ms-btn--ghost:not(:disabled):active {
  transform: translateY(var(--lift-press));
}

.ms-btn--danger {
  background: var(--danger);
  color: var(--ink);
  border: var(--border-comic);
  box-shadow: var(--shadow-comic);
}

@media (hover: hover) {
  .ms-btn--danger:not(:disabled):hover {
    transform: translateY(var(--lift-hover));
    box-shadow: var(--shadow-comic-lift);
  }
}

.ms-btn--danger:not(:disabled):active {
  transform: translateY(var(--lift-press));
  box-shadow: var(--shadow-comic-pressed);
}

/* ------------------------------------------------------------------ */
/* CrosshairDot (component #8) — 4px paper dot on the PROJECTED shot    */
/* ray (plan 02-01): JS writes translate3d per frame; CSS margins       */
/* pre-center the dot on that point, with the viewport center as the    */
/* pre-first-frame default.                                            */
/* ------------------------------------------------------------------ */

.ms-crosshair {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--sp-xs);
  height: var(--sp-xs);
  /* negative half-size margins: translate3d lands the CENTER on the point */
  margin: calc(var(--sp-xs) / -2) 0 0 calc(var(--sp-xs) / -2);
  transform: translate3d(50vw, 50vh, 0); /* rest at exact center until driven */
  background: var(--paper);
  border: 1px solid var(--ink); /* 1px outline chrome per spec */
  border-radius: 50%;
  opacity: 0.7;
  pointer-events: none;
  z-index: var(--z-hud);
}

/* ------------------------------------------------------------------ */
/* ReplayBanner (component #9) — top-center pill, gold border           */
/* ------------------------------------------------------------------ */

.ms-replay-banner {
  position: absolute;
  top: var(--sp-md);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--navy-raised);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: var(--text-label-size);
  line-height: var(--text-label-lh);
  border: 2px solid var(--gold); /* gold border (not fill) per spec */
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-comic);
  white-space: nowrap;
  pointer-events: none; /* informational only — canvas keeps input */
  z-index: var(--z-hud);
  transition:
    opacity var(--dur-panel) var(--ease-out),
    visibility var(--dur-panel) var(--ease-out);
}

/* ------------------------------------------------------------------ */
/* InlineConfirm (component #7) — small comic card at modal z-30        */
/* ------------------------------------------------------------------ */

.ms-confirm {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  width: var(--size-progress); /* small card, 240px spec dimension */
  padding: var(--sp-md);
  background: var(--navy-raised);
  border: var(--border-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-comic);
  z-index: var(--z-modal);
}

.ms-confirm__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-sm);
}

/* ------------------------------------------------------------------ */
/* Controls hint grid (shared: boot card + pause card)                  */
/* ------------------------------------------------------------------ */

.ms-hint-grid {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: var(--sp-sm) var(--sp-lg);
  justify-content: center;
}

.ms-hint {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.ms-hint-key {
  font-family: var(--font-mono);
  font-size: var(--text-label-size);
  line-height: var(--text-label-lh);
  color: var(--paper);
  background: var(--navy-raised);
  border: 1px solid var(--navy-line); /* keycap hairline chrome */
  border-radius: var(--radius-sm);
  padding: 0 var(--sp-xs);
  min-width: var(--hit-target);
  text-align: center;
}

.ms-hint-label {
  color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* BootOverlay (component #1)                                          */
/* ------------------------------------------------------------------ */

.ms-boot {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2xl); /* boot-screen vertical rhythm */
  padding: var(--sp-3xl);
  background: var(--ink);
  z-index: var(--z-panel);
  transition:
    opacity var(--dur-panel) var(--ease-out),
    visibility var(--dur-panel) var(--ease-out);
}

.ms-boot__wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-display-size);
  line-height: var(--text-display-lh);
  font-weight: var(--weight-regular); /* Titan One ships one weight only */
  color: var(--gold);
  -webkit-text-stroke: var(--stroke-display) var(--ink);
  text-shadow: var(--shadow-comic); /* comic hard shadow (offset, no blur) */
}

.ms-boot__progress-track {
  width: var(--size-progress); /* 240px spec dimension */
  height: var(--sp-sm);
  background: var(--navy-raised);
  border: var(--border-line);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.ms-boot__progress-fill {
  width: 0%;
  height: 100%;
  background: var(--gold); /* reserved use 5: loading progress fill */
  transition: width var(--dur-panel) var(--ease-out);
}

.ms-boot__status {
  text-align: center;
}

/* Error variant: guidance copy replaces the status line; the bar goes. */
.ms-boot--error .ms-boot__progress-track {
  display: none;
}

.ms-boot--error .ms-boot__status {
  color: var(--paper);
  font-size: var(--text-body-size);
  line-height: var(--text-body-lh);
  max-width: calc(var(--size-progress) * 2);
}

/* ------------------------------------------------------------------ */
/* PauseOverlay (component #2)                                         */
/* ------------------------------------------------------------------ */

.ms-pause {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--ink) 70%, transparent); /* dim only */
  cursor: pointer; /* click anywhere → re-lock */
  z-index: var(--z-panel);
  transition:
    opacity var(--dur-panel) var(--ease-out),
    visibility var(--dur-panel) var(--ease-out);
}

.ms-pause__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-lg);
  background: var(--navy-raised);
  border: var(--border-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-comic);
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* DebugPanel (component #3) — passive shell, top-left                 */
/* ------------------------------------------------------------------ */

.ms-debug {
  position: absolute;
  top: var(--sp-md); /* md inset from viewport top-left per spec */
  left: var(--sp-md);
  width: var(--size-debug-panel);
  max-width: calc(100vw - var(--sp-xl));
  /* #521: ten sections overflow small viewports — the panel scrolls its own
   * column instead of pushing the tail sections out of reach. */
  max-height: calc(100vh - 2 * var(--sp-md));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  padding: var(--sp-md);
  background: color-mix(in srgb, var(--navy-raised) 92%, transparent);
  border: var(--border-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-comic);
  /* #520: dev chrome must sit above EVERY game UI layer (menus are --z-menu:
   * 24, modals 30) — otherwise the panel hides behind title buttons or the
   * pause card. Only toasts (--z-toast: 40) stay above it. */
  z-index: calc(var(--z-modal) + 1);
  transition:
    opacity var(--dur-panel) var(--ease-out),
    visibility var(--dur-panel) var(--ease-out);
}

.ms-debug__section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.ms-debug__section-title {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-lh);
}

.ms-debug__rows {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs); /* readout cell gaps */
}

.ms-debug__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-sm);
}

.ms-debug__value {
  color: var(--paper);
  text-align: right;
}

.ms-debug__value--gold {
  color: var(--gold); /* reserved use 4: highlighted key values */
}

.ms-debug__runs {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

/* SKIRMISH section slot (plan 05-05): the skirmish overlay's compact
   control group mounts here — same column shape as the RUNS slot. */
.ms-debug__skirmish {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

/* HITCH section slot (one-key pass): the hitch meter's graph + readout
   mounts here (debug/hitchMeter.js) — same column shape as the RUNS slot. */
.ms-debug__hitch {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

/* RACE progression controls (plans 03-01 → 03-04): per-skill tier rows —
   label + n/6 [+] — capstone, the race switcher, respec and the save-failed
   badge. Development chrome only. */
.ms-debug__race-controls {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.ms-debug__grant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
}

.ms-debug__grant-row .ms-label {
  color: var(--muted);
}

.ms-debug__grant-btns {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.ms-debug__grant-tier {
  min-width: 4ch;
  text-align: center;
}

.ms-debug__grant-btn {
  min-width: 24px;
  min-height: 24px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-raised);
  border: 1px solid var(--navy-line);
  border-radius: var(--radius-sm);
  color: var(--paper);
  cursor: pointer;
}

@media (hover: hover) {
  .ms-debug__grant-btn:hover {
    border-color: var(--gold);
  }
}

.ms-debug__grant-btn:disabled {
  opacity: 0.45;
  cursor: default;
  border-color: var(--navy-line);
}

/* Full-width variants: capstone, race switcher rows, respec. */
.ms-debug__grant-btn--wide {
  width: 100%;
  justify-content: center;
  font-size: 12px;
}

/* The QUEUED switch target — gold border until the respawn applies it. */
.ms-debug__grant-btn--queued {
  border-color: var(--gold);
  color: var(--gold);
}

/* An ACTIVE toggle (SILHOUETTE CUTOUT ON — 03-07) — gold border + fill tint. */
.ms-debug__grant-btn--active {
  border-color: var(--gold);
  color: var(--gold);
  background: color-mix(in srgb, var(--gold) 14%, var(--navy-raised));
}

/* Small muted hint line (switcher state). */
.ms-debug__hint {
  color: var(--muted);
  font-size: 11px;
}

/* Storage-degradation badge (quota / private mode). */
.ms-debug__save-failed {
  color: var(--gold);
  font-size: 11px;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Icon buttons (44px targets)                                          */
/* ------------------------------------------------------------------ */

.ms-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--hit-target);
  min-height: var(--hit-target);
  padding: 0;
  background: transparent;
  color: var(--paper);
  border: 1px solid transparent; /* hairline chrome appears on hover */
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background-color var(--dur-press) var(--ease-out),
    border-color var(--dur-press) var(--ease-out),
    transform var(--dur-press) var(--ease-out);
}

@media (hover: hover) {
  .ms-icon-btn:not(:disabled):hover {
    background: var(--navy-raised);
    border-color: var(--navy-line);
    transform: translateY(var(--lift-hover));
  }
}

.ms-icon-btn:not(:disabled):active {
  transform: translateY(var(--lift-press));
}

.ms-icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ------------------------------------------------------------------ */
/* RecordingsList (component #4) — RUNS section body                   */
/* ------------------------------------------------------------------ */

.ms-runs {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.ms-runs__list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  max-height: var(--size-runs-list-max); /* 160px → scroll per spec */
  overflow-y: auto;
}

.ms-runs__row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.ms-runs__marker {
  width: var(--sp-xs);
  height: var(--sp-xs);
  flex: none;
  border-radius: 50%;
  background: var(--gold); /* reserved use 6: active row marker */
  visibility: hidden;
}

.ms-runs__row.ms-is-active .ms-runs__marker {
  visibility: visible;
}

.ms-runs__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ms-runs__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* single-line ellipsis per spec */
}

.ms-runs__badge {
  align-self: flex-start;
  padding: 0 var(--sp-sm);
  background: var(--navy-raised);
  border: 1px solid var(--navy-line);
  border-radius: var(--radius-pill);
}

.ms-runs__row.ms-is-unreadable {
  opacity: 0.6;
}

.ms-runs__empty {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  padding: var(--sp-xs) 0;
}

/* ------------------------------------------------------------------ */
/* TransportControls (component #5) — record toggle + timer            */
/* ------------------------------------------------------------------ */

.ms-transport {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

/* One-key pass (2026-10-05): the toggle is the RUNS section's labeled
   button — the panel-button look (the F9 route is gone), icon + text. */
.ms-transport__toggle {
  gap: var(--sp-xs);
  padding: 0 10px;
  background: var(--navy-raised);
  border-color: var(--navy-line);
  font-size: 12px;
}

/* Engaged toggle state — reserved gold use 2, with the recording pulse. */
.ms-transport__toggle.ms-is-recording {
  background: var(--gold);
  color: var(--ink);
  border: var(--border-comic);
  box-shadow: var(--shadow-comic);
}

@keyframes ms-recording-pulse {
  0%,
  100% {
    box-shadow:
      var(--shadow-comic),
      0 0 0 0 color-mix(in srgb, var(--gold) 55%, transparent);
  }
  50% {
    box-shadow:
      var(--shadow-comic),
      0 0 0 var(--sp-sm) color-mix(in srgb, var(--gold) 0%, transparent);
  }
}

.ms-transport__toggle.ms-is-recording {
  animation: ms-recording-pulse 1.6s var(--ease-out) infinite;
}

.ms-transport__timer {
  color: var(--muted);
}

.ms-transport__timer.ms-is-recording {
  color: var(--gold); /* reserved use 4: highlighted key value */
}

/* ------------------------------------------------------------------ */
/* Menu screens (plan 06-01) — screenManager's leave fade + the title  */
/* and results screens                                                  */
/* ------------------------------------------------------------------ */

/* The out-fade screenManager puts on a dying screen — the SAME duration as
   --dur-panel, so a screen swap reads as one continuous move (the incoming
   screen is built fresh; only the exit needs motion). */
.ms-leaving {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-panel) var(--ease-out);
}

/* Title screen (06-03, UI-SPEC #2): ink field, the wordmark with ONE ink
   ripple ring expanding behind it and the synced heartbeat (sizes and
   durations injected INLINE from HUD_CONSTANTS.titleFx by title.js — zero
   magic numbers here), the menu column (Play primary / Practice ghost /
   Profile + Settings stubs) and the bottom-center version chip. */
.ms-title {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2xl);
  padding: var(--sp-3xl);
  background: var(--ink);
  z-index: var(--z-panel);
}

.ms-title__mark {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The ripple ring: width/height/border-width/opacity/duration arrive inline
   from the chrome constants; this class supplies the mechanics — centered,
   expanding from nothing, paper stroke, ease-out, looping. */
.ms-title__ripple {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  border-radius: 50%;
  border-style: solid;
  border-color: var(--paper);
  animation: ms-title-ripple var(--ease-out) infinite;
  pointer-events: none;
}

@keyframes ms-title-ripple {
  from {
    transform: translate(-50%, -50%) scale(0);
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0; /* fade the loop seam — the 15% peak is the inline base */
  }
}

/* The boot wordmark rule supplies the Titan One + gold + stroke treatment;
   the menu scale is the one addition (token-derived, no raw px). The
   heartbeat's peak scale arrives via --title-heartbeat (title.js sets it
   from the same constants; the fallback only covers style-less contexts). */
.ms-title__wordmark {
  margin: 0;
  font-size: calc(var(--text-display-size) * 1.6);
  line-height: 1.05;
  animation: ms-title-heartbeat var(--ease-out) infinite;
}

@keyframes ms-title-heartbeat {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(var(--title-heartbeat, 1.02));
  }
}

/* The ink moment IS motion — under reduced motion it goes entirely (the
   global rule would otherwise freeze a full-size static ring visible). */
@media (prefers-reduced-motion: reduce) {
  .ms-title__ripple {
    display: none;
  }
}

/* Menu column: the two live CTAs + the two disabled stubs. */
.ms-title__menu {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  min-width: var(--size-progress);
}

/* Disabled stubs read at 50% (the menu spec's dim for coming-soon rows). */
.ms-title__stub {
  opacity: 0.5;
}

.ms-title__version {
  position: absolute;
  bottom: var(--sp-lg);
  margin: 0;
  color: var(--muted);
}

/* Full menu screens (06-03, UI-SPEC #3/#4): the shared chrome — fullscreen
   ink, 3xl padding, the 150ms enter fade-rise (ms-leaving's twin), scroll
   when content overflows. */
.ms-screen {
  pointer-events: auto; /* menus are interactive — override the #ui-root none */
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
  padding: var(--sp-3xl);
  background: var(--ink);
  z-index: var(--z-panel);
  overflow-y: auto;
  animation: ms-screen-in var(--dur-panel) var(--ease-out);
}

@keyframes ms-screen-in {
  from {
    opacity: 0;
    transform: translateY(var(--sp-sm));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ms-screen__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
}

.ms-screen__title {
  margin: 0;
}

.ms-screen__body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xl);
}

/* Sticky footer: summary + CTA stay reachable while the sections scroll. */
.ms-screen__footer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  margin-top: auto;
  padding-top: var(--sp-sm);
  background: var(--ink);
}

/* Race select (06-03, UI-SPEC #3): the four large cards in a row, the
   integrated P3 tree below, the K hint + Continue footer. */
.ms-raceselect__cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-md);
}

/* Selected card (gold use 21): 2px gold border + the gold left marker, on
   top of the card's own comic chrome. */
.ms-raceselect__card--selected {
  border-color: var(--gold);
  box-shadow: inset 3px 0 0 var(--gold), var(--shadow-comic);
}

.ms-raceselect__tree {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  padding: var(--sp-lg);
  background: var(--navy-raised);
  border: var(--border-line);
  border-radius: var(--radius-lg);
}

/* Match setup (06-03, UI-SPEC #4): three stacked sections — mode cards,
   map cards with the generated SVG thumbs, bots stepper + tier segments. */
.ms-matchsetup__section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.ms-matchsetup__modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-md);
}

.ms-matchsetup__maps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--size-progress), 1fr));
  gap: var(--sp-md);
}

/* Pick cards (mode + map): raised, line-bordered, full hit targets;
   selected = gold border + marker (gold use 21). */
.ms-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-xs);
  min-height: var(--hit-target);
  padding: var(--sp-md);
  background: var(--navy-raised);
  border: 2px solid var(--navy-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-comic);
  color: var(--paper);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) {
  .ms-card:hover {
    border-color: var(--muted);
  }
}

.ms-card:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.ms-card--selected {
  border-color: var(--gold);
  box-shadow: inset 3px 0 0 var(--gold), var(--shadow-comic);
}

.ms-card--mode {
  flex-direction: row;
  align-items: center;
  gap: var(--sp-md);
}

.ms-card--mode .ms-icon {
  width: var(--text-heading-size);
  height: var(--text-heading-size);
  flex: none;
}

.ms-card__name {
  margin: 0;
}

/* Map names render in Titan One 20 (the spec's map-name treatment). */
.ms-card__name--map {
  font-family: var(--font-display);
  font-weight: var(--weight-regular); /* Titan One ships one weight only */
}

.ms-card__blurb {
  margin: 0;
  color: var(--muted);
}

/* The generated thumbnail (mapThumb.js): full card width, height by the
   344×160 viewBox aspect. */
.ms-card__thumb {
  width: 100%;
}

.ms-card__thumb svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.ms-card__footprint {
  margin-top: auto;
  color: var(--muted);
}

/* Stepper buttons: 44px hit targets, glyph buttons. */
.ms-stepper__btn {
  width: var(--hit-target);
  height: var(--hit-target);
  background: var(--navy-raised);
  border: 2px solid var(--navy-line);
  border-radius: var(--radius-sm);
  color: var(--paper);
  font: inherit;
  font-size: var(--text-heading-size);
  cursor: pointer;
}

.ms-stepper__btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Segment pills (race select roster toggle). */
.ms-segment {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  min-height: var(--hit-target);
  padding: var(--sp-xs) var(--sp-md);
  background: var(--navy-raised);
  border: 2px solid var(--navy-line);
  border-radius: var(--radius-pill);
  color: var(--paper);
  font: inherit;
  cursor: pointer;
}

.ms-segment--selected {
  border-color: var(--gold); /* gold use 21 — the selected marker */
  color: var(--gold);
}

.ms-matchsetup__summary {
  margin: 0;
  color: var(--muted);
}

/* Pause card, the 06-03 additions: the Leave Match action and the nested
   confirm card at modal z. */
.ms-pause__actions {
  display: flex;
  justify-content: center;
  margin-top: var(--sp-sm);
}

.ms-pause__confirm {
  position: relative;
  z-index: var(--z-modal);
  margin-top: var(--sp-sm);
}

/* Results screen (UI-SPEC menu flow #3): the verdict card over a dimmed
   arena. Gold = the WIN word + the own row (the scoreboard's signals);
   DEFEAT reads paper, DRAW muted (07.3-17, UI-SPEC S12). */
.ms-results {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-xl);
  background: color-mix(in srgb, var(--ink) 70%, transparent);
  z-index: var(--z-panel);
}

.ms-results__card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  max-height: calc(100vh - var(--sp-3xl));
  max-height: calc(100dvh - var(--sp-3xl)); /* visible viewport on mobile (vh fallback above) */
  overflow-y: auto;
  padding: var(--sp-lg);
  background: var(--navy-raised);
  border: var(--border-comic);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-comic);
}

.ms-results__heading--win {
  color: var(--gold); /* the verdict's one signal word (skirmish precedent) */
}

/* 07.3-17 (UI-SPEC S12): DEFEAT reads paper, DRAW muted — the winWord
   verdict colours. */
.ms-results__heading--lose {
  color: var(--paper);
}

.ms-results__heading--draw {
  color: var(--muted);
}

.ms-results__sub {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  color: var(--muted);
}

/* The winner's team dot — tinted by the SAME --team-a/--team-b custom
   properties the match wiring injects on #ui-root (paper when absent). */
.ms-results__dot {
  width: var(--sp-sm);
  height: var(--sp-sm);
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--paper);
}

.ms-results__dot--a {
  background: var(--team-a, var(--paper));
}

.ms-results__dot--b {
  background: var(--team-b, var(--paper));
}

.ms-results__labels {
  color: var(--muted);
}

.ms-results__payout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-md);
  padding: var(--sp-xs) 0;
  color: var(--paper);
}

/* 06-05 payout row: "+{n} XP" gold (gold use 24) + the LVL chip when the
   match leveled the local player + "+{n} earned" beside it. */
.ms-results__payout-values {
  display: inline-flex;
  align-items: baseline;
  gap: var(--sp-sm);
}

.ms-results__xp {
  color: var(--gold);
  font-weight: var(--weight-semibold);
}

.ms-results__earned {
  color: var(--muted);
}

/* The LVL chip: gold pill (gold use 24), 80 ms 1.2→1 pop on mount. */
.ms-results__lvl {
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: var(--text-label-size);
  line-height: 1;
  padding: 3px 6px;
  border-radius: var(--radius-pill);
  background: var(--gold);
  color: var(--ink);
  animation: ms-results-lvl-pop 80ms ease-out;
}

@keyframes ms-results-lvl-pop {
  from {
    transform: scale(1.2);
  }
  to {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ms-results__lvl {
    animation: none;
  }
}

.ms-results__actions {
  display: flex;
  gap: var(--sp-sm);
  margin-top: var(--sp-xs);
}

/* ---------------------------------------------------------------------------
   Lobby flow (plan 07-04) — browser / create / room screens. Shares the menu
   chrome (ms-screen, ms-card, ms-segment, ms-stepper); only the lobby-specific
   anatomy lives here. Text inputs are new to the menu flow (the menus were
   button-only until now): token-styled, 44px hit floor, gold focus ring from
   the global :focus-visible rule.
   --------------------------------------------------------------------------- */

.ms-input {
  min-height: 44px;
  padding: 6px var(--sp-sm);
  background: var(--navy-raised);
  border: 2px solid var(--navy-line);
  border-radius: var(--radius-sm);
  color: var(--paper);
  font: inherit;
}

.ms-input::placeholder {
  color: var(--muted);
}

/* The join-code field: 5ch mono — a code is always exactly 5 glyphs. */
.ms-input--code {
  width: 7ch;
  font-family: var(--font-mono, monospace);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
}

.ms-lobby-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.ms-lobby-status {
  margin: 0;
  color: var(--muted);
}

/* Browser screen: join row + the open-lobby list. */
.ms-lobby-join__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-sm);
}

.ms-lobby-list__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
}

.ms-lobby-list__rows {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.ms-lobby-list__empty {
  margin: 0;
  color: var(--muted);
}

/* One open lobby — a full-width row button: code (mono), mode·map line,
   players/capacity right-aligned. */
.ms-lobby-row {
  display: grid;
  grid-template-columns: 7ch 1fr auto;
  align-items: center;
  gap: var(--sp-md);
  min-height: 44px;
  padding: var(--sp-xs) var(--sp-sm);
  background: var(--navy-raised);
  border: 2px solid var(--navy-line);
  border-radius: var(--radius-sm);
  color: var(--paper);
  font: inherit;
  cursor: pointer;
}

@media (hover: hover) {
  .ms-lobby-row:hover {
    border-color: var(--gold);
  }
}

.ms-lobby-row__code {
  font-size: var(--text-label-size);
  letter-spacing: 0.12em;
  color: var(--gold);
}

.ms-lobby-row__line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-lobby-row__count {
  color: var(--muted);
}

.ms-lobby-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  min-height: 44px;
}

/* Room screen: the share block, the roster columns, the settings list and
   the host-control strip. */
.ms-lobby-room__code {
  letter-spacing: 0.16em;
}

.ms-lobby-share__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-sm);
}

.ms-lobby-share__code {
  min-width: 7ch;
  padding: 3px var(--sp-sm);
  border: 2px solid var(--navy-line);
  border-radius: var(--radius-sm);
  background: var(--navy-raised);
  font-size: var(--text-display-size);
  letter-spacing: 0.16em;
  color: var(--gold);
}

.ms-lobby-share__status {
  color: var(--muted);
  overflow-wrap: anywhere; /* a failed link copy shows the full URL */
}

.ms-lobby-teams {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-md);
}

.ms-lobby-team {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  padding: var(--sp-sm);
  border: 2px solid var(--navy-line);
  border-radius: var(--radius-sm);
  background: var(--navy-raised);
}

.ms-lobby-team--self {
  border-color: var(--gold); /* your column — the selected-marker precedent */
}

/* Team tints (yellow vs blue) ride the page-level --team-a/--team-b custom
   properties main.js injects from the configured pair — never a literal. */
.ms-lobby-team--alpha {
  border-top: 6px solid var(--team-a, var(--navy-line));
}

.ms-lobby-team--bravo {
  border-top: 6px solid var(--team-b, var(--navy-line));
}

.ms-lobby-team--alpha .ms-lobby-team__name {
  color: var(--team-a, var(--paper));
}

.ms-lobby-team--bravo .ms-lobby-team__name {
  color: var(--team-b, var(--paper));
}

.ms-lobby-team__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
}

.ms-lobby-players {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.ms-lobby-player {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  min-height: 32px;
}

.ms-lobby-player__name {
  overflow-wrap: anywhere; /* long hostile nicknames never blow the layout */
}

.ms-lobby-player__tag {
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--navy-line);
  color: var(--muted);
  font-size: var(--text-label-size);
  line-height: 1.2;
}

.ms-lobby-player__tag--you {
  border-color: var(--gold);
  color: var(--gold);
}

.ms-lobby-room__hint,
.ms-lobby-room__waiting {
  margin: 0;
  color: var(--muted);
}

.ms-lobby-settings {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  margin: 0;
  padding: 0;
  list-style: none;
}


/* Pointer routing (07.1-04, replaces the 07-era !important/JS patches):
   #ui-root passes clicks through to the canvas; every interactive control
   and every full-screen menu surface opts back in. (The patches existed
   because an unterminated comment in .ms-screen had swallowed its whole
   layout block — fixed above.) */
.ms-ui button,
.ms-ui input,
.ms-ui select,
.ms-ui a,
.ms-ui .ms-card,
.ms-title,
.ms-screen,
.ms-results,
.ms-lobby {
  pointer-events: auto;
}
