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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  color: white;
  overflow: hidden;
  user-select: none;
}

.game-container {
  width: 100vw;
  height: 100vh;
  position: relative;
}

.screen {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  left: 0;
}

.hidden {
  display: none !important;
}

/* Start Screen */
.start-content {
  text-align: center;
  max-width: 600px;
  padding: 20px;
}

.start-content h1 {
  font-size: 4rem;
  margin-bottom: 20px;
  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5),
      0 0 20px rgba(255, 255, 255, 0.3);
  }
  to {
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5),
      0 0 30px rgba(255, 255, 255, 0.6);
  }
}

.car-display {
  font-size: 6rem;
  margin: 20px 0;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.subtitle {
  font-size: 1.5rem;
  margin-bottom: 30px;
  opacity: 0.9;
}

.game-modes {
  margin: 30px 0;
}

.game-modes h3 {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.mode-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 15px 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 120px;
  font-size: 1rem;
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.mode-btn.selected {
  background: rgba(255, 255, 255, 0.3);
  border-color: #ffff00;
  box-shadow: 0 0 20px rgba(255, 255, 0, 0.5);
}

.controls-info {
  margin: 30px 0;
  background: rgba(0, 0, 0, 0.3);
  padding: 20px;
  border-radius: 10px;
}

.controls-info h3 {
  margin-bottom: 15px;
}

.control-item {
  margin: 8px 0;
  font-size: 1.1rem;
}

.key {
  background: rgba(255, 255, 255, 0.2);
  padding: 5px 10px;
  border-radius: 5px;
  font-weight: bold;
  margin: 0 5px;
}

/* Buttons */
.btn {
  padding: 15px 30px;
  border: none;
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-primary {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
}

.btn-secondary {
  background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(116, 185, 255, 0.4);
}

.btn-secondary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(116, 185, 255, 0.6);
}

/* Game Screen */
#game-screen {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.8);
  padding: 15px 20px;
  font-size: 1.1rem;
  font-weight: bold;
  z-index: 100;
}

.hud-left,
.hud-right {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hud-center {
  text-align: center;
}

.speed {
  font-size: 1.5rem;
  color: #ffff00;
  text-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
}

#game-canvas {
  flex: 1;
  background: #333;
  display: block;
  margin: 0 auto;
  border: 2px solid #555;
}

/* Mobile Controls */
.mobile-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: none;
  flex-direction: column;
  gap: 5px;
  z-index: 200;
}

.control-row {
  display: flex;
  gap: 5px;
  justify-content: center;
}

.control-btn {
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  color: white;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.control-btn:active {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0.95);
}

/* Game Over Screen */
.game-over-content {
  text-align: center;
  max-width: 500px;
  padding: 20px;
}

.game-over-content h1 {
  font-size: 3rem;
  margin-bottom: 30px;
  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
}

.final-stats {
  background: rgba(0, 0, 0, 0.3);
  padding: 30px;
  border-radius: 15px;
  margin-bottom: 30px;
}

.stat {
  display: flex;
  justify-content: space-between;
  margin: 10px 0;
  font-size: 1.2rem;
}

.stat-label {
  opacity: 0.8;
}

.stat-value {
  font-weight: bold;
  color: #ffff00;
}

.performance-rating {
  margin: 30px 0;
}

#rating-text {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

#rating-emoji {
  font-size: 4rem;
  animation: bounce 1s ease-in-out infinite;
}

.game-over-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Pause Overlay */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.pause-content {
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 40px;
  border-radius: 15px;
  backdrop-filter: blur(10px);
}

.pause-content h2 {
  font-size: 2.5rem;
  margin-bottom: 20px;
}

.pause-content p {
  font-size: 1.2rem;
  opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 768px) {
  .start-content h1 {
    font-size: 2.5rem;
  }

  .car-display {
    font-size: 4rem;
  }

  .mode-buttons {
    flex-direction: column;
    align-items: center;
  }

  .mode-btn {
    width: 100%;
    max-width: 250px;
  }

  .mobile-controls {
    display: flex;
  }

  .hud {
    font-size: 0.9rem;
    padding: 10px;
  }

  .hud-left,
  .hud-right {
    font-size: 0.8rem;
  }

  .speed {
    font-size: 1.2rem;
  }

  #game-canvas {
    max-width: 100%;
    height: auto;
  }

  .game-over-content h1 {
    font-size: 2rem;
  }

  .game-over-buttons {
    flex-direction: column;
    align-items: center;
  }

  .btn {
    width: 100%;
    max-width: 250px;
  }
}

@media (max-height: 600px) {
  .start-content h1 {
    font-size: 2rem;
  }

  .car-display {
    font-size: 3rem;
    margin: 10px 0;
  }

  .controls-info {
    margin: 15px 0;
    padding: 15px;
  }

  .game-modes {
    margin: 15px 0;
  }
}

/* Performance optimizations */
.game-container * {
  will-change: transform;
}

#game-canvas {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}
