@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
  background: #0a0e27;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15),
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 9999;
}

#game-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
  user-select: none;
  z-index: 1;
  position: relative;
}

#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 300px;
  margin-bottom: 0.5rem;
  font-size: 8px;
  color: #0f0;
  text-shadow: 2px 2px 0 #000;
  background: #1a1a2e;
  border: 3px solid #0f0;
  padding: 6px;
}

#hud span { font-weight: 700; color: #0f0; }

#mute-btn {
  background: #1a1a2e;
  border: 2px solid #0f0;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  color: #0f0;
  transition: all 0.05s;
}

#mute-btn:hover { background: #0f0; color: #000; transform: scale(1.1); }
#mute-btn:active { transform: scale(0.95); }

#night-btn {
  background: #1a1a2e;
  border: 2px solid #0f0;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  color: #0f0;
  transition: all 0.05s;
}

#night-btn:hover { background: #0f0; color: #000; transform: scale(1.1); }
#night-btn:active { transform: scale(0.95); }

#canvas-wrap {
  position: relative;
  width: 300px;
  height: 420px;
  border: 4px solid #0f0;
  background: #000;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0, 255, 0, 0.3);
}

canvas { display: block; }

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0a0e27;
  color: #0f0;
  text-align: center;
  gap: 8px;
  padding: 16px;
  border: 2px solid #0f0;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
}

#overlay h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #ff00ff;
}

#overlay p {
  font-size: 6px;
  color: #0f0;
  line-height: 1.4;
}

#overlay .score-big {
  font-size: 16px;
  font-weight: 700;
  color: #ff00ff;
}

#start-btn {
  margin-top: 8px;
  padding: 8px 12px;
  font-size: 8px;
  font-family: 'Press Start 2P', monospace;
  font-weight: 700;
  background: #ff00ff;
  color: #0a0e27;
  border: 3px solid #0f0;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.05s;
  text-shadow: none;
}

#start-btn:hover { background: #0f0; color: #000; box-shadow: 0 0 10px #0f0; }
#start-btn:active { transform: scale(0.9); }

#ctrl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 300px;
  margin-top: 0.75rem;
  gap: 10px;
}

.ctrl-btn {
  width: 80px;
  height: 48px;
  font-size: 20px;
  background: #1a1a2e;
  border: 3px solid #0f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0f0;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.05s;
  box-shadow: inset 0 0 5px rgba(0, 255, 0, 0.2);
}

.ctrl-btn:active { background: #0f0; color: #000; transform: scale(0.92); }

#best-row {
  margin-top: 0.5rem;
  font-size: 7px;
  color: #0f0;
  text-shadow: 1px 1px 0 #000;
}

#best-row span { color: #ff00ff; font-weight: 700; }

.diff-label {
  font-size: 6px;
  letter-spacing: 2px;
  color: #0f0;
  text-transform: uppercase;
  margin-bottom: 2px;
  text-shadow: 1px 1px 0 #000;
}

#diff-row { display: flex; gap: 2px; margin: 4px 0 2px; }
.diff-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 7px;
  font-family: 'Press Start 2P', monospace;
  font-weight: 700;
  background: #1a1a2e;
  color: #0f0;
  border: 2px solid #0f0;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.05s;
}

.diff-btn.active { background: #0f0; color: #0a0e27; }
.diff-btn:hover:not(.active) { background: #0a3d0a; }
.diff-btn:active { transform: scale(0.92); }

/* Vehicle selector */
#vehicle-row { display: flex; gap: 2px; margin: 4px 0 8px; }
.vehicle-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 7px;
  font-family: 'Press Start 2P', monospace;
  font-weight: 700;
  background: #1a1a2e;
  color: #0f0;
  border: 2px solid #0f0;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.05s;
}

.vehicle-btn.active { background: #0f0; color: #0a0e27; }
.vehicle-btn:hover:not(.active) { background: #0a3d0a; }
.vehicle-btn:active { transform: scale(0.92); }

/* Mode selector */
#mode-row { display: flex; gap: 2px; margin: 4px 0 8px; }
.mode-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 7px;
  font-family: 'Press Start 2P', monospace;
  font-weight: 700;
  background: #1a1a2e;
  color: #0f0;
  border: 2px solid #0f0;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.05s;
}

.mode-btn.active { background: #0f0; color: #0a0e27; }
.mode-btn:hover:not(.active) { background: #0a3d0a; }
.mode-btn:active { transform: scale(0.92); }

/* Theme selector */
#theme-row { display: flex; gap: 2px; margin: 4px 0 4px; }
.theme-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: 6px;
  font-family: 'Press Start 2P', monospace;
  font-weight: 700;
  background: #1a1a2e;
  color: #0f0;
  border: 2px solid #0f0;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.05s;
}
.theme-btn.active { background: #0f0; color: #0a0e27; }
.theme-btn:hover:not(.active) { background: #0a3d0a; }
.theme-btn:active { transform: scale(0.92); }

/* Gear indicator */
#gear-cell {
  font-size: 7px;
  color: #0f0;
  text-shadow: 1px 1px 0 #000;
}

#gear-disp {
  font-weight: 700;
  color: #ff00ff;
}

/* Shield indicator */
#shield-cell {
  font-size: 7px;
  color: #0f0;
  text-shadow: 1px 1px 0 #000;
}

#speed-cell {
  font-size: 7px;
  color: #0f0;
  text-shadow: 1px 1px 0 #000;
}

#speed-disp {
  color: #ff00ff;
  font-weight: 700;
}

#speed-unit {
  color: #0f0;
}
