:root {
  --font: 'Fredoka', system-ui, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  --text: #1a1a2e;
  --text-muted: rgba(26, 26, 46, 0.65);
  --bg: #eef2ff;
  --bg-accent: #c7d2fe;
  --card: #ffffff;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --success: #22c55e;
  --danger: #ef4444;
  --border: rgba(99, 102, 241, 0.2);
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  background-image:
    radial-gradient(circle at 10% 20%, var(--bg-accent) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, var(--bg-accent) 0%, transparent 35%);
}

a { color: var(--accent); }

h1, h2, h3 { margin: 0 0 0.5rem; line-height: 1.2; }

.subtitle { color: var(--text-muted); margin: 0 0 1.25rem; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: var(--font);
  font-weight: 600;
  font-size: 1rem;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--accent); border: 2px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-lg { padding: 0.85rem 1.5rem; font-size: 1.1rem; width: 100%; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
.btn-complete { background: var(--success); color: #fff; flex-shrink: 0; min-height: 48px; }
.btn-camera {
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.btn-camera:hover { background: var(--accent-hover); }
.btn-gallery {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.btn-gallery:hover { background: var(--bg-accent); }
.btn-photo-opt {
  background: transparent;
  color: var(--text-muted);
  border: 2px solid var(--border);
  padding: 0.5rem;
  font-size: 1.1rem;
  min-height: 48px;
  width: 48px;
  flex-shrink: 0;
}
.btn-icon {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text);
  font-size: 1.1rem;
}

/* Forms */
.form label, .form fieldset { display: block; margin-bottom: 1rem; }
.form label > span, .form fieldset > legend {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}
.form input[type="text"],
.form input[type="password"],
.form input[type="number"],
.form input[type="date"],
.form input[type="file"],
.form select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-family: var(--font);
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}
.form hr { border: none; border-top: 2px solid var(--border); margin: 1.5rem 0; }

.checkbox-group { border: none; padding: 0; }
.checkbox-inline {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500 !important;
  margin-bottom: 0.5rem !important;
}
.checkbox-inline input { width: auto; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-weight: 500;
}
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-info { background: #e0e7ff; color: #3730a3; }
.hint { color: var(--text-muted); font-size: 0.9rem; }
.muted { color: var(--text-muted); font-size: 0.85rem; display: block; }
.hidden { display: none !important; }

/* Avatars */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid var(--accent);
  background: var(--card);
}
.avatar-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-accent);
}
.avatar-sm { width: 36px; height: 36px; font-size: 1.1rem; }
.avatar-md { width: 48px; height: 48px; font-size: 1.5rem; }
.avatar-lg { width: 72px; height: 72px; font-size: 2.25rem; }
.avatar-xl { width: 120px; height: 120px; font-size: 3.5rem; }

/* Setup */
.setup-page {
  max-width: 420px;
  margin: 0 auto;
  padding: 2rem 1rem;
}
.setup-hero { font-size: 3rem; text-align: center; margin-bottom: 0.5rem; }
.footer-link { text-align: center; margin-top: 1.5rem; font-size: 0.9rem; }

.item-body { flex: 1; min-width: 120px; }

/* Kid app shell */
.kid-app { overflow-x: hidden; }
.kid-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
}

.kid-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.kid-pull-indicator {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.5rem;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.kid-pull-indicator.is-visible { opacity: 1; }

.kid-login {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.login-header { text-align: center; margin-bottom: 1.25rem; }
.login-header h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }

.kid-login-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  opacity: 0.85;
}
.kid-login-brand > span[aria-hidden] { font-size: 1.2rem; }

.kid-username-label {
  display: block;
  margin: 0 auto 1rem;
  max-width: 300px;
}
.kid-username-label > span {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
  text-align: center;
}
#username-input {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm, 12px);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#username-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(167,139,250,0.18);
}
#username-input::placeholder { color: var(--text-muted); opacity: 0.55; font-weight: 400; }

