:root {
  --void: #05060a;
  --blaze: #ff4d1a;
  --plasma: #00f0ff;
  --volt: #d6ff3a;
  --fog: #9aa3b5;
  --foam: #f2f4f8;
  --font-display: "Bebas Neue", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--foam);
  font-family: var(--font-mono);
  user-select: none;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
}

#game canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(
    ellipse 75% 70% at 50% 45%,
    transparent 40%,
    rgba(5, 6, 10, 0.55) 100%
  );
  transition: background 0.15s ease;
}

.vignette.kick {
  background: radial-gradient(
    ellipse 70% 65% at 50% 45%,
    rgba(214, 255, 58, 0.12) 0%,
    transparent 45%,
    rgba(5, 6, 10, 0.5) 100%
  );
}

body.boosting .vignette {
  background: radial-gradient(
    ellipse 80% 75% at 50% 45%,
    transparent 35%,
    rgba(255, 77, 26, 0.12) 100%
  );
}

body.redline .vignette {
  background: radial-gradient(
    ellipse 85% 80% at 50% 45%,
    rgba(214, 255, 58, 0.1) 0%,
    transparent 40%,
    rgba(255, 77, 26, 0.22) 100%
  );
}

body.redline .hud .stat .value {
  color: var(--volt);
  text-shadow: 0 0 18px rgba(214, 255, 58, 0.55);
}

.speedlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 36px,
      rgba(0, 240, 255, 0.045) 37px,
      transparent 38px
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 18px,
      rgba(255, 77, 26, 0.03) 19px,
      transparent 20px
    );
  mix-blend-mode: screen;
  transition: opacity 0.12s linear;
}

.speedlines.hot {
  animation: streak 0.1s linear infinite;
}

.speedlines.redline {
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 22px,
      rgba(214, 255, 58, 0.08) 23px,
      transparent 24px
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 12px,
      rgba(255, 77, 26, 0.07) 13px,
      transparent 14px
    ),
    radial-gradient(ellipse 60% 50% at 50% 50%, rgba(255, 255, 255, 0.06), transparent 70%);
  animation: streak 0.06s linear infinite;
}

.chromab {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  background:
    linear-gradient(90deg, rgba(0, 240, 255, 0.04), transparent 18%, transparent 82%, rgba(255, 77, 26, 0.05));
  mix-blend-mode: screen;
  transition: opacity 0.15s ease;
}

body.redline .chromab,
body.boosting .chromab {
  opacity: 1;
}

body.redline .chromab {
  opacity: 0.85;
  background:
    linear-gradient(90deg, rgba(0, 240, 255, 0.07), transparent 22%, transparent 78%, rgba(255, 77, 26, 0.08)),
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(214, 255, 58, 0.05), transparent 65%);
}

@keyframes streak {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(24px);
  }
}

.hud {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hud.live {
  opacity: 1;
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 1.75rem);
  background: linear-gradient(
    180deg,
    rgba(5, 6, 10, 0.72) 0%,
    rgba(5, 6, 10, 0.35) 70%,
    transparent 100%
  );
}

.stat {
  text-align: center;
  min-width: 3.2rem;
}

.stat .label {
  display: block;
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  color: rgba(154, 163, 181, 0.95);
  margin-bottom: 0.15rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.stat .value {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 3.2rem);
  line-height: 0.9;
  letter-spacing: 0.02em;
  color: var(--foam);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
}

.brand-block {
  min-width: 7rem;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: 0.08em;
  color: var(--blaze);
  line-height: 1;
}

.zone {
  margin-top: 0.25rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--volt);
  text-shadow: 0 0 16px rgba(214, 255, 58, 0.35);
  max-width: 12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body[data-zone="asteroid"] .zone {
  color: #ffaa44;
}
body[data-zone="solar"] .zone {
  color: #ffcc33;
}
body[data-zone="ice"] .zone {
  color: #a8e6ff;
}
body[data-zone="market"] .zone {
  color: #ff66cc;
}
body[data-zone="plasma"] .zone {
  color: #33ff99;
}
body[data-zone="neon"] .zone {
  color: var(--plasma);
}

#place {
  color: var(--volt);
  text-shadow: 0 0 24px rgba(214, 255, 58, 0.4);
}

