* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background: #0a0a1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  font-family: 'Segoe UI', Arial, sans-serif;
  overflow: hidden;
  color: #fff;
}

/* Stars background */
#stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* HUD */
#hud {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
}

.hud-box {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 6px 14px;
  text-align: center;
  min-width: 72px;
}

.hud-label {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hud-value {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

#hud-level .hud-value { color: #a78bfa; }
#hud-score .hud-value { color: #facc15; }
#hud-balls .hud-value { color: #6ee7b7; }

/* Canvas wrapper */
#canvas-wrap {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 420px;
  display: flex;
  justify-content: center;
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  max-width: 420px;
  cursor: crosshair;
}

/* Bottom controls */
#bottom-bar {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 10px;
  gap: 10px;
}

#next-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#next-bubble-wrap span {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#next-canvas {
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}

#shoot-btn {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 0;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s;
}

#shoot-btn:active {
  background: rgba(255,255,255,0.16);
  transform: scale(0.97);
}

#swap-btn {
  background: rgba(167,139,250,0.15);
  border: 1px solid rgba(167,139,250,0.35);
  border-radius: 12px;
  color: #a78bfa;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

#swap-btn:active {
  background: rgba(167,139,250,0.28);
  transform: scale(0.97);
}

/* Overlay screens */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10,10,26,0.92);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.overlay.active { display: flex; }

.overlay h1 {
  font-size: clamp(28px, 7vw, 48px);
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.overlay p {
  font-size: 15px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 28px;
  line-height: 1.5;
}

.overlay-score {
  font-size: clamp(36px, 10vw, 60px);
  font-weight: 800;
  color: #facc15;
  margin-bottom: 4px;
}

.overlay-label {
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  margin-bottom: 24px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 14px 40px;
  cursor: pointer;
  letter-spacing: 0.02em;
  margin: 6px;
  transition: opacity 0.15s, transform 0.15s;
}

.btn-primary:active { opacity: 0.85; transform: scale(0.97); }

.btn-secondary {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 14px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 32px;
  cursor: pointer;
  margin: 6px;
  transition: background 0.15s;
}

.btn-secondary:active { background: rgba(255,255,255,0.08); }

/* Level clear banner */
#level-banner {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 90;
  background: rgba(99,102,241,0.92);
  border-radius: 20px;
  padding: 20px 40px;
  text-align: center;
  pointer-events: none;
}

#level-banner.show { display: block; animation: popIn 0.3s ease; }

#level-banner h2 { font-size: 26px; font-weight: 800; }
#level-banner p { font-size: 14px; color: rgba(255,255,255,0.8); margin-top: 4px; }

@keyframes popIn {
  from { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

/* Pop particles */
.pop-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: particleFade 0.5s ease-out forwards;
}

@keyframes particleFade {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* Danger zone indicator */
#danger-line {
  position: absolute;
  left: 0; right: 0;
  border-top: 1px dashed rgba(239,68,68,0.35);
  pointer-events: none;
  z-index: 5;
}