:root {
  --bg: #0a0e1a;
  --bg2: #131a2e;
  --fg: #e8eefc;
  --muted: #8a96b8;
  --accent: #18d1ff;
  --accent-soft: rgba(24, 209, 255, 0.15);
  --card: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(900px 500px at 30% 10%, rgba(80, 20, 120, 0.35) 0%, transparent 60%),
    radial-gradient(700px 600px at 75% 80%, rgba(20, 60, 120, 0.3) 0%, transparent 55%),
    radial-gradient(500px 400px at 50% 50%, rgba(120, 20, 80, 0.15) 0%, transparent 70%),
    var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* HUD on top */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  padding: max(env(safe-area-inset-top), 10px) 14px 10px;
  pointer-events: none;
}
.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(10,14,26,0.85), rgba(10,14,26,0.55));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}
.hud-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.hud-level { font-weight: 700; font-size: 15px; }
.hud-score { color: var(--accent); font-size: 13px; font-weight: 600; }
.hud-moves { color: var(--muted); font-size: 12px; }
.hud-actions { display: flex; gap: 6px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, opacity .15s ease;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.09); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #04222b;
  border-color: transparent;
}
.btn-primary:hover { background: #49defF; }

/* Canvas area fills the viewport under the HUD */
.game-canvas {
  position: fixed;
  inset: 0;
}
.game-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* critical: let Pixi handle pointer events */
}

.hint-text {
  position: fixed;
  bottom: 60px; /* sit just above the audio bar */
  left: 0; right: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  z-index: 5;
}

/* Victory overlay */
.victory {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 18, 0.55);
  backdrop-filter: blur(4px);
  z-index: 20;
  animation: fadein .25s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.victory-card {
  background: linear-gradient(180deg, #1a2240, #11182f);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 34px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px var(--accent-soft);
  animation: pop .3s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.victory-emoji { font-size: 44px; }
.victory-title { font-size: 26px; font-weight: 800; margin-top: 4px; }
.victory-sub { color: var(--muted); margin: 6px 0 4px; font-size: 14px; }
.victory-score { color: var(--accent); font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.victory-next { color: var(--muted); margin-bottom: 16px; font-size: 13px; font-weight: 600; }
.victory-auto { color: var(--muted); margin-top: 10px; font-size: 12px; }

@media (max-width: 380px) {
  .btn { padding: 8px 8px; font-size: 12px; }
  .hint-text { display: none; }
  .audio-bar { font-size: 11px; }
  .audio-info { max-width: 90px; }
}

/* Background music control bar */
#audio-host { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; pointer-events: none; padding: 0 10px max(env(safe-area-inset-bottom), 8px); }
.audio-bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 560px;
  width: 100%;
  background: linear-gradient(180deg, rgba(10,14,26,0.85), rgba(10,14,26,0.7));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 10px;
  backdrop-filter: blur(8px);
  color: var(--fg);
  margin-top: 28px; /* lift above the hint footer */
}
.audio-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font-size: 15px;
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  transition: background .15s ease, transform .08s ease;
}
.audio-btn:hover { background: rgba(255,255,255,0.10); }
.audio-btn:active { transform: scale(0.94); }
.audio-btn[data-act="toggle"] { background: var(--accent); color: #04222b; border-color: transparent; font-size: 13px; }
.audio-info {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}
.audio-title {
  display: block;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg);
  text-transform: capitalize;
}
.audio-vol {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.audio-vol-icon { font-size: 13px; }
.audio-vol input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 64px;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  outline: none;
}
.audio-vol input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.audio-vol input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
