/*
  MYTHSTRIKE menu design system (splash redesign) — loaded LAST.

  One language for every menu surface over the live 3D stage:
    - the TITLE splash (wordmark lockup, starburst, map backdrop veil,
      entrance + idle motion, tip strip)
    - the SCREEN chrome shared by race select, match setup, lobbies,
      settings and how to play: back pill + breadcrumb + display title in
      the header, glass panels, ink cards with hover / press / selected
      juice, and a footer BAND that sits flush on the screen edge (safe-area
      padded) so no CTA shadow ever floats over a gap
    - pause / results / skills (K) / shop (B) cards join the same chrome.

  Motion: transform + opacity only (never layout properties), springy
  entrances staggered through --i, collapsed by reduced motion (the OS
  preference rule in tokens.css and :root.ms-reduced-motion in ux.css).
  Everything is procedural CSS/SVG — no image or font assets.
*/

/* ================================================================== */
/* TITLE — splash composition                                          */
/* ================================================================== */

.ms-title {
  --title-gx: max(var(--gutter), calc(env(safe-area-inset-left, 0px) + 16px));
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto auto minmax(0, 1.25fr) auto;
  grid-template-areas: "." "mark" "menu" "." "foot";
  justify-items: start;
  align-items: start;
  gap: 0;
  padding: max(24px, env(safe-area-inset-top, 0px)) var(--title-gx) 0;
  background: none;
  overflow: hidden;
  isolation: isolate;
}

/* ---- backdrop veil (07.3 D-14, UI-SPEC S4) -------------------------
   A full-screen ink layer just under the title UI: it fades up over the
   map, the map swaps, it fades back out. Opacity only — the crossfade
   stays under reduced motion (the global 1ms rule is overridden below). */
.ms-title__veil {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: 0;
  background: var(--grape-deep);
  transition: opacity var(--dur-enter) var(--ease-soft);
}

.ms-title__veil--on {
  opacity: 1;
}

:root.ms-reduced-motion .ms-ui .ms-title__veil {
  transition-duration: var(--dur-enter) !important;
}

/* ---- mood layer --------------------------------------------------- */
.ms-title__fx {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.ms-title__fx > span {
  position: absolute;
  inset: 0;
  display: block;
}

/* Left ink scrim (menu legibility) + bottom band + a violet top tint that
   pulls the bright sky into the UI palette. */
.ms-title__scrim {
  background:
    linear-gradient(90deg, rgba(18, 14, 39, 0.82) 0%, rgba(27, 23, 51, 0.58) 26%, rgba(27, 23, 51, 0.12) 46%, rgba(27, 23, 51, 0) 58%),
    linear-gradient(0deg, rgba(18, 14, 39, 0.78) 0%, rgba(18, 14, 39, 0) 22%),
    linear-gradient(180deg, rgba(58, 36, 120, 0.42) 0%, rgba(58, 36, 120, 0) 30%),
    radial-gradient(130% 100% at 70% 55%, rgba(0, 0, 0, 0) 55%, rgba(18, 14, 39, 0.55) 100%);
}

/* Warm glow on the backdrop side (sits under the scrim). */
.ms-title__glow {
  background:
    radial-gradient(40% 46% at 70% 52%, rgba(255, 197, 49, 0.24) 0%, rgba(255, 197, 49, 0) 70%),
    radial-gradient(30% 36% at 86% 30%, rgba(139, 108, 255, 0.26) 0%, rgba(139, 108, 255, 0) 70%);
  mix-blend-mode: screen;
  animation: ms-title-glow 7s ease-in-out infinite alternate;
}

@keyframes ms-title-glow {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

/* Comic halftone dots fading in from the left + bottom corners. */
.ms-title__dots {
  background: radial-gradient(rgba(255, 248, 232, 0.13) 1.4px, transparent 1.9px) 0 0 / 14px 14px;
  -webkit-mask-image: radial-gradient(120% 90% at 0% 100%, #000 0%, transparent 55%);
  mask-image: radial-gradient(120% 90% at 0% 100%, #000 0%, transparent 55%);
  opacity: 0.8;
}

/* Slow light rays fanning behind the wordmark (rotation only). */
.ms-title__rays {
  inset: auto;
  left: calc(var(--title-gx) - 30vmax + 16vw);
  top: calc(-30vmax + 22vh);
  width: 60vmax;
  height: 60vmax;
  background: repeating-conic-gradient(from 0deg, rgba(255, 214, 102, 0.1) 0deg 7deg, rgba(255, 214, 102, 0) 7deg 20deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, rgba(0, 0, 0, 0.6) 30%, transparent 62%);
  mask-image: radial-gradient(circle, #000 0%, rgba(0, 0, 0, 0.6) 30%, transparent 62%);
  border-radius: 50%;
  animation: ms-title-rays 80s linear infinite;
}

@keyframes ms-title-rays {
  to { transform: rotate(360deg); }
}

/* ---- wordmark lockup ---------------------------------------------- */
.ms-title__mark {
  --wm: clamp(64px, min(9.2vw, 15vh), 170px); /* the STRIKE glyph size */
  grid-area: mark;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  /* Top room for the badge's upper rays (it centers on the letters). */
  margin: calc(var(--wm) * 0.22) 0 clamp(36px, 7vh, 68px);
  isolation: isolate;
}

.ms-title__ripple {
  display: none;
}

.ms-title__wordmark,
.ms-boot__wordmark.ms-title__wordmark {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--wm);
  line-height: 0.86;
  letter-spacing: 0;
  color: var(--gold);
  text-shadow: none;
  animation: none;
  transform: none;
}

.ms-title__word {
  display: flex;
  white-space: nowrap;
}

.ms-title__word--myth {
  font-size: 0.5em;
  margin: 0 0 -0.04em;
  transform: rotate(-3deg);
  transform-origin: center bottom;
}

.ms-title__word--strike {
  transform: rotate(-3deg);
  transform-origin: center;
}

.ms-title__letter {
  --i: 0;
  display: inline-block;
  animation: ms-letter-in 620ms var(--ease-back) backwards;
  animation-delay: calc(180ms + var(--i) * 55ms);
}

/* Each glyph: gold fill painted OVER a fat ink stroke, an ink drop
   shadow, a slight per-letter tilt, and a lighter top highlight (::before)
   + a travelling glint (::after) layered over the fill. */
.ms-title__glyph {
  --tilt: 0deg;
  position: relative;
  display: inline-block;
  padding: 0 0.012em;
  color: var(--gold);
  -webkit-text-stroke: 0.16em var(--stroke-ink);
  paint-order: stroke fill;
  text-shadow:
    0 0.06em 0 var(--stroke-ink),
    0 0.1em 0 var(--stroke-ink),
    0 0.18em 0.14em rgba(14, 11, 31, 0.45);
  transform: rotate(var(--tilt));
  animation: ms-letter-float 3.6s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.33s);
}

.ms-title__word--myth .ms-title__glyph {
  color: var(--paper);
  -webkit-text-stroke-width: 0.2em;
}

.ms-title__glyph::before,
.ms-title__glyph::after {
  content: attr(data-ch);
  position: absolute;
  inset: 0;
  padding: inherit;
  -webkit-text-stroke: 0;
  text-shadow: none;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  pointer-events: none;
}

/* Warm top highlight: the comic "lit from above" band. */
.ms-title__glyph::before {
  background-image: linear-gradient(180deg, #fff3b8 0%, #ffe07a 34%, rgba(255, 224, 122, 0) 52%, rgba(217, 138, 0, 0) 70%, rgba(217, 138, 0, 0.7) 100%);
}

.ms-title__word--myth .ms-title__glyph::before {
  background-image: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0) 55%, rgba(185, 177, 220, 0.6) 100%);
}

/* Glint: a white sheen that flashes letter by letter every few seconds. */
.ms-title__glyph::after {
  background-image: linear-gradient(115deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.95) 48%, rgba(255, 255, 255, 0) 64%);
  opacity: 0;
  animation: ms-letter-glint 5.2s ease-in-out infinite;
  animation-delay: calc(1.6s + var(--i) * 70ms);
}

.ms-title__letter:nth-child(odd) .ms-title__glyph { --tilt: -2.5deg; }
.ms-title__letter:nth-child(3n) .ms-title__glyph { --tilt: 3deg; }
.ms-title__letter:nth-child(4n + 2) .ms-title__glyph { --tilt: 1.5deg; }

@keyframes ms-letter-in {
  0% { opacity: 0; transform: translateY(-0.9em) scale(1.35) rotate(-10deg); }
  55% { opacity: 1; transform: translateY(0.06em) scale(0.92, 1.08); }
  78% { transform: translateY(-0.02em) scale(1.04, 0.96); }
  100% { opacity: 1; transform: none; }
}

@keyframes ms-letter-float {
  0%, 100% { transform: translateY(0) rotate(var(--tilt)); }
  50% { transform: translateY(-0.035em) rotate(calc(var(--tilt) * -0.4)); }
}

@keyframes ms-letter-glint {
  0%, 82%, 100% { opacity: 0; }
  88% { opacity: 1; }
}

/* Comic starburst behind the lockup: ink outline, grape fill, gold core. */
/* It sits inside the wordmark, centered on the letters (badge + name share
   one center on the title, the loading screen and the share image). */
.ms-title__burst {
  position: absolute;
  z-index: -1;
  left: calc(50% - var(--wm) * 2.4);
  top: calc(50% - var(--wm) * 1.44);
  width: calc(var(--wm) * 4.8);
  height: calc(var(--wm) * 2.88);
  max-width: none;
  transform: rotate(-4deg);
  overflow: visible;
  animation: ms-burst-in 700ms var(--ease-back) backwards 60ms;
  pointer-events: none;
}

.ms-title__burst-outer {
  fill: rgba(42, 36, 80, 0.9);
  stroke: var(--stroke-ink);
  stroke-width: 6;
  stroke-linejoin: round;
}

.ms-title__burst-inner {
  fill: rgba(139, 108, 255, 0.28);
  stroke: rgba(255, 197, 49, 0.55);
  stroke-width: 2.5;
  stroke-dasharray: 10 8;
  stroke-linejoin: round;
}

@keyframes ms-burst-in {
  0% { opacity: 0; transform: rotate(-30deg) scale(0.3); }
  60% { opacity: 1; transform: rotate(0deg) scale(1.06); }
  100% { opacity: 1; transform: rotate(-4deg) scale(1); }
}

/* Sparkles: four-point comic glints popping around the lockup. */
.ms-title__sparks {
  position: absolute;
  inset: -12% -8% -6% -6%;
  z-index: 1;
  pointer-events: none;
}

.ms-title__spark {
  --s: 0;
  position: absolute;
  width: calc(var(--wm) * 0.26);
  height: calc(var(--wm) * 0.26);
  background: radial-gradient(circle, #fff 0 18%, #fff3b8 34%, #ffc531 70%);
  clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
  opacity: 0;
  transform: scale(0);
  animation: ms-spark 3.4s ease-in-out infinite;
  animation-delay: calc(1.4s + var(--s) * 0.57s);
}

.ms-title__spark:nth-child(1) { left: 4%; top: 18%; }
.ms-title__spark:nth-child(2) { left: 46%; top: 2%; width: calc(var(--wm) * 0.18); height: calc(var(--wm) * 0.18); }
.ms-title__spark:nth-child(3) { left: 88%; top: 22%; }
.ms-title__spark:nth-child(4) { left: 94%; top: 58%; width: calc(var(--wm) * 0.18); height: calc(var(--wm) * 0.18); }
.ms-title__spark:nth-child(5) { left: 28%; top: 54%; width: calc(var(--wm) * 0.16); height: calc(var(--wm) * 0.16); }
.ms-title__spark:nth-child(6) { left: 66%; top: 44%; }

@keyframes ms-spark {
  0%, 62%, 100% { opacity: 0; transform: scale(0) rotate(0deg); }
  72% { opacity: 1; transform: scale(1.15) rotate(45deg); }
  84% { opacity: 0.9; transform: scale(0.7) rotate(90deg); }
}

/* Tagline ribbon: a coral banner with notched ends, slapped on at a tilt. */
.ms-title__tagline {
  position: relative;
  align-self: center;
  margin: clamp(6px, 1vw, 14px) 0 0;
  padding: 0;
  font-family: var(--font-display);
  /* Never wider than a phone: the claim stays on one line. */
  font-size: min(calc(var(--wm) * 0.27), 4.4vw);
  line-height: 1.1;
  background: none;
  border: 0;
  box-shadow: none;
  clip-path: none;
  white-space: nowrap;
  transform: rotate(-3deg);
  animation: ms-tagline-in 520ms var(--ease-back) backwards 900ms;
}

/* The slogan: red comic letters in the wordmark's style: a coral fill over
   a fat ink stroke and ink drop, with a light-to-deep gradient painted over
   the fill from data-text (the same trick as the wordmark's glyphs). */
.ms-title__slogan {
  position: relative;
  display: inline-block;
  padding: 0 0.04em;
  color: var(--coral);
  -webkit-text-stroke: 0.2em var(--stroke-ink);
  paint-order: stroke fill;
  text-shadow:
    0 0.08em 0 var(--stroke-ink),
    0 0.14em 0 var(--stroke-ink),
    0 0.24em 0.18em rgba(14, 11, 31, 0.45);
}

.ms-title__slogan::before {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  padding: inherit;
  -webkit-text-stroke: 0;
  text-shadow: none;
  color: transparent;
  background-image: linear-gradient(180deg, #ffd1d5 0%, #ff8a95 30%, rgba(255, 95, 109, 0) 55%, rgba(194, 35, 58, 0.85) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  pointer-events: none;
}

@keyframes ms-tagline-in {
  0% { opacity: 0; transform: rotate(-14deg) scale(1.8); }
  60% { opacity: 1; transform: rotate(-1deg) scale(0.94); }
  100% { opacity: 1; transform: rotate(-3deg) scale(1); }
}

/* ---- menu column --------------------------------------------------- */
.ms-title__menu {
  grid-area: menu;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(410px, 100%);
  min-width: 0;
  max-height: none;
  overflow: visible;
  padding: 0;
}

.ms-title__menu .ms-menuentry,
.ms-title__menu .ms-btn.ms-menuentry {
  --i: 0;
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 22px;
  align-items: center;
  column-gap: 14px;
  width: 100%;
  min-height: 60px;
  padding: 7px 16px 7px 8px;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  justify-content: stretch;
  border: 3px solid var(--stroke-ink);
  border-radius: 16px;
  background: var(--glass);
  color: var(--paper);
  box-shadow: 0 5px 0 var(--stroke-ink), inset 0 0 0 2px var(--glass-line);
  overflow: hidden;
  isolation: isolate;
  transform: none;
  transition:
    transform var(--dur-hover) var(--ease-spring),
    box-shadow var(--dur-hover) var(--ease-out),
    color var(--dur-hover) var(--ease-out);
  animation: ms-entry-in 520ms var(--ease-back) backwards;
  animation-delay: calc(560ms + var(--i) * 70ms);
}

/* The hover fill: a grape ink band that wipes in from the left. */
.ms-menuentry::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, #4b3d9a 0%, #3a3170 100%);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 260ms var(--ease-soft);
}

.ms-menuentry__icon,
.ms-title__menu .ms-menuentry__icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(255, 248, 232, 0.08);
  border: 2px solid var(--stroke-ink);
  box-shadow: inset 0 -3px 0 rgba(14, 11, 31, 0.35);
  color: var(--gold);
  transition: transform 260ms var(--ease-spring);
}

.ms-menuentry__icon .ms-icon {
  width: 26px;
  height: 26px;
}

.ms-title__menu .ms-menuentry__label {
  font-size: 21px;
  line-height: 1.05;
  letter-spacing: 0.03em;
}

.ms-title__menu .ms-menuentry__sub {
  font-size: 13px;
  opacity: 0.78;
}

.ms-menuentry__go {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--gold);
  opacity: 0.55;
  transition: transform 220ms var(--ease-spring), opacity var(--dur-hover) var(--ease-out);
}

