:root {
  --green: #3dba7e;
  --green-dark: #2a9463;
  --green-light: #e8f9f1;
  --yellow: #ffd166;
  --orange: #ff9f43;
  --blue: #4fc3f7;
  --purple: #a78bfa;
  --red: #ff6b6b;
  --bg: #f7fdf9;
  --card: #ffffff;
  --text: #1a2e1f;
  --muted: #7a9882;
  --border: #d4edd9;
  --shadow: 0 4px 20px rgba(61,186,126,0.12);
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button { -webkit-user-select: none; user-select: none; }

/* ── SCREENS ── */
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ── DEMO BANNER ── */
.demo-banner {
  display: none;
  background: var(--purple); color: white;
  text-align: center; font-size: 12px; font-weight: 800;
  padding: calc(6px + var(--safe-top)) 12px 6px;
  position: sticky; top: 0; z-index: 500;
}
body.demo .demo-banner { display: block; }

/* ── LANDING ── */
#screen-landing {
  background: linear-gradient(160deg, #e8f9f1 0%, #fff8e7 100%);
  align-items: center;
  justify-content: center;
  padding: calc(32px + var(--safe-top)) 20px calc(32px + var(--safe-bottom));
  text-align: center;
}

.logo-wrap { margin-bottom: 8px; }
.logo-icon { font-size: 64px; line-height: 1; display: block; animation: bounce 2s infinite; }
@keyframes bounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.logo-text {
  font-family: 'Fredoka One', cursive;
  font-size: 42px;
  color: var(--green-dark);
  letter-spacing: 1px;
}
.logo-sub { font-size: 15px; color: var(--muted); font-weight: 600; margin-bottom: 36px; }

.plan-cards { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 400px; margin-bottom: 28px; }

.plan-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 20px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  text-align: left;
  position: relative;
  overflow: hidden;
}
.plan-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.plan-card.paid { border-color: var(--yellow); background: linear-gradient(135deg,#fff8e7,#fff); }
.plan-badge {
  position: absolute; top: 14px; right: 14px;
  background: var(--yellow); color: #7a5a00;
  font-size: 11px; font-weight: 800; padding: 3px 10px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.5px;
}
.plan-name { font-family: 'Fredoka One', cursive; font-size: 22px; color: var(--green-dark); }
.plan-price { font-size: 13px; color: var(--muted); font-weight: 700; margin: 2px 0 10px; }
.plan-features { list-style: none; }
.plan-features li { font-size: 14px; color: var(--text); margin-bottom: 5px; font-weight: 600; }
.plan-features li::before { content: '✓ '; color: var(--green); font-weight: 900; }
.plan-features li.locked { color: var(--muted); }
.plan-features li.locked::before { content: '🔒 '; }

.demo-note { font-size: 12px; color: var(--muted); font-weight: 600; }
.landing-login-link {
  margin-top: 18px; background: none; border: none;
  font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 800;
  color: var(--green-dark); text-decoration: underline; cursor: pointer;
}

/* ── AUTH SCREENS (login + setup) ── */
.auth-screen {
  background: linear-gradient(160deg, #e8f9f1 0%, #fff8e7 100%);
  align-items: center;
  justify-content: center;
  padding: calc(32px + var(--safe-top)) 20px calc(32px + var(--safe-bottom));
}
.login-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-header .back-btn {
  float: left; background: none; border: none; font-size: 22px; cursor: pointer; margin-top: -4px;
}
.login-title { font-family: 'Fredoka One', cursive; font-size: 26px; color: var(--green-dark); }
.login-sub { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 4px; }

.role-toggle {
  display: flex; background: var(--green-light);
  border-radius: 12px; padding: 4px; margin-bottom: 22px;
}
.role-btn {
  flex: 1; padding: 10px; border: none; border-radius: 10px; background: transparent;
  font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 800; cursor: pointer;
  color: var(--muted); transition: all 0.2s;
}
.role-btn.active { background: var(--card); color: var(--green-dark); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.form-group { margin-bottom: 16px; }
.form-label { font-size: 13px; font-weight: 800; color: var(--text); margin-bottom: 6px; display: block; }
.form-input {
  width: 100%; padding: 12px 16px; border: 2px solid var(--border);
  border-radius: 12px; font-family: 'Nunito', sans-serif; font-size: 16px; font-weight: 600;
  color: var(--text); background: var(--bg); outline: none; transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--green); }

.btn {
  width: 100%; padding: 14px; border: none; border-radius: 14px;
  font-family: 'Fredoka One', cursive; font-size: 18px; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s; letter-spacing: 0.5px;
}
.btn:active { transform: scale(0.97); }
.btn-green { background: var(--green); color: white; box-shadow: 0 4px 14px rgba(61,186,126,0.35); }
.btn-green:hover { background: var(--green-dark); box-shadow: 0 6px 18px rgba(61,186,126,0.4); }
.btn-yellow { background: var(--yellow); color: #7a5a00; box-shadow: 0 4px 14px rgba(255,209,102,0.4); }
.btn-ghost { background: var(--border); color: var(--muted); }

/* setup wizard */
.setup-steps { display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; }
.setup-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); transition: background 0.2s; }
.setup-dot.active { background: var(--green); }

.setup-kid-list { margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.setup-kid-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--green-light); border-radius: 14px; padding: 10px 14px;
}
.setup-kid-emoji { font-size: 26px; }
.setup-kid-name { flex: 1; font-weight: 800; font-size: 15px; }
.setup-kid-pin { font-size: 13px; color: var(--muted); font-weight: 700; }
.setup-kid-remove {
  background: none; border: none; color: var(--red); font-size: 18px; cursor: pointer; font-weight: 800;
}

.avatar-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.avatar-opt {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--border);
  background: var(--green-light); font-size: 22px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all 0.15s;
}
.avatar-opt.selected { border-color: var(--green); background: var(--green); transform: scale(1.1); }

