/* ==========================================================================
   NEON APEX — HUD stylesheet.
   Broadcast telemetry language: hairline glass panels, micro labels with wide
   tracking, huge tabular mono numerals, one cyan accent line per panel.
   Owns everything inside #hud; never touches #stage or #boot.
   ========================================================================== */

.nx-root {
  --nx-margin: 32px;
  --ink: #05070e;
  --deep: #0b1230;
  --haze: #2a3a72;
  --fg: #f2f5ff;
  --muted: rgba(214, 226, 255, 0.82);
  --line: rgba(190, 202, 232, 0.13);
  --glass: rgba(6, 10, 20, 0.46);
  --cyan: #4ff0e1;
  --magenta: #ff2e88;
  --amber: #ffb545;
  --lime: #a8ff60;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Inter, system-ui, sans-serif;

  /* The HUD floats over a moving picture, so every glyph carries its own dark
     edge. Without this, labels vanish the moment a bright skyline drifts under
     them. */
  text-shadow: 0 1px 3px rgba(4, 6, 12, 0.8);

  position: absolute;
  inset: 0;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.2;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
  pointer-events: none;
}

.nx-root *,
.nx-root *::before,
.nx-root *::after {
  box-sizing: border-box;
}

/* ------------------------------------------------------------- primitives */

.nx-mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
  letter-spacing: 0.015em;
}

.nx-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.nx-panel {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 2px;
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.9);
}

/* a single hairline accent per panel */
.nx-panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 12px;
  width: 34px;
  height: 1px;
  background: var(--cyan);
  opacity: 0.85;
  box-shadow: 0 0 12px rgba(79, 240, 225, 0.55);
}

/* ------------------------------------------------ crt / terminal layer ==== */

/* Above the 3D scene, *below* every screen: the picture gets the phosphor
   treatment without ever laying a band across a glyph. */
.nx-crt {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.9;
  animation: nxCrtBreathe 9s steps(2, jump-none) infinite;
}

.nx-crt-scan {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(3, 5, 12, 0.30) 0px,
    rgba(3, 5, 12, 0.30) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.55;
}

.nx-crt-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(130% 105% at 50% 48%, transparent 62%, rgba(2, 4, 10, 0.42) 100%),
    linear-gradient(180deg, rgba(79, 240, 225, 0.035), transparent 24%, transparent 76%, rgba(255, 46, 136, 0.03));
}

@keyframes nxCrtBreathe {
  0%, 100% { opacity: 0.88; }
  50% { opacity: 0.94; }
}

/* The off switch: one class removes the layer and every fringe with it. */
.nx-crt-off .nx-crt { display: none; }

.nx-crt-off .nx-panel::after,
.nx-crt-off .nx-charge::after,
.nx-crt-off .nx-delta::after,
.nx-crt-off .nx-pos::after { display: none; }

/* One pixel of chromatic fringing on every glass edge — magenta left, cyan
   right, the way a cheap capture card splits a hard vertical. */
.nx-panel::after,
.nx-charge::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-left: 1px solid rgba(255, 46, 136, 0.30);
  border-right: 1px solid rgba(79, 240, 225, 0.26);
  mix-blend-mode: screen;
}

.nx-screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 380ms cubic-bezier(0.22, 0.61, 0.36, 1), visibility 0s linear 380ms;
}

.nx-screen.is-on {
  opacity: 1;
  visibility: visible;
  transition: opacity 380ms cubic-bezier(0.22, 0.61, 0.36, 1), visibility 0s linear 0s;
}

/* A fading-out screen must not answer clicks through its buttons. */
.nx-screen:not(.is-on) [data-interactive] {
  pointer-events: none !important;
}

/* ============================================================ 1. menu ==== */

.nx-menu {
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 40%, rgba(5, 7, 14, 0.25), rgba(5, 7, 14, 0.72));
  cursor: pointer;
}

.nx-menu-bloom {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(44% 32% at 50% 31%, rgba(79, 240, 225, 0.16), transparent 70%),
    radial-gradient(70% 50% at 50% 50%, rgba(42, 58, 114, 0.30), transparent 78%);
  filter: blur(6px);
  pointer-events: none;
}

.nx-menu-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(22px, 3.4vh, 40px);
  padding: 28px;
  max-width: min(980px, 88vw);
  text-align: center;
}

.nx-wordmark {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(44px, 7.6vw, 128px);
  font-weight: 200;
  line-height: 0.98;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: #eef2ff;
  text-shadow: 0 0 26px rgba(79, 240, 225, 0.28), 0 0 90px rgba(79, 240, 225, 0.16);
}

/* The title resolving out of glyph soup; the tint marks the decode sweep. */
.nx-wordmark.is-decoding {
  color: #d9fbf7;
  text-shadow: 0 0 28px rgba(79, 240, 225, 0.55), 0 0 90px rgba(255, 46, 136, 0.14);
}

.nx-subtitle {
  margin: 14px 0 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  text-transform: uppercase;
  color: rgba(214, 226, 255, 0.82);
}

.nx-cta {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 16px clamp(38px, 5vw, 72px) 14px;
  background: rgba(79, 240, 225, 0.06);
  border: 1px solid rgba(79, 240, 225, 0.36);
  border-radius: 2px;
  color: var(--fg);
  font-family: var(--sans);
  cursor: pointer;
  transition: background 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.nx-cta::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 1px;
  background: var(--cyan);
  opacity: 0.9;
  box-shadow: 0 0 14px rgba(79, 240, 225, 0.7);
}

