:root {
  --game-bg: linear-gradient(180deg, #bae6fd 0%, #e0f2fe 55%, #86efac 55%, #4ade80 100%);
  --car-color: #ef4444;
  --car-dark: #b91c1c;
}

.car-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  background: var(--game-bg);
  padding: 10px 16px 16px;
}

/* Scenery */
.scenery-sky {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  height: 45%;
  pointer-events: none;
  overflow: hidden;
}

.cloud {
  position: absolute;
  font-size: clamp(32px, 8vw, 48px);
  line-height: 1;
  opacity: 0.85;
}

.cloud-1 {
  top: 15%;
  left: 12%;
  animation: cloud-float 22s linear infinite;
}

.cloud-2 {
  top: 40%;
  right: 15%;
  animation: cloud-float 28s linear infinite reverse;
}

@keyframes cloud-float {
  0% { transform: translateX(0); }
  50% { transform: translateX(40px); }
  100% { transform: translateX(0); }
}

.sun-decor {
  position: absolute;
  top: 8px;
  left: 20px;
  font-size: clamp(36px, 9vw, 50px);
  line-height: 1;
  animation: sun-spin 20s linear infinite;
}

@keyframes sun-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.scenery-hills {
  position: absolute;
  top: 42%;
  left: -20px;
  right: -20px;
  height: 60px;
  background: radial-gradient(ellipse at center bottom, #4ade80 0%, #22c55e 100%);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  pointer-events: none;
}

/* Celebratory Sparkles Layer */
.particles-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 25;
}

.car-spark {
  position: absolute;
  font-size: clamp(22px, 6vw, 32px);
  line-height: 1;
  pointer-events: none;
  animation: spark-fly 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes spark-fly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.6);
  }
  60% {
    opacity: 1;
    transform: translate(var(--tx, 0), var(--ty, -30px)) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx, 0), var(--ty, -50px)) scale(0.8);
  }
}

/* Road */
.road-track {
  position: absolute;
  bottom: 68px;
  left: 0;
  right: 0;
  height: 72px;
  background: #334155;
  border-top: 4px solid #64748b;
  display: flex;
  align-items: center;
  overflow: hidden;
  z-index: 2;
}

.road-stripes {
  width: 200%;
  height: 8px;
  background-image: repeating-linear-gradient(
    90deg,
    #f8fafc 0,
    #f8fafc 35px,
    transparent 35px,
    transparent 65px
  );
}

.driving .road-stripes {
  animation: road-scroll 0.5s linear infinite;
}

@keyframes road-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-65px); }
}

