:root {
  --pink: #ff2e9a;        /* Barbie hot pink */
  --pink-dark: #e0218a;
  --pink-soft: #ff9ed2;
  --purple: #c026d3;
  --blue: #38bdf8;
  --green: #2dd4a7;
  --red: #fb5d8f;
  --amber: #ffcf3f;
  --bg: #fff0f8;
  --card: #ffffff;
  --ink: #6b1248;
  --muted: #c98ab4;
  --shadow: 0 12px 34px rgba(255, 46, 154, 0.28);
  --radius: 24px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* The hidden attribute must always win over any display rule below
   (e.g. .auth { display:flex }), otherwise the login screen stays on top
   of the app after sign-in. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }

/* ===== Boy theme (blue) — applied when the active child is a boy ===== */
body.theme-boy {
  --pink: #3b82f6;
  --pink-dark: #2563eb;
  --pink-soft: #93c5fd;
  --purple: #6366f1;
  --bg: #eef4ff;
  --ink: #15356b;
  --muted: #8aa6d6;
  --shadow: 0 12px 34px rgba(59, 130, 246, 0.28);
  background:
    radial-gradient(circle at 12% 8%, rgba(147,197,253,0.55) 0, transparent 42%),
    radial-gradient(circle at 88% 0%, rgba(99,102,241,0.28) 0, transparent 40%),
    linear-gradient(175deg, #e3efff 0%, #cfe1ff 45%, #dbe2ff 100%);
}
body.theme-boy .hero {
  background: linear-gradient(135deg, #5b9bff 0%, var(--pink) 45%, var(--purple) 100%);
}
body {
  font-family: "Fredoka", "Baloo 2", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(255,158,210,0.5) 0, transparent 42%),
    radial-gradient(circle at 88% 0%, rgba(192,38,211,0.28) 0, transparent 40%),
    linear-gradient(175deg, #ffe3f3 0%, #ffd0ec 45%, #f6d9ff 100%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  overscroll-behavior-y: contain;
}

.app { max-width: 520px; margin: 0 auto; padding: 0 16px 40px; }

/* ===== Hero ===== */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #ff5bb0 0%, var(--pink) 45%, var(--purple) 100%);
  border-radius: 0 0 38px 38px;
  padding: calc(env(safe-area-inset-top, 12px) + 14px) 22px 26px;
  margin: 0 -16px 18px;
  color: #fff;
  box-shadow: var(--shadow);
}
.sparkles { position: absolute; inset: 0; pointer-events: none; }
.sparkles span { position: absolute; font-size: 16px; opacity: 0.85; animation: twinkle 2.6s ease-in-out infinite; }
.sparkles span:nth-child(1){ top: 14%; left: 8%; animation-delay: 0s; }
.sparkles span:nth-child(2){ top: 8%; right: 30%; font-size: 13px; animation-delay: .5s; }
.sparkles span:nth-child(3){ top: 40%; right: 10%; font-size: 12px; animation-delay: 1s; }
.sparkles span:nth-child(4){ bottom: 30%; left: 14%; font-size: 14px; animation-delay: 1.4s; }
.sparkles span:nth-child(5){ top: 22%; right: 46%; font-size: 11px; animation-delay: 1.9s; }
@keyframes twinkle { 0%,100%{ transform: scale(0.8) rotate(0); opacity:.4 } 50%{ transform: scale(1.2) rotate(12deg); opacity:1 } }
.hero-top { display: flex; justify-content: space-between; align-items: center; position: relative; }
.hero-actions { display: flex; gap: 8px; }
.icon-btn.unlocked { background: rgba(45,212,167,0.55); box-shadow: 0 0 0 2px rgba(255,255,255,0.5); }
.gate-q { font-size: 30px; font-weight: 800; text-align: center; color: var(--pink-dark);
  margin: 8px 0 16px; letter-spacing: 1px; }
#gateAnswer { text-align: center; font-size: 22px; font-weight: 700; }
.hello { font-size: 15px; opacity: 0.95; font-weight: 500; }
.name { margin: 2px 0 4px; font-size: 31px; font-weight: 700; letter-spacing: 0.3px;
  text-shadow: 0 2px 10px rgba(108,8,72,0.25); }
.royal { font-size: 14px; font-weight: 700; color: #fff; opacity: 0.92; margin: 0 0 14px; }
.icon-btn { background: rgba(255,255,255,0.25); border: none; width: 40px; height: 40px;
  border-radius: 14px; font-size: 19px; cursor: pointer; }

.score-card {
  /* NOTE: no backdrop-filter — on iOS Safari it mis-renders the big score number
     (the "0" collapsed to a comma). A translucent white keeps the same frosted look. */
  background: rgba(255,255,255,0.22);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; align-items: center; gap: 14px;
  border: 1px solid rgba(255,255,255,0.3);
  overflow: visible;
}
.score-star { font-size: 46px; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.15)); flex: 0 0 auto; }
.score-number { font-size: 54px; font-weight: 800; line-height: 1.2; white-space: nowrap;
  flex: 0 0 auto; padding: 0 2px; }
