:root {
  --bg: #f4f1ff;
  --card: #ffffff;
  --ink: #2b2550;
  --muted: #6b6690;
  --line: #e4defa;
  --brand: #5b4bdb;
  --brand-dark: #4636c4;
  --brand-soft: #ebe7ff;
  --good: #23a26d;
  --good-soft: #e1f7ec;
  --oops: #e2843a;
  --oops-soft: #fff1e4;
  --sun: #ffc93c;
  --radius: 20px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 18px/1.5 'Nunito', system-ui, sans-serif;
  min-height: 100vh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 18px; min-height: 48px; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; font-weight: 900; }
h1 { font-size: clamp(30px, 6vw, 42px); }
h2 { font-size: 28px; }
h3 { font-size: 21px; margin-top: 22px; }
p { margin: 8px 0; }
main { max-width: 860px; margin: 0 auto; padding: 8px 16px 60px; outline: none; }
.small { font-size: 14px; color: var(--muted); }
.eyebrow { display: block; font-size: 12px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--brand); }
.error { color: #b8401d; font-weight: 700; }
.center { text-align: center; }

/* ---------- Header ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(244, 241, 255, .92); backdrop-filter: blur(8px); }
.brand { border: 0; background: none; white-space: nowrap; font-weight: 900; font-size: 22px; color: var(--brand); padding: 6px 4px; }
.pills { display: flex; align-items: center; gap: 6px; }
.pill { background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: 16px; white-space: nowrap; }
.icon-btn { position: relative; width: 46px; height: 46px; padding: 0; border-radius: 50%; font-size: 20px; }
.sync-dot { position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: transparent; }
.sync-dot.synced { background: var(--good); }
.sync-dot.syncing { background: var(--sun); }
.sync-dot.error { background: var(--oops); }

/* ---------- Shared pieces ---------- */
.panel { background: var(--card); border-radius: 26px; padding: 24px; margin: 12px auto; max-width: 720px; box-shadow: 0 4px 0 var(--line); }
.panel.wide { max-width: 860px; }
.back { border: 0; background: none; padding: 6px 0; min-height: 40px; color: var(--muted); font-weight: 700; }
.primary { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 800; box-shadow: 0 4px 0 var(--brand-dark); }
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--brand-dark); }
.big-btn { font-size: 20px; padding: 14px 26px; min-height: 58px; border-radius: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 4px; }
.center-actions { justify-content: center; }
.danger { color: #b8401d; }
.link { border: 0; background: none; padding: 4px; min-height: 0; text-decoration: underline; font-size: 14px; }
.meter { height: 22px; background: var(--brand-soft); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; min-width: 22px; border-radius: 999px; background: linear-gradient(90deg, #8f7bff, var(--brand)); transition: width .6s ease; }
.meter.mini { height: 12px; max-width: 360px; margin: 12px auto 4px; }
.meter.mini span { min-width: 12px; }
.speak { border: 0; background: var(--brand-soft); border-radius: 50%; width: 40px; height: 40px; min-height: 40px; padding: 0; font-size: 18px; vertical-align: middle; }
.banner { background: #fff7d6; border: 2px solid #ffe58a; border-radius: 16px; padding: 10px 14px; margin: 10px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-weight: 700; }
.banner button { background: var(--sun); border-color: var(--sun); font-weight: 800; min-height: 42px; padding: 8px 16px; }
.banner.subtle { background: var(--card); border-color: var(--line); font-weight: 600; font-size: 14px; color: var(--muted); }

/* ---------- Home ---------- */
.home h1 { margin: 10px 0 14px; }
.week-card { background: var(--card); border-radius: 24px; padding: 18px 20px; box-shadow: 0 4px 0 var(--line); }
.week-top, .week-bottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.week-top { margin-bottom: 12px; }
.week-top strong { font-size: 20px; }
.ready-label { font-weight: 900; color: var(--brand); }
.week-bottom { margin-top: 10px; font-size: 16px; }
.goal { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-weight: 700; }
.goal i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); display: inline-block; }
.goal i.on { background: var(--sun); border-color: #f0b400; }

.next-quest { width: 100%; margin: 18px 0 6px; display: flex; align-items: center; gap: 16px; text-align: left; padding: 18px 22px; border: 0; border-radius: 24px; color: #fff; background: linear-gradient(120deg, #6a5af9, #a35cf5); box-shadow: 0 6px 0 #4636c4; animation: breathe 3s ease-in-out infinite; }
.next-quest:active { transform: translateY(3px); box-shadow: 0 3px 0 #4636c4; }
.next-quest small { display: block; font-size: 15px; opacity: .9; font-weight: 700; }
.next-quest strong { font-size: 26px; }
.nq-icon { font-size: 44px; }
.nq-arrow { margin-left: auto; font-size: 28px; }
@keyframes breathe { 50% { transform: scale(1.015); } }

.section-title { font-size: 20px; margin: 22px 0 10px; color: var(--muted); }
.game-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.game-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 16px; border-radius: 22px; border: 0; box-shadow: 0 4px 0 rgba(0,0,0,.08); min-height: 150px; }
.game-tile:active { transform: translateY(2px); }
.tile-icon { font-size: 34px; }
.game-tile strong { font-size: 19px; }
.game-tile .small { color: inherit; opacity: .75; }
.mins { margin-top: auto; font-size: 13px; font-weight: 800; opacity: .6; }
.game-tile.meaning { background: #ffe3e3; }
.game-tile.detective { background: #dff1ff; }
.game-tile.gap { background: #e2f7e7; }
.game-tile.memory { background: #fff1d1; }
.game-tile.lightning { background: #f0e4ff; }
.game-tile.test { background: #e6e9f2; }

.extras { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.extra { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 16px; border-radius: 22px; border: 2px solid var(--line); text-align: left; }
.extra > span:first-child { font-size: 30px; }

/* ---------- Play screens ---------- */
.play { padding-top: 14px; }
.play-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-name { font-weight: 900; color: var(--brand); }
.combo { min-width: 90px; text-align: right; font-weight: 900; color: var(--oops); }
.combo.hot { animation: pop .4s ease; }
.progress, .timer { height: 14px; background: var(--brand-soft); border-radius: 999px; overflow: hidden; margin: 12px 0 18px; }
.progress span, .timer span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s ease; }
.timer span { background: var(--good); transition: width .1s linear; }
.timer span.low { background: var(--oops); }
.retry-tag { display: inline-block; background: var(--oops-soft); color: #9c4f12; font-weight: 800; padding: 4px 12px; border-radius: 999px; font-size: 14px; }
.prompt { font-size: 24px; font-weight: 700; margin: 6px 0 18px; line-height: 1.45; }
.the-word { font-size: 34px; color: var(--brand); font-weight: 900; }
.clue-label { display: block; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.clue { font-size: 24px; }
.sentence { display: block; font-size: 24px; background: #f7f5ff; border-radius: 16px; padding: 16px; }
.blank { display: inline-block; min-width: 110px; border-bottom: 4px solid var(--brand); color: transparent; }
.choices { display: grid; gap: 12px; }
.choices.big { grid-template-columns: 1fr 1fr; }
.choice { display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px; font-size: 19px; font-weight: 700; border-radius: 18px; border-width: 3px; min-height: 66px; transition: transform .1s, background .2s, border-color .2s; }
.choices.big .choice { font-size: 22px; justify-content: flex-start; }
.choice:not(:disabled):active { transform: scale(.98); }
.letter { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-weight: 900; font-size: 16px; }
.choice.correct { background: var(--good-soft); border-color: var(--good); }
.choice.correct .letter { background: var(--good); color: #fff; }
.choice.wrong { background: var(--oops-soft); border-color: var(--oops); }
.choice.gone { opacity: .25; }
.choice:disabled:not(.correct):not(.wrong):not(.gone) { opacity: .6; }
.shake { animation: shake .4s ease; }
#feedback { margin-top: 16px; }
#feedback .good { font-size: 26px; font-weight: 900; color: var(--good); margin: 0 0 10px; animation: pop .35s ease; }
#feedback .soft { font-size: 20px; font-weight: 800; color: #9c4f12; margin: 0; }
#feedback .explain { background: var(--oops-soft); border-radius: 14px; padding: 12px 16px; font-size: 19px; }
#feedback button { margin-top: 8px; width: 100%; }
.helper { margin-top: 18px; background: none; border-style: dashed; font-weight: 700; color: var(--muted); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }

/* Memory */
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.mcard { position: relative; min-height: 120px; padding: 10px; border-radius: 16px; border: 3px solid var(--line); font-weight: 700; font-size: 15px; line-height: 1.3; }
.mcard .mface { display: none; }
.mcard .mback { font-size: 40px; font-weight: 900; color: #fff; }
.mcard:not(.open):not(.matched) { background: linear-gradient(135deg, #8f7bff, var(--brand)); border-color: var(--brand); }
.mcard.open, .mcard.matched { animation: flip .25s ease; }
.mcard.open .mback, .mcard.matched .mback { display: none; }
.mcard.open .mface, .mcard.matched .mface { display: block; }
.mcard.word .mface { font-size: 20px; font-weight: 900; color: var(--brand); }
.mcard.matched { background: var(--good-soft); border-color: var(--good); }
@keyframes flip { from { transform: rotateY(90deg); } to { transform: rotateY(0); } }

/* Results & hatching */
.results .big-emoji, .born { font-size: 80px; animation: pop .5s ease; }
.born { font-size: 120px; }
.stars-earned { font-size: 32px; font-weight: 900; color: #c98a00; }
.review { text-align: left; background: #f7f5ff; border-radius: 18px; padding: 14px 18px; margin-top: 16px; }
.review-item { padding: 8px 0; border-top: 1px solid var(--line); }
.review-item:first-of-type { border-top: 0; }
.egg { font-size: 120px; border: 0; background: none; padding: 10px 30px; }
.egg.wobble { animation: wobble .5s ease; }
@keyframes wobble { 25% { transform: rotate(-14deg); } 50% { transform: rotate(12deg); } 75% { transform: rotate(-6deg); } }
.critter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 18px; }
.critter { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; background: #f7f5ff; border-radius: 16px; text-align: center; }
.critter span { font-size: 44px; }
.critter small { font-weight: 800; font-size: 13px; }
.critter.locked { opacity: .45; }

/* Floating +1 and confetti */
.float-text { position: absolute; z-index: 50; transform: translate(-50%, 0); font-weight: 900; font-size: 24px; color: #c98a00; pointer-events: none; animation: float-up 1.1s ease forwards; }
@keyframes float-up { to { transform: translate(-50%, -70px); opacity: 0; } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { top: 105%; transform: rotate(720deg); } }

/* ---------- Grown-up & setup ---------- */
label { display: block; font-weight: 800; margin: 16px 0 6px; }
input, textarea { width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: #fcfbff; font-size: 17px; }
textarea { resize: vertical; line-height: 1.5; }
.inline { display: flex; gap: 10px; }
.inline input { flex: 1; }
.week-list { list-style: none; padding: 0; margin: 0; }
.week-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border: 2px solid var(--line); border-radius: 16px; margin-bottom: 8px; }
.week-list li.current { border-color: var(--brand); background: var(--brand-soft); }
.week-list li > div:first-child { display: flex; flex-direction: column; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { min-height: 40px; padding: 6px 12px; font-size: 15px; }
.loading { font-weight: 700; color: var(--brand); }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.word-card { border: 2px solid var(--line); border-radius: 18px; padding: 14px 16px; margin: 14px 0; }
.word-card header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.word-card h3 { margin: 0; }
.card-links { margin-left: auto; display: flex; gap: 6px; }
.word-card fieldset { border: 0; padding: 0; margin: 8px 0 0; }
.option { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; margin: 6px 0; padding: 10px; border-radius: 12px; background: #f7f5ff; cursor: pointer; }
.option input { width: auto; margin-top: 5px; }
.option em { color: var(--muted); font-size: 14px; }
.note { background: #fff7d6; padding: 8px 12px; border-radius: 10px; }
.syll { color: var(--muted); font-weight: 700; letter-spacing: .5px; }
.pos { font-size: 13px; font-weight: 800; color: var(--brand); background: var(--brand-soft); padding: 2px 10px; border-radius: 999px; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--card) 30%); padding: 18px 0 10px; margin-bottom: 0; }

/* Notebook */
.notebook-list { padding: 0; margin: 16px 0 0; list-style: none; counter-reset: nb; }
.nb-item { counter-increment: nb; border: 2px solid var(--line); border-radius: 18px; padding: 14px 16px; margin-bottom: 12px; }
.nb-item.done { border-color: var(--good); background: #f6fdf9; }
.nb-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nb-head h3 { margin: 0; }
.nb-head h3::before { content: counter(nb) ". "; color: var(--muted); }
.def { font-size: 20px; font-weight: 700; margin: 8px 0 4px; }
.example { color: var(--muted); font-style: italic; }
.wrote { margin-top: 8px; font-weight: 800; }
.nb-item.done .wrote { background: var(--good-soft); border-color: var(--good); }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .game-grid { grid-template-columns: 1fr 1fr; }
  .memory-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
  body { font-size: 17px; }
  .panel { padding: 18px 16px; border-radius: 22px; }
  .brand { font-size: 19px; }
  .pill { padding: 5px 9px; font-size: 14px; }
  .icon-btn { width: 40px; height: 40px; }
  .choices.big { grid-template-columns: 1fr; }
  .memory-grid { grid-template-columns: repeat(2, 1fr); }
  .prompt, .clue, .sentence { font-size: 21px; }
  .next-quest strong { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Printing the notebook ---------- */
@media print {
  body { background: #fff; }
  .topbar, .back, .no-print, .speak, .wrote { display: none !important; }
  .panel { box-shadow: none; padding: 0; }
  .nb-item { break-inside: avoid; }
}

/* ---------- Subject hub ---------- */
.daily { margin: -4px 0 14px; }
.subjects { display: grid; gap: 14px; }
.subject { display: flex; align-items: center; gap: 18px; text-align: left; padding: 20px; border: 0; border-radius: 26px; box-shadow: 0 5px 0 rgba(0,0,0,.1); }
.subject:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.1); }
.subject.words { background: linear-gradient(120deg, #ffe3e3, #fff1d1); }
.subject.math { background: linear-gradient(120deg, #dff1ff, #e2f7e7); }
.subject-icon { font-size: 54px; }
.subject-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.subject-body strong { font-size: 26px; font-weight: 900; }
.subject-body .meter { height: 14px; background: rgba(255,255,255,.8); margin: 4px 0; }
.subject-body .meter span { min-width: 14px; }

/* ---------- Times tables ---------- */
.table-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip-btn { min-width: 58px; min-height: 48px; padding: 6px 10px; font-weight: 900; font-size: 18px; }
.chip-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.trick { background: #fff7d6; border: 2px solid #ffe58a; border-radius: 16px; padding: 12px 16px; margin: 12px 0; font-weight: 700; }
.trick-label { display: block; font-size: 12px; font-weight: 900; letter-spacing: 1.5px; text-transform: uppercase; color: #a07400; }
.big-trick { font-size: 20px; }
.math-grid .m-learn { background: #fff1d1; }
.math-grid .m-skip { background: #e2f7e7; }
.math-grid .m-dots { background: #ffe3e3; }
.math-grid .m-power { background: #f0e4ff; }
.math-grid .m-clock { background: #dff1ff; }
.math-grid .m-chart { background: #e6e9f2; }
.fact { font-weight: 900; color: var(--brand); font-size: 30px; white-space: nowrap; }
.fact.big { font-size: 46px; }
.answer-line { font-size: 24px; text-align: center; }
.answer-line strong { color: var(--good); font-size: 30px; }
.slow-down { background: #e1f7ec; border-radius: 14px; padding: 10px 14px; font-weight: 800; color: #17704b; }

.dots { display: flex; flex-direction: column; align-items: center; gap: 5px; margin: 14px auto; padding: 12px; background: #fcfbff; border-radius: 16px; width: fit-content; max-width: 100%; }
.dot-row { display: flex; gap: 5px; }
.dot-row i { width: 18px; height: 18px; border-radius: 50%; display: block; }
.dots.small .dot-row i { width: 13px; height: 13px; }
.dots.small, .dots.small .dot-row { gap: 3px; }
.band-label { align-self: flex-start; font-size: 14px; font-weight: 900; margin-top: 4px; }
.band-label.b0 { color: #5b4bdb; }
.band-label.b1 { color: #e0622f; }
.band-label.b2 { color: #1b8a5c; }
.band-label.b3 { color: #c03f93; }
.band-label.crossed { color: #d33; }
.dot-row.b0 i { background: #7b6cf6; }
.dot-row.b1 i { background: #ff8a5c; }
.dot-row.b2 i { background: #23a26d; }
.dot-row.b3 i { background: #e05bb0; }
.dot-row.crossed { position: relative; opacity: .45; }
.dot-row.crossed i { background: #aaa; }
.dot-row.crossed::after { content: ''; position: absolute; left: -4px; right: -4px; top: 50%; border-top: 3px solid #d33; }

.steps { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.steps li { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); font-size: 22px; font-weight: 800; opacity: .5; }
.steps li.now { opacity: 1; border-color: var(--brand); background: var(--brand-soft); }
.steps li.done, .steps.shown li { opacity: 1; border-color: var(--good); background: var(--good-soft); }
.steps .a { color: var(--brand); }
.steps li.done .a { color: var(--good); }
.hint { min-height: 26px; font-weight: 800; color: #9c4f12; text-align: center; }

.pad-display { display: flex; align-items: center; justify-content: center; min-height: 64px; margin: 10px auto; max-width: 320px; border: 3px solid var(--brand); border-radius: 16px; font-size: 38px; font-weight: 900; background: #fff; }
.pad-display.good { border-color: var(--good); background: var(--good-soft); }
.pad-display.bad { border-color: var(--oops); background: var(--oops-soft); }
.caret { width: 3px; height: 36px; margin-left: 3px; background: var(--brand); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 0 auto; }
.pad button { min-height: 64px; font-size: 28px; font-weight: 900; border-radius: 16px; border-width: 3px; }
.pad button:active { transform: scale(.95); background: var(--brand-soft); }
.pad .pad-go { background: var(--good); border-color: var(--good); color: #fff; }
.pad .pad-back { color: var(--muted); }
#pad.off, #workpad.off { opacity: .5; pointer-events: none; }

.climb { position: relative; max-width: 360px; margin: 0 auto; }
.ladder { list-style: none; margin: 10px 0; padding: 0 0 0 48px; display: flex; flex-direction: column; gap: 4px; }
.ladder li { display: flex; justify-content: space-between; padding: 6px 14px; border-radius: 12px; background: #f7f5ff; border: 2px solid var(--line); font-weight: 800; }
.ladder li span { color: var(--muted); font-size: 15px; }
.ladder li.done { background: var(--good-soft); border-color: var(--good); }
.ladder li.done b { color: var(--good); }
.ladder li.now { border-color: var(--brand); background: var(--brand-soft); animation: pop .35s ease; }
.climber { display: none; }

.fact-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 6px 12px; background: var(--brand-soft); border-radius: 999px; font-weight: 800; }

.legend { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; font-size: 14px; font-weight: 800; }
.legend span { padding: 4px 10px; border-radius: 8px; }
.chart-wrap { overflow-x: auto; }
.fact-chart { border-collapse: separate; border-spacing: 3px; margin: 0 auto; }
.fact-chart th { font-size: 14px; color: var(--muted); min-width: 30px; }
.fact-chart td button { width: 100%; min-width: 36px; min-height: 36px; padding: 2px; border-radius: 8px; border: 0; font-size: 13px; font-weight: 800; }
.l0 { background: #eeecf5; color: #9a96b0; }
.l1 { background: #ffe1c7; }
.l2 { background: #c9f0d3; }
.l3 { background: #23a26d; color: #fff; }
.fact-chart button.focus { outline: 2px solid var(--brand); }

.settings-row { display: flex; flex-wrap: wrap; gap: 12px; }
.settings-row label { margin: 6px 0; font-size: 15px; }
select { display: block; margin-top: 6px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fcfbff; font: inherit; font-size: 17px; min-height: 48px; }

@media (max-width: 480px) {
  .subject-icon { font-size: 40px; }
  .subject-body strong { font-size: 22px; }
  .fact.big { font-size: 38px; }
  .pad button { min-height: 58px; }
}

/* Side by side on tablets and laptops so the number pad stays on screen */
@media (min-width: 700px) {
  .panel.play:has(.work) { max-width: 860px; }
  .work { display: grid; grid-template-columns: 1fr 330px; gap: 20px; align-items: start; }
  .work .steps li { font-size: 19px; padding: 8px 12px; }
  .work .pad button { min-height: 56px; }
}

/* Times-table picker */
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.pick-tile { display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: center; padding: 16px 12px; border-radius: 22px; background: linear-gradient(160deg, #dff1ff, #e2f7e7); border: 0; box-shadow: 0 4px 0 rgba(0,0,0,.08); }
.pick-tile:active { transform: translateY(2px); }
.pick-tile strong { font-size: 34px; font-weight: 900; color: var(--brand); }
.pick-tile .meter { height: 10px; background: rgba(255,255,255,.85); }
.pick-tile .meter span { min-width: 10px; }

/* ---------- Critter Camp & shop ---------- */
.camp-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.camp-top h2 { margin: 0; }
.wallet { background: #fff7d6; border: 2px solid #ffe58a; border-radius: 999px; padding: 6px 14px; font-weight: 900; color: #8a6400; }
.shop-btn { width: 100%; margin: 14px 0 8px; }
button.critter { border: 2px solid transparent; min-height: 0; }
button.critter.bff { border-color: #ff8fb1; }
.critter .hearts { font-size: 10px; letter-spacing: -1px; }
.shiny > span:first-child, .critter-big.shiny, .born.shiny { filter: sepia(1) saturate(4) hue-rotate(-12deg) brightness(1.1) drop-shadow(0 0 8px #ffd700); }
.critter.shiny { background: linear-gradient(160deg, #fff7d6, #ffeaa0); }
.critter-big { font-size: 120px; line-height: 1.1; cursor: pointer; user-select: none; }
.critter-big.wiggle { animation: wiggle .6s ease; }
@keyframes wiggle { 20% { transform: rotate(-12deg) scale(1.1); } 40% { transform: rotate(10deg) scale(1.15); } 60% { transform: rotate(-6deg) translateY(-14px); } 100% { transform: none; } }
.hearts-big { font-size: 24px; }
.feed-msg { min-height: 28px; font-size: 20px; font-weight: 900; color: #d14a7a; }
.food-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.food { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 90px; padding: 10px 6px; border-radius: 18px; }
.food span { font-size: 36px; }
.food b { font-size: 14px; color: var(--brand); }
.food:disabled { opacity: .4; }
.shop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.food-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.shop-item { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 16px 12px; border: 2px solid var(--line); border-radius: 20px; background: #fcfbff; }
.shop-item.rare { background: #f3ecff; border-color: #d8c8ff; }
.shop-item.golden { background: #fff7d6; border-color: #ffe58a; }
.shop-icon { font-size: 48px; }
.shop-item .buy { margin-top: auto; width: 100%; font-size: 16px; }
.buy:disabled { background: #e6e3f2; border-color: #e6e3f2; color: var(--muted); box-shadow: none; }
.egg.rare, .egg.golden { filter: drop-shadow(0 0 12px #ffd700); }
.egg-nudge { display: block; width: 100%; margin-top: 16px; background: #fff7d6; border-color: #ffe58a; font-weight: 800; animation: breathe 3s ease-in-out infinite; }
@media (max-width: 600px) { .shop-grid { grid-template-columns: 1fr; } }

/* ---------- Reading ---------- */
.subject.reading { background: linear-gradient(120deg, #f0e4ff, #ffe3e3); }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.skill-card { display: flex; flex-direction: column; gap: 4px; padding: 12px; background: var(--card); border-radius: 18px; box-shadow: 0 3px 0 var(--line); }
.skill-icon { font-size: 26px; }
.skill-card strong { font-size: 15px; }
.skill-card .meter { height: 10px; }
.skill-card .meter span { min-width: 10px; }
.library { display: grid; gap: 10px; }
.book { display: flex; align-items: center; gap: 14px; text-align: left; padding: 12px 16px; border-radius: 18px; }
.book-icon { font-size: 30px; }
.book-body { flex: 1; display: flex; flex-direction: column; }
.book .nq-arrow { font-size: 18px; color: var(--muted); }
.kind-toggle { display: inline-flex; gap: 6px; background: var(--brand-soft); padding: 5px; border-radius: 16px; margin: 6px 0 16px; }
.kind-toggle button { border: 0; background: transparent; font-weight: 800; }
.kind-toggle button.on { background: var(--card); box-shadow: 0 2px 0 var(--line); color: var(--brand); }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.topic { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 8px; border-radius: 20px; }
.topic span { font-size: 38px; }
.writing { animation: wiggle 1.4s ease-in-out infinite; }

.reader h2 { margin-top: 6px; }
.dots-row { display: flex; gap: 6px; margin: 6px 0 14px; }
.dots-row span { flex: 1; height: 8px; border-radius: 8px; background: var(--brand-soft); }
.dots-row span.done { background: #b9aefc; }
.dots-row span.now { background: var(--brand); }
.story-part p, .story-all p { font-size: 22px; line-height: 1.75; margin: 0 0 16px; }
.story-part { background: #fffdf6; border: 2px solid #f3e9c6; border-radius: 20px; padding: 20px 22px; }
.story-all p { font-size: 19px; }
.speak-all { border-style: dashed; font-weight: 700; color: var(--muted); }
.vocab-word { border: 0; padding: 0 3px; min-height: 0; border-radius: 6px; background: #fff1b8; font: inherit; font-weight: 800; color: #6b4d00; border-bottom: 2px dotted #c99a00; }
.vocab-pop { min-height: 24px; font-size: 16px; color: #6b4d00; }
.reader-actions { justify-content: space-between; }
.reader-actions .primary { margin-left: auto; }

.skill-badge { display: inline-block; font-size: 14px; font-weight: 900; color: var(--brand); background: var(--brand-soft); padding: 4px 12px; border-radius: 999px; margin-bottom: 8px; }
.lookback { border: 2px solid var(--line); border-radius: 16px; margin-bottom: 14px; background: #fffdf6; }
.lookback summary { cursor: pointer; padding: 12px 16px; font-weight: 800; }
.lookback .story-all { max-height: 46vh; overflow-y: auto; padding: 0 16px 6px; }
.lookback .story-all p { font-size: 17px; line-height: 1.6; }
mark { background: #ffe066; padding: 1px 2px; border-radius: 4px; }
.reading-q .choice { font-size: 18px; }
.why { background: var(--good-soft) !important; }
@media (min-width: 900px) {
  .panel.reading-q { max-width: 1100px; }
  .q-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
  .lookback .story-all { max-height: 62vh; }
}
.class-passage { margin-top: 14px; border: 2px solid var(--line); border-radius: 16px; padding: 10px 14px; }
.class-passage summary { cursor: pointer; }