/* Car stage */
.car-stage {
  position: absolute;
  bottom: 82px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.car-body-box {
  position: relative;
  width: clamp(260px, 68vw, 320px);
  height: clamp(120px, 32vw, 150px);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light beam anchored inside car-body-box */
.light-beam {
  position: absolute;
  top: 40px;
  right: -140px;
  width: 150px;
  height: 85px;
  background: radial-gradient(ellipse at left, rgba(254, 240, 138, 0.95) 0%, rgba(254, 240, 138, 0) 75%);
  transform: rotate(-4deg);
  pointer-events: none;
  z-index: 15;
}

.driving .car-body-box {
  animation: car-ride 0.35s ease-in-out infinite alternate;
}

@keyframes car-ride {
  0% { transform: translateY(0); }
  100% { transform: translateY(-3.5px); }
}

/* High specificity to work during driving as well */
.car-body-box.car-bounce,
.driving .car-body-box.car-bounce {
  animation: car-spring 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes car-spring {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-28px); }
}

.part-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

.part-btn:focus-visible {
  outline: 4px solid #f59e0b;
  border-radius: 12px;
}

/* Car shell */
.car-shell {
  position: absolute;
  inset: 0;
  background: var(--car-color, #ef4444);
  border-radius: 36px 54px 18px 18px;
  box-shadow: inset 0 -8px 16px rgba(0, 0, 0, 0.18), 0 10px 24px rgba(0, 0, 0, 0.15);
  transition: background 0.3s ease;
}

.car-roof {
  position: absolute;
  top: -40px;
  left: 55px;
  width: 135px;
  height: 52px;
  background: var(--car-dark, #b91c1c);
  border-radius: 30px 40px 0 0;
  transition: background 0.3s ease;
}

/* Driver button */
.driver-btn {
  position: absolute;
  top: -34px;
  left: 70px;
  width: 105px;
  height: 42px;
  background: #e0f2fe;
  border: 4px solid var(--car-dark, #b91c1c);
  border-radius: 24px 34px 0 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 8;
  overflow: hidden;
  transition: border-color 0.3s ease;
}

.driver-btn:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

.driver-emoji {
  font-size: 32px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  transition: transform 0.2s ease-out;
}

.driver-btn.jump .driver-emoji {
  animation: driver-wave 0.5s ease-out;
}

@keyframes driver-wave {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.25) rotate(-10deg); }
  100% { transform: translateY(0) scale(1); }
}

/* Horn & Headlight buttons */
.car-horn-btn {
  position: absolute;
  top: 14px;
  left: 22px;
  z-index: 10;
  font-size: clamp(32px, 8vw, 40px);
  line-height: 1;
  transition: transform 0.1s ease;
}

.car-horn-btn:active {
  transform: scale(1.25);
}

.car-horn-btn.horn-active {
  animation: horn-pulse 0.25s ease-out;
}

@keyframes horn-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.28) rotate(-8deg); }
  100% { transform: scale(1); }
}

.car-light-btn {
  position: absolute;
  top: 48px;
  right: 10px;
  z-index: 10;
  font-size: clamp(32px, 8vw, 40px);
  line-height: 1;
  transition: transform 0.1s ease;
}

.car-light-btn:active {
  transform: scale(1.25);
}

.car-light-btn.light-active .light-icon {
  filter: drop-shadow(0 0 10px #fde047) drop-shadow(0 0 16px #facc15);
  transform: scale(1.15);
}

/* Wheels */
.wheels-row {
  position: absolute;
  bottom: -28px;
  left: 28px;
  right: 28px;
  display: flex;
  justify-content: space-between;
  z-index: 10;
}

.wheel-btn {
  font-size: clamp(52px, 14vw, 64px);
  line-height: 1;
  transition: transform 0.4s ease;
}

.wheel-spin,
.driving .wheel-btn {
  animation: wheel-rotate 0.45s linear infinite;
}

@keyframes wheel-rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Controls at bottom */
.car-controls {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: min(92vw, 440px);
  z-index: 20;
}

.car-colors {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 5px 12px;
  border-radius: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.color-dot-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-dot-btn:hover {
  transform: scale(1.15);
}

.color-dot-btn:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

.color-dot-btn.active {
  transform: scale(1.22);
  border-color: #0f172a;
}

.drive-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: clamp(14px, 3.6vw, 16px);
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 26px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
  transition: transform 0.12s ease-out, background 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}

.driving-active {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
}

.drive-toggle-btn:hover {
  transform: translateY(-2px) scale(1.03);
}

.drive-toggle-btn:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 3px;
}

.drive-icon {
  font-size: 20px;
  line-height: 1;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cloud-1, .cloud-2, .sun-decor {
    animation: none;
  }
  .driving .road-stripes {
    animation: none;
  }
  .driving .car-body-box {
    animation: none;
  }
  .wheel-spin,
  .driving .wheel-btn {
    animation: none;
  }
  .car-bounce,
  .car-body-box.car-bounce,
  .driving .car-body-box.car-bounce {
    animation: none;
  }
  .driver-btn.jump .driver-emoji {
    animation: none;
  }
  .car-horn-btn.horn-active {
    animation: none;
  }
  .car-spark {
    animation: none;
  }
}
