:root {
  --bg-1: #020816;
  --bg-2: #061733;
  --bg-3: #0c2c63;
  --ink: #e8f2ff;
  --line: #264b8f;
  --blue-1: #8fc3ff;
  --blue-2: #4a90ff;
  --blue-3: #1f56c5;
  --cyan: #5ff2ff;
  --pink: #ff6b9f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Verdana", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 18%, rgba(95, 242, 255, 0.12), transparent 30%),
    radial-gradient(circle at 82% 78%, rgba(74, 144, 255, 0.2), transparent 35%),
    linear-gradient(160deg, #01040d 0%, #071735 48%, #0b285a 100%);
  display: grid;
  place-items: center;
  padding: 14px;
}

.game-shell {
  width: min(1060px, 100%);
  background: linear-gradient(180deg, rgba(4, 14, 34, 0.96), rgba(2, 9, 24, 0.96));
  border: 2px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
}

.hud {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(9, 28, 66, 0.92), rgba(8, 23, 54, 0.92));
}

.hud h1 {
  margin: 0;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-weight: 700;
}

.stats p {
  margin: 0;
  padding: 4px 8px;
  border: 1px solid rgba(143, 195, 255, 0.45);
  border-radius: 999px;
  background: rgba(143, 195, 255, 0.09);
}

.charge-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9rem;
}

.charge-bar {
  width: 220px;
  max-width: 45vw;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(143, 195, 255, 0.5);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

#charge-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #5ff2ff, #8fc3ff 55%, #4a90ff);
}

.controls {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 0.94rem;
}

.controls p { margin: 0; }

.run-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.run-actions button.active-ammo {
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35), 0 0 14px rgba(95, 242, 255, 0.45);
}

.touch-controls {
  margin-top: 8px;
  display: none;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: 1px solid rgba(143, 195, 255, 0.55);
  background: linear-gradient(180deg, rgba(143, 195, 255, 0.32), rgba(74, 144, 255, 0.28));
  color: #edf5ff;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }

.game-area { position: relative; }

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: linear-gradient(180deg, #051432 0%, #0d2f66 55%, #103d84 100%);
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
  background: rgba(2, 8, 23, 0.8);
}

.overlay.visible { display: grid; }

.overlay h2 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.overlay p { margin: 0; }

.start-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

#victory-overlay h2 {
  color: #7ef5ff;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
  width: min(760px, 100%);
}

.upgrade-btn {
  min-height: 94px;
  text-align: left;
  line-height: 1.35;
  white-space: normal;
}

#pitstop-skip-btn {
  margin-top: 6px;
}

@media (max-width: 780px) {
  .touch-controls { display: flex; }
  .controls { font-size: 0.88rem; }
  .charge-bar { width: 160px; }
  .upgrade-grid {
    grid-template-columns: 1fr;
  }
}