.ms-menuentry__go .ms-icon {
  width: 18px;
  height: 18px;
  transform: rotate(90deg);
}

@media (hover: hover) {
  .ms-title__menu .ms-menuentry:not(:disabled):hover {
    transform: translateX(8px);
    background: var(--glass);
    box-shadow: 0 6px 0 var(--stroke-ink), inset 0 0 0 2px rgba(255, 248, 232, 0.22), 0 0 0 3px rgba(255, 197, 49, 0.35);
  }

  .ms-title__menu .ms-menuentry:hover::before {
    transform: scaleX(1);
  }

  .ms-title__menu .ms-menuentry:hover .ms-menuentry__icon {
    transform: rotate(-8deg) scale(1.1);
  }

  .ms-title__menu .ms-menuentry:hover .ms-menuentry__go {
    opacity: 1;
    transform: translateX(4px);
  }
}

.ms-title__menu .ms-menuentry:focus-visible {
  transform: translateX(8px);
}

.ms-title__menu .ms-menuentry:focus-visible::before {
  transform: scaleX(1);
}

.ms-title__menu .ms-menuentry:focus-visible .ms-menuentry__go {
  opacity: 1;
  transform: translateX(4px);
}

.ms-title__menu .ms-menuentry:not(:disabled):active {
  transform: translateX(8px) translateY(4px) scale(0.985);
  box-shadow: 0 1px 0 var(--stroke-ink), inset 0 0 0 2px var(--glass-line);
  transition-duration: var(--dur-press);
}

/* Each secondary door gets its own accent (icon tile + hover rim). */
.ms-title__menu [data-entry="online"] { --door: var(--sky); }
.ms-title__menu [data-entry="practice"] { --door: var(--mint); }
.ms-title__menu [data-entry="settings"] { --door: var(--mint); }
.ms-title__menu [data-entry="howToPlay"] { --door: var(--coral); }

.ms-title__menu .ms-btn--ghost .ms-menuentry__icon {
  color: var(--door, var(--gold));
  background: color-mix(in srgb, var(--door, var(--gold)) 16%, rgba(14, 11, 31, 0.4));
}

.ms-title__menu .ms-btn--ghost .ms-menuentry__go {
  color: var(--door, var(--gold));
}

/* The PLAY call to action: fat gold slab, display type, a shine sweep and
   a breathing halo — the one thing on the screen that asks to be pressed. */
.ms-title__menu .ms-btn--primary.ms-menuentry {
  grid-template-columns: 58px minmax(0, 1fr) 30px;
  min-height: 84px;
  margin-bottom: 6px;
  padding: 10px 18px 10px 12px;
  color: var(--stroke-ink);
  background: linear-gradient(180deg, #ffe587 0%, var(--gold) 52%, #ffab00 100%);
  box-shadow: 0 6px 0 var(--stroke-ink), 0 14px 26px rgba(14, 11, 31, 0.4), inset 0 3px 0 rgba(255, 255, 255, 0.55), inset 0 -4px 0 rgba(217, 138, 0, 0.55);
}

.ms-title__menu .ms-btn--primary.ms-menuentry::before {
  display: none;
}

/* The icon tile breathes (scale only) — a quiet "press me". */
.ms-title__menu .ms-btn--primary .ms-menuentry__icon {
  animation: ms-cta-breathe 2.4s ease-in-out infinite 1.6s;
}

@keyframes ms-cta-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07) rotate(-4deg); }
}

/* Shine sweep (clipped to the button by the ::after's own clip-path). */
.ms-title__menu .ms-btn--primary.ms-menuentry::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 13px;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0.7) 50%, rgba(255, 255, 255, 0) 62%);
  transform: translateX(-110%);
  animation: ms-cta-shine 3.8s ease-in-out infinite 1.9s;
  pointer-events: none;
}

@keyframes ms-cta-shine {
  0% { transform: translateX(-110%); }
  30%, 100% { transform: translateX(110%); }
}

.ms-title__menu .ms-btn--primary .ms-menuentry__icon {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  background: var(--stroke-ink);
  border-color: var(--stroke-ink);
  color: var(--gold);
  box-shadow: inset 0 -4px 0 rgba(255, 197, 49, 0.2);
}

.ms-title__menu .ms-btn--primary .ms-menuentry__icon .ms-icon {
  width: 32px;
  height: 32px;
}

.ms-title__menu .ms-btn--primary .ms-menuentry__label {
  font-size: 34px;
  letter-spacing: 0.04em;
}

.ms-title__menu .ms-btn--primary .ms-menuentry__sub {
  font-size: 14px;
  font-weight: var(--weight-semibold);
  opacity: 0.85;
}

.ms-title__menu .ms-btn--primary .ms-menuentry__go {
  width: 30px;
  height: 30px;
  color: var(--stroke-ink);
  opacity: 0.9;
  animation: ms-cta-nudge 1.6s ease-in-out infinite 1.6s;
}

.ms-title__menu .ms-btn--primary .ms-menuentry__go .ms-icon {
  width: 26px;
  height: 26px;
}

@keyframes ms-cta-nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(5px); }
}

@media (hover: hover) {
  .ms-title__menu .ms-btn--primary.ms-menuentry:not(:disabled):hover {
    transform: translateX(8px) scale(1.02);
    background: linear-gradient(180deg, #fff0b0 0%, #ffd24d 52%, #ffb31a 100%);
    box-shadow: 0 8px 0 var(--stroke-ink), 0 18px 30px rgba(14, 11, 31, 0.45), inset 0 3px 0 rgba(255, 255, 255, 0.6), inset 0 -4px 0 rgba(217, 138, 0, 0.55), 0 0 0 4px rgba(255, 248, 232, 0.35);
  }

  .ms-title__menu .ms-btn--primary.ms-menuentry:hover::before {
    transform: none;
  }
}

.ms-title__menu .ms-btn--primary.ms-menuentry:focus-visible::before {
  transform: none;
}

.ms-title__menu .ms-btn--primary.ms-menuentry:not(:disabled):active {
  transform: translateX(8px) translateY(5px) scale(0.98);
  box-shadow: 0 1px 0 var(--stroke-ink), inset 0 3px 0 rgba(255, 255, 255, 0.4);
}

@keyframes ms-entry-in {
  0% { opacity: 0; transform: translateX(-60px) scale(0.92); }
  100% { opacity: 1; transform: none; }
}

/* ---- bottom strip: tip + version (07.3 F4, UI-SPEC S4) -------------
   The foot spans the screen edge to edge; its --title-gx side padding puts
   the tip bubble's left edge on the menu column's left edge. The bubble
   takes min(560px, row − version chip − gap) (flex basis 560px, shrinks),
   the chip sits on the same row. Both share one bottom line (flex-end) at
   --sp-lg from the screen edge, so the taller tip never dips below the
   chip; both keep --title-gx to their side edge. */
.ms-title__foot {
  grid-area: foot;
  justify-self: stretch;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-md);
  margin: 0 calc(-1 * var(--title-gx));
  padding: var(--sp-md) var(--title-gx) max(var(--sp-lg), env(safe-area-inset-bottom, 0px));
  animation: ms-foot-in 500ms var(--ease-soft) backwards 1000ms;
}

@keyframes ms-foot-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

.ms-title__tip {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex: 0 1 560px;
  min-width: 0;
  max-width: 560px;
  margin: 0;
  padding: var(--sp-sm) var(--sp-md) var(--sp-sm) var(--sp-sm);
  border-radius: var(--radius-lg);
  background: rgba(18, 14, 39, 0.78);
  border: 2px solid rgba(255, 248, 232, 0.1);
  box-shadow: 0 3px 0 rgba(14, 11, 31, 0.6);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--paper);
}

.ms-title__tiptag {
  flex: none;
  padding: 4px 10px 5px;
  border-radius: 999px;
  background: var(--sky);
  border: 2px solid var(--stroke-ink);
  box-shadow: 0 2px 0 var(--stroke-ink);
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stroke-ink);
}

/* All tips share one cell: the stack is as tall as the longest tip, so
   rotating to a tip with more lines never moves the menu. */
.ms-title__tipstack {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
}

.ms-title__tiptext {
  grid-area: 1 / 1;
  align-self: center;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  visibility: hidden;
}

.ms-title__tiptext--on {
  visibility: visible;
}

.ms-title__tiptext--a {
  animation: ms-tip-in-a 420ms var(--ease-soft);
}

.ms-title__tiptext--b {
  animation: ms-tip-in-b 420ms var(--ease-soft);
}

@keyframes ms-tip-in-a {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes ms-tip-in-b {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.ms-title__meta {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--sp-md);
  position: relative;
}

/* "Install app": styled like the legal links beside it. */
.ms-title__install {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}

.ms-title__install:hover,
.ms-title__install:focus-visible {
  color: var(--paper);
  text-decoration: underline;
}

/* The install hint bubble rises above the foot row (never shifts layout). */
.ms-title__installhint {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: min(340px, 80vw);
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(14, 11, 30, 0.92);
  color: var(--paper);
  font-size: 13px;
  line-height: 1.4;
  z-index: 2;
}

.ms-title__legal {
  display: flex;
  gap: 12px;
  font-size: 12px;
}

.ms-title__legal a {
  color: var(--muted);
  text-decoration: none;
}

.ms-title__legal a:hover,
.ms-title__legal a:focus-visible {
  color: var(--paper);
  text-decoration: underline;
}

.ms-about__line {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.5;
}

.ms-about__line strong {
  color: var(--paper);
}

.ms-about__links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.ms-about__link {
  color: var(--paper);
}

.ms-title__version,
.ms-label.ms-title__version {
  position: static;
  flex: none;
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(18, 14, 39, 0.7);
  border: 2px solid rgba(255, 248, 232, 0.12);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  opacity: 1;
  text-shadow: none;
}

/* ---- return visits: calm, quick re-entry --------------------------- */
.ms-title--return .ms-title__letter,
.ms-title--return .ms-title__burst,
.ms-title--return .ms-title__tagline,
.ms-title--return .ms-title__foot {
  animation: none;
}

.ms-title--return .ms-title__mark {
  animation: ms-fade-rise 320ms var(--ease-soft) backwards;
}

.ms-title--return .ms-title__menu .ms-menuentry {
  animation-duration: 380ms;
  animation-delay: calc(60ms + var(--i) * 40ms);
}

@keyframes ms-fade-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ---- title: phones on their side (844×390) ------------------------- */
@media (max-height: 520px) and (orientation: landscape) {
  .ms-title {
    grid-template-rows: minmax(0, 1fr) auto auto minmax(0, 1fr) auto;
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    flex-direction: initial;
  }

  .ms-title__mark {
    --wm: clamp(40px, 13.5vh, 72px);
    margin-bottom: 30px;
  }

  .ms-title__tagline {
    margin-top: 6px;
  }

  .ms-title__menu {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: min(390px, 48vw);
  }

  .ms-title__menu .ms-btn--primary.ms-menuentry {
    grid-column: 1 / -1;
    grid-template-columns: 44px minmax(0, 1fr) 24px;
    min-height: 58px;
    margin-bottom: 0;
    padding: 6px 12px 6px 7px;
  }

  .ms-title__menu .ms-btn--primary .ms-menuentry__icon {
    width: 42px;
    height: 42px;
  }

  .ms-title__menu .ms-btn--primary .ms-menuentry__label {
    font-size: 24px;
  }

  .ms-title__menu .ms-btn--primary .ms-menuentry__sub {
    font-size: 12px;
  }

  /* Secondary doors become compact icon tiles (label only). */
  .ms-title__menu .ms-btn--ghost.ms-menuentry {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    row-gap: 3px;
    min-height: 60px;
    padding: 6px 4px 7px;
    text-align: center;
  }

  .ms-title__menu .ms-btn--ghost .ms-menuentry__icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .ms-title__menu .ms-btn--ghost .ms-menuentry__icon .ms-icon {
    width: 18px;
    height: 18px;
  }

  .ms-title__menu .ms-btn--ghost .ms-menuentry__label {
    font-size: 12px;
    white-space: nowrap;
  }

  .ms-title__menu .ms-btn--ghost .ms-menuentry__sub,
  .ms-title__menu .ms-btn--ghost .ms-menuentry__go {
    display: none;
  }

  .ms-title__menu .ms-btn--ghost.ms-menuentry:not(:disabled):hover,
  .ms-title__menu .ms-btn--ghost.ms-menuentry:focus-visible {
    transform: translateY(-3px);
  }

  .ms-title__tip {
    font-size: 12px;
  }

  .ms-title__version,
  .ms-label.ms-title__version {
    padding: 4px 9px;
    font-size: 11px;
  }

  .ms-title__tiptag {
    font-size: 11px;
    padding: 2px 8px 3px;
  }
}

/* ---- title: narrow portrait (390×844, 360×640) -----------------------
   Rows: account-chip safe row (padding) → lockup → the free STAGE band
   the map backdrop shows through →
   menu → tip + version. Every size keys off the viewport so nothing
   overlaps from 320×568 up to large phones. */
.ms-title__stage {
  display: none;
}

@media (max-width: 600px) and (orientation: portrait) {
  .ms-title {
    --chip-row: calc(var(--hit-target) + 14px);
    --title-gx: max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
    grid-template-rows: auto minmax(72px, 1fr) auto auto;
    grid-template-areas: "mark" "stage" "menu" "foot";
    justify-items: center;
    padding-top: calc(max(10px, env(safe-area-inset-top, 0px)) + var(--chip-row));
  }

  .ms-title__stage {
    display: block;
    grid-area: stage;
    justify-self: stretch;
    align-self: stretch;
    min-height: 0;
    pointer-events: none;
  }

  .ms-title__scrim {
    background:
      linear-gradient(180deg, rgba(18, 14, 39, 0.72) 0%, rgba(27, 23, 51, 0.2) 22%, rgba(27, 23, 51, 0) 36%, rgba(27, 23, 51, 0) 50%, rgba(18, 14, 39, 0.8) 64%, rgba(18, 14, 39, 0.94) 100%);
  }

  .ms-title__rays {
    left: calc(50% - 30vmax);
    top: calc(-30vmax + 14vh);
  }

  .ms-title__mark {
    --wm: clamp(44px, min(19vw, 9vh), 92px);
    align-items: center;
    margin-bottom: 0;
  }

  .ms-title__wordmark,
  .ms-boot__wordmark.ms-title__wordmark {
    align-items: center;
  }

  /* A flatter burst: its lower rays stay clear of the stage band. */
  .ms-title__burst {
    left: calc(50% - var(--wm) * 2.3);
    top: calc(50% - var(--wm) * 1.1);
    width: calc(var(--wm) * 4.6);
    height: calc(var(--wm) * 2.2);
  }

  .ms-title__tagline {
    margin: clamp(8px, 1.6vh, 14px) 0 0;
  }

  .ms-title__menu {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: min(100%, 440px);
  }

  .ms-title__menu .ms-btn--primary.ms-menuentry {
    grid-column: 1 / -1;
    grid-template-columns: 52px minmax(0, 1fr) 26px;
    column-gap: 12px;
    min-height: clamp(64px, 9vh, 76px);
    margin-bottom: 2px;
    padding: 8px 14px 8px 10px;
  }

  .ms-title__menu .ms-btn--primary .ms-menuentry__icon {
    width: 52px;
    height: 52px;
  }

  .ms-title__menu .ms-btn--primary .ms-menuentry__label {
    font-size: clamp(26px, 8vw, 30px);
  }

  .ms-title__menu .ms-btn--primary .ms-menuentry__sub {
    font-size: 13px;
    line-height: 1.25;
  }

  .ms-title__menu .ms-btn--ghost.ms-menuentry {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    row-gap: 4px;
    min-height: clamp(62px, 8.6vh, 76px);
    padding: 8px 4px 9px;
    text-align: center;
  }

  .ms-title__menu .ms-btn--ghost .ms-menuentry__icon {
    width: 34px;
    height: 34px;
  }

  .ms-title__menu .ms-btn--ghost .ms-menuentry__icon .ms-icon {
    width: 21px;
    height: 21px;
  }

  .ms-title__menu .ms-btn--ghost .ms-menuentry__label {
    font-size: clamp(11.5px, 3.4vw, 13px);
    white-space: nowrap;
  }

  .ms-title__menu .ms-btn--ghost .ms-menuentry__sub,
  .ms-title__menu .ms-btn--ghost .ms-menuentry__go {
    display: none;
  }

  .ms-title__menu .ms-btn--ghost.ms-menuentry:not(:disabled):hover,
  .ms-title__menu .ms-btn--ghost.ms-menuentry:focus-visible,
  .ms-title__menu .ms-btn--primary.ms-menuentry:focus-visible {
    transform: translateY(-3px);
  }

  .ms-title__menu .ms-menuentry,
  .ms-title__menu .ms-btn.ms-menuentry {
    animation-name: ms-fade-rise;
  }

  /* The foot stacks: the tip spans the full width between the gutters,
     the links and version chip sit centered under it. The tip text stays a
     notch smaller here so the longest DE tip keeps to two lines. */
  .ms-title__foot {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-sm);
    margin-top: 10px;
    padding-top: 0;
    padding-bottom: max(var(--sp-md), env(safe-area-inset-bottom, 0px));
  }

  .ms-title__tip {
    flex: none;
    max-width: none;
    font-size: 12.5px;
  }

  .ms-title__tiptag {
    font-size: 11px;
    padding: 3px 8px 4px;
  }

  .ms-title__version,
  .ms-label.ms-title__version {
    align-self: center;
    padding: 4px 8px;
    font-size: 11px;
  }

  /* Legal links, "install app" and the version chip: one centered row
     under the tip (wraps centered on the narrowest phones, never mid-link). */
  .ms-title__meta {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
  }

  .ms-title__legal {
    flex-wrap: wrap;
    justify-content: center;
  }

  .ms-title__legal > * {
    white-space: nowrap;
  }

  .ms-title__installhint {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
  }
}

