:root {
  --bg0: #05070b;
  --bg1: #0c121c;
  --ink: #f2f5f8;
  --muted: #8b97a8;
  --amber: #ffb020;
  --cyan: #3de0c5;
  --red: #ff3b4a;
  --glass: rgba(10, 14, 22, 0.55);
  --glass-border: rgba(255, 255, 255, 0.12);
  --font-display: "Bebas Neue", Impact, sans-serif;
  --font-race: "Orbitron", ui-sans-serif, system-ui, sans-serif;
  --font-ui: "Rajdhani", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  font-family: var(--font-ui);
  background:
    radial-gradient(900px 500px at 15% 0%, rgba(61, 224, 197, 0.12), transparent 55%),
    radial-gradient(1000px 600px at 90% 10%, rgba(255, 176, 32, 0.1), transparent 50%),
    linear-gradient(165deg, #070b12 0%, #101826 42%, #070a10 100%);
  overflow: hidden;
}

#app {
  max-width: 1080px;
  height: 100%;
  margin: 0 auto;
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.stage-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 10px;
}

.stage-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--glass-border);
  background: #000;
  box-shadow:
    0 0 0 1px rgba(61, 224, 197, 0.08),
    0 20px 50px rgba(0, 0, 0, 0.45),
    inset 0 0 80px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 960 / 640;
}

html.shot-mode #overlay,
html.shot-mode #pause-overlay,
html.shot-mode #crash-flash,
html.shot-mode #crash-banner,
html.shot-mode #combo-pop {
  display: none !important;
}

.hud-overlay {
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 12px 10px;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.hud-brand-mark {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: 0.12em;
  line-height: 0.9;
  text-shadow: 0 0 24px rgba(61, 224, 197, 0.35);
}

.hud-brand-sub {
  display: block;
  margin-top: 4px;
  font-family: var(--font-race);
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  color: var(--cyan);
  opacity: 0.85;
}

.hud-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.health-wrap {
  min-width: 150px;
  padding: 7px 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
}

.health-label {
  display: block;
  font-family: var(--font-race);
  font-size: 0.5rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 4px;
}

.health-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #2fe0a8, #7dffb2);
  box-shadow: 0 0 12px rgba(47, 224, 168, 0.45);
  transition: width 0.15s ease-out, background 0.2s;
}

.health-fill.hurt {
  background: linear-gradient(90deg, #ff3b4a, #ff8a1f);
  box-shadow: 0 0 14px rgba(255, 59, 74, 0.5);
}

.hud-in-game-bottom {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 12px;
}

.dash-panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px 12px 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
}

.dash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.dash-row-stats {
  align-items: flex-end;
}

.points-board {
  display: flex;
  align-items: flex-end;
  gap: 22px;
  flex: 1;
  min-width: 0;
}

.points-board .hud-stat {
  text-align: left;
}

.dash-toggles {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 20px;
}

.traffic-toggle {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0;
}

.traffic-toggle-label {
  font-family: var(--font-race);
  font-size: 0.48rem;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.traffic-toggle-btns {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.traffic-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-race);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  padding: 8px 12px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s, box-shadow 0.12s;
}

.traffic-btn + .traffic-btn {
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.traffic-btn:hover {
  color: var(--ink);
}

.traffic-btn.active {
  color: #1a1205;
  background: linear-gradient(180deg, #ffb020, #ff8a1f);
  box-shadow: inset 0 0 12px rgba(255, 200, 80, 0.35);
}

.steer-toggle {
  gap: 10px;
}

.steer-slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.28);
  padding: 6px 10px;
}

.steer-end {
  font-family: var(--font-race);
  font-size: 0.48rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.steer-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 4px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
}