.nx-cta:hover,
.nx-cta:focus-visible {
  background: rgba(79, 240, 225, 0.14);
  border-color: rgba(79, 240, 225, 0.7);
  box-shadow: 0 0 34px -8px rgba(79, 240, 225, 0.55);
  outline: none;
}

.nx-cta-main {
  font-size: clamp(15px, 1.35vw, 21px);
  font-weight: 500;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  text-transform: uppercase;
}

.nx-cta-hint {
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(214, 226, 255, 0.76);
}

.nx-menu-meta {
  display: flex;
  align-items: center;
  gap: clamp(18px, 2.4vw, 34px);
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.nx-best,
.nx-quality,
.nx-mute {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  background: none;
  border: 0;
  padding: 0;
  color: var(--fg);
  font-family: var(--sans);
  text-align: left;
}

.nx-best-val {
  font-size: 15px;
  color: #dfe6ff;
}

.nx-quality,
.nx-mute {
  cursor: pointer;
  padding: 2px 0;
}

.nx-quality:hover .nx-label,
.nx-mute:hover .nx-label {
  color: rgba(242, 245, 255, 0.72);
}

.nx-seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.nx-seg i {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 4px 10px 3px;
  color: var(--muted);
  background: rgba(5, 7, 14, 0.25);
  transition: color 160ms ease, background 160ms ease;
}

.nx-seg i + i {
  border-left: 1px solid var(--line);
}

.nx-seg i.is-on {
  color: var(--cyan);
  background: rgba(79, 240, 225, 0.10);
}

.nx-mute-val {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cyan);
  padding: 4px 10px 3px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(5, 7, 14, 0.25);
}

.nx-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 52px;
  padding-top: 2px;
  text-align: left;
}

.nx-legend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 132px;
}

.nx-keys {
  display: inline-flex;
  gap: 4px;
}

.nx-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 21px;
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  color: rgba(242, 245, 255, 0.82);
  background: rgba(190, 202, 232, 0.08);
  border: 1px solid var(--line);
  border-bottom-color: rgba(190, 202, 232, 0.26);
  border-radius: 2px;
}

.nx-keys kbd.wide {
  min-width: 46px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 10px;
}

.nx-legend-name {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(214, 226, 255, 0.80);
}

/* ======================================================== 2. countdown ==== */

.nx-countdown {
  display: grid;
  place-items: center;
}

.nx-count {
  position: relative;
  display: grid;
  place-items: center;
  width: min(46vw, 420px);
  aspect-ratio: 1;
}

.nx-count-ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(79, 240, 225, 0.55);
  border-radius: 50%;
  box-shadow: 0 0 40px -12px rgba(79, 240, 225, 0.55), inset 0 0 40px -18px rgba(79, 240, 225, 0.5);
  opacity: 0;
}

.nx-count-ring.is-tick {
  animation: nxRingCollapse 900ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.nx-count-num {
  /* Smaller, dimmer, and lit by a wide soft halo rather than a tight one: a 340 px near-white glyph
     at full opacity, re-flashed every second over a night scene, is the most strain the HUD asks for
     and it is asking before the player has touched anything. */
  font-size: clamp(88px, 15vw, 224px);
  font-weight: 100;
  line-height: 0.84;
  letter-spacing: 0.02em;
  color: #d7ebff;
  text-shadow: 0 0 96px rgba(120, 200, 255, 0.22);
}

.nx-count-num.is-go {
  font-size: clamp(84px, 14vw, 220px);
  font-weight: 200;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  color: var(--cyan);
  text-shadow: 0 0 110px rgba(79, 240, 225, 0.3);
}

.nx-count-num.is-tick {
  animation: nxCountTick 900ms cubic-bezier(0.16, 0.8, 0.28, 1) both;
}

@keyframes nxCountTick {
  /* No `filter: blur()` on the way in: blurring a bright glyph spreads its energy over more pixels
     instead of dimming it, so the burst read as a brighter smear, not a softer arrival. The peek is
     also held at 62% rather than 100%, and the pop is 1.12x rather than 1.42x. */
  0% { opacity: 0; transform: scale(1.12); }
  22% { opacity: 0.62; transform: scale(1); }
  70% { opacity: 0.5; transform: scale(0.99); }
  100% { opacity: 0; transform: scale(0.94); }
}

@keyframes nxRingCollapse {
  0% { opacity: 0; transform: scale(1.85); }
  26% { opacity: 0.38; }
  100% { opacity: 0; transform: scale(1); }
}

/* ============================================================ 3. race ===== */

.nx-race {
  pointer-events: none;
}

.nx-race.is-dim {
  opacity: 0.25;
  filter: saturate(0.65);
}

.nx-region {
  position: absolute;
}

.nx-tl {
  top: var(--nx-margin);
  left: var(--nx-margin);
}

.nx-tc {
  top: var(--nx-margin);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.nx-tr {
  top: var(--nx-margin);
  right: var(--nx-margin);
}

.nx-bl {
  bottom: var(--nx-margin);
  left: var(--nx-margin);
}

.nx-br {
  bottom: var(--nx-margin);
  right: var(--nx-margin);
}

.nx-bc {
  bottom: var(--nx-margin);
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, 30vw);
}

/* ---- lap panel ---- */

.nx-lap {
  min-width: 214px;
  padding: 12px 16px 12px;
}

.nx-lap-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(190, 202, 232, 0.09);
}

.nx-lap-count {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 13px;
  color: #dfe6ff;
}

.nx-lap-count b {
  font-weight: 500;
  font-size: 15px;
  color: var(--fg);
}

.nx-lap-sep {
  color: rgba(214, 226, 255, 0.72);
}

