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

html, body {
  width: 100%;
  height: 100%;
  background: #080808;
  font-family: 'Space Grotesk', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#game-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100% - 16px, 1200px);
  filter: drop-shadow(0 16px 48px rgba(0,0,0,0.85));
}

#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 11px 24px;
  background: #111111;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(0, 0, 0, 0.8);
  border-radius: 8px 8px 0 0;
  color: #cccccc;
  letter-spacing: 1px;
  position: relative;
}

#hud::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 24px;
  right: 24px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.07) 30%,
    rgba(255,255,255,0.07) 70%,
    transparent 100%
  );
}

#hud .score-group {
  display: flex;
  gap: 36px;
}

#hud .score-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

#hud .label {
  font-family: 'Space Mono', monospace;
  color: rgba(170, 170, 170, 0.72);
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
}

#hud #score-value,
#hud #hiscore-value {
  font-family: 'Space Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #eeeeee;
}

#hud .wheels-label {
  color: rgba(180, 140, 0, 0.80);
}

#hud #wheels-value {
  font-family: 'Space Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffcc33;
  text-shadow: 0 0 8px rgba(255, 200, 50, 0.4);
}

#gameCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 1200 / 400;
  border-left: 1px solid rgba(255, 255, 255, 0.07);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  border-top: none;
  background: #080808;
  image-rendering: auto;
  cursor: pointer;
  border-radius: 0 0 8px 8px;
}

#controls-hint {
  margin-top: 14px;
  font-family: 'Space Mono', monospace;
  color: rgba(180, 180, 180, 0.60);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-align: center;
  line-height: 2;
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

#touch-controls {
  display: none;
  gap: 16px;
  margin-top: 18px;
}

@media (pointer: coarse) {
  #touch-controls {
    display: flex;
  }
}

.touch-btn {
  padding: 16px 40px;
  background: #1a1a1a;
  color: #bbbbbb;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  font-family: 'Space Grotesk', Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.08s, transform 0.08s;
}

.touch-btn:active {
  background: #262626;
  transform: scale(0.95);
}

#pause-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', Arial, sans-serif;
  font-weight: 700;
  color: #cccccc;
  font-size: 22px;
  letter-spacing: 6px;
  pointer-events: none;
  text-shadow: 0 0 24px rgba(255,255,255,0.12);
  border-radius: 0 0 8px 8px;
}

#pause-overlay.visible {
  display: flex;
}

/* ── Name-entry overlay ──────────────────────────────────────── */
#name-input-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.80);
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

#name-input-box {
  background: #111111;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(360px, 92vw);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.90);
}

#name-input-title {
  font-family: 'Space Grotesk', Arial, sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #ffcc33;
  letter-spacing: 2px;
  text-shadow: 0 0 18px rgba(255, 200, 50, 0.45);
  text-align: center;
}

#name-input-hint {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: rgba(170, 170, 170, 0.65);
  letter-spacing: 1.5px;
  text-align: center;
  text-transform: uppercase;
}

#name-input-field {
  width: 100%;
  background: #1c1c1c;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #ffffff;
  font-family: 'Space Grotesk', Arial, sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
  padding: 14px 16px;
  outline: none;
  -webkit-appearance: none;
  caret-color: #ffcc33;
}

#name-input-field:focus {
  border-color: rgba(255, 204, 51, 0.45);
  box-shadow: 0 0 0 2px rgba(255, 204, 51, 0.12);
}

#name-input-field::placeholder {
  color: rgba(255, 255, 255, 0.18);
  letter-spacing: 2px;
}

#name-input-submit {
  width: 100%;
  background: #1e1e1e;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top-color: rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: #eeeeee;
  font-family: 'Space Grotesk', Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 14px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}

#name-input-submit:active {
  background: #2a2a2a;
  transform: scale(0.97);
}

@media (max-width: 600px) {
  #hud {
    padding: 8px 14px;
  }
  #hud .label {
    font-size: 8px;
  }
  #hud #score-value,
  #hud #hiscore-value {
    font-size: 14px;
  }
  #controls-hint {
    font-size: 9px;
    letter-spacing: 1px;
  }
  .touch-btn {
    padding: 12px 28px;
    font-size: 12px;
  }
}
