:root {
  --bg: #fffdf5;
  --ink: #2b2140;
  --muted: #7a7091;
  --yellow: #ffd23f;
  --yellow-deep: #f5b700;
  --purple: #8e4fd6;
  --purple-deep: #6a2fb5;
  --green: #7bd23c;
  --green-deep: #4fa81a;
  --pink: #ff6f91;
  --blue: #2f8cf0;
  --red: #e0182d;
  --card: #ffffff;
  --line: #ece6f5;
  --radius: 24px;
  --shadow: 0 6px 0 rgba(43, 33, 64, 0.08), 0 14px 30px rgba(43, 33, 64, 0.08);
  font-family: "Baloo 2", "Andika", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

.view { min-height: 100%; padding: 16px max(16px, env(safe-area-inset-left)) 40px; max-width: 980px; margin: 0 auto; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 8px; }
.brand { font-weight: 800; font-size: 30px; letter-spacing: -0.5px; color: var(--purple-deep); }
.brand.small { font-size: 22px; }
.logo-bee { display: inline-block; animation: bob 2.4s ease-in-out infinite; }
.ghost { padding: 10px 16px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); font-weight: 600; color: var(--purple-deep); }

@keyframes bob { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-5px) rotate(6deg); } }

/* ---------- hero ---------- */
.hero { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; }
.mascot { width: min(46%, 380px); height: auto; mix-blend-mode: multiply; }
.hero-text h1 { font-size: clamp(30px, 6vw, 52px); margin: 0; line-height: 1.05; }
.hero-text p { margin: 6px 0 10px; font-size: 20px; color: var(--muted); }
.dots { display: flex; gap: 8px; }
.dots span { width: 26px; height: 26px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 14px; }
.dots span.on { background: var(--yellow); box-shadow: inset 0 -3px 0 var(--yellow-deep); }

@media (max-width: 560px) {
  .hero { flex-direction: column; text-align: center; }
  .mascot { width: 80%; }
  .dots { justify-content: center; }
}