.nx-lap-time {
  font-size: clamp(24px, 2.15vw, 32px);
  font-weight: 400;
  line-height: 1.12;
  padding: 8px 0 6px;
  color: var(--fg);
  white-space: nowrap;
}

.nx-lap-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nx-lap-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 22px;
  font-size: 12px;
  color: rgba(223, 230, 255, 0.82);
  white-space: nowrap;
}

.nx-lap-row .nx-mono.is-best {
  color: var(--cyan);
}

/* ---- delta pill — cut corners, hairline magenta rule ---- */

.nx-delta {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 16px 7px 14px;
  border: 1px solid rgba(190, 202, 232, 0.16);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(11, 18, 48, 0.54), rgba(5, 7, 14, 0.44));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  clip-path: polygon(
    0 0,
    calc(100% - 12px) 0,
    100% 12px,
    100% 100%,
    12px 100%,
    0 calc(100% - 12px)
  );
  transition: border-color 200ms ease, color 200ms ease, background 200ms ease;
}

.nx-delta::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 46, 136, 0.9), rgba(255, 46, 136, 0.04));
}

.nx-delta::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-left: 1px solid rgba(255, 46, 136, 0.30);
  border-right: 1px solid rgba(79, 240, 225, 0.26);
  mix-blend-mode: screen;
}

.nx-delta-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.nx-delta-val {
  min-width: 62px;
  text-align: right;
  font-size: 15px;
  color: var(--muted);
}

/* Lap-complete tear: 120 ms sideways, then the HUD drops the class itself. */
.nx-delta.nx-glitch {
  animation: nxDeltaTear 120ms steps(3, jump-none) both;
}

@keyframes nxDeltaTear {
  0% { transform: none; filter: none; }
  22% {
    transform: translateX(-6px) skewX(-9deg);
    filter: drop-shadow(2px 0 0 rgba(255, 46, 136, 0.85)) drop-shadow(-2px 0 0 rgba(79, 240, 225, 0.65));
  }
  52% { transform: translateX(5px) skewX(6deg); }
  78% { transform: translateX(-2px) skewX(-2deg); }
  100% { transform: none; filter: none; }
}

.nx-delta.is-ahead {
  border-color: rgba(168, 255, 96, 0.45);
  background: rgba(35, 60, 24, 0.36);
}

.nx-delta.is-ahead .nx-delta-val {
  color: var(--lime);
  text-shadow: 0 0 18px rgba(168, 255, 96, 0.45);
}

.nx-delta.is-behind {
  border-color: rgba(255, 181, 69, 0.45);
  background: rgba(64, 45, 14, 0.36);
}

.nx-delta.is-behind .nx-delta-val {
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255, 181, 69, 0.4);
}

.nx-delta.is-empty {
  opacity: 0.5;
}

.nx-combo {
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.nx-combo.is-on {
  opacity: 1;
  transform: none;
}

/* ---- position panel — mirrored cuts, magenta rule ---- */

.nx-pos {
  position: relative;
  min-width: 140px;
  padding: 10px 15px 12px;
  text-align: right;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(11, 18, 48, 0.52), rgba(5, 7, 14, 0.44));
  clip-path: polygon(
    12px 0,
    100% 0,
    100% calc(100% - 12px),
    calc(100% - 12px) 100%,
    0 100%,
    0 12px
  );
}

/* the panel's single accent line goes magenta and moves to the cut corner */
.nx-panel.nx-pos::before {
  top: 0;
  left: auto;
  right: 14px;
  width: 46px;
  background: var(--magenta);
  opacity: 0.8;
  box-shadow: 0 0 12px rgba(255, 46, 136, 0.5);
}

.nx-pos-tag {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.nx-pos-line {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 8px;
}

.nx-pos-slot {
  font-size: 20px;
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--fg);
}

.nx-pos-slot b {
  font-weight: 400;
}

.nx-pos-field {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.nx-pos-ticks {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 9px;
}

.nx-pos-ticks i {
  display: block;
  width: 15px;
  height: 3px;
  background: rgba(190, 202, 232, 0.22);
  transition: background 180ms ease, box-shadow 180ms ease;
}

.nx-pos-ticks i.is-player {
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(79, 240, 225, 0.6);
}

/* ---- minimap ---- */

.nx-minimap {
  position: relative;
  /* Bigger, because it is now a heading-up dial you actually read at 200 km/h rather than a
     squiggle you glance at: 184 px sits clear of the drift/boost bars (bottom centre) and the
     speed cluster (bottom right), and still leaves the road ahead unobscured. */
  width: 184px;
  height: 184px;
  border-radius: 50%;
  border: 1px solid rgba(79, 240, 225, 0.34);
  background:
    radial-gradient(circle at 50% 42%, rgba(79, 240, 225, 0.09), transparent 68%),
    rgba(6, 10, 20, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 0 18px rgba(79, 240, 225, 0.12), inset 0 0 22px rgba(79, 240, 225, 0.06);
  overflow: hidden;
}

.nx-map-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- scoped dial ---- */

/**
 * The near view: the same circuit, zoomed to about 75 m about the car.
 *
 * It sits directly above the global dial — closer to where the eye actually is, and to the road — and
 * is drawn at 42% so the asphalt reads through it. The two answer different questions: the global dial
 * says where on the lap you are, this one says what the next corner does, which at 84 px on a phone the
 * global one cannot (a 40 m corner is under four pixels there).
 */
.nx-scope-region {
  left: var(--nx-margin);
  bottom: calc(var(--nx-margin) + 196px);
}

.nx-scope {
  position: relative;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  /*
   * No ring, no plate, no glow.
   *
   * The dial is the road and nothing else: the previous version drew a lit circle, a disc under it and an
   * inset halo, which framed the map like a widget sitting on the windscreen. The edge now fades with a mask
   * instead of being outlined, so the path trails off into the scene rather than stopping at a boundary the
   * eye can trace.
   */
  border: none;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 54%, transparent 78%);
  mask-image: radial-gradient(circle at 50% 50%, #000 54%, transparent 78%);
}

.nx-scope-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.nx-map-track {
  fill: none;
  stroke: rgba(79, 240, 225, 0.60);
  stroke-width: 1.3;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 2.4px rgba(79, 240, 225, 0.55));
}

/* The bridge deck: the frozen slice of curve between t = 0.30 and t = 0.40. */
.nx-map-bridge {
  fill: none;
  stroke: var(--magenta);
  stroke-width: 2.2;
  stroke-linecap: butt;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 4px rgba(255, 46, 136, 0.9));
}

