/* ===== PoundPop — base styles ===== */
:root {
  --bg: #f2f7fb;
  --card: #ffffff;
  --text: #1c2733;
  --muted: #64748b;
  --accent: #0ea5e9;
  --accent-deep: #0369a1;
  --pop: #22c55e;
  --danger: #ef4444;
  --bubble-empty: #dbeafe;
  --bubble-ring: #93c5fd;
  --bubble-hi: #7dd3fc;
  --shadow: 0 4px 18px rgba(14, 116, 190, 0.12);
}

/* ===== Premium themes (applied on <body>) ===== */
body.theme-bubblegum {
  --accent: #ec4899;
  --accent-deep: #be185d;
  --bubble-hi: #f9a8d4;
  --bubble-empty: #fce7f3;
  --bubble-ring: #f9a8d4;
}
body.theme-gold {
  --accent: #f59e0b;
  --accent-deep: #b45309;
  --bubble-hi: #fde68a;
  --bubble-empty: #fef3c7;
  --bubble-ring: #fcd34d;
}
body.theme-forest {
  --accent: #22c55e;
  --accent-deep: #15803d;
  --bubble-hi: #86efac;
  --bubble-empty: #dcfce7;
  --bubble-ring: #86efac;
}
@media (prefers-color-scheme: dark) {
  body.theme-bubblegum { --bubble-empty: #4a1d35; --bubble-ring: #86315e; }
  body.theme-gold { --bubble-empty: #453107; --bubble-ring: #92650f; }
  body.theme-forest { --bubble-empty: #14351f; --bubble-ring: #226637; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d141c;
    --card: #16202b;
    --text: #e7eef5;
    --muted: #8ba0b5;
    --bubble-empty: #1e3a5f;
    --bubble-ring: #2b5a8c;
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.screen { max-width: 720px; margin: 0 auto; padding: 20px; }
.hidden { display: none !important; }

/* ===== Setup ===== */
#setup-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.setup-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.logo { font-size: 52px; }
h1 { font-size: 30px; margin: 6px 0 4px; }
.tagline { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 24px; }

#setup-form { text-align: left; }
#setup-form label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 5px; }
#setup-form input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--bubble-ring);
  border-radius: 12px;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}
#setup-form input:focus { outline: none; border-color: var(--accent); }

.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ===== Buttons ===== */
.btn-primary {
  display: block;
  width: 100%;
  margin-top: 22px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.btn-primary:active { transform: scale(0.97); }

.btn-gain {
  background: var(--card);
  border: 2px solid var(--bubble-ring);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-gain:active { transform: scale(0.97); }

.btn-ghost {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 10px;
  text-decoration: underline;
}

.btn-danger {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: var(--danger);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.icon-btn { background: none; border: none; font-size: 22px; cursor: pointer; }

/* ===== Tracker ===== */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 4px 0 14px; }
.brand { font-weight: 800; font-size: 20px; }

.stats-row { display: flex; gap: 10px; margin-bottom: 14px; }
.stat {
  flex: 1;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: center;
  padding: 14px 6px;
}
.stat-main .stat-value { color: var(--accent); }
.stat-value { font-size: 22px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--muted); }

.progress-track {
  height: 10px;
  border-radius: 6px;
  background: var(--bubble-empty);
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--pop));
  transition: width 0.4s ease;
}

.actions { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.btn-pop { margin-top: 0; flex: 1; }

.milestone-banner {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #422c00;
  font-weight: 700;
  text-align: center;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 16px;
  animation: bounce-in 0.5s ease;
}

@keyframes bounce-in {
  0% { transform: scale(0.7); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* ===== Bubble grid ===== */
.bubble-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 8px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.bubble {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--bubble-empty);
  border: 2px solid var(--bubble-ring);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--muted);
  user-select: none;
  transition: transform 0.12s ease, background 0.25s ease;
  position: relative;
}
.bubble:hover { transform: scale(1.12); }

.bubble.filled {
  background: radial-gradient(circle at 32% 30%, var(--bubble-hi), var(--accent) 55%, var(--accent-deep));
  border-color: var(--accent-deep);
  color: rgba(255, 255, 255, 0.9);
  font-weight: 700;
}

.bubble.milestone { border-width: 3px; border-color: #f59e0b; }
.bubble.milestone.filled {
  background: radial-gradient(circle at 32% 30%, #fde68a, #f59e0b 55%, #b45309);
  border-color: #b45309;
}

.bubble.just-popped { animation: pop 0.45s ease; }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.5); }
  100% { transform: scale(1); }
}

.foot-note { text-align: center; color: var(--muted); font-size: 12px; padding: 16px 0 30px; }

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-card {
  background: var(--card);
  border-radius: 20px;
  padding: 28px;
  width: 90%;
  max-width: 360px;
  text-align: center;
}
.modal-card h2 { margin-bottom: 10px; }
.modal-card p { color: var(--muted); font-size: 14px; margin-bottom: 8px; }

/* ===== Premium / paywall ===== */
.topbar-right { display: flex; align-items: center; gap: 8px; }

.premium-pill {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: #422c00;
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  box-shadow: var(--shadow);
}
.premium-pill.is-premium { background: linear-gradient(135deg, #86efac, #22c55e); color: #052e16; }

.theme-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.theme-chip {
  border: 2px solid var(--bubble-ring);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.theme-chip.active { border-color: var(--accent); background: var(--bubble-empty); }
.theme-chip.locked { opacity: 0.65; }

.paywall-card { max-width: 400px; }
.paywall-crown { font-size: 44px; }
.paywall-features {
  list-style: none;
  text-align: left;
  margin: 14px 0 18px;
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.plan-row { display: flex; gap: 10px; }
.plan-btn {
  flex: 1;
  border: 2px solid var(--bubble-ring);
  background: var(--bg);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  transition: transform 0.1s ease;
}
.plan-btn:active { transform: scale(0.97); }
.plan-best { border-color: #f59e0b; }
.plan-badge {
  position: absolute;
  top: -10px;
  background: #f59e0b;
  color: #422c00;
  font-size: 10px;
  font-weight: 800;
  border-radius: 999px;
  padding: 2px 8px;
}
.plan-price { font-size: 20px; font-weight: 800; }
.plan-term { font-size: 12px; color: var(--muted); }

/* ===== Account / auth ===== */
.account-block {
  border-top: 1px solid var(--bubble-empty);
  border-bottom: 1px solid var(--bubble-empty);
  padding: 12px 0;
  margin: 12px 0;
}
.account-block .btn-gain { width: 100%; margin-top: 8px; }

.auth-form { display: grid; gap: 10px; margin-top: 14px; text-align: left; }
.auth-form input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--bubble-ring);
  border-radius: 12px;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}
.auth-form input:focus { outline: none; border-color: var(--accent); }
.auth-form .btn-primary { margin-top: 4px; }
.auth-error { color: var(--danger); font-size: 13px; font-weight: 600; text-align: center; }

.sync-dot { font-size: 12px; color: var(--muted); }

/* ===== Confetti ===== */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}
