* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0c0a09;
  color: #fafaf9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Space Grotesk", sans-serif;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at center, #1c1917 0%, #0c0a09 100%);
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* TOP PACENOTE HUD */
#hud-top {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.pacenote-box {
  background: rgba(28, 25, 23, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid #f97316;
  padding: 8px 18px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 0 16px rgba(249, 115, 22, 0.4);
  transition: transform 0.15s ease;
}

.pace-icon {
  font-size: 22px;
  font-weight: 900;
  color: #f97316;
}

.pace-text {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: #fafaf9;
}

.telemetry-right {
  display: flex;
  gap: 10px;
}

.stat-badge {
  background: rgba(28, 25, 23, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(249, 115, 22, 0.35);
  padding: 8px 14px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.badge-tag {
  font-size: 8px;
  font-weight: 800;
  color: #a8a29e;
  letter-spacing: 0.8px;
}

.badge-val {
  font-size: 17px;
  font-weight: 900;
  color: #ffffff;
  font-family: monospace;
}

.delta-green {
  color: #10b981;
}

/* BOTTOM SPEED CLUSTER */
#hud-bottom {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  pointer-events: none;
  z-index: 10;
}

.speed-cluster {
  background: rgba(28, 25, 23, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(249, 115, 22, 0.35);
  padding: 10px 18px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.gear-badge {
  background: #f97316;
  color: #0c0a09;
  font-size: 24px;
  font-weight: 900;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
}

.speed-unit {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#hud-speed {
  font-size: 26px;
  font-weight: 900;
  color: #ffffff;
  font-family: monospace;
  line-height: 1;
}

.speed-unit span {
  font-size: 10px;
  font-weight: 800;
  color: #f97316;
}

/* OVERLAYS */
.overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(28, 25, 23, 0.94) 0%, rgba(12, 10, 9, 0.98) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: opacity 0.25s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.card {
  background: rgba(28, 25, 23, 0.92);
  border: 1px solid rgba(249, 115, 22, 0.35);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 480px;
  width: 92%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(249, 115, 22, 0.2);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #f97316, transparent);
}

.rally-badge {
  display: inline-block;
  padding: 4px 14px;
  background: rgba(249, 115, 22, 0.15);
  border: 1px solid #f97316;
  color: #ffedd5;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  border-radius: 30px;
  margin-bottom: 12px;
}

.menu-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffffff;
  margin-bottom: 4px;
  text-shadow: 0 0 16px rgba(249, 115, 22, 0.6);
}

.subtitle {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #f97316;
  margin-bottom: 12px;
}

.desc {
  font-size: 13px;
  line-height: 1.5;
  color: #d6d3d1;
  margin-bottom: 20px;
}

.controls-guide {
  background: rgba(12, 10, 9, 0.7);
  border: 1px solid rgba(249, 115, 22, 0.2);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 22px;
  display: flex;
  justify-content: space-around;
  gap: 16px;
  text-align: left;
}

.guide-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-item {
  color: #fafaf9;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

kbd {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
  font-family: monospace;
}

.btn-start {
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 50%, #9a3412 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  padding: 14px 28px;
  width: 100%;
  box-shadow: 0 4px 20px rgba(234, 88, 12, 0.4);
  transition: all 0.2s ease;
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 26px rgba(234, 88, 12, 0.6);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  padding: 12px 24px;
  cursor: pointer;
  width: 100%;
  margin-top: 10px;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0 24px;
}

.stat-card {
  background: rgba(12, 10, 9, 0.65);
  border: 1px solid rgba(249, 115, 22, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 9px;
  font-weight: 700;
  color: #f97316;
  letter-spacing: 0.8px;
}

.stat-val {
  font-size: 18px;
  font-weight: 900;
  color: #ffffff;
  font-family: monospace;
  margin-top: 4px;
}

.stat-val.highlight {
  color: #f97316;
  font-size: 22px;
}

/* TOUCH CONTROLS */
#touch-controls {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 20;
}

@media (pointer: coarse), (max-width: 820px) {
  #touch-controls {
    display: flex;
  }
}

.steer-box, .pedal-box {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.touch-btn {
  background: rgba(28, 25, 23, 0.85);
  border: 1px solid rgba(249, 115, 22, 0.4);
  color: #ffffff;
  border-radius: 14px;
  width: 58px;
  height: 58px;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

.gas-touch {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.6);
  font-size: 12px;
  width: 66px;
  height: 66px;
}

.brake-touch {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
  font-size: 11px;
}

.handbrake-touch {
  background: rgba(249, 115, 22, 0.25);
  border-color: rgba(249, 115, 22, 0.6);
  font-size: 9px;
}