.nx-map-trail-dot {
  fill: var(--cyan);
  opacity: 0;
}

/* fade the tail out; the head of the trail is the freshest sample */
.nx-map-trail-dot.is-on { opacity: 0.46; }
.nx-map-trail-dot.is-on:nth-child(2) { opacity: 0.36; }
.nx-map-trail-dot.is-on:nth-child(3) { opacity: 0.26; }
.nx-map-trail-dot.is-on:nth-child(4) { opacity: 0.18; }
.nx-map-trail-dot.is-on:nth-child(5) { opacity: 0.11; }
.nx-map-trail-dot.is-on:nth-child(6) { opacity: 0.06; }

.nx-map-player {
  fill: var(--cyan);
  filter: drop-shadow(0 0 5px rgba(79, 240, 225, 1)) drop-shadow(0 0 10px rgba(79, 240, 225, 0.5));
}

/*
 * The scoped dial sits in the driver's eyeline, so it has to be quieter than the overview in the corner.
 * Same geometry, a third of the weight: no drop shadows, a thinner line, and hues pulled toward the scene's
 * twilight rather than the full-saturation neon that reads well at 128 px but glares at 4x the area.
 */
.nx-scope .nx-map-track {
  stroke: rgba(126, 214, 232, 0.28);
  stroke-width: 1;
  filter: none;
}

.nx-scope .nx-map-bridge {
  stroke: rgba(255, 96, 158, 0.3);
  stroke-width: 1.3;
  filter: none;
}

.nx-scope .nx-map-player {
  fill: rgba(158, 240, 234, 0.9);
  filter: none;
}

.nx-scope .nx-map-rival {
  fill: rgba(255, 128, 176, 0.32);
}

.nx-map-heading {
  stroke: var(--cyan);
  stroke-width: 1.8;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.nx-map-rival {
  fill: var(--magenta);
  filter: drop-shadow(0 0 3px rgba(255, 46, 136, 0.8));
  transition: opacity 260ms ease;
}

.nx-map-label {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  text-transform: uppercase;
  /* Sits on top of the minimap's own track lines, so it carries a plate. */
  color: rgba(233, 240, 255, 0.94);
  padding: 2px 7px 2px 7px;
  background: rgba(4, 7, 14, 0.82);
  border-radius: 2px;
  white-space: nowrap;
}

/* ---- speedometer ---- */

.nx-speedo {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding: 14px 18px 12px;
  width: clamp(238px, 21vw, 320px);
}

.nx-shifts {
  display: flex;
  gap: 3px;
  align-self: center;
}

.nx-shifts i {
  display: block;
  width: 17px;
  height: 3px;
  background: rgba(190, 202, 232, 0.14);
  transition: background 90ms linear, box-shadow 90ms linear;
}

.nx-shifts i.is-lit {
  background: var(--cyan);
  box-shadow: 0 0 9px rgba(79, 240, 225, 0.75);
}

.nx-shifts i:nth-child(n + 5).is-lit {
  background: var(--magenta);
  box-shadow: 0 0 10px rgba(255, 46, 136, 0.85);
}

.nx-shifts i.is-flash {
  animation: nxShiftFlash 220ms steps(2, jump-none) infinite;
}

@keyframes nxShiftFlash {
  0% { opacity: 1; }
  100% { opacity: 0.18; }
}

.nx-tach {
  position: relative;
  width: 100%;
}

.nx-tach-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.nx-tach-track {
  fill: none;
  stroke: rgba(190, 202, 232, 0.13);
  stroke-width: 2;
  stroke-linecap: butt;
}

.nx-tach-fill {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 2.4;
  stroke-linecap: butt;
  stroke-dasharray: 0 100;
  filter: drop-shadow(0 0 5px rgba(79, 240, 225, 0.7));
  transition: stroke 180ms ease;
}

.nx-tach-fill.is-limiter {
  stroke: var(--magenta);
  filter: drop-shadow(0 0 7px rgba(255, 46, 136, 0.85));
}

.nx-tach-ticks line {
  stroke: rgba(190, 202, 232, 0.22);
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
}

.nx-tach-ticks line.is-major {
  stroke: rgba(190, 202, 232, 0.45);
  stroke-width: 1.1;
}

.nx-speed-read {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.nx-speed {
  min-width: 3ch;
  text-align: center;
  font-size: clamp(58px, min(6.3vw, 13vh), 128px);
  font-weight: 300;
  line-height: 0.82;
  letter-spacing: 0.01em;
  color: #f6f9ff;
  text-shadow: 0 0 34px rgba(79, 240, 225, 0.22);
}

.nx-speed-unit {
  font-size: 10px;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  text-transform: uppercase;
  color: var(--muted);
}

.nx-gear-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border-top: 1px solid rgba(190, 202, 232, 0.09);
  padding-top: 8px;
}

.nx-gear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 8px;
  font-size: 15px;
  color: var(--cyan);
  border: 1px solid rgba(79, 240, 225, 0.38);
  border-radius: 2px;
  background: rgba(79, 240, 225, 0.07);
}