.toast {
  position: fixed;
  top: 28%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.88);
  z-index: 4;
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.5rem);
  letter-spacing: 0.12em;
  color: var(--volt);
  text-shadow: 0 0 30px rgba(214, 255, 58, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.toast.is-icon {
  font-size: 0;
  letter-spacing: 0;
  text-shadow: none;
  color: transparent;
}

.toast .pickup-glyph {
  width: clamp(4.2rem, 12vw, 6.5rem);
  height: clamp(4.2rem, 12vw, 6.5rem);
  filter: drop-shadow(0 0 18px rgba(214, 255, 58, 0.55));
}

.toast .pickup-glyph[data-kind="boost"] {
  filter: drop-shadow(0 0 18px rgba(0, 240, 255, 0.65));
}

.toast .pickup-glyph[data-kind="burst"] {
  filter: drop-shadow(0 0 18px rgba(214, 255, 58, 0.7));
}

.toast .pickup-glyph[data-kind="grip"] {
  filter: drop-shadow(0 0 18px rgba(255, 77, 26, 0.65));
}

.toast .pickup-glyph[data-kind="prism"] {
  filter: drop-shadow(0 0 18px rgba(255, 102, 204, 0.65));
}

.toast .pickup-glyph[data-kind="mega"] {
  width: clamp(5rem, 14vw, 7.5rem);
  height: clamp(5rem, 14vw, 7.5rem);
  filter: drop-shadow(0 0 22px rgba(255, 120, 40, 0.85));
}

.toast .pickup-x {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4.5vw, 2.4rem);
  letter-spacing: 0.08em;
  color: var(--foam);
  text-shadow: 0 0 20px rgba(242, 244, 248, 0.5);
}

.stat .value.mono {
  font-family: var(--font-mono);
  font-size: clamp(1.1rem, 2.5vw, 1.45rem);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  padding-top: 0.35rem;
}

#speed {
  color: var(--plasma);
  text-shadow: 0 0 24px rgba(0, 240, 255, 0.45);
  transition: color 0.15s, text-shadow 0.15s, transform 0.15s;
  font-variant-numeric: tabular-nums;
}

#speed.mega {
  color: #fff;
  text-shadow:
    0 0 20px rgba(214, 255, 58, 0.8),
    0 0 40px rgba(255, 77, 26, 0.45);
  letter-spacing: -0.02em;
}

#speed.pulse {
  animation: speed-punch 0.35s ease-out;
}

#place.flash {
  animation: place-flash 0.32s ease-out;
}

@keyframes place-flash {
  0% {
    transform: scale(1.35);
    color: var(--volt);
  }
  100% {
    transform: scale(1);
  }
}

body.boosting #speed {
  color: var(--volt);
  text-shadow: 0 0 28px rgba(214, 255, 58, 0.55);
}

@keyframes speed-punch {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

.boost-wrap {
  position: absolute;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%);
  width: min(280px, 70vw);
  transition: filter 0.15s;
}

.boost-wrap.firing {
  filter: drop-shadow(0 0 12px rgba(214, 255, 58, 0.65));
}

.combo-wrap {
  position: absolute;
  left: 50%;
  bottom: 3.6rem;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  pointer-events: none;
}

.combo-label {
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  color: var(--plasma);
}

.combo-value {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1;
  color: var(--volt);
  text-shadow: 0 0 16px rgba(214, 255, 58, 0.5);
}

.combo-wrap.hot .combo-value {
  color: #ff66cc;
  text-shadow: 0 0 20px rgba(255, 102, 204, 0.65);
  animation: combo-pulse 0.4s ease-in-out infinite alternate;
}

@keyframes combo-pulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.08);
  }
}

.boost-label {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--volt);
  margin-bottom: 0.4rem;
  text-align: center;
}

.boost-bar {
  height: 6px;
  background: rgba(242, 244, 248, 0.12);
  overflow: hidden;
}

.boost-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--volt), var(--blaze));
  box-shadow: 0 0 16px rgba(214, 255, 58, 0.5);
  transform-origin: left center;
  transform: scaleX(1);
  transition: filter 0.15s;
}

.boost-fill.low {
  background: linear-gradient(90deg, #ff8844, #ff4d1a);
  animation: boost-low 0.5s ease-in-out infinite alternate;
}

@keyframes boost-low {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.35);
  }
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 0.75rem;
  transform: translateX(-50%);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: rgba(154, 163, 181, 0.55);
  white-space: nowrap;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 1.25rem 1.5rem 2.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, rgba(255, 77, 26, 0.18), transparent 60%),
    rgba(5, 6, 10, 0.82);
  backdrop-filter: blur(6px);
  transition: opacity 0.35s ease, visibility 0.35s;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Keep pause/results centered even though title scrolls */
