/* Child app. Calm paper colours, rounded type, big touch targets (>= 48 px), text >= 22 px. */
:root {
  --paper: #fbf6ec;
  --card: #fffdf8;
  --ink: #1f2f46;
  --muted: #56667c;
  --line: #e6dcc8;
  --teal: #2a8a75;
  --teal-deep: #1f6d5c;
  --teal-soft: #dcefe8;
  --sun: #f4b63c;
  --sun-deep: #d99a1e;
  --sky: #e3f0f7;
  --sky-line: #9fc6db;
  --right-bg: #e0f4e8;
  --right-line: #3d9e68;
  --soft-bg: #fff1d6;
  --soft-line: #e2a94f;
  --shadow: 0 2px 0 rgba(31, 47, 70, .06), 0 8px 24px rgba(31, 47, 70, .06);
  --radius: 22px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 500 24px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
main { max-width: 980px; margin: 0 auto; padding: 16px 24px 40px; }
[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  min-height: 56px;
  min-width: 56px;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .08s ease, background-color .15s ease, box-shadow .15s ease;
}
button:active:not(:disabled) { transform: translateY(2px) scale(.98); }
button:disabled { cursor: default; }
button:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; }

.primary {
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: 28px;
  padding: 12px 36px;
  min-height: 72px;
  box-shadow: 0 5px 0 var(--teal-deep);
}
.primary:active:not(:disabled) { box-shadow: 0 2px 0 var(--teal-deep); }
.primary:disabled { background: #b9cfc8; box-shadow: 0 5px 0 #a3bab3; }
.primary.huge { font-size: 34px; min-height: 104px; padding: 20px 48px; border-radius: 28px; margin-top: 16px; }
.primary.ready { background: var(--sun); color: var(--ink); box-shadow: 0 5px 0 var(--sun-deep); }
.secondary {
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  padding: 10px 28px;
  min-height: 64px;
  border: 3px solid var(--line);
}

/* ---------------------------------------------------------------- shared pieces */
.screen { display: flex; flex-direction: column; gap: 18px; animation: arrive .25s ease-out; }
.center { align-items: center; text-align: center; }
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 64px; }
.top-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-width: 0; }
.speak {
  flex: none;
  width: 64px;
  height: 64px;
  font-size: 30px;
  background: var(--sky);
  border: 3px solid var(--sky-line);
  border-radius: 50%;
}

.title { font-size: 44px; line-height: 1.15; margin: 0; font-weight: 800; letter-spacing: -.01em; }
.lead { font-size: 26px; margin: 0; color: var(--ink); max-width: 30ch; }
.soft-note { font-size: 22px; color: var(--muted); margin: 0; min-height: 1.4em; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }

