/* Amelia's learning app.
   Target: iPad Air 1, iOS 12 Safari. That rules out flexbox `gap`, `clamp()`,
   `aspect-ratio`, `:is()` and CSS nesting — spacing is done with margins. */

:root {
  --ink: #16233a;
  --ink-soft: #5b6b85;
  --paper: #f4f7fd;
  --card: #ffffff;
  --line: #dde5f2;
  --reading: #6c4bd6;
  --reading-soft: #ece6ff;
  --maths: #0d8a6a;
  --maths-soft: #dcf5ee;
  --sun: #f5a623;
  --ok: #1a9c58;
  --ok-soft: #dff5e8;
  --no: #d8443c;
  --no-soft: #fde8e7;
  --shadow: 0 2px 0 rgba(22,35,58,.10), 0 8px 24px rgba(22,35,58,.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: rgba(0,0,0,0); }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body {
  display: -webkit-flex; display: flex;
  -webkit-flex-direction: column; flex-direction: column;
  user-select: none; -webkit-user-select: none;
}

button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
button:disabled { cursor: default; }

/* ------------------------------------------------------------------- hud */
#hud {
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
  -webkit-flex-shrink: 0; flex-shrink: 0;
}
.hud-back {
  font-size: 19px; font-weight: 600; color: var(--ink-soft);
  padding: 10px 14px 10px 4px; margin: 0;
}
.hud-title { font-size: 19px; font-weight: 700; -webkit-flex: 1; flex: 1; text-align: center; }
.hud-right { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; }
.hud-prog {
  font-size: 16px; font-weight: 700; color: var(--ink-soft);
  background: var(--paper); border-radius: 999px; padding: 6px 12px; margin-right: 10px;
}
.hud-speak { font-size: 24px; padding: 6px 4px; }
.hud-speak.off { opacity: .35; }

#root {
  -webkit-flex: 1; flex: 1;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 18px;
  position: relative;
}

/* ------------------------------------------------------------------ home */
.home { max-width: 860px; margin: 0 auto; padding-top: 10px; }
.home-head {
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: space-between; justify-content: space-between;
  margin-bottom: 26px;
}
.home-hi { font-size: 38px; margin: 0; letter-spacing: -.5px; }
.home-stats { display: -webkit-flex; display: flex; }
.stat { text-align: center; margin-left: 22px; }
.stat-n { font-size: 30px; font-weight: 800; color: var(--sun); line-height: 1; }
.stat-l { font-size: 13px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .6px; margin-top: 4px; }

.picker { display: -webkit-flex; display: flex; }
.card {
  -webkit-flex: 1; flex: 1;
  background: var(--card); border-radius: 26px; padding: 30px 24px 24px;
  text-align: left; box-shadow: var(--shadow); margin-right: 18px;
  border: 3px solid transparent; transition: transform .12s ease;
}
.card:last-child { margin-right: 0; }
.card:active { transform: scale(.975); }
.card-reading { border-color: var(--reading-soft); }
.card-maths { border-color: var(--maths-soft); }
.card-icon { font-size: 54px; line-height: 1; margin-bottom: 14px; }
.card-label { font-size: 30px; font-weight: 800; letter-spacing: -.3px; }
.card-sub { font-size: 16px; color: var(--ink-soft); margin-top: 6px; }
.card-bar { height: 10px; background: var(--paper); border-radius: 999px; margin-top: 18px; overflow: hidden; }
.card-bar-fill { height: 100%; border-radius: 999px; background: var(--sun); }
.card-reading .card-bar-fill { background: var(--reading); }
.card-maths .card-bar-fill { background: var(--maths); }

.parent-dot {
  position: absolute; right: 10px; bottom: 6px;
  font-size: 26px; color: var(--line); padding: 14px 18px; letter-spacing: 2px;
}

