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

body {
  background: rgb(0, 0, 255);
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  user-select: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  display: block;
  background: #2d5a1e;
}

/* ===== СТАРТОВЫЙ ЭКРАН ===== */
#start-screen {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #00e5ff 0%, #0044ff 50%, #0015ff 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.5s;
}

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

.title {
  font-size: 6.7rem;
  font-weight: 1000;
  color: #ff0000;
  text-shadow: 40px 40px 40px rgba(255,221,87,0.5), 4px 10px 0 #e74c3c;
  margin-bottom: 0.2em;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.subtitle {
  font-size: 1.4rem;
  color: #a8d8ea;
  margin-bottom: 2em;
}

.instructions {
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 1.5em 2.5em;
  margin-bottom: 2em;
}

.instructions p {
  color: #e0e0e0;
  font-size: 1.1rem;
  margin: 0.4em 0;
}

.car-select {
  margin-bottom: 2em;
  text-align: center;
}

.car-select .label {
  color: #a8d8ea;
  font-size: 1.1rem;
  margin-bottom: 0.8em;
}

.cars-row {
  display: flex;
  gap: 1em;
}

.car-option {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: rgba(255,255,255,0.1);
  border: 3px solid transparent;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.car-option:hover { background: rgba(255,255,255,0.2); }
.car-option.selected { border-color: #ffdd57; background: rgba(255,221,87,0.2); }

#start-btn {
  font-size: 1.8rem;
  font-weight: 900;
  padding: 0.8em 2em;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 0 #922b21, 0 6px 20px rgba(231,76,60,0.4);
}

#start-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #922b21, 0 8px 30px rgba(231,76,60,0.6); }
#start-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #922b21; }

/* ===== HUD ===== */
#hud {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#position {
  font-size: 2.2rem;
  font-weight: 900;
  color: #ffdd57;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
}

#lap {
  font-size: 1.1rem;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  background: rgba(0,0,0,0.5);
  padding: 4px 12px;
  border-radius: 8px;
}

#speed-bar {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 200px;
  height: 20px;
  background: rgba(0,0,0,0.6);
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.3);
}

#speed-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2ecc71, #f1c40f, #e74c3c);
  border-radius: 8px;
  transition: width 0.1s;
}

#speed-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-shadow: 1px 1px 0 #000;
}

#item-box {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 70px;
  height: 70px;
  background: rgba(0,0,0,0.6);
  border: 3px solid #ffdd57;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  z-index: 50;
}

#nitro-bar {
  position: absolute;
  bottom: 20px;
  left: 230px;
  width: 140px;
  height: 20px;
  background: rgba(0,0,0,0.6);
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.3);
}

#nitro-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #3498db, #9b59b6);
  border-radius: 8px;
  transition: width 0.15s;
}

#nitro-bar span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  text-shadow: 1px 1px 0 #000;
}

/* ===== ФИНИШ ===== */
#finish-screen {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#finish-position {
  font-size: 3rem;
  font-weight: 900;
  color: #ffdd57;
  margin: 0.5em 0;
}

#finish-time {
  font-size: 1.3rem;
  color: #a8d8ea;
  margin-bottom: 1.5em;
}

#finish-screen button {
  font-size: 1.4rem;
  font-weight: 700;
  padding: 0.6em 1.5em;
  border: none;
  border-radius: 12px;
  background: #2ecc71;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #27ae60;
  transition: all 0.15s;
}

#finish-screen button:hover { transform: translateY(-2px); }
#finish-screen button:active { transform: translateY(2px); box-shadow: 0 2px 0 #27ae60; }

/* ===== ПАУЗА ===== */
#pause-screen {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 150;
}

#pause-screen p { color: #ccc; font-size: 1.2rem; margin-top: 1em; }
