/*
  MYTHSTRIKE HUD SYSTEM (in-match HUD pass) — the single layout + chrome
  layer for the in-match HUD. Loaded after touch.css (index.html), so it
  owns every rule below; hud.css keeps the component base rules the older
  specs pin, this file arranges them into ONE calm system:

  ZONES (desktop)
    top-left      chat (online) · onboarding tips (left-middle)
    top-center    score strip · toasts · mode line · spectate chip · banners
    top-right     kill feed
    bottom-left   status zone (buffs, DODGED/WARDED, training) above the
                  PLAYER PANEL: [ULT][skill][skill][skill] slot row,
                  HP (primary line), race + level + thin XP track
    bottom-right  owned-item strip above the WEAPON PANEL: [1][2][3][4][G]
                  slot row, mag/reload bar + big ammo, weapon name + money
    bottom-center transient only (round chip, prompts, audio chip) — the
                  crosshair and the action stay clear

  ZONES (touch, landscape) — fewer, smaller:
    top-left      touch bar · compact player panel (HP + XP) · buffs to its
                  right · kill feed (≤ 3 rows) under it
    top-center    strip (fits between the bars) · tips · chat · toasts
    top-right     touch bar (view, skills + points badge, shop) · money pill
    bottom        stick (left) · weapon panel centered in the free band ·
                  fire arc (right; ult ring = the ultimate slot)

  GRID + TYPE: one panel recipe (.ms-hudc), one slot recipe (.ms-hslot),
  one inset/gap/padding set, two radii (panel / inner), exactly three type
  sizes — L (Titan One: HP + ammo), M (Titan One: level, money, feed
  names, cooldown seconds), S (Rubik 600 caps: labels, keycaps, units).
  Rest state is subdued; highlight only on change (low HP pulse, ult
  ready glow, low ammo tint, gold active slot, points badge). Animations
  are opacity/transform only and die under reduced motion (ux.css +
  the media query at the end).
*/

/* ------------------------------------------------------------------ */
/* Tokens                                                               */
/* ------------------------------------------------------------------ */
:root {
  --hud-inset: 16px;
  --hud-gap: 8px;
  --hud-pad: 10px;
  --hud-radius: 16px;
  --hud-radius-in: 10px;
  --hud-slot: 40px;
  --hud-slot-gap: 6px;
  --hud-glyph: 20px;
  /* 07.3 UI-SPEC "Changed token values" (Pitfall 5): six weapon chips
     (5 guns + G) need 6×40 + 5×6 = 270px; the content box is
     296 − 2×10 pad − 2×2 border = 272px (measured by hud-layout.mjs). */
  --hud-panel-w: 296px;
  --hud-bar-h: 10px;
  --hud-thin-h: 4px;
  --hud-fs-l: 30px;
  --hud-fs-m: 16px;
  --hud-fs-s: 11px;
  /* The menu glass recipe (tokens.css --glass / --glass-line), a touch
     more transparent over the live match. */
  --hud-bg: linear-gradient(180deg, rgba(47, 39, 92, 0.8) 0%, rgba(27, 23, 51, 0.82) 100%);
  --hud-bg-in: rgba(18, 14, 39, 0.55);
  --hud-slot-line: rgba(111, 98, 186, 0.55);
  --hud-hair: var(--glass-line);
  --hud-track: rgba(255, 248, 232, 0.12);
  --hud-shadow: 0 3px 0 var(--stroke-ink), 0 6px 14px rgba(14, 11, 31, 0.22);
  /* Board grids (07.3 UI-SPEC "New tokens"): ONE column template shared by
     labels, legend-aligned headers and rows. Consumers: the Tab scoreboard
     (F2, --board-cols) and the death/results boards (F32,
     --board-cols-results — adds the damage column). 4ch/6ch stat tracks fit
     3–4-digit XP and money values. */
  --board-cols: var(--sp-lg) minmax(96px, 1fr) repeat(3, 4ch) repeat(2, 6ch);
  --board-cols-results: var(--sp-lg) minmax(88px, 1fr) repeat(3, 4ch) repeat(3, 6ch);
}

@media (min-width: 1700px) and (min-height: 950px) {
  :root {
    --hud-inset: 24px;
    --hud-pad: 12px;
    --hud-slot: 46px;
    --hud-slot-gap: 7px;
    --hud-glyph: 24px;
    --hud-panel-w: 340px; /* 6×46 + 5×7 = 311px in 340 − 2×12 − 2×2 = 312px */
    --hud-bar-h: 12px;
    --hud-fs-l: 34px;
    --hud-fs-m: 18px;
    --hud-fs-s: 12px;
  }
}

/* Narrow desktop windows (< 1040px, e.g. 1024×768): 296px panels reach
   into the crosshair's bottom-center lane (the middle 40% of the width,
   tools/e2e/hud-layout.mjs). 290px clears the lane down to ~1020px; its
   content box is 290 − 2×10 pad − 2×2 border = 266px, so the MINIMUM slot
   gap drops to 5px (6×40 + 5×5 = 265px). The rows are space-between, so
   the painted gap stays ≈5.2px. Touch keeps its own values (html.ms-touch
   wins on specificity). */
@media (max-width: 1039px) {
  :root {
    --hud-panel-w: 290px;
    --hud-slot-gap: 5px;
  }
}