/* Short portrait phones (360×640, 375×667): tighter rows. */
@media (max-width: 600px) and (max-height: 720px) and (orientation: portrait) {
  .ms-title {
    --chip-row: calc(var(--hit-target) + 10px);
    grid-template-rows: auto minmax(64px, 1fr) auto auto;
  }

  .ms-title__mark {
    --wm: clamp(42px, min(17vw, 8.6vh), 80px);
  }

  .ms-title__menu .ms-btn--primary.ms-menuentry {
    min-height: 62px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .ms-title__menu .ms-btn--primary .ms-menuentry__icon {
    width: 44px;
    height: 44px;
  }

  .ms-title__menu .ms-btn--ghost.ms-menuentry {
    min-height: 58px;
    padding: 6px 4px 7px;
  }

  .ms-title__menu .ms-btn--ghost .ms-menuentry__icon {
    width: 28px;
    height: 28px;
  }

  .ms-title__menu .ms-btn--ghost .ms-menuentry__icon .ms-icon {
    width: 18px;
    height: 18px;
  }

  .ms-title__foot {
    margin-top: 8px;
  }

  .ms-title__tip {
    font-size: 12px;
  }
}

/* ---- "your race" card over the map backdrop ------------------------ */
.ms-title__hero {
  position: absolute;
  right: max(var(--gutter), calc(env(safe-area-inset-right, 0px) + 16px));
  bottom: calc(max(12px, env(safe-area-inset-bottom, 0px)) + 64px);
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  grid-template-areas:
    "sigil text text"
    "ltag bar lvl"
    "xp xp xp"
    "note note note"
    "otag obar olvl"
    "oxp oxp oxp"
    "onote onote onote"
    "all all all";
  align-items: center;
  column-gap: 12px;
  row-gap: 6px;
  width: min(320px, 32vw);
  padding: 12px 14px 10px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--race-accent, var(--gold)) 26%, transparent) 0%, transparent 55%),
    var(--glass);
  border: 3px solid var(--stroke-ink);
  box-shadow: 0 6px 0 var(--stroke-ink), var(--shadow-drop), inset 0 0 0 2px var(--glass-line);
  animation: ms-hero-in 560ms var(--ease-back) backwards 1150ms;
}

@keyframes ms-hero-in {
  from { opacity: 0; transform: translateX(40px) rotate(3deg); }
  to { opacity: 1; transform: none; }
}

.ms-title--return .ms-title__hero {
  animation: ms-fade-rise 320ms var(--ease-soft) backwards;
}

.ms-title__herosigil {
  grid-area: sigil;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 15px;
  background: var(--race-accent, var(--gold));
  border: 3px solid var(--stroke-ink);
  box-shadow: 0 3px 0 var(--stroke-ink), inset 0 2px 0 rgba(255, 255, 255, 0.35);
  color: var(--stroke-ink);
  transform: rotate(-4deg);
}

.ms-title__herosigil .ms-icon {
  width: 30px;
  height: 30px;
}

.ms-title__herotext {
  grid-area: text;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ms-title__heroeyebrow {
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.ms-title__heroname {
  font-family: var(--font-display);
  font-size: clamp(18px, 1.7vw, 22px);
  line-height: 1.1;
  color: var(--paper);
  -webkit-text-stroke: 0.12em var(--stroke-ink);
  paint-order: stroke fill;
  text-shadow: 0 2px 0 var(--stroke-ink);
  overflow-wrap: anywhere;
}

.ms-title__herorole {
  font-size: 12px;
  line-height: 1.25;
  color: color-mix(in srgb, var(--race-accent, var(--gold)) 65%, #fff);
}

.ms-title__herolvl {
  grid-area: lvl;
  justify-self: end;
  align-self: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe587 0%, var(--gold) 100%);
  border: 2px solid var(--stroke-ink);
  box-shadow: 0 2px 0 var(--stroke-ink);
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--stroke-ink);
  white-space: nowrap;
}

.ms-title__heroxp {
  grid-area: bar;
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(14, 11, 31, 0.75);
  border: 2px solid var(--stroke-ink);
  overflow: hidden;
}

.ms-title__heroxpfill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep) 0%, var(--gold) 70%, #fff0b0 100%);
}

.ms-title__heroxptext {
  grid-area: xp;
  justify-self: end;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.ms-title__heroxptext:empty,
.ms-title__heroxptext[hidden],
.ms-title__heroxp[hidden] {
  display: none;
}

/* The ONLINE row's bar + XP line (the account's level, sky-tinted). */
.ms-title__heroxp.ms-title__heroxp--online {
  grid-area: obar;
}

.ms-title__heroxp--online .ms-title__heroxpfill {
  background: linear-gradient(90deg, #3d8fd1 0%, var(--sky) 70%, #d6efff 100%);
}

.ms-title__heroxptext.ms-title__heroxptext--online {
  grid-area: oxp;
}

/* Two separate progressions: a LOCAL row (browser-only) and an ONLINE row
   (the account), each behind its own tag. */
.ms-title__herotag {
  justify-self: start;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--gold);
}

.ms-title__herotag--local {
  grid-area: ltag;
}

.ms-title__herotag--online {
  grid-area: otag;
  color: var(--sky);
}

.ms-title__heroonlinenote {
  grid-area: onote;
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
}

.ms-title__herolvl.ms-title__herolvl--online {
  grid-area: olvl;
  background: linear-gradient(180deg, #a8dcff 0%, var(--sky) 100%);
}

.ms-title__herolvl.ms-title__herolvl--off {
  background: rgba(14, 11, 31, 0.6);
  color: var(--muted);
}

.ms-title__heroall {
  grid-area: all;
  margin-top: 2px;
  min-height: 36px;
  padding: 6px 12px;
  border: 2px solid var(--stroke-ink);
  border-radius: 12px;
  background: rgba(14, 11, 31, 0.55);
  box-shadow: 0 3px 0 var(--stroke-ink);
  color: var(--paper);
  font: var(--weight-semibold) 13px / 1.2 var(--font-ui);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 120ms ease-out, background-color 120ms ease-out;
}

.ms-title__heroall:hover {
  background: rgba(255, 197, 49, 0.18);
  transform: translateY(-1px);
}

.ms-title__heroall:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--stroke-ink);
}

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

.ms-title__herolocalnote {
  grid-area: note;
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
}

@media (max-width: 600px) {
  .ms-title__hero {
    display: none;
  }
}

/* Phones in landscape: a compact card in the free right half — only the
   two level rows with their XP (bar, LVL pill, "340 / 500 XP") and the
   "all levels" button; race identity and notes stay on the big screens. */
@media (max-height: 520px) and (min-width: 601px) {
  .ms-title__hero {
    grid-template-areas:
      "text text text"
      "ltag bar lvl"
      "xp xp xp"
      "otag obar olvl"
      "oxp oxp oxp"
      "all all all";
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: 8px;
    row-gap: 3px;
    width: min(260px, 34vw);
    padding: 8px 10px;
    border-radius: 14px;
    bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + 44px);
  }

  .ms-title__heroname {
    font-size: 15px;
  }

  .ms-title__herosigil,
  .ms-title__heroeyebrow,
  .ms-title__herorole,
  .ms-title__herolocalnote,
  .ms-title__heroonlinenote {
    display: none;
  }

  .ms-title__herolvl {
    padding: 2px 8px;
    font-size: 12px;
  }

  .ms-title__heroxp {
    height: 9px;
  }

  .ms-title__heroxptext {
    font-size: 10px;
  }

  .ms-title__heroall {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 12px;
  }
}

@media (max-width: 1100px) {
  .ms-title__hero {
    width: 280px;
  }
}

/* ================================================================== */
/* SCREEN CHROME — shared by every full menu screen                     */
/* ================================================================== */

.ms-screen {
  --gx-l: max(var(--gutter), calc(env(safe-area-inset-left, 0px) + 12px));
  --gx-r: max(var(--gutter), calc(env(safe-area-inset-right, 0px) + 12px));
  --gtop: max(20px, calc(env(safe-area-inset-top, 0px) + 12px));
  --gbot: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  gap: 16px;
  padding: var(--gtop) var(--gx-r) 0 var(--gx-l);
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(18, 14, 39, 0.72) 0%, rgba(27, 23, 51, 0.28) 16%, rgba(27, 23, 51, 0.12) 60%, rgba(18, 14, 39, 0.55) 100%),
    radial-gradient(120% 90% at 50% 50%, rgba(27, 23, 51, 0) 50%, rgba(18, 14, 39, 0.5) 100%);
  animation: ms-screen-fade 220ms var(--ease-out) both;
}

/* Screens without a footer band keep a bottom gutter. */
.ms-screen:not(:has(> .ms-screen__footer)) {
  padding-bottom: var(--gbot);
}

@keyframes ms-screen-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Leaving: fade + a hair of shrink (150 ms, the manager's timer). */
.ms-screen.ms-leaving,
.ms-title.ms-leaving {
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}

/* Entrance choreography: header drops in, content rises from the side we
   are travelling to, the footer band slides up — staggered. */
.ms-screen > .ms-screen__header {
  animation: ms-in-down 420ms var(--ease-back) backwards 40ms;
}

.ms-screen > :not(.ms-screen__header):not(.ms-screen__footer) {
  animation: ms-in-fwd 460ms var(--ease-soft) backwards 110ms;
}

.ms-screen > :not(.ms-screen__header):not(.ms-screen__footer) + :not(.ms-screen__header):not(.ms-screen__footer) {
  animation-delay: 170ms;
}

.ms-screen.ms-nav-back > :not(.ms-screen__header):not(.ms-screen__footer) {
  animation-name: ms-in-back;
}

.ms-screen > .ms-screen__footer {
  animation: ms-in-band 420ms var(--ease-soft) backwards 180ms;
}

@keyframes ms-in-down {
  from { opacity: 0; transform: translateY(-18px); }
  to { opacity: 1; transform: none; }
}

@keyframes ms-in-fwd {
  from { opacity: 0; transform: translateX(36px); }
  to { opacity: 1; transform: none; }
}

@keyframes ms-in-back {
  from { opacity: 0; transform: translateX(-36px); }
  to { opacity: 1; transform: none; }
}

@keyframes ms-in-band {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: none; }
}

/* ---- header: back pill · breadcrumb + title · aside ---------------- */
.ms-screen__header,
.ms-screen > .ms-screen__header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  min-height: 64px;
  margin: 0;
  flex: none;
}

.ms-screen__titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 0 1 auto;
}

.ms-crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 6px;
  margin: 0;
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 2px 0 var(--stroke-ink);
}

.ms-crumbs__item:first-child {
  color: rgba(255, 248, 232, 0.72);
}

.ms-crumbs__item + .ms-crumbs__item::before {
  content: "›";
  margin-right: 6px;
  color: rgba(255, 248, 232, 0.5);
}

/* Staging marker (dev.mythstrike.com only, see ui/devBuild.js): a red
   DEVELOPMENT tag beside the brand on the title screen and in every
   screen header. */
.ms-dev-tag {
  display: inline-block;
  padding: 0.2em 0.55em 0.25em;
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.16em;
  line-height: 1.1;
  text-transform: uppercase;
  color: #fff;
  background: #e0202e;
  border: 2px solid var(--stroke-ink);
  border-radius: 6px;
  text-shadow: none;
  box-shadow: 0 3px 0 var(--stroke-ink);
  white-space: nowrap;
}

.ms-crumbs__dev {
  font-size: 10px;
}

.ms-crumbs__dev + .ms-crumbs__item::before {
  content: none;
}

.ms-title__dev {
  position: relative;
  align-self: flex-start;
  margin: clamp(6px, 0.8vw, 12px) 0 0 0.3em;
  font-size: clamp(12px, 1.1vw, 18px);
  transform: rotate(-3deg);
}

.ms-screen__title,
.ms-screen .ms-screen__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: clamp(30px, 3.4vw, 50px);
  line-height: 1.02;
  letter-spacing: 0.01em;
  color: var(--paper);
  -webkit-text-stroke: 0.14em var(--stroke-ink);
  paint-order: stroke fill;
  text-shadow: 0 0.08em 0 var(--stroke-ink), 0 0.16em 0.14em rgba(14, 11, 31, 0.4);
  overflow-wrap: anywhere;
}

.ms-screen__aside {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
}

.ms-screen__aside:empty {
  display: none;
}

/* The back pill: round arrow disc + label + Esc keycap. */
.ms-backbtn,
.ms-screen__header .ms-backbtn.ms-btn {
  flex: none;
  gap: 10px;
  min-height: 52px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  border: 3px solid var(--stroke-ink);
  background: var(--glass);
  color: var(--paper);
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 4px 0 var(--stroke-ink), inset 0 0 0 2px var(--glass-line);
  transition: transform var(--dur-hover) var(--ease-spring), box-shadow var(--dur-hover) var(--ease-out), background-color var(--dur-hover);
}