.form-error {
  display: none; background: #ffe8e8; color: #b33a3a; border-radius: 10px;
  font-size: 13px; font-weight: 700; padding: 10px 14px; margin-bottom: 16px;
}
.form-error.show { display: block; }

/* ── PARENT DASHBOARD ── */
#screen-parent {
  background: var(--bg);
  padding-bottom: calc(40px + var(--safe-bottom));
}
.top-bar {
  background: var(--green-dark);
  padding: calc(16px + var(--safe-top)) 20px 20px;
  color: white;
  position: relative;
}
.top-bar-row { display: flex; align-items: center; justify-content: space-between; }
.top-greeting { font-family: 'Fredoka One', cursive; font-size: 22px; }
.top-sub { font-size: 13px; opacity: 0.8; font-weight: 600; margin-top: 2px; }
.avatar-btn {
  width: 44px; height: 44px; border-radius: 50%; background: var(--yellow);
  border: none; cursor: pointer; font-size: 22px; display: flex; align-items: center; justify-content: center;
}

.tab-bar {
  display: flex; background: var(--green-dark);
  padding: 0 20px 12px; gap: 8px;
}
.tab-btn {
  padding: 8px 16px; border: none; border-radius: 20px; background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.75); font-family: 'Nunito', sans-serif; font-size: 13px;
  font-weight: 800; cursor: pointer; transition: all 0.2s;
}
.tab-btn.active { background: white; color: var(--green-dark); }

.content-area { padding: 20px; }

/* child selector */
.child-selector {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 20px;
}
.child-selector::-webkit-scrollbar { display: none; }
.child-chip {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer;
  background: none; border: none; font-family: 'Nunito', sans-serif;
}
.child-avatar {
  width: 54px; height: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; border: 3px solid transparent; transition: all 0.2s;
}
.child-chip.active .child-avatar { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-light); }
.child-chip-name { font-size: 12px; font-weight: 800; color: var(--text); }
.child-chip.add-child .child-avatar { background: var(--green-light); border: 2px dashed var(--green); font-size: 22px; color: var(--green-dark); }

/* skill card */
.section-title {
  font-family: 'Fredoka One', cursive; font-size: 19px; color: var(--text);
  margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between;
}
.add-btn {
  background: var(--green); color: white; border: none; border-radius: 10px;
  padding: 6px 14px; font-family: 'Nunito', sans-serif; font-size: 13px; font-weight: 800;
  cursor: pointer; display: flex; align-items: center; gap: 4px;
}