.pause-overlay,
.results-overlay {
  justify-content: center;
  overflow: hidden;
}

.mode-tag {
  margin-top: 0.35rem;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--plasma);
  opacity: 0.9;
}

.ship-tag {
  margin-top: 0.2rem;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--volt);
  opacity: 0.85;
}

.hud-rail {
  position: absolute;
  right: clamp(0.75rem, 2vw, 1.5rem);
  top: 5.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: 200px;
  pointer-events: none;
}

#minimap {
  display: block;
  width: 200px;
  height: 200px;
  border-radius: 8px;
}

.ranking-wrap {
  background: rgba(5, 8, 18, 0.72);
  border: 1px solid rgba(0, 240, 255, 0.28);
  border-radius: 8px;
  padding: 0.45rem 0.55rem 0.55rem;
}

.ranking-title {
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  color: var(--plasma);
  margin-bottom: 0.35rem;
}

.ranking {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.ranking li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--fog);
}

.ranking li em {
  font-style: normal;
  font-family: var(--font-display);
  font-size: 0.95rem;
  min-width: 1.1rem;
  color: var(--plasma);
}

.ranking li.you {
  color: var(--foam);
}

.ranking li.you span {
  color: var(--blaze);
  font-weight: 700;
}

@media (max-width: 900px) {
  .hud-rail {
    top: auto;
    bottom: 5.5rem;
    right: 0.6rem;
    width: 140px;
  }
  #minimap {
    width: 140px;
    height: 140px;
  }
  .ship-row {
    flex-direction: column;
  }
  .ship-preview-wrap {
    width: 100%;
    min-height: 150px;
  }
}

.go {
  appearance: none;
  border: none;
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: 0.2em;
  padding: 0.85rem 2.4rem;
  background: var(--blaze);
  color: var(--void);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 0 40px rgba(255, 77, 26, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s;
}

.go:hover {
  transform: scale(1.04);
  box-shadow: 0 0 60px rgba(255, 77, 26, 0.65);
}

.go:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.go.secondary {
  background: transparent;
  color: var(--foam);
  border: 1px solid rgba(242, 244, 248, 0.28);
  box-shadow: none;
}

.go.secondary:hover {
  border-color: var(--plasma);
  color: var(--plasma);
  box-shadow: none;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--fog);
}

.set-row input[type="range"] {
  flex: 1;
  max-width: 140px;
  accent-color: var(--plasma);
}

.set-row.set-check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--plasma);
}

.set-row select {
  flex: 1;
  max-width: 140px;
  padding: 0.25rem 0.4rem;
  font: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ink, #e8f0ff);
  background: rgba(10, 14, 28, 0.9);
  border: 1px solid rgba(120, 160, 220, 0.35);
  border-radius: 3px;
  cursor: pointer;
}

.set-row select:focus-visible {
  outline: 1px solid var(--plasma);
}

.set-row em {
  font-style: normal;
  color: var(--plasma);
  margin-left: 0.35rem;
}

.pause-overlay,
.results-overlay {
  z-index: 6;
}

.pause-overlay[hidden],
.results-overlay[hidden] {
  display: none !important;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: stretch;
  width: min(260px, 80vw);
  margin-top: 1rem;
  pointer-events: auto;
}

.results-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  letter-spacing: 0.08em;
  color: var(--volt);
  text-shadow: 0 0 28px rgba(214, 255, 58, 0.45);
}

.results-time {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--plasma);
  margin: 0.35rem 0 0.85rem;
}

.results-list {
  list-style: none;
  width: min(320px, 88vw);
  text-align: left;
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.results-list li {
  display: flex;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid rgba(242, 244, 248, 0.08);
}

.results-list li.you {
  color: var(--blaze);
  background: rgba(255, 77, 26, 0.08);
}

.results-list em {
  font-style: normal;
  width: 1.5rem;
  color: var(--fog);
}

body.reduced-motion .speedlines,
body.reduced-motion .chromab {
  display: none !important;
}

.dev {
  position: fixed;
  top: 4.5rem;
  right: 1rem;
  z-index: 20;
  width: min(280px, calc(100vw - 2rem));
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
  padding: 0.85rem 0.95rem 1rem;
  background: rgba(8, 10, 18, 0.92);
  border: 1px solid rgba(0, 240, 255, 0.28);
  backdrop-filter: blur(12px);
  font-family: var(--font-mono);
  color: var(--foam);
  pointer-events: auto;
}

.dev-sec {
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  color: var(--plasma);
  margin: 0.65rem 0 0.45rem;
}

.dev-row.dev-check {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.dev-row.dev-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--plasma);
}

