:root {
  --bg: #05060f;
  --panel: rgba(16, 20, 40, 0.82);
  --line: rgba(140, 160, 255, 0.18);
  --text: #dfe6ff;
  --dim: #8b93b8;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(10px + var(--safe-top)) 14px 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  pointer-events: none;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 0 12px rgba(90, 140, 255, 0.55);
  z-index: 5;
}
#hud-score { font-size: 22px; min-width: 90px; }
#hud-wave  { font-size: 14px; color: var(--dim); }
#hud-high  { font-size: 13px; color: var(--dim); min-width: 90px; text-align: right; }

/* ---------- Wave banner ---------- */
#banner {
  position: fixed;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.14em;
  white-space: pre-line;
  text-shadow: 0 0 22px rgba(255, 190, 90, 0.8);
  pointer-events: none;
  z-index: 6;
  animation: bannerIn 0.35s ease-out;
}
#banner .sub { display: block; font-size: 15px; color: var(--dim); margin-top: 8px; letter-spacing: 0.1em; }
@keyframes bannerIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(1.25); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- Firework selector ---------- */
#selector {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 4px;
  padding: 8px 6px calc(10px + var(--safe-bottom));
  background: linear-gradient(to top, rgba(4, 5, 12, 0.95), rgba(4, 5, 12, 0.6) 80%, transparent);
  z-index: 5;
}

.fw-btn {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 7px 2px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.fw-btn:active { transform: scale(0.94); }

.fw-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--c) 45%, transparent 72%);
  box-shadow: 0 0 10px var(--c);
}

.fw-name { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 8.5px; letter-spacing: 0; }
.fw-ammo { font-size: 10px; color: var(--dim); font-variant-numeric: tabular-nums; }

.fw-btn.selected {
  border-color: var(--c);
  box-shadow: 0 0 14px var(--c), inset 0 0 10px rgba(255, 255, 255, 0.06);
}
.fw-btn.locked { opacity: 0.35; }
.fw-btn.empty .fw-ammo { color: #ff7373; }
.fw-btn:disabled { cursor: default; }

/* ---------- Overlay screens ---------- */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 30%, rgba(20, 26, 60, 0.55), rgba(4, 5, 12, 0.88));
  z-index: 10;
}
#overlay.hidden, #banner.hidden { display: none; }

#overlay h1 {
  font-size: clamp(30px, 9vw, 52px);
  margin: 0 0 6px;
  letter-spacing: 0.1em;
  font-weight: 900;
  background: linear-gradient(180deg, #ffe9b0, #ff9a5a 55%, #ff5a8a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(255, 150, 80, 0.45));
}
#overlay h2 { font-size: clamp(22px, 7vw, 36px); margin: 0 0 8px; letter-spacing: 0.12em; }
#overlay p { color: var(--dim); font-size: 15px; line-height: 1.55; max-width: 340px; margin: 6px 0; }
#overlay .score-big { font-size: 34px; font-weight: 800; margin: 10px 0 2px; }

.big-btn {
  margin-top: 22px;
  padding: 14px 44px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.14em;
  font-family: inherit;
  color: #0b0e1a;
  background: linear-gradient(180deg, #ffd77a, #ff9a4d);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 26px rgba(255, 170, 80, 0.55);
  transition: transform 0.08s ease;
}
.big-btn:active { transform: scale(0.95); }