.score-label { font-size: 18px; align-self: flex-end; margin-bottom: 8px; opacity: 0.9; flex: 0 0 auto; }
.score-card.bump { animation: bump 0.5s ease; }
@keyframes bump { 0%{transform:scale(1)} 35%{transform:scale(1.08)} 100%{transform:scale(1)} }

.level-bar { margin-top: 16px; }
.level-info { display: flex; justify-content: space-between; font-size: 13px; opacity: 0.95; margin-bottom: 6px; }
.level-track { height: 12px; background: rgba(255,255,255,0.25); border-radius: 20px; overflow: hidden; }
.level-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--amber), #fff7d6);
  border-radius: 20px; transition: width 0.6s cubic-bezier(.3,1.3,.5,1); }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 12px 6px; border: none; border-radius: 16px;
  background: #fff; color: var(--muted); font-size: 14px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 14px rgba(139,92,246,0.08); transition: 0.2s;
}
.tab.active { background: var(--purple); color: #fff; transform: translateY(-1px); }

/* ===== Who's giving stars bar ===== */
.giver-bar { width: 100%; margin: 0 0 14px; padding: 10px 14px; border: none; cursor: pointer;
  background: #fff; border-radius: 14px; box-shadow: 0 4px 12px rgba(139,92,246,0.08);
  font-family: inherit; font-size: 14px; color: var(--ink); text-align: left; }
.giver-bar b { color: var(--pink-dark); }
.giver-change { float: right; color: var(--muted); font-size: 12px; font-weight: 700; }
.member-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.member-chip { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 30px;
  border: 2px solid #f0e3ee; background: #fff; cursor: pointer; font-weight: 700; font-size: 14px;
  color: var(--ink); font-family: inherit; }
.member-chip.active { background: var(--pink); color: #fff; border-color: var(--pink); }
.member-chip .m-del { font-size: 12px; opacity: 0.8; }
.row-add { display: flex; gap: 8px; }
.row-add input { flex: 1; }
.row-add .btn-primary { flex: 0 0 auto; padding: 13px 18px; }

/* ===== Child photo ===== */
.name-row { display: flex; align-items: center; gap: 12px; }
.child-photo { width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
  border: 3px solid rgba(255,255,255,0.85); box-shadow: 0 4px 12px rgba(0,0,0,0.18); flex: 0 0 auto; }
.photo-row { display: flex; align-items: center; gap: 10px; }
.photo-row .btn-row { flex: 1; margin-bottom: 0; }
.photo-preview { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
  border: 2px solid #f0e3ee; }
.child-chip .chip-photo { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; vertical-align: middle; }

.tab-panel { display: none; animation: fade 0.25s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from{opacity:0; transform:translateY(6px)} to{opacity:1; transform:none} }

.section-title { font-size: 17px; margin: 6px 2px 12px; font-weight: 800; }
.section-title.minus { margin-top: 26px; color: var(--pink-dark); }
.hint { color: var(--muted); font-size: 13px; margin: 0 2px 14px; }

/* ===== Action buttons ===== */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action {
  position: relative;
  background: var(--card); border: none; border-radius: 18px; padding: 16px 12px;
  text-align: left; cursor: pointer; box-shadow: 0 6px 18px rgba(139,92,246,0.10);
  display: flex; flex-direction: column; gap: 6px; transition: transform 0.12s;
  border-left: 6px solid var(--green);
}
.action:active { transform: scale(0.95); }
.action.lose { border-left-color: var(--red); }
.action.used { opacity: 0.55; cursor: default; }
.action.used:active { transform: none; }
.action .emoji { font-size: 30px; }
.action .label { font-size: 14px; font-weight: 700; line-height: 1.2; }
.action .pts { font-size: 13px; font-weight: 800; }
.action .pts.plus { color: var(--green); }
.action .pts.minus { color: var(--red); }
.action .daily { font-size: 10px; font-weight: 700; color: var(--muted); opacity: 0.85; }
.action .done { font-size: 11px; font-weight: 700; color: var(--pink-dark); }
.action .a-del { position: absolute; top: 6px; right: 8px; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  color: var(--muted); background: rgba(107,18,72,0.07); border-radius: 50%; cursor: pointer; }

.row-emoji { display: flex; gap: 8px; }
.row-emoji #customEmoji { width: 60px; flex: 0 0 auto; text-align: center; }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600;
  color: var(--ink); margin-top: 12px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--pink); }

.custom-btn {
  width: 100%; margin-top: 16px; padding: 15px; border-radius: 16px; border: 2px dashed var(--purple);
  background: transparent; color: var(--purple); font-weight: 700; font-size: 15px; cursor: pointer;
}

/* ===== Rewards ===== */
.reward-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.reward {
  background: var(--card); border-radius: 18px; padding: 16px 12px; text-align: center;
  box-shadow: 0 6px 18px rgba(56,189,248,0.12); cursor: pointer; position: relative; transition: transform 0.12s;
}
.reward:active { transform: scale(0.95); }
.reward.locked { opacity: 0.55; }
.reward .r-emoji { font-size: 38px; }
.reward .r-name { font-weight: 700; font-size: 14px; margin: 6px 0 4px; }
.reward .r-cost { font-size: 13px; font-weight: 800; color: var(--blue); }
.reward .r-del { position: absolute; top: 6px; right: 8px; font-size: 14px; color: var(--muted);
  background: none; border: none; cursor: pointer; }

/* ===== History ===== */
.summary-row { display: flex; gap: 10px; margin-bottom: 16px; }
.summary-pill { flex: 1; background: #fff; border-radius: 16px; padding: 12px; text-align: center;
  box-shadow: 0 4px 14px rgba(139,92,246,0.08); }
.summary-pill .big { font-size: 22px; font-weight: 800; }
.summary-pill .lbl { font-size: 12px; color: var(--muted); }

.history-list { list-style: none; padding: 0; margin: 0; }
.history-item { background: #fff; border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 4px 12px rgba(139,92,246,0.07); }
.history-item .h-emoji { font-size: 24px; }
.history-item .h-text { flex: 1; }
.history-item .h-reason { font-weight: 700; font-size: 14px; }
.history-item .h-time { font-size: 12px; color: var(--muted); }
.history-item .h-pts { font-weight: 800; font-size: 16px; }
.history-item .h-pts.plus { color: var(--green); }
.history-item .h-pts.minus { color: var(--red); }
.history-item .h-del { margin-left: 4px; width: 24px; height: 24px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; border: none; cursor: pointer;
  font-size: 12px; font-weight: 700; color: var(--muted); background: rgba(107,18,72,0.07);
  border-radius: 50%; font-family: inherit; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(120px);
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 30px; font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25); opacity: 0; transition: 0.35s cubic-bezier(.3,1.3,.5,1);
  z-index: 50; font-size: 15px;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; background: rgba(59,39,64,0.45); display: flex;
  align-items: flex-end; justify-content: center; z-index: 60; padding: 12px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 26px; padding: 22px; width: 100%; max-width: 460px;
  animation: slideup 0.3s cubic-bezier(.3,1.2,.5,1); margin-bottom: env(safe-area-inset-bottom, 0); }
@keyframes slideup { from{transform:translateY(60px); opacity:0} to{transform:none; opacity:1} }
.modal-card h3 { margin: 0 0 16px; font-size: 19px; }
.modal-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.modal-card input[type=text], .modal-card input[type=number] {
  width: 100%; padding: 13px; border: 2px solid #f0e3ee; border-radius: 14px; font-size: 16px;
  font-family: inherit; }
.modal-card input:focus { outline: none; border-color: var(--purple); }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper input { text-align: center; }
.stepper button { width: 46px; height: 46px; border-radius: 14px; border: none; background: var(--bg);
  font-size: 24px; font-weight: 800; cursor: pointer; color: var(--purple); }

.seg { display: flex; gap: 8px; margin-top: 14px; }
.seg-btn { flex: 1; padding: 12px; border-radius: 14px; border: 2px solid #f0e3ee; background: #fff;
  font-weight: 700; cursor: pointer; color: var(--muted); }
.seg-btn.active { background: var(--purple); color: #fff; border-color: var(--purple); }

.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.btn-ghost { flex: 1; padding: 14px; border-radius: 14px; border: none; background: var(--bg);
  font-weight: 700; cursor: pointer; color: var(--ink); }
.btn-primary { flex: 2; padding: 14px; border-radius: 14px; border: none;
  background: var(--purple); color: #fff; font-weight: 800; cursor: pointer; }
.btn-row { width: 100%; padding: 15px; border-radius: 14px; border: none; background: var(--bg);
  font-weight: 700; cursor: pointer; text-align: left; margin-bottom: 10px; font-size: 15px; color: var(--ink); }
.btn-row.danger { color: var(--pink-dark); }
.version { text-align: center; font-size: 12px; color: var(--muted); margin: 16px 0 0; }

/* ===== Confetti ===== */
.confetti { position: fixed; top: -10px; width: 10px; height: 14px; z-index: 70; pointer-events: none; border-radius: 2px; }

/* ===== Splash loader ===== */
.splash { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(175deg, #ffe3f3, #f6d9ff); z-index: 90; }
.splash-star { font-size: 64px; animation: pop 1.1s ease-in-out infinite; }
@keyframes pop { 0%,100%{ transform: scale(0.8) rotate(-8deg) } 50%{ transform: scale(1.15) rotate(8deg) } }

/* ===== Auth screen ===== */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 22px; }
.auth-card { background: #fff; border-radius: 30px; padding: 30px 24px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(255,46,154,0.25); text-align: center; }
.auth-logo { font-size: 56px; filter: drop-shadow(0 6px 10px rgba(255,46,154,0.35)); animation: pop 2s ease-in-out infinite; }
.auth-title { font-size: 28px; margin: 6px 0 2px; color: var(--pink-dark); font-weight: 700; }
.auth-sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.auth-seg { margin-bottom: 18px; }
.auth input { width: 100%; padding: 14px; margin-bottom: 11px; border: 2px solid #f6dcee;
  border-radius: 15px; font-size: 16px; font-family: inherit; }
.auth input:focus { outline: none; border-color: var(--pink); }
.btn-primary.wide { width: 100%; margin-top: 6px; padding: 16px; font-size: 16px;
  background: linear-gradient(135deg, var(--pink), var(--purple)); }
.check.remember { display: block; margin: 2px 2px 10px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.check.remember input { width: 18px; height: 18px; vertical-align: -4px; margin-right: 8px; }
/* block layout so the checkbox + text wrap and stay inside the card on narrow phones */
.check.terms-check { display: block; margin: 6px 2px 12px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.check.terms-check input { width: 18px; height: 18px; vertical-align: -4px; margin-right: 8px; }
.check.terms-check a { color: var(--pink-dark); font-weight: 700; text-decoration: underline; cursor: pointer; }

/* ===== Founder note / Terms documents ===== */
.doc-text { max-height: 52vh; overflow-y: auto; font-size: 14px; line-height: 1.6; color: var(--ink); margin-top: 4px; }
.doc-text p { margin: 0 0 12px; }
.doc-text ol { padding-left: 20px; margin: 0 0 12px; }
.doc-text li { margin-bottom: 9px; }
.doc-text a { color: var(--pink-dark); font-weight: 700; }
.doc-sign { color: var(--pink-dark); }
.invite-code { font-size: 26px; font-weight: 800; text-align: center; letter-spacing: 2px;
  color: var(--pink-dark); margin: 6px 0 8px; }
.invite-link { font-size: 13px; color: var(--muted); text-align: center; word-break: break-all;
  background: var(--bg); padding: 10px; border-radius: 12px; margin-bottom: 4px; }
.invite-actions { margin-top: 18px; margin-bottom: 4px; }
.invite-close { margin-top: 16px; }
.auth-msg { min-height: 20px; font-size: 14px; font-weight: 600; margin: 14px 0 0; }
.install-btn { width: 100%; margin-top: 10px; padding: 14px; border-radius: 15px; border: 2px dashed var(--pink);
  background: #fff0f8; color: var(--pink-dark); font-weight: 700; font-size: 15px; cursor: pointer; font-family: inherit; }
.steps { margin: 6px 0 0; padding-left: 20px; color: var(--ink); font-size: 14px; line-height: 1.7; }
.steps li { margin-bottom: 4px; }
.install-os { margin-bottom: 14px; }
.ikon { font-size: 15px; }

/* ===== Child switcher ===== */
.child-bar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; margin: 0 0 4px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.child-bar::-webkit-scrollbar { display: none; }
.child-chip { flex: 0 0 auto; padding: 8px 14px; border: none; border-radius: 30px; cursor: pointer;
  background: rgba(255,255,255,0.25); color: #fff; font-weight: 600; font-size: 14px; font-family: inherit;
  white-space: nowrap; }
.child-chip.active { background: #fff; color: var(--pink-dark); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.child-chip.add { font-size: 18px; padding: 8px 13px; font-weight: 700; }

/* ===== Avatar picker ===== */
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatar-opt { font-size: 26px; padding: 8px 0; border-radius: 14px; border: 2px solid #f0e3ee;
  background: #fff; cursor: pointer; }
.avatar-opt.active { border-color: var(--pink); background: #fff0f8; transform: scale(1.05); }