.dev[hidden] {
  display: none;
}

.dev-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: var(--plasma);
  margin-bottom: 0.85rem;
}

.dev-x {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--fog);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

.dev-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.7rem;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--fog);
}

.dev-row em {
  font-style: normal;
  color: var(--volt);
  float: right;
}

.dev-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: rgba(242, 244, 248, 0.15);
  outline: none;
  cursor: pointer;
}

.dev-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blaze);
  border: none;
}

.dev-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.dev-actions button {
  flex: 1;
  appearance: none;
  border: 1px solid rgba(216, 230, 223, 0.2);
  background: rgba(20, 28, 40, 0.8);
  color: var(--foam);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.55rem 0.4rem;
  cursor: pointer;
}

.dev-actions button:hover {
  border-color: var(--plasma);
  color: var(--plasma);
}

.dev-note {
  margin-top: 0.7rem;
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  color: rgba(154, 163, 181, 0.55);
  line-height: 1.4;
}

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

/* ==========================================================================
   FRONT END
   One overlay, several screens. `data-screen` on .frontend picks the live one;
   everything else is display:none so it cannot be tabbed into. The 3D scene
   keeps rendering underneath, which is why the scrim is a gradient rather
   than a flat wash — the circuit stays visible behind the menu.
   ========================================================================== */

.frontend {
  display: block;
  padding: 0;
  text-align: left;
  overflow: hidden;
  background: none;
  backdrop-filter: none;
}

.fe-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(100deg, rgba(5, 6, 10, 0.94) 0%, rgba(5, 6, 10, 0.84) 38%,
      rgba(5, 6, 10, 0.3) 68%, rgba(5, 6, 10, 0.6) 100%),
    radial-gradient(ellipse 80% 60% at 18% 45%, rgba(255, 77, 26, 0.14), transparent 65%);
}

/* Stack only — do NOT set `position` here. The screens and the head/foot bars
   are absolutely positioned with `inset`, and a blanket `position: relative`
   turns those insets into offsets, shoving every screen off the right edge. */
.fe-scrim { z-index: 0; }
.fe-head,
.fe-foot,
.fe-screen { z-index: 1; }

/* --- persistent chrome --------------------------------------------------- */

.fe-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.1rem 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.fe-mark {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.32em;
  color: var(--blaze);
}

.fe-ver {
  margin-left: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--fog);
  vertical-align: 0.35em;
}

.fe-crumbs {
  display: flex;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: rgba(154, 163, 181, 0.4);
}

.fe-crumbs span {
  padding: 0.2rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 2px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.fe-crumbs span.done {
  color: var(--fog);
  border-color: rgba(255, 255, 255, 0.14);
}

.fe-crumbs span.here {
  color: var(--void);
  background: var(--plasma);
  border-color: var(--plasma);
}

/* Hide the trail on screens outside the race funnel */
.frontend[data-screen="title"] .fe-crumbs,
.frontend[data-screen="main"] .fe-crumbs,
.frontend[data-screen="records"] .fe-crumbs,
.frontend[data-screen="settings"] .fe-crumbs {
  opacity: 0;
}

.fe-venue {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--fog);
  text-align: right;
  line-height: 1.5;
}

.fe-venue b {
  display: block;
  font-weight: 700;
  color: var(--foam);
}

.fe-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.9rem 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: var(--fog);
}

.fe-keys kbd {
  display: inline-block;
  min-width: 1.35rem;
  margin: 0 0.15rem;
  padding: 0.1rem 0.3rem;
  font: inherit;
  text-align: center;
  color: var(--foam);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 2px;
}

.fe-hint {
  color: var(--volt);
  text-align: right;
}

/* --- screens ------------------------------------------------------------- */

.fe-screen {
  display: none;
  position: absolute;
  inset: 4.6rem 2rem 3.2rem;
}

.frontend[data-screen="title"] [data-for="title"],
.frontend[data-screen="main"] [data-for="main"],
.frontend[data-screen="mode"] [data-for="mode"],
.frontend[data-screen="circuit"] [data-for="circuit"],
.frontend[data-screen="craft"] [data-for="craft"],
.frontend[data-screen="records"] [data-for="records"],
.frontend[data-screen="settings"] [data-for="settings"] {
  display: flex;
  flex-direction: column;
  animation: fe-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes fe-in {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: none; }
}