.ms-backbtn > .ms-icon,
.ms-btn--icon.ms-backbtn .ms-icon {
  width: 36px;
  height: 36px;
  padding: 7px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--stroke-ink);
  border: 2px solid var(--stroke-ink);
  transition: transform 220ms var(--ease-spring);
}

.ms-keycap {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 24px;
  padding: 0 6px;
  border-radius: 7px;
  background: linear-gradient(180deg, #fff8e8 0%, #e6dcf5 100%);
  color: var(--stroke-ink);
  border: 2px solid var(--stroke-ink);
  box-shadow: 0 2px 0 var(--stroke-ink);
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: none;
}

@media (hover: hover) {
  .ms-screen__header .ms-backbtn.ms-btn:not(:disabled):hover {
    transform: translateX(-4px);
    background: var(--glass);
    box-shadow: 0 5px 0 var(--stroke-ink), inset 0 0 0 2px rgba(255, 248, 232, 0.22), 0 0 0 3px rgba(255, 197, 49, 0.3);
  }

  .ms-backbtn:hover > .ms-icon {
    transform: translateX(-3px) rotate(-6deg);
  }
}

.ms-screen__header .ms-backbtn.ms-btn:not(:disabled):active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--stroke-ink);
}

html.ms-touch .ms-backbtn__key {
  display: none;
}

/* Step pill (play flow) + connection chip (online). */
.ms-steppill,
.ms-statuschip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  margin: 0;
  padding: 6px 14px 6px 10px;
  border-radius: 999px;
  background: rgba(18, 14, 39, 0.82);
  border: 2px solid var(--stroke-ink);
  box-shadow: 0 3px 0 var(--stroke-ink), inset 0 0 0 1px var(--glass-line);
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: 13px;
  line-height: 1.2;
  color: var(--paper);
  white-space: nowrap;
}

.ms-steppill__dots {
  display: inline-flex;
  gap: 5px;
}

.ms-steppill__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 248, 232, 0.22);
  border: 2px solid var(--stroke-ink);
}

.ms-steppill__dot--done {
  background: var(--mint);
}

.ms-steppill__dot--on {
  background: var(--gold);
  transform: scale(1.25);
}

.ms-statuschip {
  max-width: min(360px, 44vw);
}

.ms-statuschip__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-statuschip__dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 2px var(--stroke-ink);
}

.ms-statuschip--ok .ms-statuschip__dot {
  background: var(--mint);
  animation: ms-dot-pulse 2s ease-in-out infinite;
}

.ms-statuschip--busy .ms-statuschip__dot {
  background: var(--gold);
  animation: ms-dot-pulse 0.9s ease-in-out infinite;
}

.ms-statuschip--bad .ms-statuschip__dot {
  background: var(--coral);
}

.ms-statuschip--bad {
  color: #ffd2d6;
}

@keyframes ms-dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.7; }
}

/* ---- footer band: flush on the screen edge ------------------------- */
.ms-screen > .ms-screen__footer,
.ms-screen__footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 14px;
  margin: auto calc(-1 * var(--gx-r)) 0 calc(-1 * var(--gx-l));
  padding: 12px var(--gx-r) var(--gbot) var(--gx-l);
  background: linear-gradient(180deg, rgba(42, 36, 80, 0.96) 0%, rgba(18, 14, 39, 0.98) 100%);
  border-top: 3px solid var(--stroke-ink);
  box-shadow: 0 -10px 28px rgba(14, 11, 31, 0.35), inset 0 2px 0 rgba(255, 248, 232, 0.07);
}

/* A gold hairline accent riding the top edge of the band. */
.ms-screen > .ms-screen__footer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 197, 49, 0) 0%, rgba(255, 197, 49, 0.55) 30%, rgba(255, 197, 49, 0.55) 70%, rgba(255, 197, 49, 0) 100%);
  pointer-events: none;
}

/* Left side of the band: secondary content (summary / roster / reset). */
.ms-screen__footer > :first-child:not(:last-child) {
  margin-right: auto;
}

.ms-screen__footnote {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  min-width: 0;
}

.ms-screen__footer .ms-btn--primary {
  min-height: 60px;
  min-width: 230px;
  padding: 8px 30px;
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: 24px;
  letter-spacing: 0.04em;
  border-radius: 16px;
  margin-left: 0;
}

.ms-matchsetup__summary,
.ms-screen__footer .ms-matchsetup__summary {
  display: inline-block;
  min-height: 0;
  margin: 0;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(255, 248, 232, 0.06);
  border: 2px solid rgba(255, 248, 232, 0.1);
  color: var(--paper);
  font-size: 14px;
  line-height: 1.3;
  box-shadow: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================================================================== */
/* BUTTON JUICE — every chunky button                                   */
/* ================================================================== */

.ms-btn--primary,
.ms-btn--ghost,
.ms-btn--danger {
  transition:
    transform var(--dur-hover) var(--ease-spring),
    box-shadow var(--dur-hover) var(--ease-out),
    filter var(--dur-hover) var(--ease-out),
    background-color var(--dur-hover) var(--ease-out);
}

.ms-btn--primary {
  background: linear-gradient(180deg, #ffe587 0%, var(--gold) 52%, #ffab00 100%);
  box-shadow: 0 5px 0 var(--stroke-ink), 0 10px 18px rgba(14, 11, 31, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.5), inset 0 -3px 0 rgba(217, 138, 0, 0.5);
}

@media (hover: hover) {
  .ms-btn--primary:not(:disabled):hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 0 var(--stroke-ink), 0 16px 24px rgba(14, 11, 31, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.6), inset 0 -3px 0 rgba(217, 138, 0, 0.5);
  }
}

.ms-btn--primary:not(:disabled):active,
.ms-btn--ghost:not(:disabled):active,
.ms-btn--danger:not(:disabled):active {
  transform: translateY(4px) scale(0.98);
  box-shadow: 0 1px 0 var(--stroke-ink);
  transition-duration: var(--dur-press);
}

.ms-btn:disabled {
  filter: saturate(0.4);
}

/* ================================================================== */
/* PANELS + CARDS — one glass recipe, one ink-card recipe              */
/* ================================================================== */

.ms-glass,
.ms-help__card,
.ms-settings__section,
.ms-raceselect__tree,
.ms-matchsetup > .ms-screen__body,
.ms-lobby-create > .ms-screen__body,
.ms-lobby-joincard,
.ms-lobby-list,
.ms-lobby-room__side > section,
.ms-lobby-room__roster,
.ms-lobby-host {
  background: var(--glass);
  border: 3px solid var(--stroke-ink);
  border-radius: 20px;
  box-shadow: 0 7px 0 var(--stroke-ink), var(--shadow-drop), inset 0 0 0 2px var(--glass-line);
  backdrop-filter: blur(8px);
}

/* Section eyebrows: gold caps with a short ink rule after them. */
.ms-screen__eyebrow,
.ms-label--eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.ms-screen__eyebrow::after {
  content: "";
  flex: 1 1 auto;
  height: 2px;
  min-width: 24px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 197, 49, 0.4), rgba(255, 197, 49, 0));
}

/* Ink cards: lift + tilt on hover, squash on press, gold ring + a check
   stamp when selected. */
.ms-card {
  position: relative;
  background: var(--card-rest);
  border: 3px solid var(--stroke-ink);
  border-radius: 16px;
  box-shadow: 0 5px 0 var(--stroke-ink), inset 0 0 0 2px var(--glass-line);
  transition:
    transform 200ms var(--ease-spring),
    box-shadow var(--dur-hover) var(--ease-out),
    background-color var(--dur-hover) var(--ease-out);
}

@media (hover: hover) {
  .ms-card:not(:disabled):hover {
    transform: translateY(-4px) rotate(-0.4deg);
    background: var(--card-hover);
    box-shadow: 0 9px 0 var(--stroke-ink), 0 14px 22px rgba(14, 11, 31, 0.3), inset 0 0 0 2px rgba(255, 248, 232, 0.16);
  }
}

.ms-card:not(:disabled):active {
  transform: translateY(3px) scale(0.985);
  box-shadow: 0 2px 0 var(--stroke-ink);
  transition-duration: var(--dur-press);
}

.ms-card--selected,
.ms-card--selected:hover {
  background: var(--card-on);
  box-shadow: 0 5px 0 var(--stroke-ink), 0 0 0 3px var(--gold), 0 0 24px rgba(255, 197, 49, 0.38), inset 0 0 0 2px rgba(255, 248, 232, 0.14);
}

/* The check stamp on a selected card (pops in). */
.ms-card--selected::after {
  content: "";
  position: absolute;
  top: -10px;
  right: -10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 12.5l4 4 8-9' fill='none' stroke='%230e0b1f' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / 70% no-repeat,
    var(--gold);
  border: 3px solid var(--stroke-ink);
  box-shadow: 0 2px 0 var(--stroke-ink);
  animation: ms-stamp 360ms var(--ease-back) both;
  pointer-events: none;
}

@keyframes ms-stamp {
  0% { opacity: 0; transform: scale(2) rotate(-30deg); }
  60% { opacity: 1; transform: scale(0.9) rotate(6deg); }
  100% { opacity: 1; transform: none; }
}

/* Segments + steppers + inputs: the same ink language. */
.ms-segment {
  min-height: 44px;
  border: 3px solid var(--stroke-ink);
  border-radius: 12px;
  background: var(--card-rest);
  color: var(--paper);
  box-shadow: 0 4px 0 var(--stroke-ink);
  transition: transform 180ms var(--ease-spring), background-color var(--dur-hover), box-shadow var(--dur-hover);
}

@media (hover: hover) {
  .ms-segment:not(:disabled):hover {
    transform: translateY(-2px);
    background: var(--card-hover);
  }
}

.ms-segment:not(:disabled):active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--stroke-ink);
}

.ms-segment--selected,
.ms-segment--selected:hover {
  background: linear-gradient(180deg, #ffe587 0%, var(--gold) 60%, #ffb000 100%);
  color: var(--stroke-ink);
}

.ms-stepper__btn {
  min-width: 48px;
  min-height: 48px;
  border: 3px solid var(--stroke-ink);
  border-radius: 12px;
  background: linear-gradient(180deg, #7fd0ff 0%, var(--sky) 100%);
  color: var(--stroke-ink);
  font-size: 22px;
  box-shadow: 0 4px 0 var(--stroke-ink);
  transition: transform 180ms var(--ease-spring), box-shadow var(--dur-hover);
}

.ms-stepper__btn:disabled {
  background: var(--card-rest);
  color: var(--muted);
  opacity: 0.6;
}

.ms-stepper__btn:not(:disabled):active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--stroke-ink);
}

/* 07.3 D-15 (UI-SPEC "Stepper anatomy"): ONE stepper for bots, rounds and
   the time limit — [−] [value well] [+]. The well is the sunken-track
   recipe; its fixed width (--stepper-value-w) fits "20 min" / "20 Min."
   so stepping never changes the row width. */
.ms-stepper {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
}

.ms-stepper__btn {
  width: 48px;
  height: 48px;
  padding: 0;
  font-family: var(--font-ui);
  line-height: 1;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.ms-stepper__btn[hidden] {
  display: none;
}

.ms-stepper__value {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--sp-xs);
  width: var(--stepper-value-w);
  height: 48px;
  padding: 0 var(--sp-xs);
  line-height: 42px;
  background: var(--grape-deep);
  border: 3px solid var(--stroke-ink);
  border-radius: 12px;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.25);
  color: var(--paper);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ms-stepper__num {
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--text-heading-size);
}

.ms-stepper__unit {
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: var(--text-label-size);
  color: var(--muted);
}

.ms-stepper__unit[hidden] {
  display: none;
}

.ms-input {
  min-height: 48px;
  padding: 8px 14px;
  border: 3px solid var(--stroke-ink);
  border-radius: 12px;
  background: var(--paper);
  color: var(--stroke-ink);
  font-size: 16px;
  box-shadow: inset 0 3px 0 rgba(14, 11, 31, 0.14), 0 3px 0 var(--stroke-ink);
}

/* ---- Form field (07.3-15, UI-SPEC S3 — F13/F14/F15) ------------------
   Every text input (account forms, lobby browser, create-lobby password)
   is built by ui/formField.js: label → input (4px), an inline error row
   that is `hidden` (no layout space) while empty, and a hint that floats
   as a bubble below the FOCUSED field without moving anything. The hint is
   linked with aria-describedby whether or not it is visible. */
.ms-field {
  position: relative;
  display: grid;
  gap: var(--sp-xs);
  min-width: 0;
}

.ms-field__label {
  font: var(--weight-regular, 400) 12px / 1.4 var(--font-ui);
  color: var(--muted);
}

.ms-field__hint {
  position: absolute;
  top: calc(100% + var(--sp-xs));
  left: 0;
  max-width: 100%;
  box-sizing: border-box;
  z-index: 2;
  pointer-events: none;
  padding: var(--sp-xs) var(--sp-sm);
  background: var(--grape-deep);
  border: 2px solid var(--stroke-ink);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 0 var(--stroke-ink);
  font: var(--weight-regular, 400) 12px / 1.4 var(--font-ui);
  color: var(--paper);
  opacity: 0;
  transition: opacity var(--dur-panel) ease-out;
}

.ms-field:focus-within .ms-field__hint {
  opacity: 1;
}

.ms-field--invalid .ms-field__hint {
  display: none;
}

.ms-field--invalid input {
  border-color: var(--danger);
}

.ms-field__error {
  margin: 0;
  font: var(--weight-regular, 400) 12px / 1.4 var(--font-ui);
  color: var(--danger);
}

.ms-field__error::before {
  content: "⚠ ";
}

.ms-field__error[hidden] {
  display: none !important;
}

/* The chat line shares the input recipe at the 44px floor and 16px text
   (no iOS zoom-on-focus); it adds no layout rows (UI-SPEC S3). */
.ms-chat__input {
  min-height: 44px;
  font-size: 16px;
}

/* Tabs: a sunken ink track, the active tab is a raised gold key. */
.ms-tabs {
  gap: 6px;
  padding: 5px;
  border-radius: 16px;
  background: rgba(14, 11, 31, 0.6);
  border: 2px solid var(--stroke-ink);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.25);
}

.ms-tabs__tab {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  transition: transform 180ms var(--ease-spring), background-color var(--dur-hover), color var(--dur-hover);
}

