/* Reset */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #000; font-family: Inter, system-ui, sans-serif; }

/* Root variable for speed */
:root {
  --speed: 8s; /* Default 8 seconds */
}

/* Scene */
.scene {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, #020217 0%, #07021a 50%, #000 100%);
}

/* Stars */
.stars {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(#ffffff1a 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.35;
  filter: blur(0.4px);
  animation: twinkle 8s linear infinite;
}
@keyframes twinkle {
  0%,100% { opacity: 0.25; }
  50% { opacity: 0.45; }
}

/* City */
.city-layer {
  position: absolute;
  bottom: 30%;
  left: -10%;
  width: 120%;
  background-repeat: repeat-x;
  background-position: 0 100%;
  will-change: transform;
}
.city-layer.layer1 {
  height: 35%;
  background-image: linear-gradient(90deg,
    rgba(40,10,60,0.0) 0%,
    rgba(30,10,50,0.6) 2%,
    rgba(40,20,70,0.6) 20%,
    rgba(30,10,50,0.4) 35%,
    rgba(40,10,60,0.0) 100%);
  opacity: 0.35;
  filter: blur(2px);
  animation: city1 var(--speed) linear infinite;
}
.city-layer.layer2 {
  bottom: 22%;
  height: 45%;
  background-image: linear-gradient(90deg,
    rgba(120,0,255,0.0) 0%,
    rgba(80,10,220,0.6) 10%,
    rgba(0,200,255,0.6) 40%,
    rgba(80,10,220,0.4) 70%,
    rgba(120,0,255,0.0) 100%);
  opacity: 0.55;
  mix-blend-mode: screen;
  animation: city2 calc(var(--speed) * 0.7) linear infinite;
}
@keyframes city1 { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes city2 { from { transform: translateX(0); } to { transform: translateX(-100%); } }

/* Road */
.road {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 28vh;
  background: linear-gradient(180deg, #06060a 0%, #0b0b10 60%, #06060a 100%);
  box-shadow: inset 0 8px 30px #000;
}

/* Lane markers */
.lane-markers {
  position: absolute;
  left: 0; right: 0; top: 40%;
  height: 6px;
  background-image: linear-gradient(90deg,
    rgba(255,255,255,0.85) 0 20px,
    rgba(255,255,255,0) 20px 60px);
  background-size: 80px 6px;
  opacity: 0.28;
  animation: lanes calc(var(--speed) * 0.12) linear infinite;
}
@keyframes lanes {
  0% { background-position-x: 0; }
  100% { background-position-x: -80px; }
}

/* Car wrapper */
.car-wrapper {
  position: absolute;
  bottom: 22vh;
  left: 50%;
  width: 460px;
  max-width: 60%;
  transform: translateX(-50%);
  pointer-events: none;
  animation: idleDrive 5s ease-in-out infinite;
}
@keyframes idleDrive {
  0%,100% { transform: translateX(-50%) translateY(0) scale(0.98); }
  25%,75% { transform: translateX(-49%) translateY(-1px) scale(1.0); }
  50% { transform: translateX(-50%) translateY(0) scale(0.99); }
}

/* Car */
#car {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 14px 20px rgba(0,0,0,0.8))
          drop-shadow(0 0 20px rgba(0,255,255,0.4));
  animation: headlightGlow 2s ease-in-out infinite;
  transform: scale(0.7) translateY(50px);
}
@keyframes headlightGlow {
  0%,100% { filter: drop-shadow(0 14px 20px rgba(0,0,0,0.8)) drop-shadow(0 0 20px rgba(0,255,255,0.4)); }
  50% { filter: drop-shadow(0 14px 20px rgba(0,0,0,0.8)) drop-shadow(0 0 45px rgba(0,255,255,0.9)); }
}

/* Neon underglow */
.neon-underglow {
  position: absolute;
  left: 10%; right: 10%; bottom: -28px;
  height: 18px;
  border-radius: 999px;
  filter: blur(18px);
  background: radial-gradient(closest-side, rgba(0,255,220,0.45), rgba(0,255,180,0.08));
  opacity: 0.8;
  mix-blend-mode: screen;
  animation: glowPulse 2s ease-in-out infinite;
}
@keyframes glowPulse {
  0%,100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Controls */
.controls {
  position: absolute;
  left: 18px; top: 18px;
  display: flex; gap: 10px; align-items: center;
  background: rgba(255,255,255,0.03);
  padding: 8px;
  border-radius: 8px;
  backdrop-filter: blur(4px);
  color: #eaeaea;
  font-size: 14px;
}
.controls button {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.06);
  padding: 6px 10px;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
}
.controls input[type="range"] { width: 140px; }
.controls label { margin-left: 6px; margin-right: 6px; color: #d7d7ff; }

.credit {
  position: absolute;
  right: 18px; bottom: 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.3);
  padding: 6px 10px;
  border-radius: 6px;
}

/* Responsive */
@media (max-width: 900px) {
  .car-wrapper { width: 380px; bottom: 20vh; }
  .road { height: 30vh; }
}
@media (max-width: 480px) {
  .car-wrapper { width: 320px; bottom: 16vh; }
  /* .controls { top: auto; bottom: 14vh; left: 10px; right: 10px; justify-content: center; } */
}