/* ---------------------------------------------------------------- levels */
.levels {
  display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap;
  max-width: 980px; margin: 0 auto;
}
.lvl {
  width: 31.5%; margin: 0 2.75% 16px 0;
  background: var(--card); border-radius: 20px; padding: 18px 16px;
  text-align: left; box-shadow: var(--shadow); border: 2px solid transparent;
}
.lvl:nth-child(3n) { margin-right: 0; }
.lvl:active { transform: scale(.97); }
.lvl.locked { opacity: .45; box-shadow: none; background: #eef2f9; }
.lvl.done { border-color: var(--sun); }
.lvl-no { font-size: 26px; font-weight: 800; color: var(--ink-soft); line-height: 1; }
.lvl-name { font-size: 20px; font-weight: 700; margin-top: 8px; }
.lvl-focus { font-size: 14px; color: var(--ink-soft); margin-top: 4px; min-height: 34px; }
.lvl-stars { font-size: 19px; color: var(--sun); margin-top: 6px; letter-spacing: 2px; }

/* ----------------------------------------------------------------- stage */
.stage { max-width: 780px; margin: 0 auto; text-align: center; }
.ask { font-size: 21px; color: var(--ink-soft); font-weight: 600; margin-bottom: 18px; }
.ask-q { font-size: 34px; color: var(--ink); font-weight: 800; letter-spacing: -.4px; margin-bottom: 20px; }

.word-big {
  font-size: 66px; font-weight: 800; letter-spacing: 2px; margin: 18px 0 6px;
  font-family: "SF Pro Rounded", -apple-system, sans-serif;
}
.sentence {
  font-size: 32px; line-height: 1.5; font-weight: 600; background: var(--card);
  border-radius: 20px; padding: 26px 24px; box-shadow: var(--shadow); margin-bottom: 14px;
}

.graphemes {
  display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap;
  -webkit-justify-content: center; justify-content: center; margin: 0 -6px;
}
.gph {
  min-width: 82px; height: 82px; margin: 6px;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  font-size: 32px; font-weight: 800; color: var(--reading);
  border: 3px solid transparent; padding: 0 12px;
}
.gph.lit { background: var(--reading); color: #fff; border-color: var(--reading); }
.gph.used { opacity: .25; }
.gph.shake { animation: shake .4s; border-color: var(--no); }

.slots {
  display: -webkit-flex; display: flex; -webkit-justify-content: center; justify-content: center;
  margin: 20px 0 22px;
}
.slot {
  min-width: 78px; height: 78px; margin: 0 6px;
  border: 3px dashed var(--line); border-radius: 18px;
  font-size: 32px; font-weight: 800; color: var(--reading);
  display: -webkit-flex; display: flex;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  padding: 0 10px;
}
.slot.filled { border-style: solid; border-color: var(--reading); background: var(--reading-soft); }

.opts {
  display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap;
  -webkit-justify-content: center; justify-content: center; margin: 4px -7px 0;
}
.opt {
  width: calc(50% - 14px); margin: 7px; min-height: 84px;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  font-size: 27px; font-weight: 700; padding: 16px 14px;
  border: 3px solid transparent;
}
.opts-word .opt { font-size: 34px; font-weight: 800; letter-spacing: 1px; }
.opts-two .opt { width: calc(50% - 14px); font-size: 30px; }
.opt:active { transform: scale(.97); }
.opt-ok { background: var(--ok-soft); border-color: var(--ok); color: #0c6b3b; }
.opt-no { background: var(--no-soft); border-color: var(--no); color: #8f2b25; }

.replay {
  font-size: 17px; font-weight: 700; color: var(--ink-soft);
  background: var(--card); border-radius: 999px; padding: 12px 22px;
  box-shadow: var(--shadow); margin: 10px 0 20px;
}

.big-btn {
  display: block; margin: 16px auto 0; min-width: 240px;
  background: var(--line); color: #9aa8bd; border-radius: 18px;
  font-size: 23px; font-weight: 800; padding: 18px 30px;
}
.big-btn.ready { background: var(--reading); color: #fff; box-shadow: var(--shadow); }
.big-btn.ghost { background: var(--card); color: var(--ink-soft); box-shadow: var(--shadow); }
.big-btn.danger { color: var(--no); }
.big-btn:active { transform: scale(.97); }

.hint {
  margin-top: 16px; font-size: 18px; color: var(--ink-soft);
  background: #fff8e8; border-radius: 14px; padding: 12px 16px; display: inline-block;
}

/* ----------------------------------------------------------------- numpad */
.numdisp {
  font-size: 52px; font-weight: 800; background: var(--card); border-radius: 18px;
  box-shadow: var(--shadow); padding: 12px; margin: 0 auto 16px; max-width: 300px;
  min-height: 78px; letter-spacing: 2px;
}
.numpad {
  display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap;
  max-width: 300px; margin: 0 auto;
}
.key {
  width: calc(33.333% - 10px); margin: 5px; height: 68px;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  font-size: 28px; font-weight: 700;
}
.key:active { transform: scale(.95); }
.key-go { background: var(--maths); color: #fff; }
.key-del { color: var(--ink-soft); }

/* ------------------------------------------------------------------- viz */
.viz-box {
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  padding: 16px; margin: 0 auto 14px; max-width: 700px;
}
.viz { width: 100%; height: auto; max-height: 240px; display: block; }
.vz-t { fill: var(--ink); font-family: -apple-system, sans-serif; }
.vz-strong { font-weight: 800; }
.vz-hop { fill: var(--maths); font-weight: 700; }
.vz-axis { stroke: var(--ink-soft); stroke-width: 2.5; }
.vz-tick { stroke: var(--ink-soft); stroke-width: 2; }
.vz-mark { fill: var(--maths); }
.vz-mark-soft { fill: #8fd3c0; }
.vz-jump { fill: none; stroke: var(--maths); stroke-width: 3; stroke-linecap: round; }
.vz-cell { fill: #fff; stroke: var(--ink-soft); stroke-width: 2; }
.vz-dot { fill: var(--maths); }
.vz-dot-add { fill: var(--sun); }
.vz-dot-odd { fill: var(--no); }
.vz-rod { fill: #cfe8ff; stroke: #4a90d9; stroke-width: 2; }
.vz-rodline { stroke: #4a90d9; stroke-width: 1; opacity: .5; }
.vz-unit { fill: #ffd9a0; stroke: var(--sun); stroke-width: 2; }
.vz-group { fill: #f7fbff; stroke: var(--line); stroke-width: 2.5; }
.vz-card { fill: #fff; stroke: var(--line); stroke-width: 2.5; }
.vz-card-q { fill: #fff8e8; stroke: var(--sun); }
.vz-clockface { fill: #fff; stroke: var(--ink); stroke-width: 4; }
.vz-hand { stroke: var(--ink); stroke-linecap: round; }
.vz-hour { stroke-width: 8; }
.vz-min { stroke-width: 5; stroke: var(--maths); }
.vz-pin { fill: var(--ink); }

/* ------------------------------------------------------------------ pips */
.pips {
  display: -webkit-flex; display: flex; -webkit-justify-content: center; justify-content: center;
  margin: 28px 0 8px;
}
.pip {
  width: 11px; height: 11px; border-radius: 50%; background: var(--line); margin: 0 4px;
}
.pip-done { background: var(--sun); }
.pip-now { background: var(--ink-soft); transform: scale(1.35); }

/* -------------------------------------------------------------- feedback */
.fb {
  position: fixed; left: 0; right: 0; bottom: 0; top: 0;
  display: -webkit-flex; display: flex;
  -webkit-flex-direction: column; flex-direction: column;
  -webkit-align-items: center; align-items: center;
  -webkit-justify-content: center; justify-content: center;
  z-index: 20; animation: pop .22s ease;
  background: rgba(244,247,253,.93);
}
.fb-face { font-size: 82px; }
.fb-msg { font-size: 32px; font-weight: 800; margin-top: 10px; }
.fb-ok .fb-msg { color: var(--ok); }
.fb-no .fb-msg { color: var(--ink-soft); }

/* ------------------------------------------------------------------ done */
.done { max-width: 620px; margin: 24px auto 0; text-align: center; }
.done-stars { font-size: 62px; color: var(--sun); letter-spacing: 6px; }
.done-msg { font-size: 40px; margin: 8px 0 4px; }
.done-score { font-size: 24px; color: var(--ink-soft); font-weight: 600; }
.done-unlock {
  margin: 20px auto 0; background: #fff8e8; border-radius: 16px;
  padding: 14px 18px; font-size: 19px; font-weight: 700; display: inline-block;
}
.done-btns { margin-top: 26px; }

/* ---------------------------------------------------------------- parent */
.pin { max-width: 340px; margin: 30px auto; text-align: center; }
.pin-dots { font-size: 34px; letter-spacing: 8px; margin: 10px 0 24px; color: var(--ink-soft); }
.pin-dots.shake { animation: shake .4s; color: var(--no); }
.pin-note { margin-top: 18px; font-size: 15px; color: var(--ink-soft); }
.numpad-pin { max-width: 280px; }

.parent { max-width: 780px; margin: 0 auto; }
.p-card {
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 18px;
}
.p-card h3 { margin: 0 0 16px; font-size: 17px; color: var(--ink-soft); font-weight: 700;
             text-transform: uppercase; letter-spacing: .6px; }
.p-note { font-size: 15px; color: var(--ink-soft); line-height: 1.5; margin-bottom: 14px; }

.chart { display: -webkit-flex; display: flex; -webkit-align-items: flex-end; align-items: flex-end; height: 130px; }
.bar-wrap { -webkit-flex: 1; flex: 1; text-align: center; }
.bar { height: 84px; display: -webkit-flex; display: flex; -webkit-align-items: flex-end; align-items: flex-end;
       margin: 0 6px; background: var(--paper); border-radius: 8px; overflow: hidden; }
.bar-fill { width: 100%; background: var(--maths); border-radius: 8px 8px 0 0; min-height: 3px; }
.bar-val { font-size: 12px; color: var(--ink-soft); font-weight: 700; height: 16px; }
.bar-lab { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }

.rows { }
.row {
  display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-dim { opacity: .45; }
.row-no { width: 30px; font-weight: 800; color: var(--ink-soft); font-size: 15px; }
.row-main { -webkit-flex: 1; flex: 1; min-width: 0; }
.row-name { font-size: 17px; font-weight: 700; }
.row-out { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.row-acc { font-size: 16px; font-weight: 700; width: 56px; text-align: right; color: var(--ink-soft); }
.row-stars { width: 62px; text-align: right; color: var(--sun); font-size: 15px; letter-spacing: 1px; }

.misses { }
.miss {
  display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.miss:last-child { border-bottom: 0; }
.miss-sub {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700;
  color: var(--ink-soft); background: var(--paper); border-radius: 6px; padding: 3px 7px; margin-right: 10px;
}
.miss-item { -webkit-flex: 1; flex: 1; font-size: 16px; font-weight: 600; }
.miss-n { font-size: 15px; font-weight: 800; color: var(--no); }


/* ------------------------------------------------------- subject theming */
/* The round takes the colour of its subject so reading and maths feel
   like different places rather than one app with two menus. */
.subj-maths .big-btn.ready { background: var(--maths); }
.subj-maths .gph { color: var(--maths); }
.subj-maths .gph.lit { background: var(--maths); border-color: var(--maths); }
.subj-maths .slot.filled { border-color: var(--maths); background: var(--maths-soft); }
.subj-maths .pip-done { background: var(--maths); }
.subj-reading .pip-done { background: var(--reading); }
.subj-reading .key-go { background: var(--reading); }
.subj-reading .vz-dot, .subj-reading .vz-mark { fill: var(--reading); }

/* ------------------------------------------------------------ animations */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
@keyframes pop {
  from { opacity: 0; transform: scale(.9); }
  to { opacity: 1; transform: scale(1); }
}

/* ------------------------------------------------------- narrow / portrait */
@media (max-width: 760px) {
  .home-hi { font-size: 30px; }
  .picker { -webkit-flex-direction: column; flex-direction: column; }
  .card { margin: 0 0 16px 0; }
  .lvl { width: 48%; margin-right: 4%; }
  .lvl:nth-child(3n) { margin-right: 4%; }
  .lvl:nth-child(2n) { margin-right: 0; }
  .opt { width: calc(100% - 14px); }
  .word-big { font-size: 52px; }
  .sentence { font-size: 26px; }
  .ask-q { font-size: 27px; }
}