/* ------------------------------------------------------------------ */
/* Type scale                                                           */
/* ------------------------------------------------------------------ */
.ms-hud-s,
.ms-cluster__name,
.ms-xpbar__eyebrow,
.ms-xpbar__max,
.ms-vitals__max,
.ms-weapon-card__name,
.ms-weapon-card__state,
.ms-weapon-card__reserve,
.ms-weapon-slot__digit,
.ms-chargering__keycap,
.ms-statuschip__word,
.ms-procword,
.ms-cluster__passive,
.ms-cluster__points,
.ms-tbtn__badge {
  font-family: var(--font-ui);
  font-size: var(--hud-fs-s);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ms-xpbar__level,
.ms-money-chip__value,
.ms-chargering__secs {
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--hud-fs-m);
  line-height: 1;
  letter-spacing: 0;
}

.ms-vitals__value,
.ms-weapon-card__mag {
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--hud-fs-l);
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ */
/* One chrome recipe for every HUD surface                              */
/* ------------------------------------------------------------------ */
.ms-hudc,
.ms-strip,
.ms-statuschip,
.ms-feed__chip,
.ms-toast,
.ms-modeline,
.ms-spectate,
.ms-cluster__status > .ms-chip,
.ms-audio-chip {
  background: var(--hud-bg);
  border: 2px solid var(--stroke-ink);
  box-shadow: var(--hud-shadow), inset 0 1px 0 var(--hud-hair);
}

.ms-hudc {
  position: relative;
  box-sizing: border-box;
  width: var(--hud-panel-w);
  padding: var(--hud-pad);
  border-radius: var(--hud-radius);
  pointer-events: none;
}

/* The score strip keeps its layout; it only joins the recipe. */
.ms-strip {
  border-radius: var(--hud-radius);
}

/* ------------------------------------------------------------------ */
/* The slot recipe — skills, ultimate, weapons, owned items             */
/* ------------------------------------------------------------------ */
.ms-hslot {
  position: relative;
  box-sizing: border-box;
  flex: none;
  display: grid;
  place-items: center;
  width: var(--hud-slot);
  height: var(--hud-slot);
  padding: 0;
  gap: 0;
  border: 2px solid var(--hud-slot-line);
  border-radius: var(--hud-radius-in);
  background: var(--hud-bg-in);
  box-shadow: none;
  color: var(--paper);
}

.ms-hslot > .ms-icon,
.ms-hslot__glyph,
.ms-chargering__sigil .ms-icon {
  width: var(--hud-glyph);
  height: var(--hud-glyph);
}

/* ------------------------------------------------------------------ */
/* PLAYER CLUSTER (bottom-left)                                         */
/* ------------------------------------------------------------------ */
.ms-cluster {
  position: absolute;
  left: var(--hud-inset);
  bottom: var(--hud-inset);
  top: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--hud-gap);
  transform: none;
  filter: none;
  pointer-events: none;
  z-index: var(--z-hud);
}