.skill-list { display: flex; flex-direction: column; gap: 12px; }
.skill-card {
  background: var(--card); border-radius: 16px; padding: 16px;
  border: 2px solid var(--border); display: flex; align-items: center; gap: 14px;
  transition: transform 0.15s;
}
.skill-card:active { transform: scale(0.99); }
.skill-icon-wrap {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0;
}
.skill-info { flex: 1; min-width: 0; }
.skill-name { font-size: 16px; font-weight: 800; color: var(--text); }
.skill-cat { font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 2px; }

.skill-status { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.status-badge {
  font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 20px; text-align: center;
}
.status-unstarted { background: #f0f4f1; color: var(--muted); }
.status-pending { background: #fff3cd; color: #856404; }
.status-confirmed { background: #d4f7e7; color: var(--green-dark); }

.skill-delete {
  background: none; border: none; color: #cdd9d0; font-size: 16px; cursor: pointer;
  padding: 4px; flex-shrink: 0;
}
.skill-delete:hover { color: var(--red); }

.confirm-btn {
  background: var(--green); color: white; border: none; border-radius: 10px;
  padding: 6px 12px; font-family: 'Nunito', sans-serif; font-size:12px; font-weight: 800;
  cursor: pointer; animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(61,186,126,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(61,186,126,0); }
}

/* progress bar */
.progress-wrap { margin-top: 16px; }
.progress-label { font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.progress-track { height: 12px; background: var(--green-light); border-radius: 20px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--blue)); border-radius: 20px; transition: width 0.6s ease; }

/* ── CHILD DASHBOARD ── */
#screen-child {
  background: linear-gradient(180deg, #e0f5ec 0%, #fff8e7 60%, #f7fdf9 100%);
  padding-bottom: calc(40px + var(--safe-bottom));
}
.child-header {
  padding: calc(28px + var(--safe-top)) 20px 20px; text-align: center;
}
.child-welcome { font-family: 'Fredoka One', cursive; font-size: 28px; color: var(--green-dark); }
.child-welcome span { color: var(--orange); }
.child-stars { font-size: 14px; font-weight: 800; color: var(--muted); margin-top: 4px; }

.star-count {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--yellow); color: #7a5a00; font-family: 'Fredoka One', cursive;
  font-size: 18px; padding: 6px 18px; border-radius: 30px; margin-top: 8px;
  box-shadow: 0 3px 10px rgba(255,209,102,0.5);
}

.child-content { padding: 0 20px; }
.child-section-title { font-family: 'Fredoka One', cursive; font-size: 21px; color: var(--text); margin-bottom: 14px; }

.child-skill-card {
  background: var(--card); border-radius: 20px; padding: 18px;
  border: 2px solid var(--border); margin-bottom: 14px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04); transition: transform 0.15s;
}
.child-skill-card:active { transform: scale(0.98); }
.child-skill-icon { font-size: 36px; width: 56px; text-align: center; flex-shrink: 0; }
.child-skill-info { flex: 1; min-width: 0; }
.child-skill-name { font-size: 17px; font-weight: 800; color: var(--text); }
.child-skill-desc { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 3px; }

.child-check-wrap { flex-shrink: 0; }
.child-checkbox {
  width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--border);
  background: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 20px; transition: all 0.2s;
}
.child-checkbox.done { background: var(--green); border-color: var(--green); }
.child-checkbox.pending { background: var(--yellow); border-color: var(--orange); animation: pulse 1.5s infinite; }

