/* Layout: one-screen phone app in a 480px column — task card on top, thumb-sized keypad at the bottom */
:root {
  --bg: #E6F2EF;
  --surface: #FFFFFF;
  --ink: #1B2A36;
  --muted: #5A6C77;
  --line: #C9DDD8;
  --sea: #17807A;
  --sea-soft: #D3ECE8;
  --on-sea: #FFFFFF;
  --coral: #EC5A39;
  --coral-soft: #FDE3DB;
  --on-coral: #FFFFFF;
  --sun: #FFB81C;
  --sun-soft: #FFF0C7;
  --good: #23955A;
  --good-soft: #DDF3E5;
  --f-display: "Baloo 2", "Arial Rounded MT Bold", system-ui, sans-serif;
  --f-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1C22; --surface: #162C35; --ink: #E8F3F1; --muted: #98B0B5; --line: #2A4852;
    --sea: #46BDB3; --sea-soft: #173C41; --on-sea: #06201E;
    --coral: #FF7E61; --coral-soft: #45261F; --on-coral: #2A0D06;
    --sun: #FFC94A; --sun-soft: #3D3214; --good: #4CC983; --good-soft: #173A29;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1C22; --surface: #162C35; --ink: #E8F3F1; --muted: #98B0B5; --line: #2A4852;
  --sea: #46BDB3; --sea-soft: #173C41; --on-sea: #06201E;
  --coral: #FF7E61; --coral-soft: #45261F; --on-coral: #2A0D06;
  --sun: #FFC94A; --sun-soft: #3D3214; --good: #4CC983; --good-soft: #173A29;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; line-height: 1.1; text-wrap: balance; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.app {
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
}
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; }
.home, .done, .parent { overflow-y: auto; padding-bottom: 8px; }

/* ---------- shared pieces ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-star { width: 36px; height: 36px; }
.brand h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.01em; }

.pill-btn {
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  background: var(--surface); border: 2px solid var(--line);
  font-weight: 800; font-size: 16px;
}
.pill-btn.primary { background: var(--sea); border-color: var(--sea); color: var(--on-sea); }
.pill-btn.danger { color: var(--coral); border-color: var(--coral-soft); }
.pill-btn.wide { width: 100%; }
.pill-btn:active { transform: translateY(1px); }

.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line);
  font-size: 20px; font-weight: 800; line-height: 1;
}
.icon-btn.off { opacity: .45; }

.big-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 100%; padding: 16px 20px; border-radius: 22px;
  background: var(--coral); color: var(--on-coral);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--coral) 60%, var(--ink));
  font-family: var(--f-display); font-weight: 800; font-size: 26px; line-height: 1.1;
}
.big-btn small { font-family: var(--f-body); font-weight: 700; font-size: 14px; opacity: .9; }
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 color-mix(in srgb, var(--coral) 60%, var(--ink)); }

.block { display: flex; flex-direction: column; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.mascot { width: 72px; height: 72px; flex: none; }
.mascot.sm { width: 40px; height: 40px; }
.mascot.lg { width: 110px; height: 110px; animation: bob 2.4s ease-in-out infinite; }

/* ---------- home ---------- */
.greet { display: flex; align-items: center; gap: 10px; }
.greet .mascot { animation: bob 2.4s ease-in-out infinite; }
.bubble {
  position: relative; flex: 1; min-width: 0;
  background: var(--surface); border-radius: 18px; padding: 12px 14px;
  font-weight: 700;
}
.bubble::before {
  content: ""; position: absolute; left: -8px; top: 50%; margin-top: -8px;
  border: 8px solid transparent; border-right-color: var(--surface); border-left: 0;
}

.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.chip {
  aspect-ratio: 1; max-width: 100%; border-radius: 16px;
  background: var(--surface); border: 2px solid var(--line);
  font-family: var(--f-display); font-weight: 800; font-size: 24px;
  display: grid; place-items: center; position: relative;
}
.chip .meter {
  position: absolute; left: 8px; right: 8px; bottom: 7px; height: 4px; border-radius: 2px;
  background: var(--line); overflow: hidden;
}
.chip .meter i { display: block; height: 100%; background: var(--sun); }

.sky { background: var(--surface); border-radius: 22px; padding: 14px; }
.sky-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sky-count { color: var(--muted); font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.grid10 { display: grid; grid-template-columns: repeat(11, 1fr); gap: 2px; }
.grid10 .hd {
  display: grid; place-items: center; font-family: var(--f-display); font-weight: 700;
  color: var(--muted); font-size: 13px; aspect-ratio: 1;
}
.grid10 .cell {
  aspect-ratio: 1; display: grid; place-items: center; position: relative;
  font-size: clamp(15px, 5vw, 24px); line-height: 1; border-radius: 6px;
}
.grid10 .cell.sel { background: var(--sun-soft); }
.lv0 { color: var(--line); }
.lv1 { color: color-mix(in srgb, var(--sun) 35%, var(--line)); }
.lv2 { color: color-mix(in srgb, var(--sun) 55%, var(--line)); }
.lv3 { color: color-mix(in srgb, var(--sun) 75%, var(--line)); }
.lv4 { color: var(--sun); }
.lv5 { color: var(--sun); text-shadow: 0 0 8px color-mix(in srgb, var(--sun) 70%, transparent); }
.cell.due::after {
  content: ""; position: absolute; right: 2px; top: 2px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--coral);
}
.sky-note { color: var(--muted); font-size: 14px; min-height: 2.9em; }
.sky-note b { color: var(--ink); }

