:root {
  --bg: #05070f;
  --cyan: #00f0ff;
  --magenta: #ff2d95;
  --yellow: #ffe566;
  --panel: rgba(8, 12, 28, 0.82);
  --text: #e8f4ff;
  --muted: #7a8ba8;
  --font-display: "Orbitron", sans-serif;
  --font-ui: "Rajdhani", sans-serif;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game-root {
  position: relative;
  width: 100%;
  height: 100%;
}

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

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.screen.hidden,
.hidden {
  display: none !important;
}

/* —— Start —— */
.start-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(0, 240, 255, 0.28), transparent 60%),
    radial-gradient(ellipse 60% 50% at 70% 80%, rgba(255, 45, 149, 0.22), transparent 55%),
    linear-gradient(180deg, #070b18 0%, #121c38 50%, #070b18 100%);
}

.start-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 240, 255, 0.03) 2px,
      rgba(0, 240, 255, 0.03) 4px
    );
  pointer-events: none;
}

.start-content {
  position: relative;
  text-align: center;
  padding: 2.5rem 2rem;
  animation: fadeUp 0.8s ease-out;
  background: rgba(6, 10, 24, 0.55);
  border: 1px solid rgba(0, 240, 255, 0.35);
  box-shadow: 0 0 60px rgba(0, 240, 255, 0.2);
  backdrop-filter: blur(10px);
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.35em;
  color: #5cffff;
  margin-bottom: 0.75rem;
}

.logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.8rem, 10vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: 0.06em;
  color: #ffffff;
  text-shadow:
    0 0 12px rgba(0, 240, 255, 0.9),
    0 0 40px rgba(0, 240, 255, 0.5);
  margin-bottom: 1rem;
}

.tagline {
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  color: #b8c9e0;
  margin-bottom: 2rem;
  text-transform: uppercase;
}

.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.2em;
  padding: 0.95rem 2.4rem;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-primary {
  background: linear-gradient(90deg, var(--cyan), #4d9fff);
  color: #041018;
  box-shadow: 0 0 28px rgba(0, 240, 255, 0.45);
}

.btn-primary:hover {
  transform: scale(1.04);
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.65);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(0, 240, 255, 0.35);
  margin-top: 0.75rem;
}

.btn-ghost:hover {
  background: rgba(0, 240, 255, 0.1);
}

.controls-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  justify-content: center;
  margin-top: 2.5rem;
  font-size: 0.95rem;
  color: var(--muted);
  max-width: 36rem;
}

.controls-hint kbd {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0.1rem 0.35rem;
  margin: 0 0.1rem;
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 3px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: var(--cyan);
  background: rgba(0, 240, 255, 0.08);
}

/* —— Countdown —— */
#screen-countdown {
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

#countdown-num {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(6rem, 25vw, 12rem);
  color: var(--cyan);
  text-shadow: 0 0 40px rgba(0, 240, 255, 0.8);
  animation: pulseCount 0.9s ease-out;
}

#countdown-num.go {
  color: var(--yellow);
  text-shadow: 0 0 40px rgba(255, 229, 102, 0.8);
}

/* —— HUD —— */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  gap: 1rem;
}

.hud-block {
  background: var(--panel);
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 0.55rem 1rem;
  min-width: 5.5rem;
  backdrop-filter: blur(8px);
}

.hud-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.25em;
  color: var(--muted);
}

.hud-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--cyan);
}

.hud-suffix {
  font-size: 0.75rem;
  color: var(--muted);
}

.hud-bottom {
  position: absolute;
  bottom: 1.2rem;
  left: 1.2rem;
  right: 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.speedo {
  background: var(--panel);
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 0.6rem 1.1rem;
  backdrop-filter: blur(8px);
}

.speed-num {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2.4rem;
  color: var(--text);
  line-height: 1;
}

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

.minimap-wrap {
  width: 140px;
  height: 140px;
  border: 1px solid rgba(0, 240, 255, 0.35);
  background: rgba(5, 7, 15, 0.75);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
}

#minimap {
  width: 100%;
  height: 100%;
  display: block;
}

#lap-flash {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 3rem;
  letter-spacing: 0.3em;
  color: var(--yellow);
  text-shadow: 0 0 30px rgba(255, 229, 102, 0.7);
  animation: lapFlash 1.2s ease-out forwards;
}

/* —— Touch —— */
#touch-controls {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.touch-left,
.touch-right {
  position: absolute;
  bottom: 1.5rem;
  display: flex;
  gap: 0.6rem;
  pointer-events: auto;
}

.touch-left {
  left: 1rem;
}

.touch-right {
  right: 1rem;
  flex-direction: column;
}

.touch-btn {
  width: 64px;
  height: 64px;
  border: 1px solid rgba(0, 240, 255, 0.4);
  background: rgba(8, 12, 28, 0.65);
  color: var(--cyan);
  font-size: 1.4rem;
  border-radius: 12px;
  backdrop-filter: blur(6px);
  -webkit-tap-highlight-color: transparent;
}

.touch-btn:active,
.touch-btn.active {
  background: rgba(0, 240, 255, 0.3);
}

.touch-accel {
  height: 80px;
}

/* —— Results / Pause —— */
.results-panel,
.pause-panel {
  background: var(--panel);
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 2.5rem 2rem;
  text-align: center;
  min-width: min(90vw, 380px);
  backdrop-filter: blur(16px);
  box-shadow: 0 0 60px rgba(0, 240, 255, 0.15);
  animation: fadeUp 0.5s ease-out;
}

.results-panel h2,
.pause-panel h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: 0.15em;
  margin-bottom: 1.5rem;
  color: var(--cyan);
}

#results-list {
  list-style: none;
  text-align: left;
  margin-bottom: 1.25rem;
}

#results-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 1.15rem;
  letter-spacing: 0.05em;
}

#results-list li.player {
  color: var(--yellow);
  font-weight: 700;
}

#results-list li .place {
  font-family: var(--font-display);
  color: var(--muted);
  margin-right: 0.75rem;
  min-width: 1.5rem;
}

.results-time {
  font-family: var(--font-display);
  color: var(--muted);
  margin-bottom: 1.5rem;
  letter-spacing: 0.1em;
}

.pause-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseCount {
  from {
    opacity: 0;
    transform: scale(1.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes lapFlash {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.7);
  }
  20% {
    opacity: 1;
    transform: translateX(-50%) scale(1.05);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
}

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

  .hud-value {
    font-size: 1.1rem;
  }

  .speed-num {
    font-size: 1.8rem;
  }

  .minimap-wrap {
    width: 100px;
    height: 100px;
  }
}
