/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep:    #0d0d1a;
  --bg-mid:     #1a1a2e;
  --bg-card:    #16213e;
  --accent:     #7c6af7;
  --accent2:    #a78bfa;
  --gold:       #f59e0b;
  --text:       #e2e8f0;
  --text-muted: #94a3b8;
  --success:    #34d399;
  --danger:     #f87171;
  --radius:     20px;
  --radius-sm:  12px;
  --shadow:     0 8px 32px rgba(0,0,0,0.4);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Nunito', sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== SCREENS ===== */
.screen {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
}
.screen.active { display: flex; }
.screen.overlay {
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
}

/* ===== SPLASH SCREEN ===== */
#splash-screen {
  background: linear-gradient(160deg, #0d0d1a 0%, #1a1a2e 50%, #0f3460 100%);
  justify-content: center;
  gap: 0;
}

.splash-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(124,106,247,0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(167,139,250,0.1) 0%, transparent 50%);
  pointer-events: none;
}

.splash-content {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  z-index: 1; padding: 40px 24px;
  padding-bottom: 80px;
}

/* Logo bubbles */
.app-logo {
  position: relative;
  width: 120px; height: 120px;
  margin-bottom: 8px;
}
.logo-bubble {
  position: absolute;
  border-radius: 50%;
  animation: float 3s ease-in-out infinite;
}
.logo-bubble.b1 {
  width: 80px; height: 80px;
  background: radial-gradient(circle at 35% 35%, #a78bfa, #7c6af7);
  top: 20px; left: 20px;
  box-shadow: 0 0 30px rgba(124,106,247,0.6), inset 0 -4px 8px rgba(0,0,0,0.2);
  animation-delay: 0s;
}
.logo-bubble.b2 {
  width: 44px; height: 44px;
  background: radial-gradient(circle at 35% 35%, #67e8f9, #06b6d4);
  top: 0; right: 10px;
  box-shadow: 0 0 20px rgba(6,182,212,0.5);
  animation-delay: 0.5s;
}
.logo-bubble.b3 {
  width: 30px; height: 30px;
  background: radial-gradient(circle at 35% 35%, #fde68a, #f59e0b);
  bottom: 10px; right: 0;
  box-shadow: 0 0 15px rgba(245,158,11,0.5);
  animation-delay: 1s;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-10px); }
}

.app-title {
  font-size: 2.2rem; font-weight: 800;
  background: linear-gradient(135deg, #a78bfa, #67e8f9);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
.app-subtitle {
  font-size: 1rem; color: var(--text-muted);
  font-weight: 300; letter-spacing: 2px;
  text-transform: uppercase;
}
.high-score-display {
  font-size: 0.85rem; color: var(--text-muted);
  margin-top: 4px;
}
.high-score-display span { color: var(--gold); font-weight: 700; }

/* ===== BUTTONS ===== */
.btn-primary {
  width: 220px; padding: 16px 32px;
  background: linear-gradient(135deg, #7c6af7, #a78bfa);
  border: none; border-radius: 50px;
  color: #fff; font-family: 'Nunito', sans-serif;
  font-size: 1.1rem; font-weight: 700;
  cursor: pointer; letter-spacing: 0.5px;
  box-shadow: 0 4px 20px rgba(124,106,247,0.5);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:active { transform: scale(0.96); box-shadow: 0 2px 10px rgba(124,106,247,0.4); }

.btn-secondary {
  width: 220px; padding: 14px 32px;
  background: transparent;
  border: 2px solid rgba(167,139,250,0.4);
  border-radius: 50px;
  color: var(--accent2); font-family: 'Nunito', sans-serif;
  font-size: 1rem; font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-secondary:active { background: rgba(124,106,247,0.15); }

.btn-ghost {
  width: 220px; padding: 12px 32px;
  background: transparent; border: none;
  color: var(--text-muted); font-family: 'Nunito', sans-serif;
  font-size: 0.95rem; cursor: pointer;
  transition: color 0.2s;
}
.btn-ghost:active { color: var(--text); }

.btn-premium {
  width: 220px; padding: 16px 32px;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  border: none; border-radius: 50px;
  color: #1a1a2e; font-family: 'Nunito', sans-serif;
  font-size: 1.1rem; font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(245,158,11,0.5);
  transition: transform 0.15s;
}
.btn-premium:active { transform: scale(0.96); }

/* ===== AD BANNER ===== */
.ad-banner {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 60px;
  background: rgba(255,255,255,0.05);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; color: var(--text-muted);
  letter-spacing: 1px;
}
.ad-banner.hidden { display: none; }

/* ===== GAME SCREEN ===== */
#game-screen {
  background: var(--bg-deep);
  justify-content: flex-start;
  padding: 0;
}

.game-header {
  width: 100%; padding: 12px 20px 8px;
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  z-index: 10;
}
.hud-item { display: flex; flex-direction: column; align-items: center; min-width: 70px; }
.hud-item.center { align-items: center; }
.hud-label { font-size: 0.65rem; color: var(--text-muted); letter-spacing: 2px; font-weight: 600; }
.hud-value { font-size: 1.4rem; font-weight: 800; color: var(--text); line-height: 1.2; }

#game-canvas {
  display: block;
  width: 100%;
  flex: 1;
  touch-action: none;
}

.game-footer {
  width: 100%; padding: 10px 24px;
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,0.03);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.btn-icon {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%; font-size: 1.2rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.btn-icon:active { background: rgba(255,255,255,0.15); }

.theme-switcher { display: flex; gap: 10px; align-items: center; }
.theme-dot {
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
  transition: transform 0.2s, border-color 0.2s;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; color: var(--gold);
}
.theme-dot[data-theme="ocean"]  { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.theme-dot[data-theme="sunset"] { background: linear-gradient(135deg, #f97316, #ec4899); }
.theme-dot[data-theme="forest"] { background: linear-gradient(135deg, #22c55e, #06b6d4); }
.theme-dot[data-theme="galaxy"] { background: linear-gradient(135deg, #7c6af7, #f59e0b); }
.theme-dot.active { border-color: #fff; transform: scale(1.2); }
.theme-dot.premium-dot { border-color: rgba(245,158,11,0.4); }

/* ===== MODAL ===== */
.modal {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 32px 28px;
  display: flex; flex-direction: column;
  align-items: center; gap: 14px;
  width: 90%; max-width: 340px;
  box-shadow: var(--shadow);
  animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modalIn {
  from { transform: scale(0.8) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal h2 { font-size: 1.6rem; font-weight: 800; }
.modal-score { color: var(--text-muted); font-size: 1rem; }

.result-emoji { font-size: 3rem; }
.score-card {
  width: 100%; background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.score-row {
  display: flex; justify-content: space-between;
  font-size: 0.95rem; color: var(--text-muted);
}
.score-row span:last-child { font-weight: 700; color: var(--text); }
.score-row.highlight span:last-child { color: var(--gold); font-size: 1.1rem; }

/* ===== PREMIUM MODAL ===== */
.premium-modal { border-color: rgba(245,158,11,0.3); }
.premium-badge {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #1a1a2e; font-weight: 800; font-size: 0.75rem;
  padding: 4px 14px; border-radius: 50px; letter-spacing: 2px;
}
.premium-features {
  list-style: none; width: 100%;
  display: flex; flex-direction: column; gap: 8px;
}
.premium-features li { font-size: 0.95rem; color: var(--text); }
.price-tag {
  font-size: 2rem; font-weight: 800; color: var(--gold);
}
.price-tag span { font-size: 0.9rem; color: var(--text-muted); font-weight: 400; }

/* ===== TOAST ===== */
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: linear-gradient(135deg, #7c6af7, #a78bfa);
  color: #fff; padding: 10px 24px; border-radius: 50px;
  font-weight: 700; font-size: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 200; white-space: nowrap;
  box-shadow: 0 4px 20px rgba(124,106,247,0.5);
}
.toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* ===== PARTICLE ===== */
.particle {
  position: fixed; border-radius: 50%;
  pointer-events: none; z-index: 50;
  animation: particleFly 0.8s ease-out forwards;
}
@keyframes particleFly {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* ===== COMBO FLASH ===== */
@keyframes comboFlash {
  0%, 100% { color: var(--text); }
  50%       { color: #fde68a; transform: scale(1.3); }
}
.combo-flash { animation: comboFlash 0.3s ease; }

/* ===== THEME BACKGROUNDS ===== */
body.theme-ocean  { --bubble-a: #06b6d4; --bubble-b: #3b82f6; --bubble-c: #a78bfa; --glow: rgba(6,182,212,0.3); }
body.theme-sunset { --bubble-a: #f97316; --bubble-b: #ec4899; --bubble-c: #fbbf24; --glow: rgba(249,115,22,0.3); }
body.theme-forest { --bubble-a: #22c55e; --bubble-b: #06b6d4; --bubble-c: #a3e635; --glow: rgba(34,197,94,0.3); }
body.theme-galaxy { --bubble-a: #7c6af7; --bubble-b: #f59e0b; --bubble-c: #ec4899; --glow: rgba(124,106,247,0.3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .app-title { font-size: 1.8rem; }
  .modal { padding: 24px 20px; }
}