:root {
  --void: #05060f;
  --deep: #0a0e27;
  --panel: #0d1230;
  --line: #1c2454;
  --cyan: #00f0ff;
  --cyan-dim: #0a8fa8;
  --magenta: #ff2e93;
  --amber: #ffb800;
  --text: #d7ecff;
  --text-dim: #6f81b8;
  --danger: #ff3b5c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--void);
  color: var(--text);
  font-family: 'Rajdhani', sans-serif;
  overflow: hidden;
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

#game-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(0, 240, 255, 0.06), transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(255, 46, 147, 0.05), transparent 55%),
    var(--void);
}

canvas#game {
  background: var(--deep);
  display: block;
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  aspect-ratio: 960 / 600;
  box-shadow: 0 0 0 1px var(--line), 0 0 60px rgba(0, 240, 255, 0.08);
  image-rendering: crisp-edges;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 28px;
  padding: 8px 22px;
  background: rgba(5, 6, 15, 0.55);
  border: 1px solid var(--line);
  border-radius: 3px;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.hud-block { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.hud-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-dim);
}
.hud-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
  font-variant-numeric: tabular-nums;
}
#hud-wave-block .hud-value { color: var(--amber); text-shadow: 0 0 10px rgba(255, 184, 0, 0.5); }

#lives-wrap {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
#lives-wrap .hud-label { writing-mode: horizontal-tb; }
#lives-icons { display: flex; gap: 4px; }
.life-icon {
  width: 14px; height: 14px;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  background: var(--cyan);
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.7);
}
.life-icon.lost { background: var(--line); box-shadow: none; opacity: 0.4; }

#weapon-bar {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 120px;
  height: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  pointer-events: none;
}
#weapon-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--magenta), var(--amber));
  transition: width 0.08s linear;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 5, 14, 0.82);
  backdrop-filter: blur(3px);
  z-index: 20;
  transition: opacity 0.25s ease;
}
.overlay.hidden { display: none; }

.panel {
  text-align: center;
  padding: 36px 44px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(13, 18, 48, 0.9), rgba(10, 14, 39, 0.9));
  border-radius: 4px;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.08), inset 0 0 60px rgba(0, 240, 255, 0.02);
  max-width: 90vw;
}

.title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: 4px;
  margin: 0 0 4px;
  color: var(--text);
}
.title span { color: var(--cyan); text-shadow: 0 0 18px rgba(0, 240, 255, 0.6); }

.title-sm {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 3px;
  color: var(--magenta);
  text-shadow: 0 0 14px rgba(255, 46, 147, 0.5);
  margin: 0 0 20px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 15px;
  letter-spacing: 1px;
  margin: 0 0 26px;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 22px;
  margin-bottom: 28px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: left;
}
.key {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  color: var(--cyan);
  border: 1px solid var(--cyan-dim);
  border-radius: 3px;
  padding: 3px 7px;
  display: inline-block;
  margin-bottom: 4px;
}

.btn {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 15px;
  padding: 13px 38px;
  background: var(--cyan);
  color: var(--void);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 0 30px rgba(0, 240, 255, 0.65); }
.btn:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  box-shadow: none;
  border: 1px solid var(--line);
  margin-top: 12px;
}
.btn-ghost:hover { color: var(--text); box-shadow: none; }

.footnote { font-size: 11px; color: var(--text-dim); margin: 18px 0 0; opacity: 0.7; }

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  font-size: 14px;
  color: var(--text-dim);
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  min-width: 220px;
}
.stat-row strong {
  font-family: 'Orbitron', sans-serif;
  color: var(--cyan);
  font-size: 15px;
}
#over-best-row strong { color: var(--amber); }

/* ---------- Wave banner ---------- */
#wave-banner {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Orbitron', sans-serif;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 8px;
  color: var(--amber);
  text-shadow: 0 0 24px rgba(255, 184, 0, 0.6);
  z-index: 15;
  pointer-events: none;
  animation: banner-flash 1.6s ease forwards;
}
#wave-banner.hidden { display: none; }
@keyframes banner-flash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Touch controls ---------- */
#touch-controls {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
#touch-controls.hidden { display: none; }
#touch-stick-zone {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 130px;
  height: 130px;
  pointer-events: auto;
}
#touch-stick-base {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid var(--cyan-dim);
}
#touch-stick-nub {
  position: absolute;
  top: 50%; left: 50%;
  width: 52px; height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.35);
  border: 1px solid var(--cyan);
}
#touch-fire-zone {
  position: absolute;
  right: 30px;
  bottom: 34px;
  width: 90px;
  height: 90px;
  pointer-events: auto;
}
#touch-fire-btn {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 46, 147, 0.18);
  border: 1px solid var(--magenta);
  color: var(--magenta);
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

@media (max-width: 700px) {
  #hud { gap: 16px; padding: 6px 14px; }
  .hud-value { font-size: 15px; }
}