/* ---------- play ---------- */
.dots { flex: 1; display: flex; gap: 4px; }
.dots i { flex: 1; height: 10px; border-radius: 5px; background: var(--line); }
.dots i.cur { background: var(--sea); }
.dots i.ok { background: var(--good); }
.dots i.help { background: var(--sun); }

.card {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--surface); border-radius: 26px; padding: 18px 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  border: 3px solid transparent;
  transition: border-color .2s, background-color .2s;
}
.card.right { border-color: var(--good); background: var(--good-soft); }
.card.shake { animation: shake .4s; }
.tag {
  align-self: center; padding: 3px 12px; border-radius: 999px;
  background: var(--sun-soft); color: var(--ink); font-weight: 800; font-size: 13px;
  text-transform: uppercase; letter-spacing: .06em;
}
.prompt {
  font-family: var(--f-display); font-weight: 800;
  font-size: clamp(44px, 14vw, 68px); line-height: 1;
  font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap;
}
.prompt.text { font-size: 20px; font-weight: 700; white-space: normal; line-height: 1.3; }
.prompt .op { color: var(--sea); margin: 0 .12em; }
.slot {
  display: inline-block; min-width: 1.5em; padding: 0 .1em;
  border-bottom: 5px dashed var(--sea); color: var(--sea); text-align: center;
}
.slot.empty { color: var(--line); }
.slot.filled { border-bottom-style: solid; }

.helper {
  display: flex; gap: 10px; align-items: flex-start; width: 100%;
  background: var(--sea-soft); border-radius: 18px; padding: 12px;
}
.helper.good { background: transparent; justify-content: center; align-items: center; }
.helper-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; font-weight: 700; }
.helper.good .helper-body { flex: none; font-size: 22px; font-family: var(--f-display); color: var(--good); }
.array-wrap { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.array { display: grid; gap: 3px; }
.array i { width: var(--d); height: var(--d); border-radius: 50%; background: var(--sea); }
.array i.alt { background: var(--coral); }
.array-cap { font-size: 14px; color: var(--muted); }

.group-area { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.pile {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  min-height: 34px; padding: 8px; border-radius: 16px; background: var(--coral-soft);
}
.pile.empty { background: transparent; }
.apple {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, color-mix(in srgb, var(--coral) 55%, #fff), var(--coral) 60%);
  position: relative; flex: none;
}
.apple::after {
  content: ""; position: absolute; top: -4px; left: 13px; width: 8px; height: 6px;
  background: var(--good); border-radius: 0 8px 0 8px;
}
.baskets { display: grid; grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); gap: 8px; }
.basket {
  min-height: 92px; padding: 8px 6px 22px; position: relative;
  border: 3px dashed var(--sea); border-top-width: 0; border-radius: 0 0 22px 22px;
  background: var(--sea-soft);
  display: flex; flex-wrap: wrap; align-content: flex-end; justify-content: center; gap: 4px;
}
.basket .apple { width: 20px; height: 20px; }
.basket .apple::after { left: 10px; width: 6px; height: 5px; }
.basket .count {
  position: absolute; bottom: 2px; left: 0; right: 0; text-align: center;
  font-family: var(--f-display); font-weight: 800; font-size: 15px; color: var(--sea);
}
.baskets.uneven .basket { border-color: var(--coral); }

.controls { display: flex; flex-direction: column; gap: 10px; }
.control-row { display: flex; gap: 8px; justify-content: space-between; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  min-height: 58px; border-radius: 16px;
  background: var(--surface); box-shadow: 0 4px 0 var(--line);
  font-family: var(--f-display); font-weight: 800; font-size: 30px; line-height: 1;
}
.keypad button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.keypad .k-del { color: var(--muted); font-size: 26px; }
.keypad .k-ok { background: var(--sea); color: var(--on-sea); box-shadow: 0 4px 0 color-mix(in srgb, var(--sea) 60%, var(--ink)); }
.keypad.locked { opacity: .5; pointer-events: none; }

/* ---------- done ---------- */
.done-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 12px; text-align: center; }
.done-title { font-size: 34px; font-weight: 800; }
.done-score { font-weight: 700; color: var(--muted); }
.done-score b { color: var(--ink); font-size: 20px; }
.fact-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fact {
  padding: 6px 12px; border-radius: 12px; background: var(--surface);
  font-family: var(--f-display); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums;
}
.fact.good { background: var(--good-soft); }
.fact.again { background: var(--sun-soft); }

/* ---------- parent ---------- */
.parent-title { font-size: 24px; }
.parent-summary { background: var(--surface); padding: 14px; border-radius: 16px; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.tables { display: flex; flex-direction: column; gap: 8px; }
.trow { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: center; }
.trow b { font-family: var(--f-display); font-size: 18px; text-align: right; }
.tcells { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.tcells i { height: 11px; border-radius: 3px; }
.st-new { background: var(--line); }
.st-learning { background: color-mix(in srgb, var(--sun) 45%, var(--line)); }
.st-practice { background: var(--sun); }
.st-mastered { background: var(--good); }
.st-review { background: var(--coral); }
.weak-list, .session-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.weak-list li, .session-list li {
  background: var(--surface); padding: 10px 12px; border-radius: 12px;
  display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums;
}
.weak-list li span:last-child, .session-list li span:last-child { color: var(--muted); font-size: 14px; text-align: right; }
.confirm { background: var(--coral-soft); padding: 12px; border-radius: 14px; display: flex; flex-direction: column; gap: 10px; font-weight: 700; }

@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-5px) rotate(3deg); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 50% { transform: translateX(7px); } 75% { transform: translateX(-4px); } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.pop { animation: pop .35s ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-height: 640px) {
  .keypad button { min-height: 50px; font-size: 26px; }
  .card { padding: 12px; gap: 10px; }
}