.kid-pin-label {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0.5rem 0 0.75rem;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.pin-dots span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: transparent;
  transition: background 0.2s;
}
.pin-dots span.filled { background: var(--accent); }

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  max-width: 300px;
  margin: 0 auto;
}
.pin-key {
  min-height: 64px;
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 2px solid var(--border);
}
.pin-key.empty { visibility: hidden; pointer-events: none; box-shadow: none; border: none; background: transparent; }
.pin-del { font-size: 1.25rem; color: var(--danger); }
.pin-error { text-align: center; min-height: 1.5rem; }
.shake { animation: shake 0.45s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.kid-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--card);
  border-bottom: 2px solid var(--border);
}
.kid-header-text { flex: 1; }
.kid-header h1 { font-size: 1.25rem; }
.points-today { margin: 0; color: var(--accent); font-weight: 600; }

.kid-tabs {
  display: flex;
  gap: 0.15rem;
  padding: 0.35rem 0.5rem;
  padding-bottom: calc(0.35rem + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 2px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

.kid-tabs.kid-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
}

.kid-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.65rem;
  min-height: 52px;
  padding: 0.35rem 0.2rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.kid-tab-icon { font-size: 1.25rem; line-height: 1; }
.kid-tab-label { line-height: 1.1; }
.kid-tab.active { background: var(--accent); color: #fff; }

.kid-panel {
  padding: 1rem;
  flex: 1;
}
.kid-panel:not(.active) { display: none; }
.panel-title { font-size: 1.1rem; margin-bottom: 1rem; }
.empty-state { text-align: center; color: var(--text-muted); padding: 2rem 1rem; }

.chore-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.chore-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--card);
  padding: 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  animation: popIn 0.35s ease backwards;
}
.chore-card.done {
  opacity: 0.7;
  background: rgba(255,255,255,0.6);
}
.chore-info { flex: 1; min-width: 0; }
.chore-title { font-weight: 600; font-size: 1.05rem; display: block; }
.chore-meta { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.25rem; flex-wrap: wrap; }
.chore-points { color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.badge-photo { font-size: 0.75rem; background: var(--bg-accent); padding: 0.15rem 0.5rem; border-radius: 999px; }
.done-heading { font-size: 0.95rem; color: var(--text-muted); margin: 1.5rem 0 0.75rem; }
.done-check { font-size: 1.5rem; color: var(--success); }

/* Bonus missions section */
.bonus-heading {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.75rem 0 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
}
.bonus-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}
.chore-list-bonus .chore-card {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--card) 80%, color-mix(in srgb, var(--accent) 8%, transparent));
}

/* Streak */
.streak-badge {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ea580c;
  margin: 0.15rem 0 0;
}
.streak-badge-empty { display: none; }

/* Rewards shop */
.rewards-balance {
  font-size: 0.95rem;
  margin: 0 0 1rem;
  color: var(--text-muted);
}
.rewards-balance strong { color: var(--accent); font-size: 1.1rem; }
.rewards-balance-total { font-size: 0.8rem; opacity: 0.85; }
.rewards-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.reward-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--card);
  padding: 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
}
.reward-info { flex: 1; min-width: 0; }
.reward-title { font-weight: 600; font-size: 1.05rem; display: block; }
.reward-desc {
  display: block;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.reward-cost {
  display: inline-block;
  margin-top: 0.35rem;
  font-weight: 700;
  color: var(--accent);
  font-size: 0.9rem;
}
.reward-redeem-btn { flex-shrink: 0; }
.reward-redeem-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.reward-status-pending {
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-accent);
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
}
.toast.redeem-success { background: var(--success); }

