:root {
  --bg: #05060c;
  --fg: #e6f1ff;
  --accent: #00e5ff;
  --accent-2: #ff2e63;
  --good: #39ff88;
  --warn: #ffd23f;
  --muted: #8aa;
  --panel: rgba(10, 14, 24, 0.82);
  --panel-border: rgba(0, 229, 255, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "Menlo", "Consolas", monospace;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#app, #app canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  transition: transform 60ms ease-out;
}
#crosshair.kick { transform: translate(-50%, -50%) scale(1.5); }
#crosshair.hit .ch { background: var(--good); box-shadow: 0 0 8px var(--good); }
.ch {
  position: absolute;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.8);
  transition: background 90ms, box-shadow 90ms;
}
.ch-n, .ch-s { left: 50%; width: 2px; height: 9px; margin-left: -1px; }
.ch-e, .ch-w { top: 50%; height: 2px; width: 9px; margin-top: -1px; }
.ch-n { top: 0; } .ch-s { bottom: 0; }
.ch-w { left: 0; } .ch-e { right: 0; }
.ch-dot {
  position: absolute; left: 50%; top: 50%;
  width: 2px; height: 2px; margin: -1px 0 0 -1px;
  background: var(--accent); border-radius: 50%;
}

#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 18px;
  padding-top: max(16px, env(safe-area-inset-top));
}
.label {
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  color: var(--muted);
  margin-bottom: 3px;
}
#score-box #score {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.55);
  font-variant-numeric: tabular-nums;
}
#score-box.bump #score { animation: bump 200ms ease-out; }
@keyframes bump { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }

#health-box { text-align: right; }
#health-bar {
  width: 190px;
  height: 14px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 7px;
  overflow: hidden;
  background: rgba(0,0,0,0.4);
}
#health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--good), #b6ff5e);
  transition: width 220ms ease-out, background 220ms;
  border-radius: 7px;
}

#combo {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  color: var(--warn);
  text-shadow: 0 0 10px rgba(255, 210, 63, 0.6);
}

#mute-btn, #fire-btn { pointer-events: auto; }
#mute-btn {
  position: absolute;
  bottom: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 16px;
  width: 44px; height: 44px;
  font-size: 1.1rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--fg);
  cursor: pointer;
}

#fire-btn {
  position: absolute;
  right: 26px;
  bottom: 40px;
  bottom: max(40px, calc(env(safe-area-inset-bottom) + 24px));
  width: 110px; height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(255,46,99,0.9), rgba(160,20,50,0.85));
  border: 2px solid rgba(255,255,255,0.5);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.1em;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(255,46,99,0.5);
}
#fire-btn:active { transform: scale(0.93); }

/* floating score popups */
.popup {
  position: absolute;
  z-index: 11;
  pointer-events: none;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--warn);
  text-shadow: 0 0 8px rgba(0,0,0,0.8);
  transform: translate(-50%, -50%);
  animation: floatUp 850ms ease-out forwards;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -40%) scale(0.7); }
  20%  { opacity: 1; transform: translate(-50%, -55%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}

/* ---------- Damage flash ---------- */
#damage-flash {
  position: fixed; inset: 0; z-index: 9;
  pointer-events: none;
  box-shadow: inset 0 0 140px 40px rgba(255, 30, 60, 0.0);
  background: rgba(255,30,60,0);
  transition: background 90ms ease-out, box-shadow 90ms ease-out;
}
#damage-flash.on {
  background: rgba(255,30,60,0.18);
  box-shadow: inset 0 0 160px 60px rgba(255, 30, 60, 0.55);
  transition: none;
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at center, rgba(5,6,12,0.55), rgba(5,6,12,0.92));
  backdrop-filter: blur(3px);
}
.panel {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 0 60px rgba(0, 229, 255, 0.12);
}
.panel h1 {
  margin: 0;
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  letter-spacing: 0.12em;
  color: var(--accent);
  text-shadow: 0 0 22px rgba(0, 229, 255, 0.55);
}
.subtitle {
  color: var(--accent-2);
  letter-spacing: 0.3em;
  font-size: clamp(0.8rem, 3.4vw, 1.05rem);
  margin: 2px 0 18px;
  text-shadow: 0 0 14px rgba(255,46,99,0.5);
}
.go-title { color: var(--accent-2); text-shadow: 0 0 22px rgba(255,46,99,0.5); }
.blurb {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
  margin: 0 0 16px;
}
#instructions {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  font-size: 0.82rem;
  color: var(--fg);
  line-height: 1.9;
}
#instructions b { color: var(--accent); }

button.primary {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 14px 40px;
  color: #021;
  background: linear-gradient(180deg, var(--accent), #00a7bd);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 26px rgba(0, 229, 255, 0.4);
  transition: transform 100ms ease, box-shadow 100ms ease;
}
button.primary:hover { transform: translateY(-2px); box-shadow: 0 0 36px rgba(0, 229, 255, 0.6); }
button.primary:active { transform: translateY(0); }

.final {
  display: flex;
  justify-content: center;
  gap: 38px;
  margin: 6px 0 14px;
}
.final .stat .label { margin-bottom: 4px; }
.final #final-score, .final #best-score {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
#final-detail { color: var(--muted); font-size: 0.8rem; margin-bottom: 22px; min-height: 1em; }

button.ghost {
  display: inline-block;
  margin-top: 18px;
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  padding: 9px 20px;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
button.ghost:hover { background: rgba(0, 229, 255, 0.1); border-color: var(--accent); }

.quality-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.seg { display: inline-flex; border: 1px solid var(--panel-border); border-radius: 8px; overflow: hidden; }
.seg button {
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  border: none;
  cursor: pointer;
}
.seg button.active { background: var(--accent); color: #021; }

/* ---------- Target indicators ---------- */
#indicators { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
.ind {
  position: absolute;
  width: 38px; height: 38px;
  --c: #00e5ff;
  border: 2px solid var(--c);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--c), inset 0 0 7px color-mix(in srgb, var(--c) 60%, transparent);
  opacity: 0.9;
  will-change: transform, left, top;
}
.ind .ind-arrow { display: none; }
.ind.edge {
  width: 30px; height: 30px;
  border: none; border-radius: 0; box-shadow: none;
}
.ind.edge .ind-arrow {
  display: block;
  width: 100%; height: 100%;
  background: var(--c);
  clip-path: polygon(0% 16%, 100% 50%, 0% 84%, 24% 50%);
  filter: drop-shadow(0 0 5px var(--c));
}

/* small screens: shrink HUD a touch */
@media (max-width: 520px) {
  #health-bar { width: 130px; }
  #score-box #score { font-size: 1.6rem; }
}