.steer-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 0;
  background: linear-gradient(180deg, #ffb020, #ff8a1f);
  border: 1px solid rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.steer-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 0;
  background: linear-gradient(180deg, #ffb020, #ff8a1f);
  border: 1px solid rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.dash-panel .speed-cluster {
  flex: 0 0 auto;
}

.dash-panel .speed-ring {
  width: 88px;
  height: 88px;
}

.dash-panel .speed-num {
  font-size: 1.2rem;
  min-width: 2.6ch;
}

.points-board .hud-stat-value {
  font-size: 1.55rem;
}

.dash-panel .control-cluster {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.dash-panel .control-btn {
  flex: 1;
  max-width: 180px;
}

.damage-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 42%, rgba(255, 40, 55, 0.55) 100%);
  animation: vignette-pulse 0.35s ease-out;
}

.damage-vignette.strong {
  background: radial-gradient(circle at center, rgba(255, 30, 50, 0.25) 20%, rgba(255, 20, 40, 0.75) 100%);
  animation: vignette-pulse 0.5s ease-out;
}

@keyframes vignette-pulse {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
}

.hud-stat {
  text-align: right;
  min-width: 52px;
}

.hud-stat-label {
  display: block;
  font-family: var(--font-race);
  font-size: 0.52rem;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.hud-stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: 0.04em;
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255, 176, 32, 0.35);
}

.hud-stat-value.dim {
  color: #cfd6df;
  text-shadow: none;
}

.hud-stat-value.combo {
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(61, 224, 197, 0.45);
}

.plate-chip {
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(180deg, #f4f0e4, #ddd5c2);
  color: #14161a;
  font-family: var(--font-race);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
}

.combo-pop {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  letter-spacing: 0.08em;
  color: #fff8e8;
  text-shadow:
    0 0 20px rgba(255, 176, 32, 0.7),
    0 4px 24px rgba(0, 0, 0, 0.6);
  animation: combo-burst 0.85s ease-out forwards;
  pointer-events: none;
  white-space: nowrap;
}

@keyframes combo-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.7);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -70%) scale(1);
  }
}

.lane-rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  width: 140px;
  padding: 7px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
}

.lane-rail span {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.lane-rail span.active {
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(61, 224, 197, 0.7);
}

.lane-rail.on-line span.active {
  background: #fff4d2;
  box-shadow: 0 0 14px rgba(255, 240, 180, 0.8);
}

.speed-ring {
  position: relative;
  width: 118px;
  height: 118px;
  background: radial-gradient(circle at 50% 45%, rgba(20, 28, 40, 0.9), rgba(5, 8, 14, 0.95));
  border: 1px solid rgba(255, 176, 32, 0.28);
  border-radius: 50%;
  box-shadow:
    0 0 30px rgba(255, 176, 32, 0.12),
    inset 0 0 24px rgba(0, 0, 0, 0.55);
}

.ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(135deg);
}

.ring-track,
.ring-arc {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
}

.ring-track {
  stroke: rgba(255, 255, 255, 0.1);
}

.ring-arc {
  stroke: var(--amber);
  stroke-dasharray: 226;
  stroke-dashoffset: 226;
  filter: drop-shadow(0 0 6px rgba(255, 176, 32, 0.65));
  transition: stroke-dashoffset 0.06s linear;
}