/* Chore action buttons group */
.chore-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Profile photo button row */
.profile-photo-btns {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: center;
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Leaderboard */
.board-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.board-period {
  flex: 1;
  font-family: var(--font);
  font-weight: 600;
  padding: 0.55rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--card);
  cursor: pointer;
  color: var(--text);
}
.board-period.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.leaderboard-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  min-height: 160px;
}
.podium-place {
  text-align: center;
  flex: 1;
  max-width: 110px;
  animation: popIn 0.4s ease backwards;
}
.podium-place:nth-child(1) { animation-delay: 0.1s; }
.podium-place:nth-child(2) { animation-delay: 0s; }
.podium-place:nth-child(3) { animation-delay: 0.2s; }
.podium-bar {
  background: var(--accent);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin: 0.5rem auto 0;
  width: 100%;
  opacity: 0.85;
}
.podium-place.rank-1 .podium-bar { height: 90px; background: linear-gradient(180deg, #fbbf24, #f59e0b); }
.podium-place.rank-2 .podium-bar { height: 65px; background: linear-gradient(180deg, #d1d5db, #9ca3af); }
.podium-place.rank-3 .podium-bar { height: 45px; background: linear-gradient(180deg, #fdba74, #ea580c); }
.podium-name { font-weight: 600; font-size: 0.9rem; margin-top: 0.35rem; }
.podium-points { font-size: 0.85rem; color: var(--accent); font-weight: 700; }
.medal { font-size: 1.25rem; display: block; }

.leaderboard-list { list-style: none; padding: 0; margin: 0; }
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  animation: popIn 0.3s ease backwards;
}
.leaderboard-rank { font-weight: 700; width: 1.5rem; color: var(--text-muted); }
.leaderboard-row .item-body { flex: 1; }

/* Profile */
.profile-editor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}
.profile-preview-wrap { margin: 0.5rem 0; }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(5rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: 999px;
  font-weight: 600;
  z-index: 100;
  box-shadow: var(--shadow);
  max-width: 90%;
  text-align: center;
}
.toast.show { animation: toastIn 0.3s ease; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.chore-card.removing {
  animation: fadeOut 0.35s ease forwards;
}
@keyframes fadeOut {
  to { opacity: 0; transform: scale(0.9); height: 0; padding: 0; margin: 0; overflow: hidden; }
}

@media (min-width: 600px) {
  .kid-shell, .kid-login { padding-left: 1rem; padding-right: 1rem; }
  .kid-tabs.kid-bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    border-radius: 16px 16px 0 0;
  }
}

@media (min-width: 768px) {
  .kid-shell { max-width: 640px; }
  .kid-tabs.kid-bottom-nav { max-width: 640px; }
}

@media (min-width: 1025px) {
  .kid-shell { max-width: 720px; }
  .kid-tabs.kid-bottom-nav { max-width: 720px; }
}

@media (hover: none) {
  .btn-primary:hover,
  .btn-camera:hover,
  .btn-gallery:hover {
    background: var(--accent);
  }
  .theme-swatch:active { transform: scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Gamification: header, level ring, streak flame ── */
.kid-header-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
}
.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 999px;
  min-height: 44px;
  padding: 0 0.65rem;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
}
.btn-logout-icon { font-size: 1rem; line-height: 1; }
.kid-level-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}
.level-ring {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--level-progress, 0%), var(--border) 0);
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.level-ring .avatar-frame {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-frame .avatar { margin: 0; }
.avatar-frame-scout {
  box-shadow: 0 0 0 2px #94a3b8, 0 0 12px rgba(148, 163, 184, 0.5);
  border-radius: 50%;
}
.avatar-frame-captain {
  box-shadow: 0 0 0 2px #fbbf24, 0 0 14px rgba(251, 191, 36, 0.55);
  border-radius: 50%;
}
.avatar-frame-legend {
  box-shadow: 0 0 0 2px #a78bfa, 0 0 0 4px rgba(167, 139, 250, 0.35), 0 0 18px rgba(167, 139, 250, 0.6);
  border-radius: 50%;
  animation: legendGlow 2.5s ease-in-out infinite;
}
@keyframes legendGlow {
  0%, 100% { box-shadow: 0 0 0 2px #a78bfa, 0 0 0 4px rgba(167, 139, 250, 0.35), 0 0 18px rgba(167, 139, 250, 0.5); }
  50% { box-shadow: 0 0 0 2px #c4b5fd, 0 0 0 6px rgba(196, 181, 253, 0.4), 0 0 24px rgba(167, 139, 250, 0.75); }
}
.profile-frame { display: inline-block; border-radius: 50%; }

.streak-flame {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.2rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #ea580c;
}
.streak-flame-icon { line-height: 1; transition: transform 0.2s; }
.streak-flame-tier-1 .streak-flame-icon { transform: scale(1.15); }
.streak-flame-tier-2 .streak-flame-icon { transform: scale(1.3); filter: drop-shadow(0 0 4px #f97316); }
.streak-flame-tier-3 .streak-flame-icon {
  transform: scale(1.45);
  animation: flamePulse 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 6px #ef4444);
}
.streak-flame-tier--1 { opacity: 0.45; }
@keyframes flamePulse {
  0%, 100% { transform: scale(1.35); }
  50% { transform: scale(1.55); }
}

.sound-toggle.muted { opacity: 0.5; }

/* Mission progress bar */
.mission-progress-wrap {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.mission-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.mission-progress-bar {
  height: 12px;
  background: var(--bg-accent);
  border-radius: 999px;
  overflow: hidden;
}
.mission-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 999px;
  transition: width 0.45s ease;
}
.mission-progress-wrap.all-complete .mission-progress-fill {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  animation: progressShine 1.5s ease infinite;
}
@keyframes progressShine {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}

/* Quest cards */
.quest-card { position: relative; }
.quest-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
  width: 2.5rem;
  text-align: center;
  line-height: 1;
}
.quest-easy { border-left: 4px solid var(--success); }
.quest-medium { border-left: 4px solid #fbbf24; }
.quest-hard { border-left: 4px solid #a855f7; }

/* Loot shop */
.loot-card.loot-locked { opacity: 0.72; }
.loot-card.loot-locked .reward-cost::after {
  content: ' 🔒';
}
.loot-card.loot-affordable {
  border-color: var(--accent);
  animation: lootPulse 2s ease-in-out infinite;
}
@keyframes lootPulse {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 8px 28px color-mix(in srgb, var(--accent) 35%, transparent); }
}

/* Badges */
.badges-heading {
  font-size: 1rem;
  margin: 1.75rem 0 0.25rem;
  text-align: center;
}
.badges-subtext {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}
.badges-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}
.badge-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.35rem;
  text-align: center;
  transition: transform 0.15s;
}
.badge-icon { font-size: 1.5rem; display: block; margin-bottom: 0.25rem; }
.badge-name { font-size: 0.68rem; font-weight: 600; line-height: 1.2; display: block; }
.badge-locked { opacity: 0.4; filter: grayscale(1); }
.badge-locked .badge-icon { filter: blur(1px); }
.badge-unlocked { border-color: var(--accent); }
.badge-card.badge-new-unlock {
  animation: badgePop 0.6s ease;
  border-color: #fbbf24;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.45);
}
@keyframes badgePop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
.hero-level-line { font-weight: 700; color: var(--accent); margin: 0; }
.hero-level-next { font-size: 0.88rem; color: var(--text-muted); margin: 0.25rem 0 0; }

/* Game modals */
.game-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.game-modal.hidden { display: none; }
.game-modal-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.25rem;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  animation: popIn 0.35s ease;
}
.game-modal-icon { font-size: 3rem; display: block; margin-bottom: 0.5rem; }
.game-modal-card h2 { font-size: 1.35rem; margin-bottom: 0.5rem; }
.game-modal-card p { color: var(--text-muted); margin: 0 0 1.25rem; line-height: 1.45; }
.welcome-splash-card .welcome-mascot { font-size: 3.5rem; display: block; margin-bottom: 0.5rem; }

/* Floating points */
.float-points-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
  overflow: hidden;
}
.float-point {
  position: absolute;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent);
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
  animation: floatUp 1s ease forwards;
  white-space: nowrap;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-80px) scale(1.2); }
}