.reduced-motion .fe-screen { animation: none !important; }

/* --- title --------------------------------------------------------------- */

[data-for="title"] {
  justify-content: center;
  align-items: flex-start;
}

.fe-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.42em;
  color: var(--plasma);
  margin-bottom: 0.9rem;
}

.fe-title {
  font-family: var(--font-display);
  font-size: clamp(3.6rem, 11vw, 9rem);
  line-height: 0.84;
  letter-spacing: 0.02em;
  color: var(--foam);
  text-shadow: 0 0 60px rgba(0, 240, 255, 0.25);
}

.fe-title em {
  display: block;
  font-style: normal;
  color: transparent;
  -webkit-text-stroke: 2px var(--blaze);
}

.fe-strap {
  margin-top: 1.2rem;
  max-width: 34ch;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--fog);
}

.fe-press {
  margin-top: 2.6rem;
  padding: 0.85rem 1.9rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: var(--void);
  background: var(--volt);
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  align-self: flex-start;
  animation: fe-pulse 2.4s ease-in-out infinite;
}

.fe-press kbd {
  font: inherit;
  padding: 0 0.3rem;
  border-bottom: 2px solid rgba(0, 0, 0, 0.35);
}

@keyframes fe-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(214, 255, 58, 0.5); }
  50%      { box-shadow: 0 0 0 14px rgba(214, 255, 58, 0); }
}

.reduced-motion .fe-press { animation: none; }

/* --- main menu ----------------------------------------------------------- */

.fe-menu {
  list-style: none;
  justify-content: center;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-start;
}

.fe-menu button {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.2vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: 0.08em;
  color: var(--fog);
  background: none;
  border: 0;
  padding: 0.1rem 0 0.1rem 2.6rem;
  cursor: pointer;
  position: relative;
  text-align: left;
  transition: color 0.16s, transform 0.16s;
}

.fe-menu button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.1rem;
  width: 1.6rem;
  height: 2px;
  background: currentColor;
  transform: scaleX(0.25);
  transform-origin: left;
  transition: transform 0.16s, background 0.16s;
}

.fe-menu button:hover,
.fe-menu button.cursor {
  color: var(--foam);
  transform: translateX(6px);
}

.fe-menu button.cursor::before {
  transform: scaleX(1);
  background: var(--blaze);
}

.fe-menu-note {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  color: rgba(154, 163, 181, 0.7);
  margin-top: 0.1rem;
}

/* --- stage screens ------------------------------------------------------- */

.fe-stage-head {
  margin-bottom: 1.4rem;
  flex: none;
}

.fe-stage-head h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.4vw, 2.8rem);
  letter-spacing: 0.12em;
  color: var(--foam);
}

.fe-stage-head p {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--fog);
  margin-top: 0.25rem;
}

.fe-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 1.6rem;
  flex: 1;
  min-height: 0;
}

.fe-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
  padding-right: 0.4rem;
}

/* Row selector shared by the circuit and craft lists */
.fe-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 0.9rem;
  text-align: left;
  color: var(--fog);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 3px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.fe-row:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--foam);
}

.fe-row.cursor {
  border-left-color: var(--plasma);
  background: rgba(0, 240, 255, 0.07);
  color: var(--foam);
}

.fe-row.active {
  border-left-color: var(--blaze);
  background: rgba(255, 77, 26, 0.1);
  color: var(--foam);
}

.fe-row.active.cursor {
  border-left-color: var(--volt);
  background: rgba(214, 255, 58, 0.1);
}

.fe-row-idx {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: rgba(154, 163, 181, 0.55);
}

.fe-row-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.09em;
  line-height: 1.05;
}

.fe-row-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  color: rgba(154, 163, 181, 0.8);
  margin-top: 0.1rem;
}

.fe-row-tag {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  padding: 0.18rem 0.45rem;
  border-radius: 2px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

/* Mode picker keeps a card look — only four, and they want room to breathe */
.fe-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.6rem;
  flex: none;
}

.mode-card {
  text-align: left;
  padding: 1rem 1.05rem 1.1rem;
  color: var(--fog);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top: 3px solid rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.mode-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.1em;
  color: var(--plasma);
  margin-bottom: 0.35rem;
}

.mode-card span {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  line-height: 1.6;
  letter-spacing: 0.04em;
}