/* Status zone: buffs, proc words, training chip — above the panel. */
.ms-cluster__status {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.ms-cluster__status > .ms-chip {
  position: relative;
  left: auto;
  bottom: auto;
  border-radius: var(--hud-radius-in);
}

.ms-hudc--player {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ms-cluster__slots,
.ms-cluster__skills,
.ms-cluster__ult {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--hud-slot-gap);
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
}

/* F31 (07.3 UI-SPEC S9): the ULT + skill slots spread evenly across the
   panel width — space-between over fixed-size cells (.ms-hslot flex: none,
   never grow). The skills wrapper dissolves so every slot (ULT, skills, a
   Phase 2 race's passive) is one flex item of the same row. */
.ms-hudc--player > .ms-cluster__slots {
  width: 100%;
  justify-content: space-between;
}

.ms-hudc--player > .ms-cluster__slots > .ms-cluster__skills {
  display: contents;
}

.ms-hudc--player > .ms-cluster__slots > .ms-cluster__ult,
.ms-hudc--player > .ms-cluster__slots .ms-hslot {
  flex: none;
}

/* Skill slot: glyph + rank pips; rank 0 reads dim; a stub shows a lock. */
.ms-cluster__skill .ms-hslot__glyph {
  color: var(--paper);
  margin-bottom: 4px;
}

.ms-hslot--off .ms-hslot__glyph,
.ms-hslot--stub .ms-hslot__glyph {
  opacity: 0.4;
}

.ms-hslot__pips {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  display: flex;
  justify-content: center;
  gap: 2px;
}

.ms-hslot__pip {
  width: 6px;
  height: 3px;
  border-radius: 2px;
  background: var(--hud-track);
}

.ms-hslot__pip--on {
  background: var(--race-accent, var(--gold));
}

/* The level-scaled passive: glyph + its current value (no pips). */
.ms-cluster__skill--passive {
  border-style: dashed;
}

.ms-cluster__passive {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1px;
  margin: 0;
  font-size: 9px;
  letter-spacing: 0;
  text-align: center;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* Unspent skill points: a gold notification badge on the panel corner. */
.ms-cluster__points {
  position: absolute;
  top: -9px;
  right: -9px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 20px;
  padding: 0 7px 0 5px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--stroke-ink);
  background: var(--gold);
  color: var(--stroke-ink);
  box-shadow: 0 2px 0 var(--stroke-ink);
  letter-spacing: 0;
  animation: none;
}

.ms-cluster__points .ms-icon {
  width: 12px;
  height: 12px;
}

.ms-cluster__points.ms-hidden {
  display: none;
}

/* ---- the ultimate slot (chargeRing.js) --------------------------------- */
.ms-chargering {
  position: relative;
  left: auto;
  bottom: auto;
  flex-direction: row;
  z-index: auto;
}

.ms-chargering__svg {
  position: absolute;
  inset: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  overflow: visible;
  pointer-events: none;
}

.ms-chargering__track {
  stroke: none;
}

.ms-chargering__arc {
  stroke: var(--race-accent, var(--gold));
  stroke-linecap: round;
  transition: none; /* per-frame data, never eased */
}

.ms-chargering__sigil {
  grid-area: 1 / 1;
  display: grid;
  place-items: center;
  color: var(--race-accent, var(--paper));
  transition: opacity 150ms ease-out;
}

.ms-chargering__lock {
  grid-area: 1 / 1;
  width: 16px;
  height: 16px;
  color: var(--muted);
  display: none;
}

.ms-chargering__secs {
  grid-area: 1 / 1;
  color: var(--paper);
  text-shadow: 0 2px 0 var(--stroke-ink);
}

.ms-chargering__keycap {
  position: absolute;
  right: -6px;
  bottom: -6px;
  left: auto;
  top: auto;
  transform: none;
  box-sizing: border-box;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 2px solid var(--stroke-ink);
  background: var(--ink);
  color: var(--muted);
  box-shadow: none;
  letter-spacing: 0;
  animation: none;
}

.ms-chargering__label {
  display: none;
}

/* locked: the lock + unlock level; the sigil hides. */
.ms-chargering--locked .ms-chargering__sigil {
  opacity: 0;
}

.ms-chargering--locked .ms-chargering__lock {
  display: block;
}

.ms-chargering--locked,
.ms-chargering--learn {
  border-style: dashed;
}

/* learn: unlocked, waiting in the Skills screen — gold corner "+". */
.ms-chargering--learn .ms-chargering__sigil {
  opacity: 0.45;
}

.ms-chargering--learn .ms-chargering__keycap {
  background: var(--gold);
  color: var(--stroke-ink);
}

/* cooling / searching: the seconds over a dimmed sigil. */
.ms-chargering--cooling .ms-chargering__sigil,
.ms-chargering--search .ms-chargering__sigil {
  opacity: 0.28;
}

.ms-chargering--search .ms-chargering__arc {
  stroke: var(--paper);
  animation: ms-chargering-search 1000ms linear infinite;
}

/* ready: accent-tinted slot, bright sigil, accent keycap, a soft glow
   that breathes on a pseudo layer (opacity only — compositor-cheap). */
.ms-chargering--ready {
  border-color: var(--race-accent, var(--gold));
  background: color-mix(in srgb, var(--race-accent, var(--gold)) 26%, rgba(14, 11, 31, 0.7));
}

.ms-chargering--ready .ms-chargering__sigil {
  color: var(--paper);
}

.ms-chargering--ready .ms-chargering__keycap {
  background: var(--race-accent, var(--gold));
  color: var(--stroke-ink);
  animation: none;
}

.ms-chargering--ready::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: calc(var(--hud-radius-in) + 4px);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--race-accent, var(--gold)) 55%, transparent), 0 0 14px color-mix(in srgb, var(--race-accent, var(--gold)) 70%, transparent);
  pointer-events: none;
  animation: ms-hud-breathe 1400ms ease-in-out infinite;
}

.ms-chargering--flash .ms-chargering__arc {
  filter: brightness(1.8);
}

@keyframes ms-hud-breathe {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

/* The ultimate press/block toast rises above the panel (its own slot). */
.ms-cluster .ms-toast--ult {
  position: absolute;
  left: calc(-1 * var(--hud-pad) - 2px);
  bottom: calc(100% + var(--hud-pad) + var(--hud-gap) + 4px);
  z-index: var(--z-hud);
}

/* ---- HP row (healthBar.js) --------------------------------------------- */
.ms-vitals {
  position: relative;
  left: auto;
  bottom: auto;
  top: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  white-space: nowrap;
  pointer-events: none;
}

/* Row order: heart · number · bar · armor (the DOM keeps its 02-era
   heart/track/num/armor order; the weapon row mirrors it: bar · ammo). */
.ms-vitals__heart {
  order: -2;
}

.ms-vitals__num {
  order: -1;
}

.ms-vitals__heart {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--coral);
  filter: none;
}

.ms-vitals__heart .ms-icon {
  width: 20px;
  height: 20px;
}

.ms-vitals__num {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  min-width: 0;
  flex: none;
}

.ms-vitals__value {
  min-width: 2.1ch;
  text-align: right;
  color: var(--paper);
  text-shadow: 0 2px 0 var(--stroke-ink);
}

.ms-vitals__max {
  color: var(--muted);
  letter-spacing: 0;
}

.ms-vitals__track {
  position: relative;
  flex: 1 1 auto;
  width: auto;
  min-width: 40px;
  height: var(--hud-bar-h);
  margin-left: 4px;
  border-radius: var(--radius-pill);
  border: 0;
  background: var(--hud-track);
  box-shadow: inset 0 0 0 1px rgba(14, 11, 31, 0.6);
  overflow: hidden;
}

.ms-vitals__fill,
.ms-vitals__trail {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  border-radius: var(--radius-pill);
}

.ms-vitals__trail {
  background: rgba(255, 241, 201, 0.85);
  transition: width 420ms ease-in;
}

.ms-vitals__fill {
  background: var(--mint);
  transition: width 120ms var(--ease-out);
}

.ms-vitals__shine {
  display: none;
}

.ms-vitals--low .ms-vitals__fill {
  background: #ffab2e;
}

.ms-vitals--critical .ms-vitals__fill {
  background: var(--coral);
}

.ms-vitals--low .ms-vitals__value {
  color: #ffc36b;
}

.ms-vitals--critical .ms-vitals__value {
  color: var(--coral);
}