.chip {
  display: inline-flex;
  align-items: center;
  font-size: 22px;
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 999px;
  min-height: 44px;
}
.chip-warm { background: #ffe7c2; color: #7a4a06; }
.chip-recall { background: #e4e1f7; color: #3e3680; }
.chip-practice { background: var(--teal-soft); color: var(--teal-deep); }
.chip-check { background: var(--sky); color: #23577a; }
.chip-teach { background: #ffe7c2; color: #7a4a06; }
.skill-title { font-size: 24px; font-weight: 700; color: var(--muted); }

.mascot { width: 120px; height: 120px; overflow: visible; }
.mascot.big { width: 150px; height: 150px; }
.mascot-star { fill: var(--sun); stroke: var(--sun-deep); stroke-width: 3; stroke-linejoin: round; }
.mascot-eye { fill: var(--ink); }
.mascot-smile { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; }
.mascot.bob { animation: bob 1.2s ease-in-out infinite; }
.mascot.sleepy .mascot-eye { transform: scaleY(.25); transform-box: fill-box; transform-origin: center; }
@keyframes bob { 50% { transform: translateY(-10px); } }

/* ---------------------------------------------------------------- login and home */
.login, .home, .rest, .loading { padding-top: 6vh; }
.done { gap: 12px; }
.done .mascot.big { width: 96px; height: 96px; }
.loading { min-height: 60vh; justify-content: center; }
.login-form { display: flex; flex-direction: column; gap: 16px; width: min(440px, 100%); }
.password {
  font: inherit;
  font-size: 28px;
  min-height: 72px;
  padding: 12px 20px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}
.password:focus { outline: none; border-color: var(--teal); }
.home .top, .done .top, .rest .top { margin-bottom: -40px; justify-content: flex-end; }
.streak { display: inline-flex; align-items: center; gap: 10px; margin: 0; font-size: 28px; font-weight: 700;
  background: var(--card); padding: 10px 24px; border-radius: 999px; box-shadow: var(--shadow); }
.streak-star { color: var(--sun); font-size: 32px; }

/* ---------------------------------------------------------------- teach */
.teach-card { display: flex; flex-direction: column; gap: 20px; }
.teach-text { margin: 0; font-size: 28px; line-height: 1.5; white-space: pre-line; max-width: 40ch; }
.vis-slot:empty { display: none; }
.dots { display: flex; justify-content: center; gap: 10px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.dot.is-on { background: var(--teal); }
.nav { display: flex; justify-content: space-between; gap: 16px; }
.nav .primary { min-width: 200px; }

/* ---------------------------------------------------------------- question */
.progress { display: inline-flex; gap: 8px; align-items: center; }
.pdot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.pdot.is-done { background: var(--teal); }
.pdot.is-now { background: var(--sun); box-shadow: 0 0 0 4px #fde6b5; }

.q-body { display: flex; flex-direction: column; gap: 20px; }
.q-main, .q-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.q-side { align-items: center; }
.prompt { margin: 0; font-size: 30px; line-height: 1.45; font-weight: 600; }

.answer-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.answer-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 240px;
  max-width: 100%;
  min-height: 84px;
  padding: 8px 22px;
  font-size: 40px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.answer-box.is-active { border-color: var(--teal); box-shadow: 0 0 0 5px var(--teal-soft); }
.caret { display: none; width: 3px; height: 44px; margin-left: 3px; background: var(--teal); border-radius: 2px; animation: blink 1.1s steps(1) infinite; }
.answer-box.is-active .caret { display: inline-block; }
@keyframes blink { 50% { opacity: 0; } }
.unit { font-size: 32px; font-weight: 700; color: var(--muted); }
.compound { gap: 24px; }
.compound-part { display: flex; align-items: center; gap: 12px; }
.compound .answer-box { min-width: 160px; }

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: min(420px, 100%);
}
.key {
  min-height: 76px;
  font-size: 36px;
  font-weight: 700;
  background: var(--card);
  border: 3px solid var(--line);
  box-shadow: 0 4px 0 var(--line);
}
.key:active:not(:disabled) { background: var(--teal-soft); box-shadow: 0 1px 0 var(--line); }
.key-back { color: var(--muted); }
.pad.is-locked { opacity: .5; pointer-events: none; }
.check { width: min(420px, 100%); }

.choices { display: flex; flex-direction: column; gap: 14px; }
.choice {
  text-align: left;
  font-size: 28px;
  font-weight: 600;
  padding: 14px 24px;
  min-height: 76px;
  background: var(--card);
  border: 3px solid var(--line);
  box-shadow: 0 4px 0 var(--line);
}
.choice.is-picked { border-color: var(--teal); background: var(--teal-soft); box-shadow: 0 4px 0 var(--teal); }
.choices.is-locked { pointer-events: none; }
.choices.is-locked .choice:not(.is-picked) { opacity: .55; }

.feedback {
  width: 100%;
  border-radius: var(--radius);
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  border: 3px solid;
  animation: arrive .25s ease-out;
}
.feedback p { margin: 0; }
.feedback.is-right { background: var(--right-bg); border-color: var(--right-line); }
.feedback.is-soft { background: var(--soft-bg); border-color: var(--soft-line); }
.fb-big { font-size: 34px; font-weight: 800; }
.feedback.is-right .fb-big { color: #1f6b43; }
.feedback.is-soft .fb-big { color: #7a4a06; }
.fb-line { font-size: 26px; font-weight: 600; }
.fb-answer { font-weight: 800; }
.fb-hint { font-size: 24px; color: var(--ink); background: rgba(255, 255, 255, .6); padding: 12px 16px; border-radius: 14px; }
.feedback .primary { align-self: stretch; margin-top: 6px; }

/* Landscape iPad: pad beside the question, so nothing scrolls. */
@media (orientation: landscape) and (min-width: 900px) {
  .question:not(.no-pad) .q-body { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 32px; align-items: start; }
  .question:not(.no-pad) .pad { width: 100%; }
  .question:not(.no-pad) .check { width: 100%; }
  .key { min-height: 70px; }
}

/* ---------------------------------------------------------------- visuals */
.vis { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.vis-caption { margin: 0; font-size: 22px; color: var(--muted); min-height: 1.4em; text-align: center; }

.pvc-grid {
  display: grid;
  grid-template-columns: var(--cols);
  border: 3px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  background: var(--card);
  max-width: 640px;
  width: 100%;
  align-self: center;
}
.pvc-head {
  background: var(--sky);
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  padding: 8px 2px;
  border-right: 2px solid var(--sky-line);
  border-bottom: 3px solid var(--ink);
}
.pvc-cell {
  min-height: 76px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 800;
  border-radius: 0;
  border-right: 2px solid var(--line);
  background: transparent;
  padding: 0;
}
.pvc-grid .is-last { border-right: 0; }
.pvc-dot { border-right: 2px solid var(--line); }
.pvc-slot { background: repeating-linear-gradient(135deg, transparent 0 10px, #f4eedf 10px 20px); }
.pvc-slot.is-right, .pvc-tap.is-picked { background: var(--right-bg); color: #1f6b43; }
.pvc-slot.is-nudge { animation: nudge .35s ease; }
@keyframes nudge { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.pvc-tray { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; }
.tile {
  width: 76px;
  height: 76px;
  font-size: 40px;
  font-weight: 800;
  background: var(--sun);
  box-shadow: 0 5px 0 var(--sun-deep);
}
.tile.is-selected { transform: translateY(-6px); box-shadow: 0 0 0 5px var(--ink), 0 9px 0 var(--sun-deep); }
.tile.is-used { visibility: hidden; }

.bar { gap: 10px; max-width: 720px; width: 100%; align-self: center; }
.bar-whole {
  position: relative;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  padding-bottom: 14px;
  border-bottom: 4px solid var(--ink);
  margin: 0 4px;
}
.bar-whole::before, .bar-whole::after { content: ""; position: absolute; bottom: -4px; width: 4px; height: 18px; background: var(--ink); }
.bar-whole::before { left: 0; } .bar-whole::after { right: 0; }
.bar-whole.is-unknown .bar-whole-label { background: var(--soft-bg); padding: 2px 14px; border-radius: 10px; }
.bar-row { display: flex; gap: 6px; }
.bar-seg {
  flex-basis: 0;
  min-width: 0;
  min-height: 92px;
  border-radius: 14px;
  background: var(--teal-soft);
  border: 3px solid var(--teal);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  text-align: center;
  line-height: 1.2;
}
.bar-seg:nth-child(2n) { background: #fde9c4; border-color: var(--sun-deep); }
.bar-seg.is-unknown { background: var(--card); border: 3px dashed var(--muted); }
.bar-seg-label { font-size: 22px; color: var(--muted); font-weight: 600; }
.bar-seg-value { font-size: 26px; font-weight: 800; white-space: nowrap; }
.bar-seg.is-unknown .bar-seg-value { font-size: 40px; color: var(--muted); }

.ladder-row { display: flex; align-items: flex-start; justify-content: center; gap: 4px; padding-bottom: 8px; }
.rung, .rung-op { margin-top: calc(var(--step) * 30px); }
.rung {
  min-width: 84px;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 16px;
  padding: 0 10px;
}
.rung.is-lit { background: var(--sun); border-color: var(--sun-deep); }
.rung-op {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 82px;
  padding-top: 18px;
  font-size: 22px;
  color: var(--muted);
  line-height: 1.1;
}
.rung-op .rung-arrow { font-size: 26px; }
.rung-op.is-lit { color: var(--ink); font-weight: 800; }
.rung-op.is-lit .rung-factor { background: var(--soft-bg); border-radius: 10px; padding: 2px 8px; }

.coin-tray { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 18px 22px; }
.money-group { display: flex; align-items: center; gap: 8px; }
.money { display: flex; align-items: center; justify-content: center; font-weight: 800; }
.money-note {
  width: 132px;
  height: 66px;
  border-radius: 10px;
  background: #cfe8d4;
  border: 3px solid #5e9c6d;
  box-shadow: inset 0 0 0 5px #e5f3e8;
  font-size: 24px;
}
.money-note-20 { background: #f6dcc4; border-color: #c08350; box-shadow: inset 0 0 0 5px #fbebdc; }
.money-note-50 { background: #d6ebf3; border-color: #5c9ab6; box-shadow: inset 0 0 0 5px #e9f4f8; }
.money-note-100 { background: #e3dcf3; border-color: #8574b8; box-shadow: inset 0 0 0 5px #f0ecf9; }
.money-note-200 { background: #fbe3b5; border-color: #c9952f; box-shadow: inset 0 0 0 5px #fdf0d6; }
.money-note-500 { background: #dfe2d6; border-color: #7e8669; box-shadow: inset 0 0 0 5px #eef0e8; }
.money-coin, .money-paise {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f3f0e6, #c9c3b3);
  border: 3px solid #9c9583;
  font-size: 22px;
}
.money-paise { width: 78px; height: 78px; font-size: 22px; background: radial-gradient(circle at 35% 30%, #fbe7c2, #d9b276); border-color: #a8834a; }
.money-count { font-size: 26px; font-weight: 800; }

/* ---------------------------------------------------------------- done */
.star-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 640px; }
.star { color: var(--sun); font-size: 48px; line-height: 1; animation: pop .4s ease-out both; text-shadow: 0 3px 0 var(--sun-deep); }
.star-more { font-size: 30px; font-weight: 800; align-self: center; }
@keyframes pop { from { transform: scale(0); } 70% { transform: scale(1.2); } to { transform: scale(1); } }
.mastered { text-align: left; width: min(560px, 100%); }
.mastered-head { margin: 0 0 6px; font-weight: 800; }
.mastered ul { margin: 0; padding-left: 28px; }
.see-you { font-size: 34px; font-weight: 800; color: var(--teal-deep); margin: 0; }

/* ---------------------------------------------------------------- demo page */
.demo .card { display: flex; flex-direction: column; gap: 12px; }
.demo-name { margin: 0; font-weight: 800; color: var(--muted); }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 700px) {
  main { padding: 12px 16px 32px; }
  .title { font-size: 36px; }
  .rung { min-width: 64px; font-size: 26px; }
  .rung-op { min-width: 64px; }
  .money-note { width: 108px; height: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