.speed-readout {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.speed-num {
  font-family: var(--font-race);
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1;
}

.speed-unit {
  font-family: var(--font-race);
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.control-cluster {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.control-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, rgba(28, 36, 50, 0.95), rgba(12, 16, 24, 0.95));
  color: var(--ink);
  font-family: var(--font-race);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  padding: 12px 12px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: border-color 0.12s, box-shadow 0.12s, color 0.12s;
}

.control-btn:hover {
  border-color: rgba(255, 176, 32, 0.55);
}

.control-btn:active,
.control-btn.active {
  border-color: var(--amber);
  color: var(--amber);
  box-shadow: 0 0 18px rgba(255, 176, 32, 0.25);
}

.control-btn.accel {
  min-width: 78px;
  background: linear-gradient(180deg, rgba(50, 36, 12, 0.95), rgba(18, 12, 6, 0.95));
}

.dash-feed {
  flex: 0 1 220px;
  min-width: 140px;
  max-width: 240px;
  max-height: 88px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
}

.dash-feed .event {
  padding: 4px 7px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: rgba(0, 0, 0, 0.4);
  border-left: 2px solid var(--cyan);
  color: #cfd6df;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: slide-in 0.22s ease-out;
}

.dash-feed .event.cut,
.dash-feed .event.weave {
  border-left-color: var(--amber);
  color: #ffe6a8;
}

.dash-feed .event.crash {
  border-left-color: var(--red);
  color: #ffb0b6;
}

.dash-feed .event.info {
  border-left-color: var(--cyan);
  color: #b8c4d0;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(800px 400px at 50% 30%, rgba(61, 224, 197, 0.08), transparent 60%),
    rgba(4, 7, 12, 0.78);
  backdrop-filter: blur(8px);
  z-index: 30;
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  position: relative;
  width: min(480px, 100%);
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(40, 55, 70, 0.35), transparent 42%),
    linear-gradient(180deg, #121821, #0a0e14);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 28px 26px 24px;
  box-shadow:
    0 0 0 1px rgba(255, 176, 32, 0.08),
    0 40px 100px rgba(0, 0, 0, 0.55);
}

.title-glow {
  position: absolute;
  inset: -40% -20% auto;
  height: 180px;
  background: radial-gradient(circle, rgba(61, 224, 197, 0.22), transparent 65%);
  pointer-events: none;
}

.overlay-kicker {
  margin: 0 0 6px;
  color: var(--cyan);
  font-family: var(--font-race);
  letter-spacing: 0.2em;
  font-size: 0.62rem;
}

.overlay-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 8vw, 4rem);
  letter-spacing: 0.08em;
  line-height: 0.92;
  text-shadow: 0 0 30px rgba(255, 176, 32, 0.25);
}

.overlay-copy {
  margin: 12px 0 16px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.controls-list {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
  font-size: 0.92rem;
  color: #aeb8c6;
}

.controls-list kbd {
  display: inline-block;
  min-width: 1.35em;
  padding: 2px 6px;
  margin-right: 2px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #1a222d;
  font-family: var(--font-race);
  font-size: 0.68rem;
  text-align: center;
}

.start-btn {
  width: 100%;
  border: none;
  background: linear-gradient(90deg, #ffb020, #ff8a1f);
  color: #1a1205;
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: 0.14em;
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(255, 176, 32, 0.35);
}

.start-btn:hover {
  filter: brightness(1.06);
}

.start-btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: none;
}

.player-hero {
  display: block;
  width: min(100%, 260px);
  height: auto;
  margin: 0 0 12px;
  object-fit: contain;
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.55));
}

.crash-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(255, 59, 74, 0.4), transparent 55%);
  z-index: 25;
  animation: flash 0.4s ease-out;
}

@keyframes flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.crash-banner {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 28;
  text-align: center;
  pointer-events: none;
  animation: crash-in 0.45s ease-out;
}

.crash-banner[hidden] {
  display: none !important;
}

.crash-banner-label {
  display: block;
  font-family: var(--font-race);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  color: var(--red);
}

.crash-banner-main {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 3.8rem);
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 0 28px rgba(255, 59, 74, 0.55);
}

