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

body {
  background: #000;
  overflow: hidden;
  font-family: 'Segoe UI', sans-serif;
  touch-action: none;
}

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

/* HUD */
#hud {
  position: fixed;
  bottom: 24px;
  right: 24px;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

/* Tachometer */
#tach {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 8px 14px;
  backdrop-filter: blur(6px);
}

#tach-track {
  width: 200px;
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

#tach-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, #4ade80 0%, #facc15 70%, #f87171 100%);
  transition: width 0.05s linear;
}

#tach-fill.redline {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
}

#tach-readout {
  min-width: 64px;
  text-align: right;
}

#rpm-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

#rpm-unit {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: 3px;
}

/* Dash: gear + speed */
#dash {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

#gear-box {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 8px 20px;
  text-align: center;
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 72px;
}

#gear-value {
  display: block;
  font-size: 3rem;
  font-weight: 800;
  color: #fde047;
  line-height: 1;
  text-shadow: 0 0 12px rgba(253, 224, 71, 0.4);
}

#gear-label {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#speedometer {
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 18px;
  text-align: center;
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#speed-value {
  display: block;
  font-size: 2.4rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

#speed-unit {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ---- Desktop-only gate (shown on phones/tablets) ---- */
#mobile-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #0b0d12;
  color: #fff;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
}

#mobile-gate-inner {
  max-width: 420px;
}

#mobile-gate-icon {
  font-size: 4rem;
  margin-bottom: 18px;
}

#mobile-gate p {
  font-size: 1.25rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
}

/* Transmission toggle states */
#btn-transmission.auto {
  border-color: rgba(52, 211, 153, 0.6);
  color: #34d399;
}

/* Pit-lane / pit-stop status banner */
#pit-status {
  display: none;
  position: fixed;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  padding: 7px 20px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: #fff;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
#pit-status.pit-limit { background: rgba(40, 90, 170, 0.8); }
#pit-status.pit-busy  { background: rgba(190, 130, 20, 0.85); }
#pit-status.pit-go    { background: rgba(30, 160, 70, 0.9); animation: status-blink 0.4s steps(2, start) infinite; }

/* Drift-mode indicator */
#drift-badge {
  display: none;
  position: fixed;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  padding: 5px 16px;
  border-radius: 999px;
  background: rgba(190, 45, 32, 0.85);
  border: 1px solid rgba(255, 130, 110, 0.5);
  color: #fff;
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  box-shadow: 0 2px 12px rgba(190, 45, 32, 0.4);
  backdrop-filter: blur(6px);
}

/* View-mode hint (top centre) */
#view-hint {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.03em;
  backdrop-filter: blur(6px);
}

/* Ignition / engine status (top-left) */
#ignition-controls {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

#engine-status {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: 8px;
}

#engine-status::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

#engine-status.status-off {
  background: rgba(0, 0, 0, 0.55);
  color: #9ca3af;
}

#engine-status.status-ignition {
  background: rgba(120, 80, 0, 0.45);
  color: #fbbf24;
}

#engine-status.status-cranking {
  background: rgba(120, 80, 0, 0.55);
  color: #fbbf24;
  animation: status-blink 0.4s steps(2, start) infinite;
}

#engine-status.status-running {
  background: rgba(0, 80, 30, 0.5);
  color: #34d399;
}

@keyframes status-blink {
  0%   { opacity: 1; }
  100% { opacity: 0.5; }
}

#ignition-buttons {
  display: flex;
  gap: 8px;
}

.ign-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(4px);
  transition: background 0.1s;
}

.ign-btn.start {
  border-color: rgba(52, 211, 153, 0.5);
  color: #34d399;
}

.ign-btn:active,
.ign-btn.pressed {
  background: rgba(255, 255, 255, 0.22);
}

.key-hint {
  font-size: 0.6rem;
  font-weight: 500;
  opacity: 0.55;
  letter-spacing: 0.04em;
}