.ms-vitals__armor {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 2px solid var(--stroke-ink);
  background: var(--sky);
  color: var(--stroke-ink);
}

.ms-vitals__armor .ms-icon {
  width: 14px;
  height: 14px;
}

.ms-vitals__armor.ms-hidden {
  display: none;
}

/* Barbed Shell armor pool: shield + "+N" (the points it still soaks). */
.ms-vitals__barb {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
  height: 22px;
  padding: 0 5px 0 3px;
  border-radius: 7px;
  border: 2px solid var(--stroke-ink);
  background: var(--sky);
  color: var(--stroke-ink);
  font-family: var(--font-ui);
  font-size: var(--hud-fs-s);
  font-weight: var(--weight-semibold);
  line-height: 1;
}

.ms-vitals__barb .ms-icon {
  width: 14px;
  height: 14px;
}

.ms-vitals__barb.ms-hidden {
  display: none;
}

/* Warding Totem slot: totems still plantable this life. */
.ms-cluster__count {
  position: absolute;
  top: 1px;
  right: 3px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  line-height: 1;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* Hit flash: the parent alternates two IDENTICAL one-shot classes (the
   healthBar.js no-forced-layout restart); each drives its own animation
   name on the children, so every hit restarts the flash. */
.ms-vitals--hit,
.ms-vitals--hit2 {
  animation: none;
}

.ms-vitals--hit .ms-vitals__track {
  animation: ms-hud-hit 260ms ease-out;
}

.ms-vitals--hit2 .ms-vitals__track {
  animation: ms-hud-hit2 260ms ease-out;
}

.ms-vitals--hit .ms-vitals__num {
  animation: ms-hud-jolt 260ms ease-out;
}

.ms-vitals--hit2 .ms-vitals__num {
  animation: ms-hud-jolt2 260ms ease-out;
}

@keyframes ms-hud-hit {
  0% { box-shadow: inset 0 0 0 1px rgba(14, 11, 31, 0.6), 0 0 0 2px var(--coral); }
  100% { box-shadow: inset 0 0 0 1px rgba(14, 11, 31, 0.6), 0 0 0 2px transparent; }
}

@keyframes ms-hud-hit2 {
  0% { box-shadow: inset 0 0 0 1px rgba(14, 11, 31, 0.6), 0 0 0 2px var(--coral); }
  100% { box-shadow: inset 0 0 0 1px rgba(14, 11, 31, 0.6), 0 0 0 2px transparent; }
}

@keyframes ms-hud-jolt {
  0% { transform: translateX(0); }
  30% { transform: translateX(-2px); }
  60% { transform: translateX(2px); }
  100% { transform: translateX(0); }
}

@keyframes ms-hud-jolt2 {
  0% { transform: translateX(0); }
  30% { transform: translateX(-2px); }
  60% { transform: translateX(2px); }
  100% { transform: translateX(0); }
}

.ms-vitals--low .ms-vitals__heart {
  animation: ms-vitals-beat 900ms ease-in-out infinite;
}

.ms-vitals--critical .ms-vitals__heart {
  animation-duration: 520ms;
}

@keyframes ms-vitals-beat {
  0%,
  100% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.22);
  }
}

/* ---- race row + XP (xpBar.js) ------------------------------------------ */
.ms-cluster__race {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.ms-cluster__sigil {
  display: flex;
  flex: none;
  color: var(--race-accent, var(--paper));
}

.ms-cluster__sigil .ms-icon {
  width: 16px;
  height: 16px;
}

.ms-cluster__name {
  flex: 0 1 auto;
  max-width: 55%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--paper);
}

.ms-xpbar {
  position: static;
  left: auto;
  bottom: auto;
  transform: none;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  z-index: auto;
}

.ms-xpbar.ms-hidden {
  display: none;
}

.ms-xpbar__left {
  display: flex;
  align-items: baseline;
  gap: 3px;
  flex: none;
}

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

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

.ms-xpbar__track {
  flex: 1 1 auto;
  width: auto;
  min-width: 24px;
  height: var(--hud-thin-h);
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--hud-track);
  overflow: hidden;
}

.ms-xpbar__fill {
  height: 100%;
  background: var(--gold);
  transform-origin: left center;
}

.ms-xpbar__text {
  flex: none;
  font-size: var(--hud-fs-s);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.ms-xpbar__text:empty,
html.ms-touch .ms-xpbar__text {
  display: none;
}

.ms-xpbar__max {
  flex: none;
  padding: 0 5px;
  border: 1px solid var(--gold);
  border-radius: var(--radius-pill);
  color: var(--gold);
}

/* XP floaters rise from above the player panel. */
.ms-xpfloater {
  left: calc(var(--hud-inset) + var(--hud-panel-w) * 0.5);
  bottom: calc(var(--hud-inset) + var(--hud-slot) * 2 + 96px);
}

/* ---- status zone tenants ----------------------------------------------- */
.ms-statuschips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ms-statuschip {
  height: 26px;
  box-sizing: border-box;
  padding: 0 8px;
  gap: 5px;
  border-radius: var(--hud-radius-in);
}

.ms-statuschip__glyph .ms-icon {
  width: 14px;
  height: 14px;
}

.ms-procword {
  padding: 0 2px;
  color: var(--paper);
  text-shadow: 0 2px 0 var(--stroke-ink);
}

.ms-procword--ward {
  color: var(--gold);
}

/* #258: the own-dodge word wears the damage-number face (display font, ink
   stroke, comic shadow), a little smaller beside the cluster. */
.ms-procword--dodge {
  font-family: var(--font-display);
  font-size: calc(var(--text-display-size) * 0.6);
  line-height: 1;
  -webkit-text-stroke: var(--stroke-display) var(--ink);
  text-shadow: var(--shadow-comic);
  text-transform: uppercase;
}

/* ------------------------------------------------------------------ */
/* WEAPON CLUSTER (bottom-right)                                        */
/* ------------------------------------------------------------------ */
.ms-weapon-zone {
  position: absolute;
  inset: auto var(--hud-inset) var(--hud-inset) auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--hud-gap);
  transform: none;
  pointer-events: none;
  z-index: var(--z-hud);
}