.mode-card:hover,
.mode-card.cursor {
  background: rgba(255, 255, 255, 0.07);
  border-top-color: var(--plasma);
  transform: translateY(-2px);
}

.mode-card.active {
  border-color: var(--blaze);
  border-top-color: var(--blaze);
  background: rgba(255, 77, 26, 0.12);
}

.mode-card.active strong {
  color: var(--volt);
}

.fe-laps {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.2rem;
  flex: none;
}

.fe-laps-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  color: var(--fog);
  margin-right: 0.4rem;
}

.lap-card {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 0.5rem 1.05rem;
  color: var(--fog);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.lap-card.active {
  color: var(--void);
  background: var(--volt);
  border-color: var(--volt);
}

.lap-card:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* --- detail panel -------------------------------------------------------- */

.fe-detail {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.1rem;
  background: rgba(8, 10, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow-y: auto;
}

.fe-detail-kicker {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.24em;
  color: var(--theme-badge, var(--plasma));
}

.fe-detail-title {
  font-family: var(--font-display);
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: 0.07em;
  color: var(--foam);
}

.fe-detail-body {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  line-height: 1.75;
  color: var(--fog);
}

.fe-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 0.2rem;
}

.fe-stats dt {
  font-family: var(--font-mono);
  font-size: 0.54rem;
  letter-spacing: 0.16em;
  color: rgba(154, 163, 181, 0.7);
}

.fe-stats dd {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--foam);
}

.fe-trackmap {
  width: 100%;
  height: auto;
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.35);
}

#ship-preview {
  width: 100%;
  height: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  background: radial-gradient(ellipse at 50% 60%, rgba(0, 240, 255, 0.09), transparent 70%);
}

/* --- stat bars ----------------------------------------------------------- */

.fe-bars {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.fe-bar {
  display: grid;
  grid-template-columns: 4.4rem 1fr 2.2rem;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.54rem;
  letter-spacing: 0.14em;
  color: var(--fog);
}

.fe-bar-track {
  height: 7px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 4px;
  overflow: hidden;
}

.fe-bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--plasma), var(--volt));
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.45);
  border-radius: 4px;
  transition: width 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.fe-bar-num {
  text-align: right;
  color: var(--foam);
  font-size: 0.56rem;
}

/* --- engage -------------------------------------------------------------- */

.fe-go {
  align-self: flex-start;
  margin-top: 1.1rem;
  padding: 0.9rem 3.2rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  color: var(--void);
  background: var(--volt);
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  flex: none;
}

.fe-go:hover,
.fe-go.cursor {
  background: var(--foam);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 240, 255, 0.3);
}

.fe-summary {
  margin-top: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--fog);
  flex: none;
}

/* --- records ------------------------------------------------------------- */

.fe-records {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.5rem;
  overflow-y: auto;
  flex: 1;
  align-content: start;
}

.fe-record {
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 3px solid var(--rec-accent, #00f0ff);
  border-radius: 2px;
}

.fe-record h4 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.09em;
  color: var(--foam);
}

.fe-record-biome {
  font-family: var(--font-mono);
  font-size: 0.54rem;
  letter-spacing: 0.18em;
  color: var(--rec-accent, #00f0ff);
}

.fe-record dl {
  display: flex;
  gap: 1.1rem;
  margin-top: 0.5rem;
}

.fe-record dt {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  letter-spacing: 0.14em;
  color: rgba(154, 163, 181, 0.7);
}

.fe-record dd {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--foam);
}

.fe-record dd.empty {
  color: rgba(154, 163, 181, 0.45);
  font-weight: 500;
}

.fe-ghost-btn {
  align-self: flex-start;
  margin-top: 1rem;
  padding: 0.5rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: var(--fog);
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 2px;
  cursor: pointer;
  flex: none;
}

.fe-ghost-btn:hover {
  color: var(--blaze);
  border-color: var(--blaze);
}

/* --- settings ------------------------------------------------------------ */

.fe-settings {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 26rem;
}

/* --- narrow screens ------------------------------------------------------ */

@media (max-width: 860px) {
  .fe-split { grid-template-columns: 1fr; }
  .fe-detail { max-height: 40vh; }
  .fe-head, .fe-foot { padding-inline: 1rem; }
  .fe-screen { inset: 4.2rem 1rem 3rem; }
  .fe-venue { display: none; }
}

@media (max-height: 620px) {
  .fe-title { font-size: clamp(2.6rem, 8vw, 5rem); }
  .fe-strap { display: none; }
}
