:root {
  --sky-top: #4f8cff;
  --sky-bottom: #c3e0ff;
  --hud-bg: rgba(20, 30, 40, 0.72);
  --hud-text: #ffffff;
  --hud-muted: #bcd3e8;
  --accent-gas: #2ecc71;
  --accent-brake: #e74c3c;
  --accent-restart: #f1c40f;
  --fuel: #f1c40f;
  --overlay-bg: rgba(10, 18, 26, 0.86);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* HUD */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 14px;
  gap: 10px;
  pointer-events: none;
}

.hud-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: auto;
}

.hud-left {
  max-width: calc(100% - 110px);
}

.hud-item {
  background: var(--hud-bg);
  border-radius: 10px;
  padding: 6px 10px;
  min-width: 70px;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  backdrop-filter: blur(3px);
}

.hud-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--hud-muted);
}

.hud-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--hud-text);
  white-space: nowrap;
}

#fuel-display.hud-value {
  color: var(--fuel);
}

/* Buttons */
.btn,
.control-btn {
  border: none;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 80ms ease, filter 80ms ease;
}

.btn:active,
.control-btn:active,
.control-btn.is-active {
  transform: scale(0.96);
  filter: brightness(0.92);
}

.btn-restart {
  padding: 10px 16px;
  font-size: 13px;
  color: #1a2530;
  background: var(--accent-restart);
  box-shadow: 0 3px 0 #c29b0b;
}

/* Canvas */
.scene {
  position: absolute;
  inset: 0;
  z-index: 1;
}

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

/* Touch controls */
.controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 14px 16px 18px;
  pointer-events: none;
  gap: 14px;
}

.control-btn {
  pointer-events: auto;
  min-width: 100px;
  min-height: 72px;
  padding: 14px 22px;
  font-size: 18px;
  color: #ffffff;
  border-bottom: 4px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}

.control-btn--brake {
  background: var(--accent-brake);
}

.control-btn--accelerate {
  background: var(--accent-gas);
}

.control-btn.is-active {
  border-bottom-width: 2px;
  transform: translateY(2px) scale(0.98);
}

/* Overlay */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay-bg);
  opacity: 1;
  transition: opacity 200ms ease;
}

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

.overlay-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 28px 32px;
  text-align: center;
  max-width: min(90%, 320px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.overlay-card h2 {
  margin: 0 0 8px;
  font-size: 26px;
  color: #1a2530;
}

.overlay-card p {
  margin: 0 0 20px;
  font-size: 15px;
  color: #4a5a6a;
}

/* Responsive tweaks */
@media (max-width: 420px) {
  .hud {
    padding: 8px 10px;
  }

  .hud-item {
    padding: 5px 8px;
    min-width: 62px;
  }

  .hud-label {
    font-size: 9px;
  }

  .hud-value {
    font-size: 13px;
  }

  .control-btn {
    min-width: 86px;
    min-height: 64px;
    font-size: 16px;
  }
}