.ms-hudc--weapon {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "slots slots"
    "bar ammo"
    "name money";
  align-items: center;
  column-gap: 10px;
  row-gap: 8px;
}

/* The card dissolves into the panel grid (its parts are grid items). */
.ms-hudc--weapon > .ms-weapon-card {
  display: contents;
}

/* F31 (07.3 S8): the six chips spread evenly across the panel width —
   space-between, fixed-size cells that never grow (.ms-hslot flex: none). */
.ms-hudc--weapon > .ms-weapon-slots {
  grid-area: slots;
  display: flex;
  justify-content: space-between;
  gap: var(--hud-slot-gap);
}

.ms-hudc--weapon > .ms-weapon-slots > .ms-hslot {
  flex: none;
}

.ms-weapon-card__bar {
  grid-area: bar;
  position: relative;
  width: auto;
  height: var(--hud-bar-h);
  margin: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--hud-track);
  box-shadow: inset 0 0 0 1px rgba(14, 11, 31, 0.6);
  overflow: hidden;
}

.ms-weapon-card__bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--paper);
  opacity: 0.85;
  transform-origin: left center;
}

.ms-weapon-card--low .ms-weapon-card__bar-fill {
  background: var(--danger);
}

.ms-weapon-card--reloading .ms-weapon-card__bar-fill {
  background: var(--gold);
  opacity: 1;
}

.ms-weapon-card__ammo {
  grid-area: ammo;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 2px;
}

.ms-weapon-card__mag {
  min-width: 2ch;
  text-align: right;
  color: var(--paper);
  text-shadow: 0 2px 0 var(--stroke-ink);
}

.ms-weapon-card__mag--low {
  color: var(--danger);
}

.ms-weapon-card__reserve {
  color: var(--muted);
  letter-spacing: 0;
}

.ms-weapon-card__name,
.ms-weapon-card__state {
  grid-area: name;
  margin: 0;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-weapon-card__name {
  color: var(--muted);
  letter-spacing: 0.1em;
}

.ms-weapon-card__state {
  color: var(--danger);
}

.ms-weapon-card__state:empty {
  display: none;
}

/* A live state line (RELOAD [R] / Reloading… / OUT) takes the name's place. */
.ms-weapon-card:has(.ms-weapon-card__state:not(:empty)) .ms-weapon-card__name {
  visibility: hidden;
}

.ms-weapon-card--reloading .ms-weapon-card__state {
  color: var(--gold);
}

.ms-weapon-card--dead > * {
  opacity: 0.5;
}

/* Money: a small line in the weapon panel (coin + balance, gold). */
.ms-hudc--weapon > .ms-money-chip {
  grid-area: money;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--gold);
}

.ms-money-chip .ms-icon {
  width: 14px;
  height: 14px;
}

.ms-money-chip__value {
  min-width: 0;
  text-shadow: 0 2px 0 var(--stroke-ink);
}

/* ---- weapon slots (weaponSlots.js) ------------------------------------- */
.ms-weapon-slot {
  color: var(--muted);
}

.ms-weapon-slot .ms-weapon-slot__glyph {
  width: var(--hud-glyph);
  height: var(--hud-glyph);
  margin-bottom: 3px;
}

.ms-weapon-slot__digit {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 9px;
  letter-spacing: 0;
  line-height: 1;
  color: var(--muted);
}

.ms-weapon-slot--active {
  border-color: var(--gold);
  background: rgba(255, 197, 49, 0.16);
  color: var(--gold);
  box-shadow: none;
}

.ms-weapon-slot--active .ms-weapon-slot__digit {
  color: var(--gold);
}

.ms-weapon-slot__marker,
.ms-weapon-slot--active .ms-weapon-slot__marker {
  display: none;
}

.ms-weapon-slot--grenade {
  border-style: dashed;
  opacity: 0.6;
}

.ms-weapon-slot--grenade-lit {
  opacity: 1;
  background: var(--hud-bg-in);
  box-shadow: none;
}

.ms-weapon-slot--grenade-lit .ms-weapon-slot__glyph,
.ms-weapon-slot--grenade-lit .ms-weapon-slot__digit {
  color: var(--gold);
}

/* ---- owned items (above the weapon panel) ------------------------------ */
/* F28 (07.3 UI-SPEC S8): a labelled ITEMS row — the S-size muted label,
   then EXACTLY two mini slots (the shop's two item slots). Absent while
   nothing is owned (the `hidden` attribute; hud.css's display: flex would
   otherwise win over the UA [hidden] rule). */
.ms-owned-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-sm); /* label → slots */
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

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

.ms-owned-strip__label {
  color: var(--muted);
  text-shadow: 0 2px 0 var(--stroke-ink);
}

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

/* Mini slot: the .ms-hslot recipe at 28×28, glyph 16px gold. */
.ms-owned-strip__slot {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--gold);
}

.ms-owned-strip__slot .ms-icon {
  width: 16px;
  height: 16px;
}