/* Leaderboard rivalry */
.leaderboard-rivalry {
  background: linear-gradient(135deg, var(--card), color-mix(in srgb, var(--accent) 12%, transparent));
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
  animation: popIn 0.4s ease;
}

/* ── Phase 3: streak shield, team quest, daily spin, loot ── */
.streak-shield-hint {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #0284c7;
}
.streak-shield-used { opacity: 0.55; color: var(--text-muted); }

.team-quest-wrap {
  background: linear-gradient(135deg, var(--card), color-mix(in srgb, var(--success) 10%, transparent));
  border: 2px solid var(--success);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.team-quest-wrap.team-quest-complete {
  border-color: #fbbf24;
  background: linear-gradient(135deg, var(--card), color-mix(in srgb, #fbbf24 15%, transparent));
}
.team-quest-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.team-quest-bar {
  height: 12px;
  background: var(--bg-accent);
  border-radius: 999px;
  overflow: hidden;
}
.team-quest-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #4ade80);
  border-radius: 999px;
  transition: width 0.45s ease;
}
.team-quest-sub {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.daily-spin-wrap {
  text-align: center;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--card);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
}
.daily-spin-btn { width: 100%; max-width: 280px; font-size: 1.05rem; }
.daily-spin-hint, .daily-spin-revealed, .daily-spin-done {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.mystery-quest-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, var(--card), color-mix(in srgb, var(--accent) 12%, transparent));
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: left;
  animation: popIn 0.4s ease;
}
.chore-card.spin-pick {
  border-color: #fbbf24;
  box-shadow: 0 0 0 3px color-mix(in srgb, #fbbf24 35%, transparent);
  animation: lootPulse 2s ease-in-out infinite;
}

.spin-modal-card { max-width: 300px; }
.spin-wheel {
  width: 120px;
  height: 120px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  border: 4px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-accent);
}
.spin-wheel-inner {
  font-size: 3rem;
  line-height: 1;
}
.spin-wheel.spinning .spin-wheel-inner {
  animation: spinRotate 1.2s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
@keyframes spinRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(1080deg); }
}