/* ---- boost + drift rails ---- */

.nx-charge {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 16px 13px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 2px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.nx-charge::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: -1px;
  height: 1px;
  background: var(--cyan);
  opacity: 0.8;
}

.nx-rail {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nx-rail .nx-label {
  width: 46px;
  flex: 0 0 46px;
}

.nx-rail-track {
  position: relative;
  flex: 1 1 auto;
  display: block;
  height: 5px;
  background: rgba(190, 202, 232, 0.11);
  border-radius: 1px;
  overflow: hidden;
}

.nx-rail-drift .nx-rail-track {
  height: 2px;
}

.nx-rail-fill {
  position: absolute;
  inset: 0;
  display: block;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 120ms linear;
}

.nx-rail-boost .nx-rail-fill {
  background: linear-gradient(90deg, rgba(79, 240, 225, 0.55), var(--cyan));
  box-shadow: 0 0 12px rgba(79, 240, 225, 0.7);
}

.nx-rail-boost .nx-rail-fill.is-empty {
  background: linear-gradient(90deg, rgba(255, 181, 69, 0.5), var(--amber));
}

.nx-rail-drift .nx-rail-fill {
  background: var(--lime);
  box-shadow: 0 0 10px rgba(168, 255, 96, 0.6);
}

.nx-rail-val {
  flex: 0 0 42px;
  text-align: right;
  font-size: 11px;
  color: rgba(223, 230, 255, 0.78);
}

/* ---- wrong way ---- */

.nx-wrongway {
  position: absolute;
  left: 50%;
  top: 61%;
  transform: translate(-50%, 0) scale(0.96);
  padding: 9px 22px 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  text-transform: uppercase;
  color: var(--magenta);
  border: 1px solid rgba(255, 46, 136, 0.5);
  border-radius: 2px;
  background: rgba(52, 6, 24, 0.42);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.nx-wrongway.is-on {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  animation: nxWrongPulse 900ms ease-in-out infinite;
}

@keyframes nxWrongPulse {
  0%, 100% { border-color: rgba(255, 46, 136, 0.5); }
  50% { border-color: rgba(255, 46, 136, 0.95); }
}

/* ========================================================== 4. paused ==== */

.nx-paused {
  display: grid;
  place-items: center;
  background: radial-gradient(90% 70% at 50% 50%, rgba(5, 7, 14, 0.55), rgba(5, 7, 14, 0.72));
}

.nx-pause-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 26px 52px 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.nx-pause-title {
  font-size: clamp(30px, 3.6vw, 54px);
  font-weight: 200;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  text-transform: uppercase;
  color: var(--fg);
  text-shadow: 0 0 40px rgba(79, 240, 225, 0.25);
}

.nx-pause-hint {
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(190, 202, 232, 0.5);
}

.nx-pause-hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 19px;
  margin: 0 4px;
  padding: 0 5px;
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(242, 245, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(190, 202, 232, 0.08);
}

/* ========================================================= 5. results ==== */

.nx-results {
  display: grid;
  place-items: center;
  background: radial-gradient(90% 80% at 50% 50%, rgba(5, 7, 14, 0.45), rgba(5, 7, 14, 0.8));
}

.nx-results-inner {
  position: relative;
  width: min(620px, 78vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 26px 20px;
  background: rgba(11, 18, 48, 0.42);
  border: 1px solid var(--line);
  border-radius: 2px;
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  box-shadow: 0 40px 90px -50px rgba(0, 0, 0, 0.95);
}

.nx-results-inner::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 26px;
  width: 42px;
  height: 1px;
  background: var(--cyan);
}

.nx-results-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.nx-results-title {
  margin: 6px 0 0;
  font-size: clamp(20px, 2vw, 30px);
  font-weight: 300;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg);
}

.nx-results-pos {
  text-align: right;
}

.nx-results-pos div {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 5px;
}

.nx-results-pos b {
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--cyan);
}