.ms-owned-strip__slot--empty {
  border: 2px dashed var(--hud-slot-line);
  background: none;
}

/* Inside the clusters a hidden tenant takes NO space (the kit's
   .ms-hidden is visibility-only — pooled status chips, the idle proc
   words, the MAX chip and the empty owned strip used to reserve an
   invisible 676px band over the scene). */
.ms-cluster .ms-hidden,
.ms-weapon-zone .ms-hidden {
  display: none;
}

/* ------------------------------------------------------------------ */
/* Other zones — consistent anchors + chrome                            */
/* ------------------------------------------------------------------ */

/* Kill feed (top-right): M-size names, compact rows. */
.ms-feed {
  top: var(--hud-inset);
  right: var(--hud-inset);
  gap: 6px;
}

/* Narrow desktop windows: the centered strip reaches the feed's column —
   the feed steps under the strip's band. */
@media (max-width: 1180px) {
  html:not(.ms-touch) .ms-feed {
    top: calc(var(--hud-inset) + 72px);
  }
}

.ms-feed__row {
  background: none;
  border: 0;
  box-shadow: none;
}

.ms-feed__chip {
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--hud-radius-in);
}

.ms-feed__actor {
  font-size: var(--hud-fs-m);
  line-height: 1.25;
}

/* ---- 07.3-17 match HUD surfaces (UI-SPEC S6 top bar, S7 kill feed, ---- */
/* ---- S10 scoreboard) — the owner rules; superseded ones deleted    ---- */

/* S6 top bar (F24, D-11): 1fr auto 1fr — the timer sits exactly in the
   middle whatever the score widths; team-coloured digits only. */
.ms-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: var(--sp-lg);
}

.ms-strip__score--a {
  grid-row: 1;
  grid-column: 1;
  justify-self: end;
}

.ms-strip__mid {
  grid-row: 1;
  grid-column: 2;
}

.ms-strip__score--b {
  grid-row: 1;
  grid-column: 3;
  justify-self: start;
}

.ms-strip__score {
  min-width: 2ch;
  font-variant-numeric: tabular-nums;
}

.ms-strip__score--a {
  text-align: end;
}

.ms-strip__score--b {
  text-align: start;
}

/* The hidden score cells (FFA shows the timer only) take no width; a
   hidden sub-line (live Auto mode) collapses. */
.ms-strip > .ms-hidden,
.ms-strip__sub[hidden] {
  display: none;
}

/* S7 kill feed (F29, D-12): the distance is the chip's last segment,
   after a thin divider; muted S-size, tabular. */
.ms-feed__dist {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  margin-left: var(--sp-xs);
  padding-left: var(--sp-sm);
  border-left: 1px solid var(--hud-hair);
  font-family: var(--font-ui);
  font-size: var(--hud-fs-s);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* S10 scoreboard (F2): legend on top, then the tables. The board stacks
   (only one of teams / FFA list is shown at a time). */
.ms-matchboard {
  flex-direction: column;
}

.ms-matchboard__legend {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--sp-md);
  row-gap: var(--sp-xs);
  margin-bottom: var(--sp-sm);
  font-family: var(--font-ui);
  font-weight: var(--weight-regular);
  font-size: var(--text-label-size);
  line-height: var(--text-label-lh);
  color: var(--muted);
}

.ms-matchboard__legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  white-space: nowrap;
}

.ms-matchboard__legend-item .ms-icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* The practice dock stays compact: no legend. */
.ms-matchboard--dock .ms-matchboard__legend {
  display: none;
}

/* ONE grid for the header row and every data row: header glyphs and cells
   both centered on the same 4ch/6ch tracks, so each value sits right
   under its column icon. */
.ms-matchboard__labels,
.ms-matchboard__row {
  display: grid;
  grid-template-columns: var(--board-cols);
  align-items: center;
  column-gap: var(--sp-sm);
}

/* The ch-based stat tracks resolve against each grid's OWN font size, so
   the header row carries the rows' body size (only the FIGHTER word stays
   label-sized): otherwise the header's 4ch/6ch tracks come out narrower
   than the rows' and the icons drift left of their numbers. */
.ms-matchboard__labels {
  font-size: var(--text-body-size);
  line-height: var(--text-body-lh);
}

.ms-matchboard__labels > .ms-matchboard__label-name {
  grid-column: 1 / 3;
  font-size: var(--text-label-size);
  line-height: var(--text-label-lh);
}

.ms-matchboard__col {
  justify-self: center;
  justify-items: center;
}