.ms-tabs__tab--on,
.ms-tabs__tab--on:hover {
  background: linear-gradient(180deg, #ffe587 0%, var(--gold) 60%, #ffb000 100%);
  color: var(--stroke-ink);
  box-shadow: 0 3px 0 var(--stroke-ink), 0 0 0 2px var(--stroke-ink);
}

html.ms-touch .ms-tabs__tab {
  min-height: 48px;
}

/* Content-heavy screens dim the live stage harder (panels stay readable
   over the map orbit). */
.ms-settings,
.ms-help,
.ms-lobby-browser,
.ms-lobby-create,
.ms-lobby-room {
  background:
    linear-gradient(180deg, rgba(18, 14, 39, 0.82) 0%, rgba(27, 23, 51, 0.6) 22%, rgba(27, 23, 51, 0.55) 70%, rgba(18, 14, 39, 0.75) 100%);
}

/* ================================================================== */
/* SETTINGS                                                             */
/* ================================================================== */

.ms-settings__body {
  padding: 6px 6px 18px 2px;
  gap: 16px;
}

.ms-settings__section {
  padding: 14px 18px 12px;
}

.ms-settings__title,
.ms-help__title {
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: 19px;
  letter-spacing: 0.05em;
  color: var(--gold);
  -webkit-text-stroke: 0.12em var(--stroke-ink);
  paint-order: stroke fill;
  text-shadow: 0 2px 0 var(--stroke-ink);
}

.ms-settings__title .ms-icon,
.ms-help__title > .ms-icon {
  width: 30px;
  height: 30px;
  padding: 5px;
  border-radius: 9px;
  background: rgba(255, 197, 49, 0.14);
  border: 2px solid var(--stroke-ink);
  color: var(--gold);
}

.ms-settings > .ms-screen__footer {
  justify-content: space-between;
}

/* Settings tabs (07.3 F5, UI-SPEC S2): General / Controls / Keybinds as
   three equal keys at the top, left-aligned to the body column. The bar
   sits outside the scrolling panels, so it never scrolls away. Touch
   height (48px) comes from html.ms-touch .ms-tabs__tab. */
.ms-settings__tabs {
  width: min(480px, 100%);
  align-self: flex-start;
  margin-bottom: var(--sp-md);
}

.ms-settings__tabs .ms-tabs__tab {
  flex: 1 1 0;
  min-width: 0;
}

/* One panel per tab; an inactive panel is `hidden` and takes no space. */
.ms-settings__body[hidden] {
  display: none !important;
}

/* General: SOUND | GRAPHICS | LANGUAGE as three columns from 1100px (short
   laptops included), one column below. */
.ms-settings__body.ms-settings__body--general {
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 1100px) {
  .ms-settings__body.ms-settings__body--general {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Controls: one column, never wider than a comfortable row. */
.ms-settings__body.ms-settings__body--controls {
  grid-template-columns: minmax(0, 1fr);
  max-width: 560px;
}

/* Keybinds: the rebinding section runs full width. */
.ms-settings__body.ms-settings__body--keybinds {
  grid-template-columns: minmax(0, 1fr);
}

/* Narrow portrait phones: the three keys stay on one row. */
@media (max-width: 600px) and (orientation: portrait) {
  .ms-settings__tabs .ms-tabs__tab {
    padding-inline: 6px;
    font-size: 13px;
  }
}

/* ================================================================== */
/* HOW TO PLAY                                                          */
/* ================================================================== */

.ms-help .ms-help__body {
  padding: 4px 6px 12px 2px;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) rgba(14, 11, 31, 0.35);
}

.ms-help__card {
  padding: 14px 18px 16px;
  gap: 8px;
}

/* Races & skills: an aligned card grid. Every card spans the same six
   subgrid rows (header · 3 skills · passive · ultimate), so within one grid
   row the cards share ONE height and every skill row lines up across. */
.ms-help__panel--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  grid-auto-rows: auto;
  column-gap: 16px;
  row-gap: 18px;
  align-items: stretch;
}

.ms-help__racecard {
  grid-row: span 6;
  display: grid;
  grid-template-rows: subgrid;
  row-gap: 8px;
  align-content: start;
  padding: 0 16px 14px;
  border-left: 3px solid var(--stroke-ink);
  overflow: hidden;
  transition: transform 220ms var(--ease-spring), box-shadow var(--dur-hover) var(--ease-out);
}

@media (hover: hover) {
  .ms-help__racecard:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 0 var(--stroke-ink), var(--shadow-drop), inset 0 0 0 2px var(--glass-line), 0 0 0 3px var(--race-accent, var(--gold));
  }
}

/* The header strip: accent-tinted band across the card top. */
.ms-help__racecard > .ms-help__racehead {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  margin: 0 -16px 4px;
  padding: 12px 16px 11px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--race-accent, var(--gold)) 34%, transparent) 0%, color-mix(in srgb, var(--race-accent, var(--gold)) 8%, transparent) 70%);
  border-bottom: 3px solid var(--stroke-ink);
  color: var(--paper);
  -webkit-text-stroke: 0;
  text-shadow: none;
  letter-spacing: 0;
}

.ms-help__racesigil {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--race-accent, var(--gold));
  border: 3px solid var(--stroke-ink);
  box-shadow: 0 3px 0 var(--stroke-ink), inset 0 2px 0 rgba(255, 255, 255, 0.35);
  color: var(--stroke-ink);
}

.ms-help__racesigil .ms-icon,
.ms-help__racecard .ms-help__title .ms-help__racesigil .ms-icon {
  width: 26px;
  height: 26px;
  color: var(--stroke-ink);
}

.ms-help__racenames {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ms-help__racename {
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1.05;
  color: var(--paper);
  -webkit-text-stroke: 0.12em var(--stroke-ink);
  paint-order: stroke fill;
  text-shadow: 0 2px 0 var(--stroke-ink);
}

.ms-help__racecard .ms-help__role {
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: 13px;
  line-height: 1.25;
  color: color-mix(in srgb, var(--race-accent, var(--gold)) 70%, #fff);
}

.ms-help__racehead > .ms-help__tag {
  align-self: start;
  margin: 2px 0 0;
}

/* Ability rows: icon · text; the tag drops to its own line under the text
   so rows never wrap raggedly. */
.ms-help__racecard .ms-help__ability {
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: start;
  column-gap: 10px;
  font-size: 14px;
  line-height: 1.38;
}

.ms-help__racecard .ms-help__ability .ms-help__bullet {
  width: 32px;
  height: 32px;
  color: var(--race-accent, var(--sky));
}

.ms-help__racecard .ms-help__abilitytext {
  display: block;
}

.ms-help__racecard .ms-help__abilitytext .ms-help__tag {
  display: table;
  margin: 4px 0 0;
}

.ms-help__ability--none {
  min-height: 0;
}

/* One column (phones): no row sharing to do — plain stacked cards. */
@media (max-width: 640px) {
  .ms-help__racecard {
    grid-row: auto;
    display: flex;
    flex-direction: column;
  }

  .ms-help__ability--none {
    display: none;
  }
}

/* The ultimate row sits on a tinted plate at the card's foot. */
.ms-help__racecard .ms-help__ability--ult {
  margin: 2px -8px 0;
  padding: 8px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--race-accent, var(--gold)) 13%, rgba(14, 11, 31, 0.5));
  border: 2px solid color-mix(in srgb, var(--race-accent, var(--gold)) 45%, var(--stroke-ink));
}

.ms-help__racecard .ms-help__ability--passive {
  margin: 0 -8px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(255, 248, 232, 0.05);
}

.ms-help__tabs .ms-tabs__tab {
  min-height: 42px;
}

/* ================================================================== */
/* RACE SELECT                                                          */
/* ================================================================== */

.ms-raceselect {
  gap: 14px 18px;
  padding-bottom: 0;
}

.ms-raceselect .ms-racecard {
  transition: transform 220ms var(--ease-spring), box-shadow var(--dur-hover) var(--ease-out), background-color var(--dur-hover);
  box-shadow: 0 5px 0 var(--stroke-ink), inset 5px 0 0 var(--race-accent, var(--gold)), inset 0 0 0 2px var(--glass-line);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--race-accent, var(--gold)) 16%, transparent) 0%, transparent 45%),
    var(--glass);
}

@media (hover: hover) {
  .ms-raceselect .ms-racecard:hover {
    transform: translateY(-3px) rotate(-0.5deg);
    background:
      linear-gradient(135deg, color-mix(in srgb, var(--race-accent, var(--gold)) 28%, transparent) 0%, transparent 55%),
      var(--glass);
    box-shadow: 0 8px 0 var(--stroke-ink), 0 12px 20px rgba(14, 11, 31, 0.3), inset 5px 0 0 var(--race-accent, var(--gold)), inset 0 0 0 2px rgba(255, 248, 232, 0.16);
  }
}

.ms-raceselect .ms-racecard:active {
  transform: translateY(2px) scale(0.98);
  transition-duration: var(--dur-press);
}

.ms-raceselect .ms-racecard.ms-raceselect__card--selected,
.ms-raceselect .ms-racecard.ms-raceselect__card--selected:hover {
  transform: translateY(-2px);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--race-accent, var(--gold)) 38%, transparent) 0%, transparent 60%),
    #3a3170;
  box-shadow:
    0 6px 0 var(--stroke-ink),
    0 0 0 3px var(--gold),
    0 0 26px rgba(255, 197, 49, 0.4),
    inset 7px 0 0 var(--race-accent, var(--gold));
  animation: ms-pick 380ms var(--ease-back);
}

@keyframes ms-pick {
  0% { transform: translateY(-2px) scale(0.94); }
  55% { transform: translateY(-2px) scale(1.04); }
  100% { transform: translateY(-2px) scale(1); }
}

.ms-raceselect__tree {
  padding: 12px 14px;
  align-self: start;
  max-height: 100%;
}

.ms-raceselect > .ms-screen__footer {
  justify-content: space-between;
}

.ms-raceselect__roster {
  flex: 0 1 auto;
  justify-content: flex-start;
  margin-left: 0;
}

/* Touch: every footer control keeps a 48 px target. */
html.ms-touch .ms-screen__footer .ms-lobby-toggle__btn,
html.ms-touch .ms-screen__footer .ms-btn {
  min-height: 48px;
}

/* ================================================================== */
/* MATCH SETUP                                                          */
/* ================================================================== */

.ms-matchsetup {
  gap: 14px 24px;
}

.ms-matchsetup > .ms-screen__body {
  padding: 18px 20px;
  gap: 18px;
  align-self: start;
  max-height: 100%;
}

.ms-card--map {
  padding: 8px;
  overflow: visible;
  position: relative;
}

/* Map/mode filter: a map the selected mode cannot use leaves the grid. */
.ms-card--unavailable,
.ms-card[hidden] {
  display: none !important;
}

/* "TDM only" tag on a single-mode map card (top-right sticker). */
.ms-card__tag {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 1px 8px;
  border: 2px solid var(--stroke-ink);
  border-radius: 999px;
  background: var(--gold);
  color: var(--stroke-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}

.ms-card__thumb {
  border-radius: 10px;
  border: 2px solid var(--stroke-ink);
  overflow: hidden;
  transition: transform 300ms var(--ease-soft);
}

.ms-card--mode .ms-icon {
  width: 34px;
  height: 34px;
  padding: 5px;
  border-radius: 10px;
  background: rgba(255, 197, 49, 0.14);
  border: 2px solid var(--stroke-ink);
}

.ms-matchsetup > .ms-screen__footer {
  justify-content: space-between;
}

/* ================================================================== */
/* SHARED MATCH-SETTINGS FORM (07.3 D-16, UI-SPEC S1) — .ms-msf         */
/* One component, three hosts (solo setup now; create lobby + lobby    */
/* room in 07.3-10). ≥1001px: two columns — MODE over MAP on the left, */
/* BOTS over RULES (then the host's LOBBY block) on the right. ≤1000px: */
/* one column MODE → MAP → BOTS → RULES → LOBBY; the body scrolls and  */
/* the footer stays sticky. Existing tokens only.                      */
/* ================================================================== */

/* The solo host: the form owns the width, centred (the old left-column
   body left a dead right half next to the 3D preview). */
.ms-matchsetup {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "header"
    "body"
    "footer";
}

.ms-matchsetup > .ms-screen__body {
  justify-self: center;
  width: min(1180px, 100%);
}

.ms-msf {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "modes"
    "maps"
    "bots"
    "rules"
    "lobby";
  align-content: start;
  gap: var(--sp-md) var(--sp-lg);
  width: min(1180px, 100%);
  margin-inline: auto;
  min-width: 0;
}

.ms-msf__section--mode { grid-area: modes; }
.ms-msf__section--map { grid-area: maps; }
.ms-msf__section--bots { grid-area: bots; }
.ms-msf__section--rules { grid-area: rules; }
/* The online hosts' separate LOBBY block (07.3-10) slots in after RULES. */
.ms-msf > .ms-msf__lobby { grid-area: lobby; }
/* The "no bots online" line under the LOBBY eyebrow. */
.ms-lobby-note {
  margin: 0;
  color: var(--gold);
}

/* Grid areas must be rectangles, so MAP spans the lower left rows while
   BOTS, RULES and the LOBBY block stack on the right. BOTS also spans the
   top of MAP's rows so the MODE row stays as tall as its cards (a shared
   row would stretch the mode cards to the BOTS height). */
@media (min-width: 1001px) {
  .ms-msf {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
      "modes bots"
      "maps bots"
      "maps rules"
      "maps lobby";
  }
}

/* Online hosts (bots: false) have no BOTS section: RULES takes its place. */
.ms-msf--nobots {
  grid-template-areas:
    "modes"
    "maps"
    "rules"
    "lobby";
}
@media (min-width: 1001px) {
  .ms-msf--nobots {
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "modes rules"
      "maps rules"
      "maps lobby";
  }
}

/* Each section: the eyebrow, then its content, --sp-sm apart. */
.ms-msf__section {
  min-width: 0;
  gap: var(--sp-sm);
}

.ms-msf__section--bots,
.ms-msf__section--rules,
.ms-msf__lobby,
.ms-msf__slot {
  display: flex;
  flex-direction: column;
}

.ms-msf__section--bots,
.ms-msf__section--rules,
.ms-msf__lobby {
  gap: 0;
}

.ms-msf__section--bots > .ms-screen__eyebrow,
.ms-msf__section--rules > .ms-screen__eyebrow,
.ms-msf__lobby > .ms-screen__eyebrow {
  margin-bottom: var(--sp-sm);
}

/* LOBBY block rows (07.3-10): the password field and the room host's
   Balance teams key sit on the same row rhythm as the switch rows. */
.ms-msf__lobby > .ms-lobby-field,
.ms-msf__lobby > .ms-msf__lobbyaction {
  padding: var(--sp-sm) 0;
  border-top: 2px solid rgba(255, 248, 232, 0.07);
}

.ms-msf__lobby > .ms-msf__lobbyaction {
  display: flex;
  justify-content: flex-end;
}

/* Rows: the .ms-setting recipe, hairline between rows, none under the
   eyebrow. The Time limit / Rounds-to-win slot shows exactly one row. */
.ms-msf__section > .ms-screen__eyebrow + .ms-setting {
  border-top: none;
}

.ms-msf [hidden] {
  display: none !important;
}

.ms-msf .ms-setting--stepper .ms-setting__control,
.ms-msf .ms-setting--toggle .ms-setting__control {
  justify-content: flex-end;
}

/* Segmented rows: label on top, one connected full-width control. */
.ms-msf .ms-setting--choice .ms-seg {
  display: flex;
  width: 100%;
}

.ms-msf .ms-setting--choice .ms-seg__opt {
  flex: 1;
  min-height: 40px;
}

/* A disabled switch (FFA friendly fire, read-only) reads as inert. */
.ms-msf .ms-switch:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Map cards: wide enough that a Titan One map name ("Himmelsgarten")
   never breaks mid-word; the grid wraps to a second row instead. */
.ms-msf .ms-matchsetup__maps {
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
  /* A taller right column (the lobby hosts' LOBBY block) never stretches
     the map cards — they keep the solo height in every host. */
  align-content: start;
}

/* Short desktop viewports (720p): the two map rows fit without the blurb
   (name, thumbnail and footprint still identify every map). */
@media (min-width: 1001px) and (max-height: 820px) {
  .ms-msf .ms-card--map .ms-card__blurb {
    display: none;
  }

  .ms-msf .ms-card__thumb img {
    max-height: 60px;
  }
}

/* Map thumbnails are <img> data: URLs (no inline markup). */
.ms-msf .ms-card__thumb {
  display: block;
  width: 100%;
}

.ms-msf .ms-card__thumb img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72px;
  object-fit: cover;
}