.nx-results-field {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.nx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.nx-table thead th {
  padding: 0 0 9px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  text-align: left;
  color: rgba(190, 202, 232, 0.4);
  border-bottom: 1px solid rgba(190, 202, 232, 0.09);
}

.nx-table th:nth-child(2),
.nx-table th:nth-child(3),
.nx-table td:nth-child(2),
.nx-table td:nth-child(3) {
  text-align: right;
}

.nx-table tbody tr {
  animation: nxRowIn 460ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.nx-table td {
  padding: 9px 0;
  border-bottom: 1px solid rgba(190, 202, 232, 0.06);
  color: rgba(223, 230, 255, 0.86);
}

.nx-table tr.is-best td {
  color: var(--fg);
  background: linear-gradient(90deg, rgba(79, 240, 225, 0.10), rgba(79, 240, 225, 0.02));
}

.nx-table tr.is-best .nx-cell-time {
  color: var(--cyan);
}

.nx-cell-lap {
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.nx-cell-time {
  font-size: 15px;
  white-space: nowrap;
}

.nx-cell-split {
  font-size: 12px;
}

.nx-cell-split.is-ahead {
  color: var(--lime);
}

.nx-cell-split.is-behind {
  color: var(--amber);
}

.nx-cell-split.is-empty {
  color: rgba(190, 202, 232, 0.32);
}

.nx-cell-empty {
  text-align: center;
  color: rgba(190, 202, 232, 0.4);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 10px;
  padding: 22px 0;
}

.nx-best-tag {
  margin-left: 10px;
  padding: 2px 6px 1px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cyan);
  border: 1px solid rgba(79, 240, 225, 0.4);
  border-radius: 2px;
  vertical-align: middle;
}

@keyframes nxRowIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

.nx-results-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.nx-results-sum {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nx-results-sum .nx-mono {
  font-size: 15px;
  color: var(--cyan);
}

.nx-restart {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 9px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--fg);
  background: rgba(79, 240, 225, 0.07);
  border: 1px solid rgba(79, 240, 225, 0.36);
  border-radius: 2px;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}

.nx-restart:hover,
.nx-restart:focus-visible {
  background: rgba(79, 240, 225, 0.15);
  border-color: rgba(79, 240, 225, 0.7);
  outline: none;
}

.nx-restart kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 5px;
  color: rgba(242, 245, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 2px;
}

/* ========================================================== 6. toast ===== */

.nx-toasts {
  position: absolute;
  top: calc(var(--nx-margin) + 66px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.nx-toast {
  position: relative;
  padding: 8px 16px 7px 18px;
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(242, 245, 255, 0.9);
  background: rgba(11, 18, 48, 0.55);
  border: 1px solid var(--line);
  border-radius: 2px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 260ms ease, transform 260ms cubic-bezier(0.22, 0.61, 0.36, 1);
  white-space: nowrap;
}

.nx-toast::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  bottom: -1px;
  width: 2px;
  background: var(--cyan);
}

.nx-toast-good::before {
  background: var(--lime);
}

.nx-toast-good {
  color: #e9ffd9;
}

.nx-toast-bad::before {
  background: var(--magenta);
}

.nx-toast-bad {
  color: #ffd8e6;
}

.nx-toast.is-in {
  opacity: 1;
  transform: none;
}

.nx-toast.is-out {
  opacity: 0;
  transform: translateY(-6px);
}

/* ==================================================== 7. responsive ====== */

@media (max-height: 660px), (max-width: 1000px) {
  .nx-root { --nx-margin: 18px; }
  .nx-lap { min-width: 190px; padding: 10px 13px; }
  .nx-lap-time { font-size: 23px; }
  .nx-minimap { width: 156px; height: 156px; }
  .nx-bc { width: min(340px, 30vw); }
}

@media (max-width: 900px) {
  .nx-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; }
  .nx-menu-meta { flex-wrap: wrap; justify-content: center; }
}

/* ============================================= 8. reduced motion ========= */

.nx-reduced .nx-screen,
.nx-reduced .nx-toast,
.nx-reduced .nx-combo,
.nx-reduced .nx-wrongway,
.nx-reduced .nx-delta {
  transition-duration: 1ms !important;
}

.nx-reduced .nx-count-num.is-tick,
.nx-reduced .nx-count-ring.is-tick,
.nx-reduced .nx-shifts i.is-flash,
.nx-reduced .nx-wrongway.is-on,
.nx-reduced .nx-table tbody tr {
  animation: none !important;
}

.nx-reduced .nx-count-num.is-tick {
  opacity: 1;
  transform: none;
}

.nx-reduced .nx-table tbody tr {
  opacity: 1;
  transform: none;
}

/* Terminal layer: the phosphor breathe is the one slow blink allowed, and it
   stops here. Scanlines stay as a still overlay. */
.nx-reduced .nx-crt,
.nx-reduced .nx-delta.nx-glitch {
  animation: none !important;
}

.nx-reduced .nx-crt {
  opacity: 0.9;
}

.nx-reduced .nx-delta.nx-glitch {
  transform: none;
  filter: none;
}

/* Same guarantee before the HUD module has read matchMedia. */
@media (prefers-reduced-motion: reduce) {
  .nx-crt { animation: none; }
  .nx-delta.nx-glitch { animation: none; transform: none; filter: none; }
}

/* ─── phone controls ────────────────────────────────────────────────────────────
   Semi-transparent pedals over the scene, one under each thumb, and the sensor
   arm switch above them. Only on coarse pointers: a desk gets the keyboard and
   nothing else. Sized in vmin so a small phone in landscape still gets a thumb
   target well past the 44 px minimum. */
.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.touch-pedal {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(26vmin, 148px);
  height: min(26vmin, 148px);
  border-radius: 50%;
  border: 2px solid rgba(120, 240, 255, 0.5);
  background: rgba(10, 24, 38, 0.3);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #dff6ff;
  font: 600 12px/1.1 -apple-system, BlinkMacSystemFont, "SF Pro Display", Inter, system-ui, sans-serif;
  letter-spacing: 0.08em;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  padding: 0;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 90ms ease, transform 90ms ease, border-color 90ms ease;
}

.touch-pedal--left { left: max(14px, env(safe-area-inset-left)); }
.touch-pedal--right {
  right: max(14px, env(safe-area-inset-right));
  border-color: rgba(255, 138, 214, 0.5);
}

.touch-pedal.is-down {
  background: rgba(79, 240, 225, 0.32);
  border-color: rgba(180, 255, 250, 0.9);
  transform: scale(0.96);
}

.touch-pedal--right.is-down {
  background: rgba(255, 138, 214, 0.32);
  border-color: rgba(255, 200, 240, 0.9);
}

.touch-pedal__glyph { font-size: 22px; line-height: 1; }
.touch-pedal__label { font-size: 10px; opacity: 0.78; text-transform: uppercase; }

.touch-tilt {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  touch-action: manipulation;
  border: 1px solid rgba(120, 240, 255, 0.45);
  border-radius: 999px;
  background: rgba(8, 20, 32, 0.55);
  color: #cdf3ff;
  font: 600 10px/1 -apple-system, BlinkMacSystemFont, Inter, system-ui, sans-serif;
  letter-spacing: 0.14em;
  padding: 9px 14px;
  -webkit-tap-highlight-color: transparent;
}

.touch-tilt.is-armed {
  border-color: rgba(79, 240, 225, 0.9);
  color: #4ff0e1;
}

.touch-tilt:disabled { opacity: 0.4; }

/* The manual route, tucked under the automatic one: small, quiet, always there. */
.touch-tilt-setup {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 38px);
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  touch-action: manipulation;
  border: 1px solid rgba(150, 170, 190, 0.4);
  border-radius: 999px;
  background: rgba(8, 20, 32, 0.45);
  color: #93a6b8;
  font: 600 9px/1 -apple-system, BlinkMacSystemFont, Inter, system-ui, sans-serif;
  letter-spacing: 0.16em;
  padding: 7px 11px;
}

/* The calibration sheet: three taps, over a dimming layer, big enough to hit with a thumb. */
.touch-cal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(3, 8, 16, 0.72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  pointer-events: auto;
}

.touch-cal[hidden] { display: none; }

.touch-cal__panel {
  width: min(88vw, 380px);
  border: 1px solid rgba(120, 240, 255, 0.5);
  border-radius: 18px;
  background: rgba(8, 18, 30, 0.94);
  color: #dff6ff;
  padding: 18px 16px 14px;
  display: grid;
  gap: 12px;
  font: 500 13px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Display", Inter, system-ui, sans-serif;
}

.touch-cal__title {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: #4ff0e1;
}

.touch-cal__step { color: #b9c7d6; }

.touch-cal__readout {
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  letter-spacing: 0.04em;
  color: #fff;
}

.touch-cal__row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.touch-cal__btn {
  padding: 14px 6px;
  border-radius: 12px;
  border: 1px solid rgba(120, 240, 255, 0.45);
  background: rgba(20, 40, 58, 0.9);
  color: #dff6ff;
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, Inter, system-ui, sans-serif;
  letter-spacing: 0.1em;
  touch-action: manipulation;
}

.touch-cal__btn.is-done {
  border-color: rgba(79, 240, 225, 0.9);
  color: #4ff0e1;
  opacity: 0.65;
}

.touch-cal__btn:disabled { opacity: 0.35; }

.touch-cal__hint { color: #ffb4d2; font-size: 12px; min-height: 1.4em; }

.touch-cal__close {
  justify-self: end;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(150, 170, 190, 0.5);
  background: transparent;
  color: #b9c7d6;
  font: 600 10px/1 -apple-system, BlinkMacSystemFont, Inter, system-ui, sans-serif;
  letter-spacing: 0.14em;
}

@media (pointer: fine) {
  .touch-controls { display: none; }
}

/* On a phone the two pedals own the bottom corners, so the HUD regions that live down there have
   to move out of their way. Measured on a 390x844 viewport: the 184 px minimap sat at the bottom
   left and the 101 px brake pedal was drawn on top of its lower half, with the speed cluster
   overlapping the accelerator the same way. Lifting the bottom regions by one pedal plus a gap
   puts both back in the clear without shrinking either. */
@media (pointer: coarse) {
  .nx-bl,
  .nx-br,
  .nx-bc {
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 118px);
  }

  /* ...and the top band is fully spoken for: LAP, SPLIT and GRID//POS own it edge to edge, so the
     tilt pills sat on top of the lap clock. On a phone they move to the left edge at mid height,
     the one band nothing else claims, stacked small and half-transparent. */
  /**
   * Right edge, just under the split pill, not left-edge-mid-height: raising the dial into its own
   * band put it exactly where the pills were (3 360 px² of overlap at 390x844). Here the pills sit
   * above the speed cluster's band and to the right of the dial's, so neither collides.
   */
  .touch-tilt {
    /* Literal, not calc(var(--nx-margin) + …): that variable is defined inside the HUD subtree and
       the pills live on <body>, so the declaration was invalid at computed-value time and the
       pills fell back to top:auto — measured at y=0, on top of the position panel. */
    top: 208px;
    right: max(8px, env(safe-area-inset-right));
    left: auto;
    transform: none;
    opacity: 0.62;
  }

  .touch-tilt-setup {
    /* +34: the pills are 30 and 25 tall, so this is a 9 px gap, not the 3 px overlap of +24. */
    top: 242px;
    right: max(8px, env(safe-area-inset-right));
    left: auto;
    transform: none;
    opacity: 0.62;
  }

  /* The centre region is centred on a screen where the LAP panel is 190 px and the position panel
     140 px, so its Split//Best pill lands on top of both. Below the top band it has the sky to
     itself, which is the one place a split time can sit without covering a number that matters. */
  .nx-tc {
    top: calc(var(--nx-margin) + 128px);
  }

  /* No caps on the top panels. Their rows are 162 and 108 px inside padding, so a 48vw/36vw cap
     squeezed the lap TIME itself into a 145 px content box and clipped 17 px of it — measured
     row by row, not assumed. They fit by tightening the margins on a narrow phone instead. */

  /**
   * The dial and the speed cluster share one band, side by side, with the dial SHRUNK rather than
   * the cluster capped: 84 + 238 + margins = 350 px fits a 360 px phone, where their own sizes
   * (156 + 238 = 394) did not, and where capping the cluster's width spilled 35 px of gauge out
   * of its box. A small dial beats no dial; hiding it was the previous compromise.
   */
  .nx-minimap { width: 84px; height: 84px; }
  /* One dial plus a gap above the global one, which is itself already lifted clear of the pedals. */
  .nx-scope-region {
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 118px + 84px + 10px);
  }
  .nx-scope { width: 84px; height: 84px; }

  /* Nothing is clipped or hidden up top: they fit at their natural size. */

  /**
   * The drift/boost bar does not belong on a portrait phone. At 30vw (117 px) its own content
   * never fitted and it overflowed by a third of its width; sizing it to content then ran it into
   * the speed cluster (9 344 px² at 360). It duplicates the DRIFT and BOOST rows the cluster
   * already shows, so where there is no room for both, the cluster keeps them. In landscape,
   * where it fits at 338 px with nothing beside it, it stays.
   */
  .nx-bc {
    display: none;
  }
}

/* Landscape is 844x390: there is no room for a bottom band above 101 px pedals, so the speed
   cluster takes the free centre strip between the pedals and the pills drop below the lap panel.
   The dial at 84 px still fits — lap ends at y 140, the brake starts at 275, the cluster at
   x 303 — so it moves up rather than disappearing. Hiding it was the old 156 px dial talking. */
@media (pointer: coarse) and (orientation: landscape) {
  /* The drift/boost bar is 30vw (253 px here) and the top band is free between the lap panel
     ending at x 208 and the position panel starting at 686, so it moves up instead of being
     hidden — the same correction the dial needed. */
  .nx-bc {
    display: block;
    bottom: auto;
    top: 18px;
    width: min(420px, 40vw);
  }

  .nx-bl {
    bottom: auto;
    top: 152px;
    left: 18px;
  }

  /* Beside the dial, not above it: the band above is the lap panel's, and the dial already starts at
     y 152 with 84 px of height, so 112 px puts the scope's left edge 10 px past the dial's right. */
  .nx-scope-region {
    bottom: auto;
    top: 152px;
    left: 112px;
  }
  .nx-scope { width: 72px; height: 72px; }

  .nx-br {
    right: auto;
    left: 50%;
    bottom: max(10px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    max-width: none;
  }

  /* 66% put the stack on top of the brake pedal (1 500 px²). The free band in landscape is
     below the lap panel and left of the speed cluster: 40% lands at y 156 on a 390 px tall
     screen, under the panel's 140 and clear of the cluster's x 303. */
  .touch-tilt { top: 40%; }
  .touch-tilt-setup { top: calc(40% + 34px); }

  /* And the split pill has nowhere to go: between the top band ending at y 140 and the speed
     cluster starting at y 192 there are 52 px for a 57 px pill, and it overlapped by 2 134 px².
     A split time is the least important number on a 390 px tall screen. */
  .nx-tc {
    display: none;
  }
}

/* A 360 px phone leaves 324 px between 18 px side margins, and the two top panels need 330.
   Six pixels short — which the old width caps paid for by clipping 17 px of the lap time.
   Tightening the side margins to 12 buys 12 px back and both panels fit at their natural size. */
@media (pointer: coarse) and (max-width: 380px) {
  .nx-tl { left: 12px; }
  .nx-tr { right: 12px; }
}

/* ====================================================== 9. HUD restructure ====
 *
 * One dial, one gauge, and the lap clock inside it. Appended last on purpose: every rule here
 * supersedes an earlier one at equal specificity, so the restructure is auditable in one place
 * instead of scattered through nine hundred lines of panel styling.
 *
 * The drift/boost rails are gone entirely — the gauge already printed DRIFT and BOOST, so they were a
 * second copy of the same two numbers occupying the bottom centre of every phone screen.
 */

/* Smaller gauge. It now carries the lap clock in its top row and hides the LAST/BEST pair, which is
   what keeps it inside its corner instead of growing into the road. */
.nx-region.nx-br {
  transform: scale(0.86);
  transform-origin: 100% 100%;
}

.nx-speedo .nx-lap {
  min-width: 0;
  width: 100%;
  padding: 0 0 6px;
  background: none;
  border: 0;
  box-shadow: none;
}

.nx-speedo .nx-lap-rows { display: none; }
.nx-speedo .nx-lap-time { font-size: 26px; letter-spacing: 0.02em; }

/* The scoped dial: four times the area, twice as transparent, a quarter across and half way down. */
.nx-scope-region {
  left: 25%;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
}

.nx-scope {
  width: min(46vh, 46vw);
  height: min(46vh, 46vw);
  background:
    radial-gradient(circle at 50% 50%, rgba(79, 240, 225, 0.04), transparent 72%),
    rgba(6, 10, 20, 0.21);
  border-color: rgba(79, 240, 225, 0.16);
}

@media (pointer: coarse) and (orientation: landscape) {
  .nx-region.nx-br {
    transform: translateX(-50%) scale(0.86);
    transform-origin: 50% 100%;
  }
  .nx-scope {
    width: min(46vh, 30vw);
    height: min(46vh, 30vw);
  }
}

/* Corrected after the audit: at 0.86 the gauge still ran into the enlarged dial (scope x speed
   4608 px2 at 360 px), so it drops to 0.72 and the dial is capped by WIDTH as well as height — height
   alone let a 166 px circle sit at a quarter of a 360 px screen and meet the gauge. */
.nx-region.nx-br { transform: scale(0.72); }
.nx-scope { width: min(46vh, 42vw); height: min(46vh, 42vw); }

@media (pointer: coarse) and (orientation: landscape) {
  .nx-region.nx-br { transform: translateX(-50%) scale(0.72); }
  .nx-scope { width: min(46vh, 27vw); height: min(46vh, 27vw); }
}