.ms-matchboard__cell {
  justify-self: center;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* TDM team header: a 4px rule in the team colour above the team name. */
.ms-matchboard__head--a,
.ms-matchboard__head--b {
  padding-top: var(--sp-xs);
  border-top: 4px solid var(--paper);
}

.ms-matchboard__head--a {
  border-top-color: var(--team-a, var(--paper));
}

.ms-matchboard__head--b {
  border-top-color: var(--team-b, var(--paper));
}

/* Own row — three cues, never hue alone (gold vs the yellow team): the
   gold Rubik 600 name (hud.css .ms-matchboard__row--own) plus this
   --card-on row fill. */
.ms-matchboard__row--own {
  background: var(--card-on);
  border-radius: var(--radius-sm);
}

/* ROUNDS modes: a fighter already down this round sits on a red fill until
   the next round starts (wins over the own-row fill — you are dead too). */
.ms-matchboard__row.ms-matchboard__row--dead {
  background: color-mix(in srgb, var(--danger) 38%, transparent);
  border-radius: var(--radius-sm);
}

/* Neutral sigil (unknown race): a muted ring in the sigil slot. */
.ms-matchboard__sigil-icon {
  display: inline-flex;
}

.ms-matchboard__sigil-icon--neutral::before {
  content: "";
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  margin: 2px;
  border: 2px solid var(--muted);
  border-radius: 50%;
}

/* Toasts / mode line / spectate chip: the same chrome, inner radius. */
.ms-toast,
.ms-modeline,
.ms-spectate {
  border-radius: var(--hud-radius-in);
}

.ms-toast {
  border-color: var(--stroke-ink);
  box-shadow: var(--hud-shadow), inset 0 0 0 1px rgba(255, 197, 49, 0.55);
}

/* Onboarding tips: the panel radius + stroke weight. */
.ms-tip {
  border-width: 2px;
  border-radius: var(--hud-radius);
  box-shadow: var(--hud-shadow);
}

/* ROUNDS spectate: the followed fighter is the focus — hide the dead
   player's own panels until the next round. */
.ms-round-watching .ms-cluster,
.ms-round-watching .ms-weapon-zone {
  visibility: hidden;
}

/* ------------------------------------------------------------------ */
/* TOUCH (html.ms-touch) — fewer, smaller, on the thumb grid             */
/* ------------------------------------------------------------------ */
/* Compact pass: the phone HUD reads at a glance but leaves the map to the
   player — about 60% of the previous panel area, more see-through. */
html.ms-touch {
  --hud-pad: 4px 7px;
  --hud-radius: 10px;
  --hud-radius-in: 7px;
  --hud-slot: clamp(26px, calc(var(--u) * 4.4), 36px);
  --hud-slot-gap: 3px;
  --hud-glyph: 14px;
  --hud-panel-w: clamp(124px, calc(var(--u) * 20), 180px);
  --hud-bar-h: 5px;
  --hud-thin-h: 3px;
  --hud-fs-l: clamp(14px, calc(var(--u) * 2.3), 20px);
  --hud-fs-m: clamp(11px, calc(var(--u) * 1.7), 14px);
  --hud-fs-s: 9px;
  --hud-bg: rgba(24, 20, 46, 0.58);
  --hud-shadow: 0 2px 0 var(--stroke-ink);
}

/* Top-left: the compact player panel under the touch bar (HP + XP only —
   the ultimate is the arc's ult button, skills live on the Skills
   screen); buffs sit to the panel's right. */
html.ms-touch .ms-cluster {
  left: calc(var(--safe-l) + var(--touch-edge));
  top: calc(var(--safe-t) + var(--touch-edge) + var(--tb-s) + 6px);
  bottom: auto;
  flex-direction: row-reverse;
  align-items: flex-start;
}

html.ms-touch .ms-cluster__status {
  flex-direction: row;
  flex-wrap: wrap;
  max-width: 34vw;
}

/* The compact width is a FLOOR, not a cap: the "MAX LEVEL" chip and the
   armor badges (Barbed Shell "+N" beside the shield) widen the card
   instead of sticking out of it. */
html.ms-touch .ms-hudc--player {
  gap: 4px;
  width: max-content;
  min-width: var(--hud-panel-w);
}

html.ms-touch .ms-cluster__slots,
html.ms-touch .ms-cluster__points,
html.ms-touch .ms-cluster__name,
html.ms-touch .ms-cluster .ms-toast--ult {
  display: none;
}

html.ms-touch .ms-vitals__heart,
html.ms-touch .ms-vitals__heart .ms-icon {
  width: 13px;
  height: 13px;
}

/* The "/100" max is implied on a phone — the bar carries the ratio. */
html.ms-touch .ms-vitals__max {
  display: none;
}

html.ms-touch .ms-vitals__track {
  min-width: 32px;
}

html.ms-touch .ms-cluster__sigil .ms-icon {
  width: 13px;
  height: 13px;
}

html.ms-touch .ms-statuschip {
  height: 20px;
  padding: 0 5px;
}

/* XP floaters: beside the compact panel. */
html.ms-touch .ms-xpfloater {
  left: calc(var(--safe-l) + var(--touch-edge) + var(--hud-panel-w) + 24px);
  top: calc(var(--safe-t) + var(--touch-edge) + var(--tb-s) + 40px);
  bottom: auto;
}

/* Kill feed: under the player panel, ≤ 3 compact rows (2 on short
   phones) — clear of the right-hand fire arc and its outer ring. */
html.ms-touch .ms-feed {
  top: calc(var(--safe-t) + var(--touch-edge) + var(--tb-s) + 6px + var(--hud-touch-player-h) + 8px);
  left: calc(var(--safe-l) + var(--touch-edge));
  right: auto;
  align-items: flex-start;
  gap: 4px;
  transform: none;
}

html.ms-touch {
  --hud-touch-player-h: calc(var(--hud-fs-l) + var(--hud-fs-s) + 24px);
}

html.ms-touch .ms-feed__row:nth-child(n + 4) {
  display: none;
}

html.ms-touch .ms-feed__chip {
  padding: 1px 7px;
  gap: 4px;
}

html.ms-touch .ms-feed__actor {
  max-width: 11ch;
}

html.ms-touch .ms-feed__sigil,
html.ms-touch .ms-feed__glyph {
  width: 13px;
  height: 13px;
}

/* The distance segment stays off the compact touch chips (S7). */
html.ms-touch .ms-feed__dist {
  display: none;
}

@media (max-height: 360px) {
  html.ms-touch .ms-feed__row:nth-child(n + 3) {
    display: none;
  }
}

/* Bottom: the weapon panel centered in the free band between the stick's
   resting ring and the fire arc's leftmost button (same token math as
   touch.css) — slots + ammo in one row. */
html.ms-touch .ms-weapon-zone {
  top: auto;
  left: calc(var(--safe-l) + var(--touch-edge) + var(--u) * 3 + var(--tstick-r) * 2 + 6px);
  right: calc(var(--safe-r) + var(--touch-edge) + var(--u) * 3 + var(--tb-l) * 0.5 + var(--ring-r) + var(--tb-m) * 0.5 + 6px);
  bottom: calc(var(--safe-b) + 8px);
  align-items: center;
}

html.ms-touch .ms-hudc--weapon {
  width: auto;
  grid-template-columns: auto auto;
  grid-template-areas:
    "slots ammo"
    "slots bar";
  column-gap: 8px;
  row-gap: 3px;
  padding: 5px;
  pointer-events: none; /* only the slot chips take taps; the rest looks through */
}

html.ms-touch .ms-weapon-card__bar {
  height: var(--hud-thin-h);
  min-width: 44px;
  align-self: start;
}

html.ms-touch .ms-weapon-card__ammo {
  align-self: end;
  padding-right: 2px;
}

html.ms-touch .ms-weapon-card__name,
html.ms-touch .ms-weapon-card__state,
html.ms-touch .ms-owned-strip,
html.ms-touch .ms-weapon-slot--grenade {
  display: none;
}

/* Touch: 5 weapon chips (G hidden — the touch grenade button covers it),
   intrinsic width; F31's space-between is desktop only (07.3 S8). */
html.ms-touch .ms-weapon-slots {
  width: auto;
  justify-content: flex-start;
  gap: var(--hud-slot-gap);
  pointer-events: auto;
}

html.ms-touch .ms-weapon-slot {
  pointer-events: auto;
}

/* Money: a small pill under the right touch bar (next to Shop). */
html.ms-touch .ms-hudc--weapon > .ms-money-chip {
  position: fixed;
  top: calc(var(--safe-t) + var(--touch-edge) + var(--tb-s) + 6px);
  right: calc(var(--safe-r) + var(--touch-edge));
  height: 26px;
  box-sizing: border-box;
  padding: 0 9px 0 7px;
  background: var(--hud-bg);
  border: 2px solid var(--stroke-ink);
  border-radius: var(--hud-radius-in);
  box-shadow: var(--hud-shadow), inset 0 1px 0 var(--hud-hair);
  pointer-events: none;
}

html.ms-touch .ms-moneyfloater {
  position: fixed;
  right: calc(var(--safe-r) + var(--touch-edge) + 8px);
  top: calc(var(--safe-t) + var(--touch-edge) + var(--tb-s) + 40px);
  bottom: auto;
}

/* Top-center on touch: the strip fits between the balanced bars; tips
   and chat take the band under it. */
html.ms-touch .ms-zone-top {
  top: calc(var(--safe-t) + var(--touch-edge) - 4px);
  max-width: calc(100vw - 2 * (var(--safe-l) + var(--touch-edge) + var(--tb-s) * 3 + 12px + 8px));
}

html.ms-touch .ms-strip {
  gap: 12px;
  padding: 3px 14px;
  min-height: var(--tb-s);
  box-sizing: border-box;
}

html.ms-touch .ms-strip__score,
html.ms-touch .ms-strip__timer {
  font-size: var(--hud-fs-m);
}

html.ms-touch .ms-strip__sub {
  font-size: 9px;
  letter-spacing: 0.08em;
}

html.ms-touch .ms-onboard {
  left: calc(var(--safe-l) + var(--touch-edge) + var(--hud-panel-w) + 10px);
  right: auto;
  top: calc(var(--safe-t) + var(--touch-edge) + var(--tb-s) + 6px);
  transform: none;
  /* between the player panel and the money pill */
  width: min(300px, calc(100vw - var(--safe-l) - var(--safe-r) - 2 * var(--touch-edge) - var(--hud-panel-w) - 120px));
}

html.ms-touch .ms-chat:not(.ms-chat--lobby) {
  left: calc(var(--safe-l) + var(--touch-edge) + var(--hud-panel-w) + 10px);
  top: calc(var(--safe-t) + var(--touch-edge) + var(--tb-s) + 6px);
  transform: none;
  width: min(360px, calc(100vw - var(--safe-l) - var(--safe-r) - 2 * var(--touch-edge) - var(--hud-panel-w) - 120px));
}

html.ms-touch .ms-modeline {
  top: calc(var(--safe-t) + var(--touch-edge) + var(--tb-s) + 10px);
}

/* ------------------------------------------------------------------ */
/* Reduced motion (OS preference; the player setting is ux.css's        */
/* :root.ms-reduced-motion rule, which covers everything under .ms-ui)  */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .ms-chargering--ready::after,
  .ms-vitals--low .ms-vitals__heart,
  .ms-chargering--search .ms-chargering__arc {
    animation: none;
  }

  .ms-chargering--ready::after {
    opacity: 1;
  }
}

:root.ms-reduced-motion .ms-chargering--ready::after {
  animation: none;
  opacity: 1;
}

/* Touch: world-anchored numbers (damage, heal, XP) shrink so they never
   swamp the crosshair on a phone screen. */
html.ms-touch .ms-dmgnum,
html.ms-touch .ms-healnum {
  font-size: 20px;
  -webkit-text-stroke-width: 4px;
}

html.ms-touch .ms-xpfloater__item {
  font-size: 13px;
}