/* Read-only (lobby joiners): same DOM; the unselected choices dim, no
   control takes pointer input, nothing lifts on hover. */
.ms-msf--readonly .ms-card,
.ms-msf--readonly .ms-seg__opt {
  pointer-events: none;
  cursor: default;
}

.ms-msf--readonly .ms-card:not(.ms-card--selected),
.ms-msf--readonly .ms-seg__opt:not(.ms-seg__opt--on) {
  opacity: 0.6;
}

/* Phones (≤480px): stepper rows stack — label on top, stepper
   left-aligned below — so a long DE label never squeezes the control. */
@media (max-width: 480px) {
  .ms-msf .ms-setting--stepper {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-xs);
  }

  .ms-msf .ms-setting--stepper .ms-setting__control {
    justify-content: flex-start;
  }

  /* Two map cards per row: the recipe's 16px name size keeps long map
     names ("Himmelsgarten") on one line. */
  .ms-msf .ms-card__name--map {
    font-size: 16px;
  }
}

/* ================================================================== */
/* LOBBIES — browser · create · room                                   */
/* ================================================================== */

/* Shared: kill the old centred-column glass on every direct child. */
.ms-screen.ms-lobby-browser > *,
.ms-screen.ms-lobby-create > *,
.ms-screen.ms-lobby-room > * {
  width: auto;
  margin-left: 0;
  margin-right: 0;
}

.ms-screen.ms-lobby-browser > .ms-screen__footer,
.ms-screen.ms-lobby-create > .ms-screen__footer,
.ms-screen.ms-lobby-room > .ms-screen__footer {
  margin: auto calc(-1 * var(--gx-r)) 0 calc(-1 * var(--gx-l));
  padding: 12px var(--gx-r) var(--gbot) var(--gx-l);
  background: linear-gradient(180deg, rgba(42, 36, 80, 0.96) 0%, rgba(18, 14, 39, 0.98) 100%);
  justify-content: space-between;
}

.ms-screen.ms-lobby-browser > .ms-screen__body,
.ms-screen.ms-lobby-room > .ms-screen__body {
  background: none;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
  border-radius: 0;
}

/* ---- browser: join card | open-lobby list ------------------------- */
.ms-screen.ms-lobby-browser > .ms-screen__body {
  display: grid;
  grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding-bottom: 16px;
}

.ms-lobby-joincard {
  display: flex;
  flex-direction: column;
  gap: var(--form-field-gap);
  padding: 18px 20px 20px;
}

.ms-lobby-join {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 07.3-15 (UI-SPEC S3): code | password are .ms-field cells on the form
   rhythm; the Join key sits one actions gap (24px) under them. */
.ms-lobby-join__row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: var(--form-field-gap);
}

.ms-lobby-join__row > .ms-btn {
  grid-column: 1 / -1;
  margin-top: calc(var(--form-actions-gap) - var(--form-field-gap));
  min-height: 52px;
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: 20px;
}

.ms-input--code {
  width: auto;
  font-size: 20px;
  letter-spacing: 0.2em;
}

.ms-lobby-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px 20px;
  min-height: 240px;
}

.ms-lobby-list__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ms-lobby-list__head > .ms-screen__eyebrow {
  flex: 1 1 auto;
}

.ms-lobby-list__rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ms-lobby-list__empty {
  display: grid;
  place-items: center;
  min-height: 150px;
  margin: 0;
  border-radius: 16px;
  border: 2px dashed rgba(255, 248, 232, 0.16);
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

.ms-lobby-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 8px 16px;
  border: 3px solid var(--stroke-ink);
  border-radius: 14px;
  background: var(--card-rest);
  box-shadow: 0 4px 0 var(--stroke-ink);
  color: var(--paper);
  cursor: pointer;
  transition: transform 200ms var(--ease-spring), background-color var(--dur-hover);
}

@media (hover: hover) {
  .ms-lobby-row:hover {
    transform: translateX(6px);
    background: var(--card-hover);
  }
}

.ms-lobby-row__code {
  font-size: 20px;
  letter-spacing: 0.14em;
  color: var(--gold);
}

/* ---- create: the glass panel around the SHARED form (07.3-10) ------ */
/* The .ms-msf grid owns the two columns (mode + map | bots + rules +
   LOBBY) exactly as in the solo Custom Match screen. */
.ms-screen.ms-lobby-create > .ms-screen__body {
  display: block;
  width: min(1180px, 100%);
  margin: 0 auto 16px;
  padding: 14px 20px; /* the solo panel's padding */
}

.ms-lobby-toggle > .ms-label {
  font-size: 15px;
  font-weight: var(--weight-semibold);
  color: var(--paper);
}

.ms-lobby-toggle__btn {
  min-width: 76px;
}

/* ---- room: share + settings | teams, host panel under -------------- */
.ms-screen.ms-lobby-room > .ms-screen__body {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  /* 07.3-10: the shared match-settings form spans the full width under
     share/summary | teams — the same two-column form as solo + create. */
  grid-template-areas:
    "side roster"
    "host host";
  grid-template-rows: auto auto;
  align-items: start;
  gap: 18px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding-bottom: 16px;
}

.ms-lobby-room__side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.ms-lobby-room__side > section,
.ms-lobby-room__roster,
.ms-lobby-host {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 18px;
  min-width: 0;
}

.ms-lobby-room__roster { grid-area: roster; }
.ms-lobby-host { grid-area: host; }

.ms-lobby-room__code.ms-screen__title {
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  color: var(--gold);
}

.ms-lobby-share__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ms-lobby-share__code {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 64px;
  border-radius: 14px;
  background: rgba(14, 11, 31, 0.6);
  border: 3px dashed rgba(255, 197, 49, 0.55);
  font-size: 34px;
  letter-spacing: 0.3em;
  color: var(--gold);
}

.ms-lobby-share__status {
  grid-column: 1 / -1;
  min-height: 1.2em;
  color: var(--mint);
}

.ms-lobby-settings {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ms-lobby-settings__row {
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 248, 232, 0.05);
  color: var(--paper);
  font-size: 13px;
}

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

.ms-lobby-team {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
  padding: 12px;
  border-radius: 16px;
  border: 3px solid var(--stroke-ink);
  background: rgba(14, 11, 31, 0.45);
  box-shadow: inset 0 4px 0 var(--team-color, var(--sky));
}

