/* Learn Habibi — bright, friendly, accessible. No external fonts or frameworks. */
:root {
  --bg: #f3f7ff; --ink: #1b2236; --muted: #4a5470; --card: #ffffff; --line: #d9e1f2;
  --brand: #5b3df5; --brand-ink: #ffffff; --brand-soft: #ece8ff;
  --ok: #0f8a4b; --ok-soft: #dcf7e8; --bad: #c62828; --bad-soft: #ffe3e3; --warn: #8a5a00; --warn-soft: #fff1cc;
  --c-challenge: #ff7a1a; --c-exam: #2f7cf6; --c-tips: #12a36b; --c-games: #8b5cf6; --c-parents: #e83e8c;
  --radius: 18px; --shadow: 0 6px 20px rgba(30, 40, 90, .10);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 18px; line-height: 1.5; }
img, svg { max-width: 100%; }
a { color: #3a2bd1; }
a:hover { color: #23179c; }
:focus-visible { outline: 4px solid #ffb703; outline-offset: 2px; border-radius: 8px; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: 10px 16px; z-index: 100; }
.skip:focus { left: 10px; top: 10px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { line-height: 1.2; margin: .4em 0 .4em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.8rem); }
h3 { font-size: 1.2rem; }
small, .small { font-size: .8em; color: var(--muted); }

/* ---------- header ---------- */
.site-header { background: linear-gradient(100deg, #5b3df5, #7b5cff 45%, #ff5fa2); color: #fff; padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 20; }
.brand { color: #fff; text-decoration: none; font-weight: 900; font-size: 1.35rem; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand:hover { color: #fff; }
.brand .logo { font-size: 1.7rem; background: #fff; border-radius: 12px; width: 44px; height: 44px; display: grid; place-items: center; }
.site-nav { flex: 1 1 auto; order: 3; width: 100%; }
.site-nav ul { list-style: none; display: flex; gap: 6px; margin: 0; padding: 2px 0; overflow-x: auto; scrollbar-width: none; }
.site-nav ul::-webkit-scrollbar { display: none; }
.site-nav a { display: flex; align-items: center; gap: 6px; color: #fff; text-decoration: none; font-weight: 800; padding: 8px 14px; border-radius: 999px; min-height: 44px; white-space: nowrap; background: rgba(255, 255, 255, .14); }
.site-nav a:hover { background: rgba(255, 255, 255, .28); color: #fff; }
.site-nav a[aria-current="page"] { background: #fff; color: #3a2bd1; }
.acct-link { margin-left: auto; color: #fff; text-decoration: none; font-weight: 800; padding: 8px 14px; border-radius: 999px; min-height: 44px; display: flex; align-items: center; gap: 6px; border: 2px solid rgba(255,255,255,.7); white-space: nowrap; }
.acct-link:hover, .acct-link[aria-current="page"] { background: #fff; color: #3a2bd1; }
.who-chip { display: flex; align-items: center; gap: 8px; background: #fff; color: var(--ink); border: 0; border-radius: 999px; padding: 4px 14px 4px 6px; min-height: 48px; cursor: pointer; font: inherit; box-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.who-avatar { font-size: 1.6rem; background: var(--brand-soft); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.who-text { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.who-text b { font-size: .95rem; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text small { font-size: .75rem; }
@media (min-width: 1000px) { .site-nav { order: 0; width: auto; } .site-nav ul { justify-content: center; } }

main { max-width: 1120px; margin: 0 auto; padding: 18px 16px 60px; }
.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 40px; border-top: 1px solid var(--line); }

/* ---------- generic ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border: 1px solid var(--line); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.stack > * + * { margin-top: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 800; border: 0; border-radius: 14px; padding: 12px 20px; min-height: 52px; cursor: pointer; background: #e7ebf5; color: var(--ink); text-decoration: none; box-shadow: 0 3px 0 rgba(0, 0, 0, .15); transition: transform .06s; }
.btn:hover { filter: brightness(.97); color: var(--ink); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .15); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { color: #fff; }
.btn-go { background: #13a35f; color: #fff; min-width: 120px; font-size: 1.1rem; }
.btn-go:hover { color: #fff; }
.btn-small { min-height: 40px; padding: 6px 14px; font-size: .9rem; }
.btn-ghost { background: transparent; box-shadow: none; border: 2px solid var(--line); }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.icon-btn { font: inherit; font-size: 1.2rem; border: 0; background: #eef1f8; border-radius: 12px; width: 44px; height: 44px; cursor: pointer; }
.tag { display: inline-block; font-size: .75rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: #eef1fb; color: #33406a; margin: 0 4px 4px 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: #fff; border: 2px solid var(--line); font-weight: 800; font-size: .9rem; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 46em; }
.note { background: var(--warn-soft); color: #5a3d00; border-radius: 14px; padding: 12px 16px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- home ---------- */
.hero { display: grid; gap: 18px; align-items: center; grid-template-columns: 1fr; background: linear-gradient(135deg, #fff6d6, #ffe3f1 50%, #e3f0ff); border-radius: 28px; padding: 24px; box-shadow: var(--shadow); }
.hero h1 { margin-top: 0; }
.hero-art { font-size: 64px; text-align: center; line-height: 1.1; }
@media (min-width: 800px) { .hero { grid-template-columns: 1.6fr 1fr; padding: 34px; } .hero-art { font-size: 90px; } }
.section-cards { margin-top: 22px; }
.section-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); border-top: 8px solid var(--c, var(--brand)); min-height: 170px; transition: transform .1s; }
.section-card:hover { transform: translateY(-3px); color: var(--ink); }
.section-card .icon { font-size: 2.6rem; }
.section-card h2 { font-size: 1.35rem; margin: 0; }
.section-card p { margin: 0; color: var(--muted); }
.year-picker { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); margin: 10px 0; }
.year-picker.compact { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.year-btn { font: inherit; border: 3px solid transparent; border-radius: 16px; padding: 10px 8px; min-height: 64px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .12); color: var(--ink); }
.year-btn b { font-size: 1.05rem; }
.year-btn .age { font-size: .82rem; font-weight: 700; color: #3c4664; }
.year-btn .us { font-size: .68rem; color: var(--muted); }
.year-btn[aria-checked="true"] { border-color: var(--ink); background: #fff8d6; }
.y0 { border-bottom: 6px solid #ff6b6b !important; } .y1 { border-bottom: 6px solid #ff9f1c !important; } .y2 { border-bottom: 6px solid #f7c600 !important; }
.y3 { border-bottom: 6px solid #2ec4b6 !important; } .y4 { border-bottom: 6px solid #3a86ff !important; } .y5 { border-bottom: 6px solid #8338ec !important; } .y6 { border-bottom: 6px solid #d63384 !important; }
.year-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: thin; }
.year-tabs .year-btn { min-width: 104px; flex: 0 0 auto; }

/* ---------- player picker ---------- */
.modal { border: 0; border-radius: 24px; padding: 20px; width: min(560px, 94vw); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.modal::backdrop { background: rgba(20, 20, 50, .55); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.player-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 10px 0; }
.player-btn { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px; border-radius: 16px; border: 3px solid var(--line); background: #fff; cursor: pointer; min-height: 110px; }
.player-btn.on { border-color: var(--brand); background: var(--brand-soft); }
.big-emoji { font-size: 2.4rem; }
.add-player summary { cursor: pointer; font-weight: 800; padding: 10px 0; min-height: 44px; }
.profile-form { display: grid; gap: 10px; }
.profile-form label { display: grid; gap: 4px; font-weight: 800; }
.profile-form input[type=text] { font: inherit; padding: 12px; border-radius: 12px; border: 2px solid var(--line); min-height: 52px; }
.field-label { font-weight: 800; }
.avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.avatar-opt { font-size: 1.6rem; border: 3px solid transparent; background: #f2f4fa; border-radius: 12px; min-height: 48px; cursor: pointer; }
.avatar-opt[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); }
@media (max-width: 480px) { .avatar-grid { grid-template-columns: repeat(6, 1fr); } }

/* ---------- questions ---------- */
.q-card { background: #fff; border-radius: var(--radius); border: 2px solid var(--line); padding: 16px 18px; box-shadow: var(--shadow); }
.q-card.correct { border-color: #36c27a; background: #f4fff8; }
.q-card.wrong { border-color: #ff8a8a; }
.q-card.revealed { border-color: #f0b400; }
.q-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.q-num { font-weight: 900; background: var(--ink); color: #fff; border-radius: 10px; padding: 2px 10px; }
.q-text { font-size: 1.3rem; font-weight: 700; margin: 6px 0 10px; }
.q-visual { margin: 6px 0 12px; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.viz { display: block; }
.emoji-count { font-size: 2.2rem; line-height: 1.2; }
.emoji-row { display: flex; gap: 6px; }
.feedback { margin-top: 10px; padding: 10px 14px; border-radius: 12px; font-weight: 700; }
.feedback.ok { background: var(--ok-soft); color: #075c31; }
.feedback.bad { background: var(--bad-soft); color: #8e1414; }
.feedback.info { background: var(--warn-soft); color: #5a3d00; }
.explain { background: #f5f7ff; border-left: 6px solid var(--brand); padding: 10px 14px; border-radius: 10px; margin-top: 10px; font-weight: 500; }
.hint { background: #fffbe6; border-left: 6px solid #f0b400; padding: 10px 14px; border-radius: 10px; margin-top: 10px; }
.q-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1; font-weight: 800; margin: 0 2px; }
.frac sup, .frac sub { font-size: .8em; vertical-align: baseline; position: static; padding: 0 3px; }
.frac sup { border-bottom: 2px solid currentColor; padding-bottom: 2px; }
.frac sub { padding-top: 2px; }
.frac .fbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* answer box & keypad */
.answer-box { max-width: 460px; }
.answer-row { display: flex; gap: 8px; }
.answer-input { font: inherit; font-size: 1.6rem; font-weight: 800; padding: 8px 14px; border: 3px solid #b8c3e0; border-radius: 14px; width: 100%; min-width: 0; min-height: 60px; text-align: center; background: #fff; color: var(--ink); }
.answer-input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 4px #ffd166; }
.keypad-toggle { margin-top: 8px; }
.keypad { display: none; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; max-width: 340px; }
.keypad.open { display: grid; }
.key { font: inherit; font-size: 1.5rem; font-weight: 800; min-height: 58px; border-radius: 14px; border: 0; background: #fff; box-shadow: 0 3px 0 #b8c3e0, inset 0 0 0 2px #dde4f5; cursor: pointer; color: var(--ink); touch-action: manipulation; }
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 #b8c3e0, inset 0 0 0 2px #dde4f5; }
.key-extra { background: #eef3ff; }
.key-del { background: #ffeaea; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; max-width: 640px; }
.choice { font: inherit; font-size: 1.4rem; font-weight: 800; min-height: 64px; border-radius: 16px; border: 3px solid #c9d3ee; background: #fff; cursor: pointer; padding: 8px 12px; color: var(--ink); touch-action: manipulation; }
.choice:hover { border-color: var(--brand); }
.choice.right { background: var(--ok-soft); border-color: #13a35f; }
.choice.wrong { background: var(--bad-soft); border-color: #e04848; }
.choice:disabled { cursor: default; }

/* score bar */
.scorebar { position: sticky; top: 118px; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: #fff; border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow); margin: 10px 0 16px; }
@media (min-width: 1000px) { .scorebar { top: 74px; } }
.progress { flex: 1 1 160px; height: 16px; background: #e8ecf7; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #13a35f, #7bd88f); width: 0; transition: width .3s; }
.score-big { font-size: 1.3rem; font-weight: 900; }

/* ---------- exams ---------- */
.exam-year { margin-top: 26px; scroll-margin-top: 90px; }
.tips-grid { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.exam-year .grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.exam-year h2 { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.exam-card { display: flex; flex-direction: column; gap: 8px; border-top: 8px solid var(--c-exam); }
.exam-card h3 { margin: 0; }
.exam-card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.exam-card .actions .break { flex-basis: 100%; height: 0; }
.exam-card .actions .btn-small { padding-left: 10px; padding-right: 10px; }
.exam-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 900; font-size: 1.3rem; padding: 4px 12px; border-radius: 12px; background: #eef3ff; }
.timer.low { background: var(--bad-soft); color: var(--bad); }
.qnav { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.qnav button { font: inherit; font-weight: 800; width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer; }
.qnav button.answered { background: #dbe8ff; border-color: #7aa7ff; }
.qnav button.current { border-color: var(--ink); box-shadow: 0 0 0 3px #ffd166; }
.qnav button.flagged::after { content: '🚩'; font-size: .6rem; position: relative; top: -14px; left: 2px; }
.result-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.result-table th, .result-table td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
.result-table tr.ok td:first-child { border-left: 5px solid #13a35f; }
.result-table tr.bad td:first-child { border-left: 5px solid #e04848; }
.table-wrap { overflow-x: auto; }
.mtc-q { font-size: clamp(2.4rem, 9vw, 4rem); font-weight: 900; text-align: center; margin: 10px 0; }
.mtc-bar { height: 14px; background: #e8ecf7; border-radius: 99px; overflow: hidden; }
.mtc-bar span { display: block; height: 100%; background: #ff9f1c; width: 100%; }
.paper { background: #fff; padding: 24px; border-radius: 12px; }
.paper-head { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; border: 2px solid #222; padding: 10px; margin: 10px 0 18px; }
.paper-q { display: grid; grid-template-columns: 44px 1fr 150px; gap: 10px; padding: 12px 0; border-bottom: 1px dashed #aaa; break-inside: avoid; page-break-inside: avoid; }
.paper-q .n { font-weight: 900; font-size: 1.1rem; }
.paper-q .box { border: 2px solid #222; min-height: 54px; border-radius: 6px; position: relative; }
.paper-q .marks { font-size: .75rem; color: #444; text-align: right; }
.paper-q .work { min-height: 50px; }
.paper-q .viz, .paper-q .emoji-count { margin: 6px 0; }
.mark-scheme td { padding: 6px 8px; }

/* ---------- tips ---------- */
.tip-card { display: flex; flex-direction: column; gap: 8px; border-top: 8px solid var(--c-tips); }
.tip-card .emoji { font-size: 2rem; }
.tip-card h3 { margin: 0; }
.try { background: #f0fbf6; border-radius: 14px; padding: 12px; margin-top: auto; }
.try h4 { margin: 0 0 6px; font-size: 1rem; color: #0b6b45; }
.hands { display: flex; gap: 3px; justify-content: center; flex-wrap: nowrap; align-items: flex-start; }
.finger { font: inherit; width: 22px; padding-left: 0; padding-right: 0; height: 64px; border-radius: 14px 14px 6px 6px; border: 2px solid #c48a52; background: #ffd9b3; cursor: pointer; display: flex; align-items: flex-end; justify-content: center; font-size: .75rem; font-weight: 800; padding-bottom: 4px; }
.finger.down { height: 30px; background: #e05a5a; color: #fff; margin-top: 34px; }
.finger.gap { margin-left: 10px; }
.big-out { font-size: 1.3rem; font-weight: 800; margin-top: 8px; min-height: 1.5em; }
.inline-input { font: inherit; font-size: 1.2rem; font-weight: 800; width: 7em; padding: 8px 10px; border-radius: 12px; border: 2px solid #b8c3e0; min-height: 48px; }
input[type=range] { width: 100%; min-height: 40px; accent-color: var(--c-tips); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.filter-bar button { font: inherit; font-weight: 800; border-radius: 999px; padding: 8px 16px; min-height: 44px; border: 2px solid var(--line); background: #fff; cursor: pointer; }
.filter-bar button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.pizza-slices path { cursor: pointer; }

/* ---------- games ---------- */
.game-card { display: flex; flex-direction: column; gap: 8px; border-top: 8px solid var(--c, var(--c-games)); text-decoration: none; color: var(--ink); }
.game-card .icon { font-size: 3rem; }
.game-card:hover { color: var(--ink); transform: translateY(-2px); }
.game-stage { background: linear-gradient(180deg, #172554, #3b1d70); color: #fff; border-radius: 24px; padding: 16px; min-height: 420px; position: relative; overflow: hidden; }
.game-stage.light { background: linear-gradient(180deg, #e6fbff, #d6f5ee); color: var(--ink); }
.game-stage.warm { background: linear-gradient(180deg, #fff3db, #ffe1c2); color: var(--ink); }
.game-stage.pink { background: linear-gradient(180deg, #ffe6f2, #f3e8ff); color: var(--ink); }
.game-hud { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.hud-pill { background: rgba(255, 255, 255, .92); color: var(--ink); border-radius: 999px; padding: 6px 14px; font-weight: 900; font-size: .95rem; }
.game-q { background: rgba(255, 255, 255, .96); color: var(--ink); border-radius: 20px; padding: 16px; max-width: 640px; margin: 0 auto; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.game-q .q-text { font-size: clamp(1.5rem, 5vw, 2.2rem); text-align: center; }
.game-q .q-visual { justify-content: center; }
.game-q .answer-box { margin: 0 auto; }
.ladder { display: flex; gap: 3px; align-items: flex-end; height: 64px; margin: 8px 0; }
.ladder span { flex: 1; background: rgba(255, 255, 255, .25); border-radius: 4px 4px 0 0; min-width: 6px; position: relative; }
.light .ladder span, .warm .ladder span, .pink .ladder span { background: rgba(0, 0, 0, .1); }
.ladder span.done { background: #ffd166; }
.ladder span.cur { background: #13d67a; outline: 3px solid #fff; }
.ladder-wrap { max-width: 640px; margin: 8px auto; }
.ladder-labels { display: flex; gap: 3px; font-size: .75rem; font-weight: 800; opacity: .9; }
.track { position: relative; height: 54px; background: rgba(255, 255, 255, .12); border-radius: 999px; margin: 10px auto; max-width: 640px; }
.track .rocket { position: absolute; top: 4px; font-size: 2.3rem; transition: left .4s; transform: rotate(45deg); }
.track .goal { position: absolute; right: 10px; top: 8px; font-size: 1.8rem; }
.timebar { height: 12px; background: rgba(0, 0, 0, .15); border-radius: 99px; overflow: hidden; max-width: 640px; margin: 6px auto; }
.timebar span { display: block; height: 100%; background: #ffd166; width: 100%; }
.bubbles { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 12px; }
.bubble { font: inherit; font-weight: 900; font-size: 1.5rem; width: 110px; height: 110px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .9); cursor: pointer; color: #0b3b36; background: radial-gradient(circle at 30% 30%, #ffffff, #a6f0e6 45%, #4cc9b8); box-shadow: 0 6px 18px rgba(0, 80, 80, .25); animation: float 3s ease-in-out infinite; touch-action: manipulation; }
.bubble:nth-child(2) { animation-delay: .5s; } .bubble:nth-child(3) { animation-delay: 1s; } .bubble:nth-child(4) { animation-delay: 1.5s; }
.bubble.right { animation: pop .35s forwards; }
.bubble.wrong { background: radial-gradient(circle at 30% 30%, #fff, #ffc4c4 45%, #ff7b7b); }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes pop { 0% { transform: scale(1); } 60% { transform: scale(1.25); opacity: .8; } 100% { transform: scale(0); opacity: 0; } }
.treasure { display: flex; gap: 4px; justify-content: center; font-size: 1.6rem; margin: 6px 0; flex-wrap: wrap; }
.speedo { font-size: 2.2rem; text-align: center; }
.level-up { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); background: #ffd166; color: #3b2600; padding: 14px 24px; border-radius: 20px; font-size: 1.6rem; font-weight: 900; z-index: 10; animation: zoom 1.4s forwards; pointer-events: none; text-align: center; }
@keyframes zoom { 0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; } 20% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }
.result-stars { font-size: 3rem; color: #f7b500; letter-spacing: 4px; text-align: center; }
.badge-list { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 6px; background: #fff7d6; border: 2px solid #ffd166; border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: .9rem; }
.badge.locked { filter: grayscale(1); opacity: .45; }
.placement-dots { display: flex; gap: 6px; justify-content: center; margin: 6px 0; }
.placement-dots span { width: 16px; height: 16px; border-radius: 50%; background: rgba(255, 255, 255, .35); border: 2px solid rgba(255, 255, 255, .7); }
.light .placement-dots span, .warm .placement-dots span, .pink .placement-dots span { background: rgba(0, 0, 0, .08); border-color: rgba(0, 0, 0, .25); }
.placement-dots span.ok { background: #13d67a; } .placement-dots span.bad { background: #ff6b6b; }

/* ---------- dashboard ---------- */
.kid-card { border-top: 8px solid var(--c-parents); }
.kid-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.kid-head .row { flex-wrap: nowrap; }
.kid-head .big-emoji { font-size: 3rem; }
.meter { height: 12px; background: #eef1f8; border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, #8b5cf6, #e83e8c); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 10px 0; }
.stat { background: #f6f7fb; border-radius: 14px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.5rem; }
.topic-row { display: grid; grid-template-columns: 1fr 120px 52px; gap: 8px; align-items: center; font-size: .9rem; padding: 3px 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data-table th, .data-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }

/* ---------- toasts / confetti ---------- */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(420px, 92vw); }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 800; box-shadow: var(--shadow); transition: opacity .4s; text-align: center; }
.toast.hide { opacity: 0; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti span { position: absolute; top: -40px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- mobile ---------- */
@media (max-width: 600px) {
  body { font-size: 17px; }
  main { padding: 12px 10px 50px; }
  .card { padding: 14px; }
  .q-text { font-size: 1.15rem; }

  .paper-q { grid-template-columns: 34px 1fr; }
  .paper-q .box-col { grid-column: 2; }
  .bubble { width: 92px; height: 92px; font-size: 1.25rem; }
  .brand { font-size: 1.15rem; }
  .brand .logo { width: 38px; height: 38px; font-size: 1.4rem; }
  .site-header { position: static; }
  .scorebar { top: 0; }
  .scorebar .muted { display: none; }
  .hero { padding: 18px; }
  .hero-art { font-size: 44px; }
  .exam-year .grid, .tips-grid { grid-template-columns: 1fr; }
  .game-stage { padding: 10px; border-radius: 18px; }
  .who-text small { display: none; }
}

/* ---------- print ---------- */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 12pt; color: #000; }
  .site-header, .site-footer, .no-print, #toasts, .confetti { display: none !important; }
  main { max-width: none; padding: 0; }
  .paper { padding: 0; }
  .card, .q-card { box-shadow: none; }
  a { color: #000; text-decoration: none; }
  .paper-q { grid-template-columns: 34px 1fr 42mm; }
  .page-break { break-before: page; page-break-before: always; }
  .emoji-count { font-size: 20pt; }
}
.choice.selected { background: #dbe8ff; border-color: #3a6ff6; box-shadow: 0 0 0 3px #a9c4ff inset; }
fieldset.card { border: 2px solid var(--line); }
fieldset label { min-height: 44px; cursor: pointer; }
fieldset input[type=radio] { width: 22px; height: 22px; }

/* ---------- family account, kid picker, worksheets ---------- */
.auth-wrap { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; max-width: 980px; }
@media (max-width: 760px) { .auth-wrap { grid-template-columns: 1fr; } }
.auth-tabs { display: flex; gap: 6px; background: var(--brand-soft); padding: 5px; border-radius: 16px; }
.auth-tabs [role=tab] { flex: 1; font: inherit; font-weight: 800; border: 0; border-radius: 12px; min-height: 48px; background: transparent; color: var(--brand); cursor: pointer; }
.auth-tabs [role=tab][aria-selected=true] { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(30, 40, 90, .15); }
.field { display: grid; gap: 4px; font-weight: 800; }
.field input, .field select, .kid-form input[type=password], .import-row select, .ws-form select { font: inherit; font-weight: 400; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); min-height: 50px; background: #fff; color: var(--ink); }
.field input:focus, .kid-form input:focus, .ws-form select:focus { outline: 3px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.form-error { color: var(--bad); font-weight: 800; margin: 0; min-height: 0; }
.form-error:empty { display: none; }
.linkish { background: none; border: 0; color: var(--brand); font: inherit; text-decoration: underline; cursor: pointer; padding: 6px 0; justify-self: start; min-height: 44px; }
.check-row { display: flex !important; align-items: center; gap: 10px; font-weight: 700; flex-wrap: wrap; }
.check-row input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--brand); }
.import-row { display: grid; gap: 6px; padding: 10px; border: 2px solid var(--line); border-radius: 14px; }
.kid-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 220px)); gap: 16px; justify-content: center; margin: 18px auto; max-width: 980px; }
.kid-tile { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px 12px; border-radius: 24px; border: 4px solid var(--line); background: #fff; cursor: pointer; min-height: 190px; box-shadow: var(--shadow); transition: transform .1s; }
.kid-tile:hover, .kid-tile:focus-visible { transform: translateY(-3px); border-color: var(--brand); }
.kid-tile.on { border-color: var(--brand); background: var(--brand-soft); }
.kid-tile b { font-size: 1.3rem; }
.kid-tile.guest { border-style: dashed; box-shadow: none; }
.kid-emoji { font-size: 4rem; line-height: 1.1; }
.pin-modal { width: min(380px, 94vw); }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 14px 0; }
.pin-dots span { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--brand); }
.pin-dots span.on { background: var(--brand); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-key { font: inherit; font-size: 1.6rem; font-weight: 800; min-height: 64px; border-radius: 16px; border: 0; background: #e7ebf5; cursor: pointer; box-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.pin-key.del { background: var(--warn-soft); }
.pin-key:nth-child(11) { grid-column: 2; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) { .shake { animation: none; } .kid-tile { transition: none; } }
.promo { background: linear-gradient(100deg, var(--brand-soft), #ffe6f2); border: 0; }
.ws-form { display: grid; gap: 18px; }
.ws-form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.ws-form legend { font-weight: 900; font-size: 1.1rem; margin-bottom: 6px; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; min-height: 44px; }
.chip:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.chip input { width: 20px; height: 20px; accent-color: var(--brand); margin: 0; }
.chip:has(input:focus-visible) { outline: 3px solid var(--brand); outline-offset: 2px; }
.ws-preview ol { padding-left: 1.6em; margin: 0; display: grid; gap: 6px; }
.ws-preview li small { margin-left: 6px; }
.ws-frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .85em; line-height: 1.05; margin: 0 2px; }
.ws-frac > span:first-child { border-bottom: 2px solid currentColor; padding: 0 2px; }
@media (max-width: 520px) {
  .kid-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kid-tile { min-height: 150px; padding: 14px 8px; border-radius: 20px; }
  .kid-emoji { font-size: 3rem; }
  .kid-tile b { font-size: 1.1rem; }
}

/* ---------- Geography ---------- */
.geo-modes { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin: 14px 0; }
.geo-mode .icon { font-size: 2.4rem; }
.geo-topic-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; }
.geo-topic-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 2px solid #e2e8f6; border-radius: 14px; background: #fff; }
.geo-q-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.geo-visual { justify-content: center; }
.geo-visual .geo-svg { width: 100%; max-width: 520px; height: auto; border-radius: 12px; border: 2px solid #dbe3f3; background: #fff; }
.geo-visual .geo-svg[viewBox="0 0 120 120"] { max-width: 170px; }
.geo-visual .geo-svg[viewBox="0 0 240 240"] { max-width: 260px; }
.geo-visual .geo-svg[aria-label^="A grid map"] { max-width: 420px; }
.geo-flag { width: 220px; max-width: 70vw; height: auto; border: 1px solid #c9d3ee; border-radius: 6px; box-shadow: 0 2px 8px rgba(30, 40, 90, .12); }
.flag-choices { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.flag-choice { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; }
.flag-choice img { width: 100%; max-width: 150px; height: auto; border: 1px solid #c9d3ee; border-radius: 4px; display: block; }
.flag-letter { font-size: 1rem; }
.geo-choices .choice { font-size: 1.15rem; }
.geo-typed { max-width: 340px; font-size: 1.3rem; }
.geo-unit { font-weight: 800; align-self: center; }
.geo-match .match-row { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(150px, 1.4fr); gap: 10px; align-items: center; max-width: 560px; }
.geo-select { width: 100%; min-height: 44px; }
.geo-select.right { border-color: #13a35f; background: var(--ok-soft); }
.geo-select.wrong { border-color: #e04848; background: var(--bad-soft); }
.geo-explain-text { display: block; margin-top: 4px; font-weight: 600; font-size: 1rem; }
.geo-next { margin-top: 10px; }
.geo-review ol { padding-left: 1.3em; margin: 0; display: grid; gap: 8px; text-align: left; }
.geo-ladder { margin-top: 10px; }
.geo-emoji { font-size: 1.4em; }
@media (max-width: 520px) { .geo-match .match-row { grid-template-columns: 1fr; gap: 4px; } }
.geo-stage .game-q { max-width: 780px; }

/* ---------- subject switch (Maths | Geography) ---------- */
.subject-switch { display: flex; background: rgba(255, 255, 255, .18); border-radius: 999px; padding: 4px; gap: 2px; }
.subject-switch a { display: flex; align-items: center; gap: 5px; color: #fff; text-decoration: none; font-weight: 900; padding: 6px 14px; border-radius: 999px; min-height: 40px; white-space: nowrap; }
.subject-switch a:hover { background: rgba(255, 255, 255, .22); color: #fff; }
.subject-switch a[aria-pressed="true"] { background: #fff; color: #3a2bd1; box-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
body.subj-geo .site-header { background: linear-gradient(100deg, #0b8f5a, #12a36b 45%, #1fa2c9); }
body.subj-geo .subject-switch a[aria-pressed="true"], body.subj-geo .site-nav a[aria-current="page"], body.subj-geo .acct-link:hover { color: #0b7a4c; }
html[data-subject="geography"] [data-subject="maths"], html:not([data-subject="geography"]) [data-subject="geography"] { display: none !important; }
body.subj-geo .hero { background: linear-gradient(120deg, #e3f8ee, #dff3fb); }
.subj-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 900; padding: 4px 12px; border-radius: 999px; background: #e3f8ee; color: #0b7a4c; }
@media (max-width: 640px) { .subject-switch { order: 2; } .subject-switch a { padding: 6px 10px; } }

/* geography versions of the games */
.geo-game .bubble { width: auto; min-width: 118px; max-width: 220px; height: auto; min-height: 96px; padding: 10px 18px; border-radius: 48px; font-size: 1.1rem; line-height: 1.2; }
.geo-game .bubble.flag-bubble { min-width: 0; padding: 14px; border-radius: 50%; width: 124px; height: 124px; display: grid; place-items: center; }
.geo-game .bubble.flag-bubble img { width: 84px; height: auto; border-radius: 4px; border: 1px solid #c9d3ee; display: block; }
.geo-game .q-visual svg { max-width: 520px; width: 100%; height: auto; }
.geo-game .q-visual .geo-flag { width: 220px; height: auto; border: 1px solid #c9d3ee; border-radius: 6px; }
.geo-game .game-q { max-width: 780px; }
.text-answer { min-width: 0; flex: 1 1 220px; }
/* geography challenge cards */
.q-card .flag-choices { display: grid; gap: 10px; }
.q-card .q-visual .geo-flag { width: 200px; height: auto; border: 1px solid #c9d3ee; border-radius: 6px; }
.q-card .q-visual svg { max-width: 520px; width: 100%; height: auto; }
.tryit { background: #f3fbf7; border: 2px dashed #9fd9bd; border-radius: 14px; padding: 12px; }