.crash-banner-sub {
  display: block;
  font-family: var(--font-ui);
  font-size: 1rem;
  color: #ffb0b6;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@keyframes crash-in {
  from {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@media (max-width: 720px) {
  html,
  body {
    overflow: auto;
  }

  .dash-row-stats {
    flex-direction: row;
    align-items: flex-end;
    flex-wrap: wrap;
  }

  .dash-feed {
    flex: 1 1 100%;
    max-width: none;
    max-height: 64px;
    order: 3;
  }

  .points-board {
    justify-content: flex-start;
    gap: 14px;
  }

  .points-board .hud-stat-value {
    font-size: 1.25rem;
  }

  .dash-panel .speed-ring {
    width: 76px;
    height: 76px;
  }
}

@media (max-height: 820px) {
  #app {
    padding: 8px 12px 8px;
  }

  .stage-wrap {
    gap: 8px;
  }

  .hud-brand-mark {
    font-size: 1.55rem;
  }

  .dash-panel {
    padding: 8px 10px;
    gap: 6px;
  }

  .dash-panel .speed-ring {
    width: 80px;
    height: 80px;
  }

  .dash-panel .speed-num {
    font-size: 1.2rem;
  }

  .points-board {
    gap: 16px;
  }

  .points-board .hud-stat-value {
    font-size: 1.3rem;
  }

  .control-btn {
    padding: 9px 10px;
    font-size: 0.58rem;
  }
}

@media (max-height: 700px) {
  .hud-overlay {
    padding: 8px 10px;
  }

  .dash-panel .speed-ring {
    width: 72px;
    height: 72px;
  }

  .points-board .hud-stat-value {
    font-size: 1.15rem;
  }

  .control-btn {
    padding: 8px 8px;
  }
}

/* —— Leaderboard —— */
.leaderboard-section {
  flex: 0 0 auto;
  margin-top: 4px;
  padding: 12px 14px 14px;
  border: 1px solid var(--glass-border);
  background: rgba(8, 12, 18, 0.72);
}

.leaderboard-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.leaderboard-title {
  margin: 0;
  font-family: var(--font-race);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--cyan);
}

.leaderboard-note {
  font-size: 0.78rem;
  color: var(--muted);
}

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

.leaderboard-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.28);
  border-left: 2px solid rgba(61, 224, 197, 0.35);
  font-size: 0.85rem;
}

.lb-rank {
  font-family: var(--font-race);
  color: var(--muted);
  font-size: 0.65rem;
}

.lb-name {
  font-weight: 700;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-family: var(--font-race);
  color: var(--amber);
  font-size: 0.75rem;
}

.lb-date {
  color: var(--muted);
  font-size: 0.72rem;
  min-width: 4.5ch;
  text-align: right;
}

.overlay-best {
  margin: 0 0 10px;
  font-family: var(--font-race);
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--amber);
}

.controls-hint {
  font-size: 0.85rem !important;
}

.controls-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.35);
  font-family: var(--font-race);
  font-size: 0.62rem;
  margin: 0 1px;
}

.text-link-btn {
  display: block;
  margin: 12px auto 0;
  border: none;
  background: none;
  color: var(--cyan);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-link-btn[hidden] {
  display: none;
}

.gameover-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 8px 0 14px;
}

.pb-banner {
  margin: 0 0 12px;
  color: var(--amber);
  font-family: var(--font-race);
  letter-spacing: 0.14em;
  font-size: 0.72rem;
}

.pb-banner[hidden] {
  display: none;
}

.name-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.name-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink);
  font-family: var(--font-race);
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.name-input:focus {
  outline: 1px solid var(--cyan);
}

.name-error {
  margin: 0;
  color: var(--red);
  font-size: 0.8rem;
}

.name-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pause-card .start-btn + .start-btn,
.gameover-card .start-btn + .start-btn {
  margin-top: 8px;
}

.start-btn.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--ink);
  box-shadow: none;
}

.start-btn.ghost:hover {
  border-color: var(--amber);
  color: var(--amber);
}

/* —— Phone layout —— */
.phone-hud,
.phone-controls,
.rotate-prompt {
  display: none;
}

html.is-phone #app {
  max-width: none;
  padding: 0;
  height: 100dvh;
}

html.is-phone .stage-wrap {
  gap: 0;
  height: 100%;
}

html.is-phone .stage-frame {
  flex: 1;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

html.is-phone #game {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  object-fit: cover;
}

html.is-phone .dash-panel {
  display: none !important;
}

html.is-phone .leaderboard-section {
  display: none;
}

html.is-phone .site-footer {
  display: none;
}