.ms-lobby-team--alpha { --team-color: var(--team-a, #ffd21a); }
.ms-lobby-team--bravo { --team-color: var(--team-b, #6a95ff); }

.ms-lobby-team--self {
  box-shadow: inset 0 4px 0 var(--team-color, var(--sky)), 0 0 0 3px var(--gold);
}

.ms-lobby-team__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ms-lobby-team__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: 22px;
  color: var(--team-color, var(--paper));
  -webkit-text-stroke: 0.1em var(--stroke-ink);
  paint-order: stroke fill;
}

.ms-lobby-team__pick {
  min-height: 44px;
  padding: 6px 14px;
  font-size: 13px;
}

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

/* The lobby chat rides the footer band's left end (its own region). */
.ms-chat.ms-chat--lobby {
  left: var(--gutter);
  bottom: max(18px, calc(env(safe-area-inset-bottom, 0px) + 14px));
  width: min(320px, calc(100vw - 32px));
}

.ms-screen.ms-lobby-room > .ms-screen__footer {
  padding-left: calc(var(--gx-l) + min(320px, 40vw) + 16px);
}

/* ================================================================== */
/* RESULTS · PAUSE · CONFIRM — cards pop in                             */
/* ================================================================== */

.ms-results__card,
.ms-pause__card,
.ms-recap__card {
  background: var(--glass);
  border: 3px solid var(--stroke-ink);
  border-radius: 22px;
  box-shadow: 0 8px 0 var(--stroke-ink), 0 24px 44px rgba(14, 11, 31, 0.45), inset 0 0 0 2px var(--glass-line);
}

.ms-results__card,
.ms-pause:not(.ms-hidden) .ms-pause__card,
.ms-recap:not(.ms-hidden) .ms-recap__card {
  animation: ms-card-pop 420ms var(--ease-back) backwards;
}

@keyframes ms-card-pop {
  0% { opacity: 0; transform: translateY(24px) scale(0.94); }
  100% { opacity: 1; transform: none; }
}

.ms-results__heading,
.ms-pause__heading {
  -webkit-text-stroke: 0.12em var(--stroke-ink);
  paint-order: stroke fill;
  padding-left: 0.12em;
}

.ms-pause__actions .ms-btn,
.ms-results__actions .ms-btn {
  border-radius: 14px;
}

@media (hover: hover) {
  .ms-pause__actions .ms-btn--ghost:not(:disabled):hover {
    transform: translateX(6px);
  }
}

/* ================================================================== */
/* SHOP (B) + SKILLS (K) — overlay panels share the pop-in               */
/* ================================================================== */

.ms-shop:not(.ms-hidden) .ms-shop__panel,
.ms-skillscreen:not(.ms-hidden) .ms-skillscreen__panel {
  animation: ms-card-pop 320ms var(--ease-back) backwards;
}

.ms-shopcard {
  transition: transform 180ms var(--ease-spring), box-shadow var(--dur-hover) var(--ease-out), background-color var(--dur-hover);
}

@media (hover: hover) {
  .ms-shopcard:not(:disabled):hover {
    transform: translateY(-3px);
  }
}

.ms-shopcard:not(:disabled):active {
  transform: translateY(2px) scale(0.98);
  transition-duration: var(--dur-press);
}

/* ================================================================== */
/* STAGGERED CARD ENTRANCES                                            */
/* ================================================================== */

.ms-raceselect__cards > *,
.ms-matchsetup__maps > .ms-card,
.ms-matchsetup__modes > .ms-card,
.ms-help__panel--grid > .ms-help__racecard,
.ms-help__panel--cols > .ms-help__col > *,
.ms-settings__body > .ms-settings__section {
  animation: ms-card-rise 440ms var(--ease-back) backwards;
  animation-delay: 160ms;
}

:is(.ms-raceselect__cards, .ms-matchsetup__maps, .ms-help__panel--grid, .ms-settings__body) > :nth-child(2) { animation-delay: 200ms; }
:is(.ms-raceselect__cards, .ms-matchsetup__maps, .ms-help__panel--grid, .ms-settings__body) > :nth-child(3) { animation-delay: 240ms; }
:is(.ms-raceselect__cards, .ms-matchsetup__maps, .ms-help__panel--grid, .ms-settings__body) > :nth-child(4) { animation-delay: 280ms; }
:is(.ms-raceselect__cards, .ms-matchsetup__maps, .ms-help__panel--grid, .ms-settings__body) > :nth-child(5) { animation-delay: 320ms; }
:is(.ms-raceselect__cards, .ms-matchsetup__maps, .ms-help__panel--grid, .ms-settings__body) > :nth-child(6) { animation-delay: 360ms; }
:is(.ms-raceselect__cards, .ms-matchsetup__maps, .ms-help__panel--grid, .ms-settings__body) > :nth-child(7) { animation-delay: 400ms; }
:is(.ms-raceselect__cards, .ms-matchsetup__maps, .ms-help__panel--grid, .ms-settings__body) > :nth-child(n + 8) { animation-delay: 440ms; }

@keyframes ms-card-rise {
  0% { opacity: 0; transform: translateY(22px) scale(0.95); }
  100% { opacity: 1; transform: none; }
}

/* A picked race card keeps its own pop (the selected rule's animation). */
.ms-raceselect__cards > .ms-racecard.ms-raceselect__card--selected {
  animation: ms-pick 380ms var(--ease-back);
}

/* ================================================================== */
/* PHONES — short landscape (844×390) + narrow portrait (390×844)      */
/* ================================================================== */

@media (max-height: 520px) and (orientation: landscape) {
  .ms-screen {
    --gtop: max(8px, calc(env(safe-area-inset-top, 0px) + 6px));
    --gbot: max(8px, env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }

  .ms-screen__header,
  .ms-screen > .ms-screen__header {
    min-height: 48px;
    gap: 12px;
  }

  .ms-backbtn,
  .ms-screen__header .ms-backbtn.ms-btn {
    min-height: 48px;
    padding: 4px 12px 4px 4px;
    font-size: 13px;
  }

  .ms-backbtn > .ms-icon,
  .ms-btn--icon.ms-backbtn .ms-icon {
    width: 34px;
    height: 34px;
  }

  .ms-crumbs {
    font-size: 11px;
  }

  .ms-screen__title,
  .ms-screen .ms-screen__title {
    font-size: 24px;
  }

  .ms-screen > .ms-screen__footer,
  .ms-screen__footer,
  .ms-screen.ms-lobby-browser > .ms-screen__footer,
  .ms-screen.ms-lobby-create > .ms-screen__footer,
  .ms-screen.ms-lobby-room > .ms-screen__footer {
    padding-top: 6px;
    padding-bottom: var(--gbot);
  }

  .ms-screen__footer .ms-btn--primary {
    min-height: 48px;
    min-width: 170px;
    font-size: 19px;
    padding: 4px 20px;
  }

  .ms-steppill,
  .ms-statuschip {
    min-height: 30px;
    padding: 3px 10px 3px 8px;
    font-size: 12px;
  }

  .ms-screen.ms-lobby-browser > .ms-screen__body,
  .ms-screen.ms-lobby-room > .ms-screen__body {
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  }

  .ms-screen.ms-lobby-create > .ms-screen__body {
    padding: 12px 14px 14px;
  }

  .ms-matchsetup__maps {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .ms-msf .ms-card--map .ms-card__thumb {
    height: 58px;
  }

  .ms-msf .ms-card--map .ms-card__thumb img {
    width: 100%;
    height: 100%;
    max-height: none;
  }

  .ms-msf .ms-card--map .ms-card__blurb {
    display: none;
  }

  .ms-matchsetup > .ms-screen__body {
    padding: 12px 14px;
    gap: 10px;
  }

  .ms-lobby-share__code {
    min-height: 48px;
    font-size: 26px;
  }

  /* Pause card: compact enough to fit a 390 px tall phone whole. */
  .ms-pause__card {
    max-height: calc(100dvh - 16px);
    padding: 12px 18px 14px;
    gap: 8px;
  }

  .ms-pause__heading {
    font-size: 26px;
  }

  .ms-pause__actions {
    gap: 8px;
  }

  .ms-pause__actions .ms-btn,
  .ms-pause__actions .ms-btn--primary {
    min-height: 48px;
  }
}

.ms-lobby-share__row > .ms-btn {
  min-height: 48px;
  padding: 6px 10px;
  font-size: 13px;
  white-space: nowrap;
}

@media (max-width: 600px) and (orientation: portrait) {
  .ms-screen {
    gap: 12px;
  }

  .ms-screen__header,
  .ms-screen > .ms-screen__header {
    flex-wrap: wrap;
    gap: 10px 12px;
    min-height: 0;
  }

  .ms-backbtn__label {
    display: none;
  }

  .ms-backbtn,
  .ms-screen__header .ms-backbtn.ms-btn {
    min-width: 52px;
    padding: 5px;
    justify-content: center;
  }

  .ms-screen__titles {
    flex: 1 1 0;
  }

  .ms-screen__title,
  .ms-screen .ms-screen__title {
    font-size: clamp(24px, 7.4vw, 32px);
  }

  .ms-screen__aside {
    flex: 1 1 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

  .ms-screen > .ms-screen__footer,
  .ms-screen__footer,
  .ms-screen.ms-lobby-browser > .ms-screen__footer,
  .ms-screen.ms-lobby-create > .ms-screen__footer,
  .ms-screen.ms-lobby-room > .ms-screen__footer {
    flex-wrap: wrap;
    gap: 10px;
  }

  .ms-screen__footer > :first-child:not(:last-child) {
    flex: 1 1 100%;
    margin-right: 0;
  }

  .ms-screen__footer .ms-btn--primary {
    flex: 1 1 100%;
    min-width: 0;
  }

  .ms-screen.ms-lobby-browser > .ms-screen__body,
  .ms-screen.ms-lobby-room > .ms-screen__body,
  .ms-screen.ms-lobby-create > .ms-screen__body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: none;
  }

  .ms-screen.ms-lobby-room > .ms-screen__body > *,
  .ms-screen.ms-lobby-create > .ms-screen__body > * {
    grid-area: auto;
  }

  .ms-screen.ms-lobby-create > .ms-screen__body {
    padding: 14px;
  }

  .ms-lobby-teams {
    grid-template-columns: minmax(0, 1fr);
  }

  .ms-lobby-team {
    min-height: 0;
  }

  .ms-chat.ms-chat--lobby {
    bottom: calc(var(--gbot, 16px) + 84px);
  }

  .ms-screen.ms-lobby-room > .ms-screen__body {
    padding-bottom: 76px;
  }

  /* Race select: ONE scrolling column — the two-up card grid at its
     natural height, then the tree panel, the footer band sticky below. */
  .ms-screen.ms-raceselect {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .ms-raceselect > .ms-raceselect__cards {
    flex: none;
    max-height: none;
    overflow: visible;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 2px;
  }

  .ms-raceselect > .ms-raceselect__tree {
    flex: none;
    max-height: none;
    overflow: visible;
  }

  .ms-raceselect .ms-racecard__skills {
    display: none;
  }

  .ms-screen.ms-lobby-room > .ms-screen__footer {
    padding-left: var(--gx-l);
  }
}

/* ================================================================== */
/* PHONE + TABLET POLISH — nothing overlaps, nothing truncates          */
/* ================================================================== */

/* Auto-fit grids never demand more than the column they live in (a 360 px
   phone forced a 360 px settings column → the panel ran off-screen). */
@media (max-width: 1099px) {
  .ms-settings__body {
    grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  }
}

.ms-help__panel--grid {
  grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr));
}

/* Never truncate: menu subtitles, race names + taglines, shop names and
   effects, footer summaries wrap instead of "…". */
.ms-menuentry__sub,
.ms-title__menu .ms-menuentry__sub {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.ms-raceselect .ms-racecard {
  container-type: inline-size;
}

/* ---- Race list identity row (07.3-15, UI-SPEC S5 — F17, F33, D-21) ----
   Every card has the SAME three-column grid — sigil / name + tagline /
   level — so every name area is equally wide and the longest name
   ("Cinderwright") keeps clear of the level column; no difficulty stars.
   The card surface, accent stripe, hover lift and gold ring are unchanged. */
/* A card is never narrower than its identity grid needs: sigil + gaps +
   the 56px level + end padding leave the name column >= ~110px, enough
   for the longest name at the 14px floor plus 16px clearance. Race select
   becomes a one-up list in its column (two-up where the column is wide);
   the K switcher is two-up in its 760px panel. */
.ms-raceselect > .ms-raceselect__cards {
  grid-template-columns: repeat(auto-fill, minmax(min(272px, 100%), 1fr));
}

.ms-skillscreen .ms-skillscreen__cards {
  grid-template-columns: repeat(auto-fill, minmax(min(268px, 100%), 1fr));
}

.ms-raceselect .ms-racecard__identity {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 56px;
  align-items: start;
  column-gap: var(--sp-sm);
  padding-inline-end: var(--sp-md);
}

.ms-skillscreen .ms-racecard__identity {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 56px;
  align-items: start;
  column-gap: var(--sp-sm);
  padding-inline-end: var(--sp-md);
}

.ms-raceselect .ms-racecard__sigil {
  width: 40px;
  height: 40px;
}

.ms-skillscreen .ms-racecard__sigil {
  width: 36px;
  height: 36px;
}

/* The text column is the name's size container, so the name scales with
   the column it actually lives in (10.5cqi of the column leaves ~24% of
   it free before the level column). */
.ms-raceselect .ms-racecard__text,
.ms-skillscreen .ms-racecard__text {
  min-width: 0;
  container-type: inline-size;
}

/* Race select: tagline and the three skill glyphs share one line under
   the name (the tagline wraps first), so a one-up card stays compact. */
.ms-raceselect .ms-racecard__text {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--sp-sm);
  row-gap: 2px;
}

.ms-raceselect .ms-racecard__text > .ms-racecard__name {
  grid-column: 1 / -1;
}

.ms-raceselect .ms-racecard__details {
  margin-top: 0;
}

/* Name: never truncated; scales with its column (container query), wraps
   only as a last resort. */
.ms-raceselect .ms-racecard__name,
.ms-skillscreen .ms-racecard__name {
  display: block;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  font-size: clamp(14px, 10.5cqi, 20px);
}

/* The level: a stacked pill in column 3, top-aligned — "LVL" over the
   number (D-10/D-13: the existing ink-well pill language). */
.ms-raceselect .ms-racecard__level,
.ms-skillscreen .ms-racecard__level {
  position: static;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 56px;
  min-width: 0;
  box-sizing: border-box;
  align-self: start;
  padding: var(--sp-xs) 0;
  border: 2px solid var(--stroke-ink);
  border-radius: var(--radius-sm);
  background: rgba(14, 11, 31, 0.55);
  color: var(--paper);
  text-align: center;
}

.ms-racecard__lvleyebrow {
  font: 600 12px / 1.1 var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ms-racecard__lvlnum {
  font: var(--weight-regular, 400) 20px / 1.1 var(--font-display);
  font-variant-numeric: tabular-nums;
  color: var(--paper);
}

.ms-raceselect .ms-racecard__tagline {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.ms-shopcard__name,
.ms-shopcard__desc {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.ms-screen__footer .ms-matchsetup__summary {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  border-radius: 18px;
}

/* Tabs on narrow screens: one row of equal keys, labels may break onto
   two lines (never a lonely fourth tab on its own row). */
@media (max-width: 600px) and (orientation: portrait) {
  .ms-help__tabs {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    align-self: stretch;
    flex-wrap: nowrap;
  }

  .ms-help__tabs .ms-tabs__tab {
    min-width: 0;
    padding-inline: 6px;
    white-space: normal;
    line-height: 1.15;
    text-align: center;
    font-size: 13px;
  }
}

/* Long single words (DE "EINSTELLUNGEN", "SPIELANLEITUNG", "Grundlagen")
   on the compact title tiles and the narrow help tabs: hyphenate by the
   document language instead of clipping at the tile edge. */
.ms-title__menu .ms-btn--ghost .ms-menuentry__label,
.ms-help__tabs .ms-tabs__tab {
  -webkit-hyphens: auto;
  hyphens: auto;
  overflow-wrap: break-word;
}

@media (max-width: 600px), (max-height: 520px) and (orientation: landscape) {
  .ms-title__menu .ms-btn--ghost.ms-menuentry {
    container-type: inline-size;
  }

  .ms-title__menu .ms-btn--ghost .ms-menuentry__label {
    width: 100%;
    white-space: normal;
    line-height: 1.05;
    letter-spacing: 0.01em;
    font-size: clamp(11px, 11.5cqi, 13px);
  }
}

@media (max-width: 600px) and (orientation: portrait) {
  .ms-help__tabs .ms-tabs__tab {
    font-size: 12px;
  }
}

/* Settings → KEY BINDINGS (keybindsPanel.js): the section joins the comic
   chrome — keys read as cream keycaps with an ink under-edge that lift on
   hover and press down, group titles are gold eyebrows, the columns never
   exceed a phone, and a narrow group stacks label over its two slots.
   (Prefixed with .ms-settings to outrank the panel's injected defaults.) */
.ms-settings .ms-kb__groups {
  display: block;
  column-count: 3;
  column-width: 260px;
  column-gap: 28px;
}

.ms-settings .ms-kb__group {
  container-type: inline-size;
  break-inside: avoid;
  margin-bottom: 6px;
}

.ms-settings .ms-kb__grouptitle {
  margin: 12px 0 4px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--gold);
  text-shadow: 0 2px 0 var(--stroke-ink);
}

.ms-settings .ms-kb__help {
  font-size: 12.5px;
  line-height: 1.35;
}

.ms-settings .ms-kb__key {
  min-width: 84px;
  min-height: 34px;
  padding: 3px 12px;
  border-radius: 10px;
  border: 2px solid var(--stroke-ink);
  background: linear-gradient(180deg, #fff8e8 0%, #e6dcf5 100%);
  box-shadow: 0 3px 0 var(--stroke-ink), inset 0 -2px 0 rgba(14, 11, 31, 0.12);
  color: var(--stroke-ink);
  transition: transform var(--dur-hover) var(--ease-spring), box-shadow var(--dur-hover) var(--ease-out), background-color var(--dur-hover);
}

.ms-settings .ms-kb__key--empty {
  background: rgba(14, 11, 31, 0.5);
  color: var(--muted);
  box-shadow: 0 3px 0 var(--stroke-ink), inset 0 0 0 1px rgba(255, 248, 232, 0.08);
}

@media (hover: hover) {
  .ms-settings .ms-kb__key:not(.ms-kb__key--listening):hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #ffffff 0%, #fff0b0 100%);
    color: var(--stroke-ink);
    box-shadow: 0 5px 0 var(--stroke-ink);
  }
}

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

.ms-settings .ms-kb__key:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--stroke-ink);
  transition-duration: var(--dur-press);
}

.ms-settings .ms-kb__key--listening,
.ms-settings .ms-kb__key--listening:hover {
  background: var(--gold);
  color: var(--stroke-ink);
}

.ms-settings .ms-kb__clear {
  min-height: 34px;
  border-radius: 10px;
}

html.ms-touch .ms-settings .ms-kb__key,
html.ms-touch .ms-settings .ms-kb__clear {
  min-height: 44px;
}

@container (max-width: 300px) {
  .ms-settings .ms-kb__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .ms-settings .ms-kb__slots {
    flex-wrap: wrap;
  }

  .ms-settings .ms-kb__key {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* Online browser: the code box stays compact so the password field shows
   its whole placeholder; the list heading keeps one line. */
.ms-lobby-join__row {
  grid-template-columns: minmax(84px, 0.6fr) minmax(0, 1.4fr);
}

.ms-input--code {
  min-width: 0;
  letter-spacing: 0.14em;
}

/* #290: the grid cells may shrink (min-width 0) and their inputs fill the
   cell — the 7ch code width INCLUDED the side padding, so the fifth glyph
   was cut, and the password input's intrinsic width poked 6 px out of the
   card on phones. Tighter side padding leaves room for all 5 glyphs. */
.ms-lobby-join__row > .ms-lobby-field {
  min-width: 0;
}

.ms-lobby-join__row .ms-input {
  width: 100%;
  min-width: 0;
}

.ms-lobby-join__row .ms-input--code {
  padding-inline: 4px;
}

.ms-lobby-list__head > .ms-screen__eyebrow {
  white-space: nowrap;
}

/* ---- 07.3-17 results board (UI-SPEC S12): the Tab board's legend + ONE
   grid for header and rows, with the damage column (--board-cols-results,
   hud-system.css). ---- */
.ms-results .ms-matchboard__labels,
.ms-results .ms-matchboard__row {
  grid-template-columns: var(--board-cols-results);
}

/* S12 victory / defeat card: glass (above), display heading, sections
   --sp-md apart, the sticky actions flush on the bottom edge. */
.ms-results__card {
  width: min(560px, 100%);
  padding: var(--sp-lg) var(--sp-lg) 0;
  gap: var(--sp-md);
}

.ms-results__heading {
  margin: 0;
  font-size: var(--text-display-size);
  line-height: var(--text-display-lh);
}

/* The standings section: legend + header + rows, rows 4px apart. */
.ms-results__board {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.ms-results__payout {
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-sm) var(--sp-md);
}

.ms-results__payout-label {
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: var(--text-label-size);
  line-height: var(--text-label-lh);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--muted);
}

.ms-results__payout-values {
  flex-wrap: wrap;
  gap: var(--sp-sm) var(--sp-md);
}

.ms-results__xp {
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-lh);
}

/* Sticky actions: the phone fade backdrop (ux.css) at every size, so the
   scrolled standings never show through the buttons. */
.ms-results__actions {
  flex-wrap: nowrap;
  gap: var(--sp-sm);
  background: linear-gradient(180deg, rgba(27, 23, 51, 0) 0%, rgb(30, 26, 58) 22%);
}

/* ---- 07.3-17 death recap card (UI-SPEC S11): the results/pause glass
   recipe (above), centred over the 70% ink dim. ---- */
.ms-recap__card {
  width: min(360px, calc(100% - 2 * var(--sp-md)));
  box-sizing: border-box;
  padding: var(--sp-md) var(--sp-lg) var(--sp-lg);
  gap: var(--sp-sm);
}

.ms-recap__heading {
  margin: 0;
  color: var(--danger);
}

.ms-recap__byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 var(--sp-xs);
  margin: 0;
  font-size: var(--text-body-size);
  line-height: var(--text-body-lh);
  color: var(--muted);
}

.ms-recap__attacker {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  color: var(--paper);
  font-weight: var(--weight-semibold);
}

.ms-recap__attacker--team-a {
  color: var(--team-a, var(--paper));
}

.ms-recap__attacker--team-b {
  color: var(--team-b, var(--paper));
}

.ms-recap__attacker-sigil,
.ms-recap__weapon {
  display: inline-flex;
}

.ms-recap__attacker-sigil:empty,
.ms-recap__weapon:empty {
  display: none;
}

.ms-recap__attacker-sigil .ms-icon,
.ms-recap__weapon .ms-icon {
  width: 16px;
  height: 16px;
}

/* Two equal cells split by a 1px glass hairline: label over value. */
.ms-recap__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: var(--sp-md);
  width: 100%;
  padding: var(--sp-sm) 0;
  border-top: 1px solid var(--glass-line);
  border-bottom: 1px solid var(--glass-line);
}

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

.ms-recap__statcell + .ms-recap__statcell {
  border-left: 1px solid var(--glass-line);
}

/* 2026-10-06 owner follow-up (quick 261006-idl): stat labels must stay on
   ONE line — nowrap + tighter tracking (tokens.css has no --tracking-tight
   token yet, so the 0.02em literal fallback documents the intent). Measured
   in Rubik 600: the longest label "SCHADEN VERURSACHT" is 146.6px at
   12px + 0.02em vs the 145px half-width cell of the 360px card, so this
   label drops one step to 11px (134.4px, fits) — tokens.css pins exactly
   4 text sizes and label is already the smallest, hence the literal. */
.ms-recap__statlabel {
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: 11px; /* one step under --text-label-size — see note above */
  line-height: var(--text-label-lh);
  letter-spacing: var(--tracking-tight, 0.02em);
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* Values are tabular-figure numbers — they never wrap, so no nowrap is
   needed here (the label rule above carries the one-line guarantee). */
.ms-recap__statvalue {
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-lh);
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

/* Rounds mode: "Out until the round ends" is body copy, not a countdown. */
.ms-recap__respawn--out {
  font-family: var(--font-ui);
  font-size: var(--text-body-size);
  line-height: var(--text-body-lh);
  color: var(--muted);
  -webkit-text-stroke: 0;
  text-shadow: none;
}

/* Results: the verdict card fits every phone — tighter stat columns,
   the LVL pill never squeezes into a circle, actions never wrap. */
.ms-results__lvl {
  white-space: nowrap;
}

.ms-results__actions .ms-btn {
  flex: 1 1 0;
  white-space: nowrap;
  min-width: 0;
}

/* Short screens: the sticky actions sit flush on the card's bottom edge
   (a padding strip let the next standings row peek out beneath them). */
@media (max-height: 520px) {
  .ms-results__card {
    padding-bottom: 0;
  }
}

@media (max-width: 520px) {
  .ms-results {
    padding: max(10px, env(safe-area-inset-top, 0px)) 10px max(10px, env(safe-area-inset-bottom, 0px));
  }

  .ms-results__card {
    padding: 14px 14px 0;
  }

  /* Compact results grid: the token (the one-grid rule below owns the
     template). */
  .ms-results {
    --board-cols-results: 18px minmax(56px, 1fr) repeat(3, 3ch) repeat(3, 5ch);
  }

  .ms-results .ms-matchboard__labels,
  .ms-results .ms-matchboard__row {
    column-gap: 4px;
    font-size: 12px;
  }


  .ms-results__actions .ms-btn {
    font-size: 14px;
    padding-inline: 10px;
  }
}

/* Lobby room chat: it always sits INSIDE the footer band, never over the
   scrolling panels. Desktop: the band's left end (existing rule).
   Landscape phones: vertically centred in the short band. Portrait: the
   band grows a chat row above the note + Start match row. */
@media (max-height: 520px) and (orientation: landscape) {
  .ms-chat.ms-chat--lobby {
    bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px));
    width: min(300px, 38vw);
  }

  .ms-chat--lobby .ms-chat__input {
    min-height: 44px;
  }

  .ms-screen.ms-lobby-room > .ms-screen__footer {
    min-height: calc(48px + 6px + max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px)));
    padding-left: calc(var(--gx-l) + min(300px, 38vw) + 16px);
  }
}