.loot-chest-icon { font-size: 1.75rem; flex-shrink: 0; }
.loot-chest { align-items: center; }
.loot-need-more {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-weight: 600;
}
.loot-modal-card .loot-modal-chest {
  font-size: 4rem;
  display: block;
  margin-bottom: 0.5rem;
  animation: badgePop 0.6s ease;
}
.loot-modal-card.loot-open .loot-modal-chest {
  animation: chestOpen 0.5s ease;
}
@keyframes chestOpen {
  0% { transform: scale(1); }
  40% { transform: scale(1.2) rotate(-8deg); }
  100% { transform: scale(1) rotate(0); }
}

/* Kid theme picker */
.theme-heading {
  font-size: 1rem;
  margin: 1.75rem 0 0.25rem;
  text-align: center;
}
.theme-subtext {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
}
.theme-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.55rem 0.25rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.theme-swatch:active { transform: scale(0.96); }
.theme-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}
.theme-swatch-emoji { font-size: 1.35rem; line-height: 1; }
.theme-swatch-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.1;
}
.theme-swatch.active .theme-swatch-label { color: var(--accent); }
.theme-swatch-space  { background: linear-gradient(160deg, #1a1744, #302b63); }
.theme-swatch-jungle { background: linear-gradient(160deg, #ecfdf5, #6ee7b7); }
.theme-swatch-ocean  { background: linear-gradient(160deg, #e0f2fe, #7dd3fc); }
.theme-swatch-candy  { background: linear-gradient(160deg, #fdf2f8, #f9a8d4); }
.theme-swatch-arcade { background: linear-gradient(160deg, #1e1433, #2d1b69); }
@media (max-width: 380px) {
  .theme-picker { grid-template-columns: repeat(3, 1fr); }
}