/* ---------- big buttons ---------- */
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.big {
  display: grid; justify-items: center; gap: 2px;
  padding: 22px 12px 18px; border-radius: 32px; color: #fff;
  box-shadow: 0 8px 0 rgba(0,0,0,0.15); transition: transform .12s;
}
.big:active { transform: translateY(4px); box-shadow: 0 4px 0 rgba(0,0,0,0.15); }
.big .emoji { font-size: 54px; line-height: 1; }
.big .label { font-size: 34px; font-weight: 800; line-height: 1.1; }
.big .sub { font-size: 16px; opacity: .9; }
.big.read { background: linear-gradient(180deg, #a56bf0, var(--purple-deep)); }
.big.write { background: linear-gradient(180deg, #95e05a, var(--green-deep)); }

/* ---------- path ---------- */
.section-title { margin: 28px 0 10px; font-size: 24px; }
.path { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.path li {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  border: 3px solid transparent; position: relative;
}
.path li.current { border-color: var(--yellow); }
.path li.done { opacity: .75; }
.path li.locked { opacity: .5; }
.path .step { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.path .name { font-size: 21px; font-weight: 800; margin: 2px 0; }
.path .age { font-size: 14px; color: var(--purple); font-weight: 600; }
.path .bar { height: 8px; border-radius: 99px; background: var(--line); margin-top: 10px; overflow: hidden; }
.path .bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.path .badge { position: absolute; top: 10px; right: 12px; font-size: 20px; }

/* ---------- flash player ---------- */
.player {
  position: fixed; inset: 0; max-width: none; padding: 0; background: #fff;
  display: grid; grid-template-rows: 1fr auto; z-index: 10;
}
.player.contrast { background: #fff; }
.close { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 16px; z-index: 2; width: 48px; height: 48px; border-radius: 50%; background: #f3eff9; font-size: 22px; color: var(--muted); }
.card { display: grid; place-items: center; align-content: center; padding: 6vh 4vw; text-align: center; cursor: pointer; overflow: hidden; }
.card-text {
  font-family: "Andika", system-ui, sans-serif; font-weight: 700; line-height: 1.05;
  white-space: nowrap; color: var(--red);
}
.card-text.wrap { white-space: normal; max-width: 92vw; }
.card-text.enter { animation: pop .25s ease-out; }
.card-pic { font-size: min(34vh, 40vw); line-height: 1; margin-top: 2vh; min-height: 1em; }
.card-pic.enter { animation: pop .35s ease-out; }
.card .msg { font-family: "Baloo 2", sans-serif; color: var(--purple-deep); font-size: clamp(36px, 8vw, 80px); font-weight: 800; }
.card .msg small { display: block; font-size: .4em; color: var(--muted); font-weight: 600; }
.card .celebrate-img { width: min(70vw, 520px); mix-blend-mode: multiply; animation: pop .5s ease-out; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.player-bar { padding: 0 24px max(18px, env(safe-area-inset-bottom)); }
.progress { height: 10px; background: #f3eff9; border-radius: 99px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--yellow); transition: width .3s; }

.confetti { position: fixed; top: -20px; font-size: 28px; pointer-events: none; animation: fall linear forwards; z-index: 20; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* ---------- writing pad ---------- */
.writer { position: fixed; inset: 0; max-width: none; padding: 0; display: grid; grid-template-rows: auto 1fr auto; background: #f6f2e8; }
.write-top, .write-bottom { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
.write-top { padding-top: max(10px, env(safe-area-inset-top)); }
.write-bottom { justify-content: center; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.write-top select { padding: 10px 14px; border-radius: 999px; border: 0; background: #fff; box-shadow: var(--shadow); font-weight: 600; }
.pen-status { margin-left: auto; font-weight: 700; font-size: 15px; color: var(--muted); background: #fff; padding: 8px 14px; border-radius: 999px; }
.pen-status.ok { color: var(--green-deep); }
.paper-wrap {
  position: relative; margin: 0 14px; border-radius: 28px; background: #fff; box-shadow: var(--shadow); overflow: hidden;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.paper-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.tool { padding: 12px 18px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); font-weight: 700; font-size: 18px; }
.tool.primary { background: var(--yellow); box-shadow: 0 5px 0 var(--yellow-deep); }
.colors { display: flex; gap: 8px; }
.colors button { width: 40px; height: 40px; border-radius: 50%; border: 4px solid #fff; box-shadow: var(--shadow); }
.colors button.on { outline: 3px solid var(--ink); }
.stars {
  position: absolute; inset: 0; display: grid; place-items: center; align-content: center; background: rgba(255,255,255,.75);
  font-size: 80px; text-align: center; animation: pop .3s ease-out;
}
.stars .lbl { font-size: 34px; font-weight: 800; color: var(--purple-deep); }
.palm-toast {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; white-space: nowrap; pointer-events: none;
}

/* ---------- parent ---------- */
.panel { background: #fff; border-radius: var(--radius); padding: 16px 18px; margin: 14px 0; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 10px; font-size: 22px; }
.row { display: flex; align-items: center; gap: 12px; padding: 8px 0; font-weight: 600; flex-wrap: wrap; }
.row input[type=text], .row select { flex: 1; min-width: 160px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; -webkit-user-select: text; user-select: text; }
.row input[type=range] { flex: 1; accent-color: var(--purple); }
.row output { min-width: 48px; text-align: right; color: var(--purple-deep); }
.toggle input { width: 24px; height: 24px; accent-color: var(--purple); }
.hint { color: var(--muted); font-size: 15px; margin: 4px 0 0; font-family: system-ui, sans-serif; }
.tips ul { margin: 0; padding-left: 20px; font-family: system-ui, sans-serif; line-height: 1.55; }
.stage-progress { font-family: system-ui, sans-serif; font-size: 15px; color: var(--muted); }
.stage-progress .words { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.stage-progress .words span { background: #fff1f2; color: var(--red); font-family: "Andika", sans-serif; font-weight: 700; padding: 3px 10px; border-radius: 10px; }
.danger { padding: 12px 18px; border-radius: 14px; background: #ffe8ec; color: #b3122a; font-weight: 700; }

/* ---------- accounts & children ---------- */
.top-right { display: flex; gap: 8px; align-items: center; }
#child-switch { border: 0; max-width: 46vw; }
.pill { padding: 10px 18px; border-radius: 999px; background: var(--purple); color: #fff; font-weight: 700; }
.pill.light { background: #f3eff9; color: var(--purple-deep); }
.pill:disabled { opacity: .5; }
.kids { list-style: none; padding: 0; margin: 0 0 4px; display: grid; gap: 8px; }
.kids li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; border: 2px solid var(--line); }
.kids li.on { border-color: var(--yellow); background: #fffbea; }
.kids .kid-main { flex: 1; text-align: left; display: grid; }
.kids .kid-name { font-weight: 800; font-size: 19px; }
.kids .kid-sub { font-size: 14px; color: var(--muted); font-family: system-ui, sans-serif; }
.kids .del { width: 36px; height: 36px; border-radius: 50%; color: var(--muted); font-size: 18px; }
.acct-form { display: grid; gap: 10px; max-width: 420px; }
.acct-form input { padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; -webkit-user-select: text; user-select: text; font-family: system-ui, sans-serif; }
.acct-tabs { display: flex; gap: 6px; margin-bottom: 4px; }
.acct-tabs button { padding: 8px 14px; border-radius: 999px; font-weight: 700; color: var(--muted); }
.acct-tabs button.on { background: #f3eff9; color: var(--purple-deep); }
.acct-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.acct-msg { font-family: system-ui, sans-serif; font-size: 15px; margin: 4px 0 0; color: var(--muted); }
.acct-msg.err { color: #b3122a; }
.acct-msg.ok { color: var(--green-deep); }
.linkish { color: var(--purple-deep); text-decoration: underline; font-size: 15px; font-family: system-ui, sans-serif; padding: 0; }
.sync { font-size: 14px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #eefbe3; color: var(--green-deep); font-family: system-ui, sans-serif; }
.sync.busy { background: #fff6d6; color: #8a6400; }
.sync.off { background: #ffe8ec; color: #b3122a; }