@media (max-width: 600px) and (orientation: portrait) {
  .ms-screen.ms-lobby-room > .ms-screen__footer {
    flex-wrap: nowrap;
    padding-top: 66px;
    padding-left: var(--gx-l);
  }

  .ms-screen.ms-lobby-room > .ms-screen__footer > .ms-lobby-room__waiting {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
  }

  .ms-screen.ms-lobby-room > .ms-screen__footer > .ms-lobby-room__waiting:empty {
    display: none;
  }

  .ms-screen.ms-lobby-room > .ms-screen__footer > .ms-btn {
    flex: 1 1 auto;
  }

  .ms-chat.ms-chat--lobby {
    left: max(16px, calc(env(safe-area-inset-left, 0px) + 12px));
    right: max(16px, calc(env(safe-area-inset-right, 0px) + 12px));
    width: auto;
    bottom: calc(max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px)) + 48px + 12px);
  }

  .ms-chat--lobby .ms-chat__input {
    min-height: 44px;
  }

  .ms-screen.ms-lobby-room > .ms-screen__body {
    padding-bottom: 12px;
  }
}

/* Race cards: small print never drops below the 11 px floor (landscape
   phones had 10 px taglines). */
@media (max-height: 520px) and (orientation: landscape) {
  .ms-raceselect .ms-racecard__tagline {
    font-size: 11px;
  }
}

/* Map cards: the "TDM only" sticker never meets the selected check stamp
   (top-right) or the footprint chip (bottom-left): on thumbnail cards it
   rides the thumbnail's top-left corner, on the lobby's text cards it
   sits bottom-right beside the footprint — tilted like a slapped label. */
.ms-card--map .ms-card__tag {
  top: 14px;
  right: auto;
  bottom: auto;
  left: 14px;
  box-shadow: 0 2px 0 var(--stroke-ink);
  transform: rotate(-5deg);
}

/* Two-up map lists: an odd last visible card spans the row instead of
   leaving an orphan half-row (five maps under TDM). */
@media (max-width: 600px) and (orientation: portrait) {
  .ms-matchsetup__maps > .ms-card:nth-child(odd of .ms-card:not([hidden])):nth-last-child(1 of .ms-card:not([hidden])) {
    grid-column: 1 / -1;
  }
}

/* Map grids: up to five maps sit on ONE row wherever there is room
   (a 4 + 1 orphan row looked unfinished); narrower bodies fall back to
   tidy 3 + 2 / 2-up rows. */
.ms-matchsetup__maps {
  grid-template-columns: repeat(auto-fit, minmax(min(108px, 100%), 1fr));
}

@media (max-width: 1100px) {
  .ms-matchsetup__maps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 600px) and (orientation: portrait) {
  .ms-matchsetup__maps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.ms-card--map .ms-card__name--map {
  overflow-wrap: anywhere;
}

/* The smallest landscape phones (iPhone SE, 568×320): the lobby browser
   and room drop to one scrolling column (two squeezed columns cut the
   Refresh button and crushed the team cards), and the footer bands stay
   one row. */
@media (max-width: 620px) and (orientation: landscape) {
  .ms-screen.ms-lobby-browser > .ms-screen__body,
  .ms-screen.ms-lobby-room > .ms-screen__body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: none;
  }

  .ms-screen.ms-lobby-room > .ms-screen__body > * {
    grid-area: auto;
  }

  .ms-screen__footer .ms-btn {
    white-space: nowrap;
  }
}

/* Lobby team cards: narrow columns (667×375) stack the name over the
   pick button and let the player row wrap (it rendered "P-l-a-y-e-r"
   one letter per line and the YOUR TEAM pill spilled onto Bravo). */
.ms-lobby-team {
  container-type: inline-size;
  min-width: 0;
}

.ms-lobby-team__head {
  flex-wrap: wrap;
  min-width: 0;
}

.ms-lobby-player {
  flex-wrap: wrap;
  min-width: 0;
}

.ms-lobby-player__name {
  flex: 0 1 auto;
  min-width: min(100%, 7ch);
  overflow-wrap: anywhere;
}

@container (max-width: 230px) {
  .ms-lobby-team__head {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .ms-lobby-team__pick {
    width: 100%;
    white-space: nowrap;
    font-size: 12px;
  }

  .ms-lobby-team__name {
    font-size: 20px;
  }
}

/* The scoreboard joins the comic chrome: a solid glass plate (the HUD
   vitals no longer ghost through it). */
.ms-matchboard:not(.ms-matchboard--dock) {
  background:
    linear-gradient(180deg, rgba(47, 39, 92, 0.97) 0%, rgba(22, 18, 44, 0.97) 100%);
  border: 3px solid var(--stroke-ink);
  box-shadow: 0 8px 0 var(--stroke-ink), 0 24px 44px rgba(14, 11, 31, 0.45), inset 0 0 0 2px var(--glass-line);
}

/* Skills screen (K) on narrow glass: the skill name owns the full first
   line; description + pips + buy share the second ("Grave / Wind" broke
   over two lines beside the pip column). */
@media (max-width: 760px) {
  .ms-skillscreen .ms-skillrow {
    grid-template-areas:
      "head head"
      "desc body";
  }
}

/* Skills screen race switcher (K): names scale with their card instead
   of truncating ("Blightbo…", "Spiritcal…") — the identity grid above. */
.ms-skillscreen .ms-racecard {
  container-type: inline-size;
}

/* Touch: segmented options, switches and sliders keep a thumb-sized hit
   area (the audit measured 34 px segments). */
html.ms-touch .ms-seg__opt {
  min-height: 44px;
}

html.ms-touch .ms-switch {
  min-height: 44px;
}

html.ms-touch .ms-setting--slider .ms-setting__control {
  min-height: 40px;
}

/* ================================================================== */
/* RACE SELECT — ALL EIGHT RACES ON SCREEN (no scrolling card list)     */
/* ================================================================== */
/* The race select (.ms-raceselect--many) card column
   steps down by the space it actually has, so the eight cards always fit:
     >= 760 px                   compact one-up rows (inline level pill)
     < 760 px + landscape phones two-up cards, level as a corner badge
     narrow portrait phones      two-up cards, level as a corner badge
   The classic four use the same tier as the eight (the class is always
   set). Every card's contents sit on the row's horizontal centre line. */

.ms-raceselect--many .ms-racecard__identity {
  align-items: center;
}

/* The level is one compact inline pill ("LVL 3") at every size; it keeps
   the same distance to the right edge as the sigil to the left edge. */
.ms-raceselect--many .ms-racecard__identity {
  grid-template-columns: 40px minmax(0, 1fr) auto;
  padding-inline-end: 0;
}

.ms-raceselect--many .ms-racecard__level {
  align-self: center;
  flex-direction: row;
  gap: 5px;
  width: auto;
  padding: 3px 9px;
}

.ms-raceselect--many .ms-racecard__lvleyebrow {
  font-size: 11px;
}

.ms-raceselect--many .ms-racecard__lvlnum {
  font-size: 16px;
}

/* Name over role line on the left, the skill glyphs beside both — the
   glyphs centred on the row instead of hanging off the role line. */
.ms-raceselect--many .ms-racecard__text > .ms-racecard__name {
  grid-column: 1;
  grid-row: 1;
}

.ms-raceselect--many .ms-racecard__text > .ms-racecard__tagline {
  grid-column: 1;
  grid-row: 2;
}

.ms-raceselect--many .ms-racecard__text > .ms-racecard__details {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
}

/* Compact one-up: one line for the name, one for role + skill glyphs. */
@media (min-width: 901px) and (min-height: 760px) {
  .ms-raceselect--many > .ms-raceselect__cards {
    gap: 7px;
    padding: 6px 14px 10px 8px;
  }

  .ms-raceselect--many .ms-racecard {
    padding: 6px 12px;
    gap: 0;
  }

  .ms-raceselect--many .ms-racecard__identity {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
  }

  .ms-raceselect--many .ms-racecard__sigil {
    width: 34px;
    height: 34px;
  }

  .ms-raceselect--many .ms-racecard__name {
    font-size: clamp(14px, 8cqi, 18px);
    line-height: 1.1;
  }

  .ms-raceselect--many .ms-racecard__level {
    flex-direction: row;
    gap: 5px;
    width: auto;
    padding: 3px 9px;
  }

  .ms-raceselect--many .ms-racecard__lvleyebrow {
    font-size: 11px;
  }

  .ms-raceselect--many .ms-racecard__lvlnum {
    font-size: 16px;
  }

  .ms-raceselect--many .ms-racecard__text > .ms-racecard__tagline {
    min-height: 0;
  }

  .ms-raceselect--many .ms-racecard__skill {
    width: 20px;
    height: 20px;
  }

  .ms-raceselect--many .ms-racecard__skill .ms-icon {
    width: 13px;
    height: 13px;
  }
}

/* Two-up: sigil + name on top, the role line under it across the card,
   the level a small badge on the card's top-right corner. */
@media (min-width: 901px) and (max-height: 759px), (min-width: 601px) and (max-height: 520px), (max-width: 600px) {
  .ms-raceselect--many > .ms-raceselect__cards,
  .ms-screen.ms-raceselect--many > .ms-raceselect__cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 12px 10px;
    padding: 10px 12px 8px 4px;
  }

  .ms-raceselect--many .ms-racecard {
    padding: 7px 9px 8px 11px;
    gap: 0;
    overflow: visible;
  }

  .ms-raceselect--many .ms-racecard__identity {
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;
    padding-inline-end: 0;
  }

  .ms-raceselect--many .ms-racecard__sigil {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  /* The XP line sits under the name (sigil 30px + gap 8px). */
  .ms-raceselect--many .ms-racecard__xp {
    margin: 1px 0 0 38px;
  }

  .ms-raceselect--many .ms-racecard__sigil .ms-icon {
    width: 20px;
    height: 20px;
  }

  .ms-raceselect--many .ms-racecard__text {
    display: contents;
  }

  .ms-raceselect--many .ms-racecard__text > .ms-racecard__name {
    grid-column: 2;
    overflow-wrap: normal;
    font-size: clamp(12px, 8.2cqi, 17px);
    line-height: 1.1;
  }

  .ms-raceselect--many .ms-racecard__text > .ms-racecard__tagline {
    grid-column: 1 / -1;
    min-height: 0;
    margin-top: 3px;
    font-size: 11px;
    line-height: 1.25;
  }

  .ms-raceselect--many .ms-racecard__details {
    display: none;
  }

  .ms-raceselect--many .ms-racecard__level {
    position: absolute;
    top: -9px;
    right: -7px;
    flex-direction: row;
    gap: 3px;
    width: auto;
    padding: 1px 7px;
    border-radius: var(--radius-pill);
    background: #1f1a3d;
    z-index: 1;
  }

  .ms-raceselect--many .ms-racecard__lvleyebrow {
    font-size: 10px;
  }

  .ms-raceselect--many .ms-racecard__lvlnum {
    font-size: 13px;
  }
}

/* Landscape phones: name only — the side panel carries the role line. */
@media (min-width: 601px) and (max-height: 520px) {
  .ms-raceselect--many > .ms-raceselect__cards {
    gap: 10px 8px;
    padding: 9px 10px 4px 2px;
  }

  .ms-raceselect--many .ms-racecard {
    padding: 5px 8px 5px 10px;
  }

  .ms-raceselect--many .ms-racecard__tagline {
    display: none;
  }
}

/* ---- Map viewer (ui/mapViewer.js): the map cards' "View" chip and the
   free-fly overlay over the menu stage. ---------------------------------- */
.ms-card__view {
  align-self: flex-start;
  margin-top: 4px;
  padding: 2px 10px;
  border: 2px solid var(--stroke-ink);
  border-radius: 999px;
  background: var(--sky);
  color: var(--stroke-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--stroke-ink);
}
.ms-card__view:hover,
.ms-card__view:focus-visible {
  background: var(--gold);
  outline: none;
}
.ms-mapviewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  font-family: var(--font-ui);
  color: var(--paper);
}
.ms-mapviewer:active { cursor: grabbing; }
.ms-mapviewer__bar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.ms-mapviewer__name {
  margin-right: auto;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--panel);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.ms-mapviewer__btn {
  pointer-events: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 2px solid var(--stroke-ink);
  border-radius: 999px;
  background: var(--panel);
  color: var(--paper);
  font: 600 14px var(--font-ui);
  cursor: pointer;
}
.ms-mapviewer__btn:hover,
.ms-mapviewer__btn:focus-visible { border-color: var(--gold); outline: none; }
.ms-mapviewer:focus { outline: none; } /* #327: the dialog holds the opening focus */
.ms-mapviewer__close { background: var(--gold); color: var(--stroke-ink); font-size: 18px; }
.ms-mapviewer__hint {
  position: absolute;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  margin: 0;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--panel);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.6s 2s;
}
.ms-mapviewer__hint--faded { opacity: 0; }
.ms-mapviewer__stick {
  position: absolute;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border: 2px solid rgba(255, 248, 232, 0.5);
  border-radius: 50%;
  background: rgba(27, 23, 51, 0.35);
  pointer-events: none;
}
.ms-mapviewer__stick[hidden] { display: none; }
.ms-mapviewer__stickdot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: rgba(255, 248, 232, 0.75);
}
.ms-mapviewer__updown {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(70px, calc(env(safe-area-inset-bottom) + 54px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ms-mapviewer__vert { width: 56px; height: 56px; padding: 0; font-size: 18px; touch-action: none; }