html.is-phone.playing-locked,
html.is-phone.playing-locked body {
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

/* Compact chrome sized for ~667×375 / 844×390 landscape */
html.is-phone .phone-hud {
  display: flex;
  pointer-events: none;
  position: absolute;
  top: max(6px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  gap: clamp(8px, 2.2vw, 14px);
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 5;
  max-width: min(70vw, 320px);
}

html.is-phone .phone-hud[hidden] {
  display: none !important;
}

.phone-hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 40px;
}

.phone-hud-label {
  font-family: var(--font-race);
  font-size: 0.38rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.phone-hud-value {
  font-family: var(--font-race);
  font-size: clamp(0.7rem, 2.8vh, 0.85rem);
  color: var(--ink);
  line-height: 1.1;
}

.phone-hud-aura {
  min-width: 56px;
}

.phone-health-bar {
  width: 54px;
  height: 6px;
  margin-top: 2px;
}

html.is-phone .phone-controls {
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}

html.is-phone .phone-controls[hidden] {
  display: none !important;
}

.phone-pause-btn {
  pointer-events: auto;
  position: absolute;
  top: max(4px, env(safe-area-inset-top, 0px));
  right: max(6px, env(safe-area-inset-right, 0px));
  width: clamp(28px, 7vh, 34px);
  height: clamp(28px, 7vh, 34px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.5);
  color: var(--ink);
  font-family: var(--font-race);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  touch-action: manipulation;
}

.phone-pedals {
  pointer-events: auto;
  position: absolute;
  right: max(8px, env(safe-area-inset-right, 0px));
  bottom: max(8px, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.phone-pedal {
  width: clamp(48px, 11vw, 58px);
  height: clamp(32px, 8.5vh, 40px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.5);
  color: var(--ink);
  font-family: var(--font-race);
  font-size: clamp(0.45rem, 1.9vh, 0.55rem);
  letter-spacing: 0.08em;
  touch-action: none;
  user-select: none;
}

.phone-pedal.gas {
  border-color: rgba(255, 176, 32, 0.55);
  color: var(--amber);
}

.phone-pedal.brake {
  border-color: rgba(255, 59, 74, 0.45);
  color: #ff8a93;
}

.phone-pedal:active,
.phone-swing-btn:active {
  background: rgba(255, 176, 32, 0.2);
}

.phone-swing {
  pointer-events: auto;
  position: absolute;
  left: max(8px, env(safe-area-inset-left, 0px));
  bottom: max(8px, env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 6px;
}

.phone-swing-btn {
  width: clamp(42px, 10.5vh, 52px);
  height: clamp(42px, 10.5vh, 52px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.5);
  color: var(--ink);
  font-size: clamp(0.85rem, 2.8vh, 1.05rem);
  touch-action: none;
  user-select: none;
}

html.is-phone .hud-brand-mark {
  font-size: clamp(1rem, 3.2vh, 1.35rem);
}

html.is-phone .hud-brand-sub,
html.is-phone .lane-rail {
  display: none;
}

html.is-phone .hud-top-right .health-wrap {
  display: none;
}

html.is-phone .hud-overlay {
  padding: 6px 8px;
}

/* Start / game-over / pause must fit short landscape viewports */
html.is-phone .overlay {
  padding: max(8px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px))
    max(8px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  align-items: center;
}

html.is-phone .overlay-card {
  width: min(420px, 100%);
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 14px 16px 12px;
}

html.is-phone .player-hero {
  width: min(100%, 120px);
  margin: 0 auto 6px;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
}

html.is-phone .overlay-card h1 {
  font-size: clamp(1.6rem, 7vh, 2.2rem);
}

html.is-phone .overlay-kicker {
  font-size: 0.5rem;
  margin-bottom: 2px;
}

html.is-phone .overlay-best {
  margin: 0 0 6px;
  font-size: 0.6rem;
}

html.is-phone .controls-hint {
  display: none !important;
}

html.is-phone .start-btn {
  font-size: 1.15rem;
  padding: 10px 12px;
}

html.is-phone .gameover-stats {
  margin: 8px 0;
}

html.is-phone .text-link-btn {
  margin-top: 6px;
  font-size: 0.78rem;
}

.rotate-prompt {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  text-align: center;
  background: #04070c;
  color: var(--ink);
  padding: 20px;
}

.rotate-prompt p {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 6vw, 1.85rem);
  letter-spacing: 0.06em;
}

.rotate-prompt span {
  color: var(--muted);
  font-size: 0.85rem;
}

html.is-phone.is-portrait .rotate-prompt:not([hidden]) {
  display: grid;
}

/* Portrait: rotate prompt only — hide start/game chrome underneath */
html.is-phone.is-portrait #overlay,
html.is-phone.is-portrait #gameover-overlay,
html.is-phone.is-portrait #pause-overlay,
html.is-phone.is-portrait #name-overlay {
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Viewing leaderboard: keep Play, show board, no in-game glitch */
html.viewing-board,
html.viewing-board body {
  overflow: auto !important;
  height: auto;
  min-height: 100%;
  overscroll-behavior: auto;
  touch-action: auto;
}

html.viewing-board #app {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

html.viewing-board #overlay:not(.hidden) {
  position: relative;
  inset: auto;
  order: -2;
  display: block;
  padding: 16px 14px 8px;
  background:
    radial-gradient(800px 400px at 50% 0%, rgba(61, 224, 197, 0.08), transparent 60%),
    rgba(4, 7, 12, 0.94);
  backdrop-filter: none;
  z-index: 5;
}

html.viewing-board #overlay .overlay-card {
  margin: 0 auto;
}

html.viewing-board .stage-wrap {
  order: -1;
  flex: 0 0 auto;
  height: auto;
  min-height: 0;
}

html.viewing-board .stage-frame {
  display: none;
}

html.viewing-board .dash-panel {
  display: none !important;
}

html.viewing-board .leaderboard-section {
  display: block !important;
  order: 0;
  margin: 0 14px 12px;
}

html.viewing-board .site-footer {
  display: block;
  order: 1;
}

html.is-phone.viewing-board #app {
  height: auto;
  padding: 0 0 12px;
}

html.is-phone.viewing-board .phone-hud,
html.is-phone.viewing-board .phone-controls {
  display: none !important;
}

html.shot-mode #gameover-overlay,
html.shot-mode #name-overlay {
  /* allow explicit screen= shots to show these */
}