.child-skill-card.completed { border-color: var(--green); background: linear-gradient(135deg, #e8f9f1, white); }
.child-skill-card.pending-confirm { border-color: var(--yellow); background: linear-gradient(135deg, #fff8e7, white); }

/* ── MODALS ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 100;
  align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: var(--card); border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(40px + var(--safe-bottom)); width: 100%; max-width: 480px;
  animation: slideUp 0.3s ease;
  max-height: 88vh; overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 0 auto 20px; }
.modal-title { font-family: 'Fredoka One', cursive; font-size: 22px; color: var(--green-dark); margin-bottom: 18px; }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.emoji-opt {
  width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--green-light); font-size: 22px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all 0.15s;
}
.emoji-opt.selected { border-color: var(--green); background: var(--green); transform: scale(1.1); }

.cat-select {
  width: 100%; padding: 12px 16px; border: 2px solid var(--border); border-radius: 12px;
  font-family: 'Nunito', sans-serif; font-size: 16px; font-weight: 600; color: var(--text);
  background: var(--bg); outline: none; margin-bottom: 16px; cursor: pointer;
}

.confirm-modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 200;
  align-items: center; justify-content: center; padding: 20px;
}
.confirm-modal.open { display: flex; }
.confirm-box {
  background: var(--card); border-radius: 24px; padding: 28px 24px;
  width: 100%; max-width: 340px; text-align: center;
  animation: popIn 0.25s ease;
}
@keyframes popIn { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.confirm-emoji { font-size: 56px; margin-bottom: 10px; }
.confirm-msg { font-family: 'Fredoka One', cursive; font-size: 21px; color: var(--text); margin-bottom: 8px; }
.confirm-sub { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 22px; }
.confirm-btns { display: flex; gap: 10px; }
.confirm-btns .btn { font-size: 16px; padding: 12px; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: calc(24px + var(--safe-bottom)); left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--green-dark); color: white; padding: 12px 22px; border-radius: 30px;
  font-weight: 800; font-size: 14px; z-index: 300; transition: transform 0.3s ease;
  white-space: nowrap; box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── CONFETTI ── */
.confetti-piece {
  position: fixed; top: -12px; z-index: 400; pointer-events: none;
  width: 10px; height: 10px; border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}

/* ── BADGES ── */
.badges-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.badge-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--card); border: 2px solid var(--border); border-radius: 14px;
  padding: 12px 10px; min-width: 70px;
}
.badge-item.earned { border-color: var(--yellow); background: #fff8e7; }
.badge-emoji { font-size: 28px; }
.badge-name { font-size: 10px; font-weight: 800; color: var(--muted); text-align: center; }
.badge-item.earned .badge-name { color: #7a5a00; }

/* ── PAID BANNER ── */
.paid-banner {
  background: linear-gradient(135deg, #fff3cd, #fff8e7);
  border: 2px solid var(--yellow); border-radius: 16px; padding: 14px 16px;
  margin-bottom: 20px; display: flex; align-items: center; gap: 12px;
}
.paid-banner-icon { font-size: 28px; }
.paid-banner-text { flex: 1; }
.paid-banner-title { font-weight: 800; font-size: 14px; color: #7a5a00; }
.paid-banner-sub { font-size: 12px; color: #a07830; font-weight: 600; }
.paid-banner-btn {
  background: var(--yellow); border: none; border-radius: 10px;
  padding: 8px 14px; font-family: 'Nunito', sans-serif; font-size: 13px; font-weight: 800;
  color: #7a5a00; cursor: pointer;
}

/* ── SETTINGS ── */
.settings-card {
  background: var(--card); border-radius: 16px; padding: 20px;
  border: 2px solid var(--border); margin-bottom: 16px;
}
.settings-card-title { font-weight: 800; margin-bottom: 6px; }
.settings-card-body { font-size: 13px; color: var(--muted); font-weight: 600; }
.pin-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.pin-reveal {
  background: var(--green-light); border: none; border-radius: 8px;
  padding: 4px 12px; font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 800;
  color: var(--green-dark); cursor: pointer;
}
.danger-btn {
  background: #ffe8e8; border: none; border-radius: 10px; width: 100%;
  padding: 12px; font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 800;
  color: #b33a3a; cursor: pointer; margin-top: 8px;
}

/* misc */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-weight: 700; }
.empty-state-icon { font-size: 48px; margin-bottom: 10px; }

.logout-row { text-align: center; margin-top: 24px; }
.logout-btn {
  background: none; border: 2px solid var(--border); border-radius: 12px;
  padding: 10px 24px; font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 800;
  color: var(--muted); cursor: pointer;
}