html.shot-mode[data-shot-screen="start"] #overlay {
  display: grid !important;
}

/* Shot helpers: when screen overlays need to show in shot mode */
html.shot-mode.show-start #overlay,
html.shot-mode.show-gameover #gameover-overlay {
  display: grid !important;
}

html.is-desktop .phone-hud,
html.is-desktop .phone-controls,
html.is-desktop .rotate-prompt {
  display: none !important;
}

/* —— Site footer —— */
.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 36;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  padding: 8px 10px max(8px, env(safe-area-inset-bottom, 0px));
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0.9;
  background: linear-gradient(180deg, transparent, rgba(4, 7, 12, 0.82) 40%);
  pointer-events: auto;
}

html.is-playing .site-footer,
html.is-phone.playing-locked .site-footer {
  display: none !important;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.site-footer a:hover {
  color: var(--cyan);
  border-bottom-color: rgba(61, 224, 197, 0.45);
}

.footer-sep {
  opacity: 0.45;
}

.footer-credit {
  color: #6f7b8c;
}

/* Legal pages */
.legal-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 36px 20px 48px;
  color: var(--ink);
}

.legal-page h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 2.4rem;
  letter-spacing: 0.08em;
}

.legal-page .legal-back {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--cyan);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}

.legal-page .legal-back:hover {
  text-decoration: underline;
}

.legal-page h2 {
  margin: 22px 0 8px;
  font-family: var(--font-race);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--cyan);
}

.legal-page p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}
