/* Served from the site itself, not Google, so a slow connection to Google can
   never hold up the first screen. Each family is one variable font file. */
@font-face { font-family: 'Baloo 2'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url('fonts/Baloo2.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url('fonts/Nunito.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --green-dark: #00945e;
  --green: #06a86b;
  --green-bright: #53d572;
  --green-soft: #93d1ac;
  --green-pale: #e6f7ee;
  --teal: #44afae;
  --amber: #e0a020;
  --amber-pale: #fdf3e0;
  --red: #df504b;
  --red-dark: #c23f3b;
  --red-pale: #fbe9e8;
  --blue: #3b54a8;
  --blue-pale: #e8ecf9;
  --purple: #7a5fc0;
  --ink: #1c2b27;
  --ink-soft: #55665f;
  --bg: #f3fbf6;
  --card: #ffffff;
  --shadow: 0 8px 24px rgba(0, 60, 40, 0.10);
  --shadow-lg: 0 20px 50px rgba(0, 60, 40, 0.20);
  --radius: 20px;
  --radius-lg: 28px;
  --tap-min: 56px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(135deg, rgba(0,148,94,0.05) 25%, transparent 25.5%),
    linear-gradient(225deg, rgba(0,148,94,0.05) 25%, transparent 25.5%),
    linear-gradient(45deg, rgba(68,175,174,0.05) 25%, transparent 25.5%),
    linear-gradient(315deg, rgba(68,175,174,0.05) 25%, transparent 25.5%);
  background-position: 36px 0, 36px 0, 0 0, 0 0;
  background-size: 72px 72px;
  background-repeat: repeat;
  color: var(--ink);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 18px;
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

h1, h2, h3, h4 { font-family: 'Baloo 2', 'Nunito', sans-serif; margin: 0; font-weight: 700; }
h1 { font-size: 30px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
p { line-height: 1.5; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
  /* Stops iPad Safari zooming in on a double tap and removes its tap delay,
     which is why a quick second tap used to zoom the page instead. */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
input {
  font-family: inherit;
  font-size: 18px;
}

.bg-blobs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
/* The soft colour behind every screen. These were blurred discs
   (filter: blur(60px)), which an iPad re-paints on every scroll and every tap
   at a real cost; a radial gradient looks the same and costs nothing. */
.blob { position: absolute; border-radius: 50%; opacity: 0.30; }
.blob-a { width: 640px; height: 640px; background: radial-gradient(circle, var(--green-bright) 0%, rgba(83,213,114,0) 68%); top: -250px; left: -230px; }
.blob-b { width: 600px; height: 600px; background: radial-gradient(circle, var(--teal) 0%, rgba(68,175,174,0) 68%); bottom: -270px; right: -210px; }
.blob-c { width: 480px; height: 480px; background: radial-gradient(circle, var(--amber) 0%, rgba(224,160,32,0) 68%); top: 40%; right: 10%; opacity: 0.18; }

/* ---------- App shell ---------- */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 24px;
  background:
    radial-gradient(ellipse 500px 260px at 15% -20%, rgba(255,255,255,0.16), transparent 60%),
    linear-gradient(115deg, var(--green-dark) 0%, var(--green) 55%, var(--teal) 130%);
  color: white;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(135deg, rgba(255,255,255,0.07) 25%, transparent 25.5%),
    linear-gradient(225deg, rgba(255,255,255,0.07) 25%, transparent 25.5%),
    linear-gradient(45deg, rgba(255,255,255,0.05) 25%, transparent 25.5%),
    linear-gradient(315deg, rgba(255,255,255,0.05) 25%, transparent 25.5%);
  background-position: 30px 0, 30px 0, 0 0, 0 0;
  background-size: 60px 60px;
  pointer-events: none;
}
.topbar > * { position: relative; z-index: 1; }
/* The shield mark is portrait, so `contain` letterboxes it inside the square
   white badge rather than distorting it. */
.topbar-logo { height: 40px; width: 40px; border-radius: 12px; background: white; padding: 5px; object-fit: contain; }
.topbar-title { font-family: 'Baloo 2', sans-serif; font-size: 22px; font-weight: 700; flex: 1; }
.topbar-sub { font-size: 13px; opacity: 0.85; margin-top: -2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.zigzag-edge {
  position: relative; z-index: 1; height: 14px; background-color: var(--green);
  background-image:
    linear-gradient(45deg, var(--bg) 8px, transparent 0),
    linear-gradient(-45deg, var(--bg) 8px, transparent 0);
  background-position: 0 0, 0 0;
  background-size: 16px 16px;
  background-repeat: repeat-x;
}

main { flex: 1; padding: 20px; max-width: 960px; margin: 0 auto; width: 100%; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-min);
  padding: 14px 26px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 18px;
  font-family: 'Baloo 2', sans-serif;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: linear-gradient(135deg, var(--green), var(--green-dark)); color: white; box-shadow: 0 6px 16px rgba(0,148,94,0.35); }
.btn-secondary { background: white; color: var(--green-dark); border: 2px solid var(--green-soft); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.input-lg {
  width: 100%;
  min-height: var(--tap-min);
  padding: 12px 18px;
  border-radius: 16px;
  border: 2px solid var(--green-soft);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 2px;
  background: var(--green-pale);
  color: var(--ink);
}
.input-lg:focus { outline: none; border-color: var(--green); }

/* ---------- Join screen ---------- */
.join-wrap { max-width: 420px; margin: 40px auto; text-align: center; }
.join-logo {
  width: 84px; height: 84px;
  border-radius: 22px;
  background: white;
  padding: 12px;
  object-fit: contain;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.join-steps { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.join-hint { color: var(--ink-soft); font-size: 15px; margin-top: 10px; }
.pin-dots { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }
.pin-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--green-soft); background: white; }
.pin-dot.filled { background: var(--green); border-color: var(--green); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.keypad button { min-height: 64px; font-size: 24px; font-weight: 800; border-radius: 16px; background: white; box-shadow: var(--shadow); color: var(--green-dark); }
.keypad button:active { transform: scale(0.94); }

/* ---------- Pupil home ---------- */
.hello-banner { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 24px; color: white; flex-shrink: 0;
  box-shadow: var(--shadow);
}
.hello-name { font-size: 26px; }
.streak-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--amber-pale); color: #8a5a05;
  padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: 15px; margin-top: 4px;
}

.section-title { font-size: 17px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-soft); margin: 24px 0 10px; font-weight: 800; }

.hw-card { background: linear-gradient(120deg, var(--green-dark), var(--green) 60%, var(--teal)); color: white; border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.hw-card::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(circle, rgba(255,255,255,0.12) 2px, transparent 2px); background-size: 22px 22px; pointer-events: none; }
.hw-card-top { display: flex; justify-content: space-between; align-items: flex-start; position: relative; z-index: 1; }
.hw-due { font-size: 13px; opacity: 0.9; font-weight: 700; }
.hw-lo { font-size: 21px; margin-top: 4px; }
.hw-points-note { position: relative; z-index: 1; margin-top: 8px; font-weight: 800; font-size: 15px; }
.hw-points { font-family: 'Baloo 2', sans-serif; font-size: 24px; color: var(--green-dark); margin-top: 8px; }
.progress-track { height: 12px; background: rgba(255,255,255,0.3); border-radius: 999px; margin-top: 16px; overflow: hidden; position: relative; z-index: 1; }
.progress-fill { height: 100%; background: white; border-radius: 999px; transition: width 0.3s ease; }
.hw-card .btn-primary { background: white; color: var(--green-dark); margin-top: 16px; box-shadow: 0 6px 16px rgba(0,0,0,0.2); }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.tile {
  background: white; border-radius: var(--radius); padding: 18px; text-align: left; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px; border: 2px solid transparent;
}
.tile:active { transform: scale(0.97); }
.tile-emoji { font-size: 30px; }
.tile-title { font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 17px; }
.tile-sub { font-size: 13px; color: var(--ink-soft); }
.tile-maths { border-color: var(--green-soft); }
.tile-spag { border-color: var(--purple); }
.tile-reading { border-color: var(--teal); }
.tile-challenge { border-color: var(--amber); }
.tile-spelling { border-color: var(--purple); }
.tile-points { margin-top: auto; font-weight: 800; font-size: 13px; color: var(--green-dark); }

.leaderboard-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--green-pale); }
.leaderboard-row:last-child { border-bottom: none; }
.lb-rank { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 20px; width: 28px; color: var(--ink-soft); }
.lb-rank.gold { color: #c9960c; }
.lb-name { flex: 1; font-weight: 700; }
.lb-points { font-weight: 800; color: var(--green-dark); }

/* ---------- Homework player ---------- */
.q-progress { display: flex; gap: 6px; margin-bottom: 18px; }
.q-dot { flex: 1; height: 8px; border-radius: 999px; background: var(--green-pale); }
.q-dot.done { background: var(--green); }
.q-dot.current { background: var(--amber); }
.q-prompt { font-size: 22px; font-weight: 800; margin-bottom: 16px; line-height: 1.4; }
.q-visual { display: flex; gap: 18px; align-items: flex-end; margin: 16px 0; flex-wrap: wrap; }
.pv-group { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pv-label { font-size: 12px; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; }
.pv-plus { align-self: center; font-size: 36px; font-weight: 800; color: var(--ink); padding: 0 6px; }
.pv-rod { width: 20px; height: 90px; background: linear-gradient(180deg, #ffe27a, #f0c93a); border: 2px solid #d4ab1f; border-radius: 4px; }
.pv-ones-grid { display: grid; grid-template-columns: repeat(5, 16px); gap: 4px; }
.pv-one { width: 16px; height: 16px; background: var(--red); border: 2px solid var(--red-dark); border-radius: 3px; }
.pv-rods-row { display: flex; gap: 4px; }

/* Hundreds flat — a 10x10 base-10 square. Green matches the hundreds
   colour used on the classroom place-value anchor charts. */
.pv-flat {
  width: 64px;
  height: 64px;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.18) 0 1px, transparent 1px 6.4px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.18) 0 1px, transparent 1px 6.4px),
    linear-gradient(160deg, #3fbd87, #00714a);
  border: 2px solid #00563a;
  border-radius: 4px;
}
/* Four flats per row: fits a 375px phone once card padding is taken off. */
.pv-flats-row { display: flex; gap: 5px; flex-wrap: wrap; max-width: 292px; }

/* Spot the mistake — the text sits on a page-like card so it reads as a piece
   of writing being proofread, not as a question. */
.error-text {
  background: #fffdf7;
  border: 2px solid var(--green-soft);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 18px;
  font-size: 19px;
  line-height: 1.75;
  color: #2a2620;
}
.err-span {
  background: #ffd9d6;
  color: var(--red-dark);
  font-weight: 800;
  border-bottom: 3px solid var(--red);
  border-radius: 4px;
  padding: 1px 3px;
}
.corrected-box {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--green-pale);
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.6;
}
.corrected-label { font-weight: 800; color: var(--green-dark); }

.opt-list { display: flex; flex-direction: column; gap: 12px; }
.opt-btn {
  min-height: var(--tap-min); border-radius: 16px; border: 2px solid var(--green-soft); background: white;
  font-size: 19px; font-weight: 700; padding: 14px 18px; text-align: left; color: var(--ink);
}
.opt-btn:active { transform: scale(0.98); }
.opt-btn.correct { background: var(--green-pale); border-color: var(--green); color: var(--green-dark); }
.opt-btn.incorrect { background: var(--red-pale); border-color: var(--red); color: var(--red-dark); }
.opt-btn.dim { opacity: 0.5; }

.feedback-box { margin-top: 18px; padding: 16px 18px; border-radius: 16px; font-size: 16px; line-height: 1.5; }
.feedback-box.correct { background: var(--green-pale); border: 2px solid var(--green-soft); color: var(--ink); }
.feedback-box.incorrect { background: var(--red-pale); border: 2px solid #f0b8b5; color: var(--ink); }
.feedback-label { font-weight: 800; font-family: 'Baloo 2', sans-serif; font-size: 17px; display: block; margin-bottom: 4px; }
.feedback-label.correct { color: var(--green-dark); }
.feedback-label.incorrect { color: var(--red-dark); }

.score-hero { text-align: center; padding: 20px 0; }
.score-num { font-family: 'Baloo 2', sans-serif; font-size: 64px; color: var(--green-dark); }
.score-msg { font-size: 19px; font-weight: 700; margin-top: 6px; }

.confetti-piece { position: fixed; top: -20px; z-index: 50; pointer-events: none; border-radius: 2px; animation: confetti-fall linear forwards; }
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(600deg); opacity: 0.9; }
}

/* ---------- Daily practice ---------- */
.topic-chip {
  display: inline-block;
  background: var(--green-pale);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.points-earned {
  margin-top: 10px;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--amber);
}
.promo-box {
  margin-top: 14px;
  background: var(--amber-pale);
  color: #8a5a05;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 800;
  font-size: 16px;
}

/* Reading — soft page feel, generous line height for young readers */
.reader { background: #fffdf7; }
.reader-body {
  margin-top: 14px;
  font-size: 19px;
  line-height: 1.75;
  color: #2a2620;
  max-width: 62ch;
}
.reader-body p { margin: 0 0 16px; white-space: pre-line; } /* keeps poem lines, numbered steps and letter sign-offs on their own lines */

/* ---------- Teacher dashboard ---------- */
.roster-table { width: 100%; border-collapse: collapse; }
.roster-table th { text-align: left; font-size: 13px; text-transform: uppercase; color: var(--ink-soft); padding: 8px 10px; border-bottom: 2px solid var(--green-pale); }
.roster-table td { padding: 10px; border-bottom: 1px solid var(--green-pale); font-size: 15px; }
.status-pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status-done { background: var(--green-pale); color: var(--green-dark); }
.status-pending { background: var(--amber-pale); color: #8a5a05; }
.status-flag { background: var(--red-pale); color: var(--red-dark); }

/* ---------- Library ---------- */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.book-card {
  display: flex; gap: 14px; text-align: left;
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px;
  border: 2px solid transparent;
}
.book-card:active { transform: scale(0.98); }
.book-cover {
  width: 72px; height: 96px; flex-shrink: 0;
  border-radius: 8px; overflow: hidden;
  background: var(--green-pale);
  box-shadow: 2px 2px 8px rgba(0,60,40,0.18);
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-meta { flex: 1; min-width: 0; }
.book-title { font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 17px; }
.book-blurb {
  font-size: 13px; color: var(--ink-soft); line-height: 1.4; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.book-status { font-size: 12px; font-weight: 800; color: var(--green-dark); margin-top: 6px; }
.book-progress { height: 7px; margin-top: 6px; background: var(--green-pale); }

.book-intro { text-align: center; }
.book-cover-lg {
  width: 150px; height: 200px; margin: 0 auto 16px;
  border-radius: 10px; overflow: hidden;
  background: var(--green-pale);
  box-shadow: 4px 6px 20px rgba(0,60,40,0.28);
}
.book-cover-lg img { width: 100%; height: 100%; object-fit: cover; }
.book-blurb-lg { font-size: 16px; color: var(--ink-soft); max-width: 46ch; margin: 0 auto; }

.level-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.level-btn {
  flex: 1; min-width: 96px;
  background: var(--green-pale); border: 3px solid transparent;
  border-radius: 16px; padding: 14px 10px;
  display: flex; flex-direction: column; gap: 3px;
}
.level-btn.chosen { border-color: var(--green); background: white; box-shadow: var(--shadow); }
.level-name { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 17px; color: var(--green-dark); }
.level-hint { font-size: 12px; color: var(--ink-soft); }

/* Trophy shelf — book spines standing on a wooden ledge */
.trophy-shelf {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end;
  padding: 16px 12px 10px;
  border-bottom: 8px solid #c89b63;
  border-radius: 4px;
  background: linear-gradient(180deg, transparent 60%, rgba(200,155,99,0.10));
}
.trophy {
  position: relative;
  width: 38px; height: 108px;
  border-radius: 3px 3px 2px 2px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 2px 2px 6px rgba(0,60,40,0.22);
}
.trophy-earned { background: linear-gradient(160deg, var(--green), var(--green-dark)); }
.trophy-own { background: linear-gradient(160deg, var(--teal), #2a7f7e); }
.trophy-spine {
  writing-mode: vertical-rl; transform: rotate(180deg);
  color: white; font-weight: 800; font-size: 11px;
  white-space: nowrap; overflow: hidden;
  /* Leave the bottom clear so a long title never runs into the ⭐ badge. */
  max-height: 76px;
  margin-bottom: 16px;
}
.trophy-badge { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 11px; }
.trophy-remove {
  position: absolute; top: 2px; right: 2px;
  width: 16px; height: 16px; line-height: 1;
  border-radius: 50%; background: rgba(0,0,0,0.3); color: white;
  font-size: 12px; font-weight: 800; padding: 0;
}

/* ---------- The reader ---------- */
.reader-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.reader-chapter { font-size: 13px; font-weight: 800; color: var(--ink-soft); }

/* ---------- The book ----------
   A turning page is two leaves: the one you are reading sits on top and
   rotates away on its spine edge, uncovering the leaf beneath. Perspective on
   the stage is what stops it looking like a flat slide. */
.book-stage {
  position: relative;
  perspective: 1500px;
  perspective-origin: 0% 50%;
  height: min(62vh, 560px);
  margin-top: 8px;
}
/* A hint of the rest of the book, stacked behind the page. */
.book-spine {
  position: absolute;
  left: -5px; top: 6px; bottom: 6px; width: 14px;
  background: linear-gradient(90deg, #d8c9a6, #efe4c9);
  border-radius: 5px 0 0 5px;
  box-shadow: inset -3px 0 6px rgba(120,90,40,0.22);
}
.leaf {
  position: absolute;
  inset: 0;
  border-radius: 4px 14px 14px 4px;
  transform-style: preserve-3d;
}
.leaf-under { opacity: 0; }
.leaf-under.visible { opacity: 1; }
.leaf-top {
  transform-origin: left center;
  transform: rotateY(0deg);
  will-change: transform;
  z-index: 2;
}
.leaf-top.instant, .leaf-top.instant .leaf-shade { transition: none !important; animation: none !important; }

/* Both faces of the leaf, plus the page beneath, share the paper look. */
.leaf-face, .leaf-under {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  background: #fdf8ec;
  border-radius: 4px 14px 14px 4px;
  border-left: 5px solid #e6d9bd;
  box-shadow: 0 10px 28px rgba(60,40,10,0.18), inset 14px 0 22px -14px rgba(120,90,40,0.30);
  padding: 22px 22px 12px;
  overflow: hidden;
}
/* The reverse of the leaf — blank paper, mirrored so it faces outward. */
.leaf-back { transform: rotateY(180deg); background: #f7f0df; }

/* Fakes the light falling across a curved sheet, so the flat plane reads as
   a bending page rather than a rotating card. */
.leaf-curve {
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: 4px 14px 14px 4px;
  background: linear-gradient(90deg,
    rgba(120,90,40,0.16) 0%, rgba(120,90,40,0.04) 7%,
    rgba(255,255,255,0) 22%, rgba(255,255,255,0) 78%,
    rgba(255,255,255,0.5) 96%, rgba(255,255,255,0.7) 100%);
}
/* Darkens as the leaf lifts, the way a real page shades as it comes up. */
.leaf-shade {
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: 4px 14px 14px 4px;
  background: linear-gradient(90deg, rgba(40,25,5,0.45), rgba(40,25,5,0.06));
  opacity: 0;
}

.leaf-top.turn-forward { animation: leaf-forward 0.62s cubic-bezier(.42,.02,.36,1) forwards; }
.leaf-top.turn-forward .leaf-shade { animation: shade-in 0.62s ease-in forwards; }
.leaf-top.turn-back { animation: leaf-back 0.62s cubic-bezier(.42,.02,.36,1) forwards; }
.leaf-top.turn-back .leaf-shade { animation: shade-out 0.62s ease-out forwards; }
.leaf-top.turned { transform: rotateY(-178deg); }

@keyframes leaf-forward {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(-178deg); }
}
@keyframes leaf-back {
  from { transform: rotateY(-178deg); }
  to   { transform: rotateY(0deg); }
}
@keyframes shade-in  { from { opacity: 0; } 60% { opacity: 0.85; } to { opacity: 0; } }
@keyframes shade-out { from { opacity: 0; } 40% { opacity: 0.85; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .leaf-top.turn-forward, .leaf-top.turn-back { animation-duration: 0.01s; }
  .leaf-shade { display: none; }
}

.page-text {
  position: relative;
  z-index: 2;
  height: calc(100% - 34px);
  overflow: hidden;
  font-size: 19px;
  line-height: 1.78;
  color: #2f2a20;
  max-width: 60ch;
  margin: 0 auto;
}
.page-text p { margin: 0 0 15px; }
.page-text h3 { font-size: 20px; margin: 0 0 12px; color: var(--green-dark); }
.page-num {
  position: absolute; bottom: 10px; left: 0; right: 0;
  text-align: center; font-size: 12px; font-weight: 700; color: #a8977a;
}
.reader-controls { display: flex; gap: 12px; margin-top: 14px; }
.reader-controls .btn { flex: 1; }

@media (max-width: 480px) {
  .book-stage { height: min(58vh, 460px); }
  .page-text { font-size: 18px; line-height: 1.7; }
}

/* ---------- Profile ---------- */
.profile-hero { text-align: center; padding: 8px 0 4px; }
.profile-hero h1 { margin-top: 12px; }
.avatar-xl {
  width: 96px; height: 96px;
  font-size: 40px;
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
}

.stat-row { display: flex; gap: 12px; margin-top: 20px; }
.stat {
  flex: 1;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 10px;
  text-align: center;
}
.stat-num { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 30px; color: var(--green-dark); }
.stat-label { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--ink-soft); letter-spacing: 0.4px; }

.swatch-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.swatch {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: var(--shadow);
}
.swatch.chosen { border-color: var(--ink); transform: scale(1.08); }

.char-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)); gap: 10px; margin-top: 10px; }
.char {
  min-height: 56px;
  border-radius: 16px;
  background: var(--green-pale);
  font-size: 26px;
  font-weight: 800;
  font-family: 'Baloo 2', sans-serif;
  color: var(--green-dark);
  border: 3px solid transparent;
}
.char.chosen { border-color: var(--green); background: white; }

.profile-line { margin: 6px 0; font-size: 16px; }
.pill-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pill { padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 800; }
.pill-good { background: var(--green-pale); color: var(--green-dark); }
.pill-work { background: var(--amber-pale); color: #8a5a05; }

.topic-toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.topic-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--green-pale);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.topic-toggle input { width: 20px; height: 20px; accent-color: var(--green); flex-shrink: 0; }
.taught-when {
  display: block;
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 1px;
}

.bottom-nav {
  position: sticky; bottom: 0; z-index: 5; display: flex; background: white; box-shadow: 0 -4px 16px rgba(0,60,40,0.10);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 14px; color: var(--ink-soft); font-size: 11px; font-weight: 800; background: transparent; }
.nav-btn.active { color: var(--green-dark); background: var(--green-pale); }
.nav-emoji { font-size: 20px; }

@media (max-width: 480px) {
  h1 { font-size: 25px; }
  .score-num { font-size: 52px; }
}

/* ---------- Read aloud & sound ---------- */
.speak-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--green-pale); color: var(--green-dark);
  border-radius: 999px; padding: 9px 18px;
  font-weight: 800; font-size: 15px; font-family: 'Baloo 2', sans-serif;
  margin-bottom: 14px;
  min-height: 44px;
}
.speak-btn:active { transform: scale(0.96); }
/* In the reader the button floats over the page rather than pushing text. */
/* On a book page the button sits in the corner so it does not break the
   reading column — but it needs a border to read as a control, not decoration. */
.leaf-front .speak-btn {
  position: absolute; bottom: 10px; right: 14px;
  margin: 0; padding: 8px 16px; font-size: 14px; min-height: 40px;
  z-index: 3;
  background: white;
  border: 2px solid var(--green-soft);
  box-shadow: 0 2px 8px rgba(60,40,10,0.14);
}

.toggle-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 4px; cursor: pointer;
}
.toggle-row + .toggle-row { border-top: 1px solid var(--green-pale); }
.toggle-row input { width: 24px; height: 24px; accent-color: var(--green); flex-shrink: 0; }
.toggle-row span { font-size: 16px; }

/* ---------- Questions to reteach ---------- */
.reteach-list { margin-top: 12px; }
.reteach-row {
  border-left: 4px solid var(--red);
  background: var(--red-pale);
  border-radius: 0 12px 12px 0;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.reteach-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reteach-q { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 17px; color: var(--red-dark); }
.reteach-pct { font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.reteach-pct.high { color: var(--red-dark); }
.reteach-prompt { font-size: 15px; margin-top: 6px; line-height: 1.45; }
.reteach-ans { font-size: 14px; margin-top: 6px; color: var(--green-dark); }
.reteach-names { font-size: 13px; color: var(--ink-soft); margin-top: 6px; font-style: italic; }

/* Countdown bar on the Next button when a correct answer will auto-advance. */
.autobar {
  position: absolute; left: 0; bottom: 0; height: 4px;
  width: 100%; transform-origin: left center;
  background: var(--green);
  border-radius: 0 0 999px 999px;
  animation: autobar 3s linear forwards;
}
#nextBtn { position: relative; overflow: hidden; }
@keyframes autobar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .autobar { display: none; } }

/* ---------- Big-screen leaderboard ----------
   Sized in vmin so one stylesheet serves the classroom projector, the
   teacher's laptop and an iPad held up to the class. */
body.display-mode { overflow: hidden; }
body.display-mode .topbar,
body.display-mode .zigzag-edge,
body.display-mode .bottom-nav { display: none !important; }

.lb-display {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  padding: 2.4vmin 3vmin 1.4vmin; background: var(--bg); z-index: 40; cursor: pointer;
  overflow: hidden;
}
.lb-top { text-align: center; }
.lb-title { font-family: 'Baloo 2', system-ui, sans-serif; font-weight: 800;
  font-size: 7.4vmin; line-height: 1.05; color: var(--green-dark); }
.lb-week { font-size: 2.3vmin; font-weight: 700; color: var(--ink-soft); margin-top: 0.6vmin; }

.lb-podium { display: flex; align-items: flex-end; justify-content: center;
  gap: 3vmin; width: 100%; flex: 1; min-height: 0; padding: 1.6vmin 0; }
.lb-col { display: flex; flex-direction: column; align-items: center; width: 22vw;
  opacity: 0; transform: translateY(6vmin) scale(0.94);
  transition: opacity .5s ease, transform .55s cubic-bezier(.22,1.4,.36,1); }
.lb-col.shown { opacity: 1; transform: none; }

.lb-card { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 2.4vmin 1.6vmin; width: 100%; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1vmin; }
.lb-medal { font-size: 7.2vmin; line-height: 1; }
.lb-avatar { width: 14vmin !important; height: 14vmin !important; font-size: 7.2vmin !important; }
.lb-name { font-family: 'Baloo 2', system-ui, sans-serif; font-weight: 800;
  font-size: 4.2vmin; color: var(--ink); line-height: 1.1; }
.lb-points { font-size: 2.7vmin; font-weight: 700; color: var(--ink-soft); }
.lb-points .n { font-size: 4.4vmin; color: var(--green-dark); display: inline-block; }
.lb-points .n.bump { animation: lb-bump .5s ease; }
@keyframes lb-bump { 40% { transform: scale(1.35); color: var(--amber); } }
.lb-card.lb-empty { opacity: .55; }

.lb-plinth { width: 88%; border-radius: 1.4vmin 1.4vmin 0 0; margin-top: 1.2vmin;
  display: flex; align-items: flex-start; justify-content: center;
  font-family: 'Baloo 2', system-ui, sans-serif; font-weight: 800; color: #fff;
  font-size: 4vmin; padding-top: 1vmin; }
.lb-p1 .lb-plinth { height: 23vmin; background: linear-gradient(180deg, var(--amber) 0%, #c8871a 100%); }
.lb-p2 .lb-plinth { height: 16vmin; background: linear-gradient(180deg, #b9c6c1 0%, #93a49e 100%); }
.lb-p3 .lb-plinth { height: 11vmin; background: linear-gradient(180deg, #d09a6a 0%, #a9764b 100%); }
.lb-p1 .lb-card { border: 0.5vmin solid var(--amber); }

.lb-foot { text-align: center; }
.lb-total { font-size: 3.1vmin; font-weight: 700; color: var(--ink); }
.lb-total b { color: var(--green-dark); font-size: 4.2vmin; }
.lb-cue { font-size: 2.9vmin; font-weight: 800; color: var(--green-dark);
  margin-top: 0.6vmin; min-height: 3.4vmin; animation: lb-pulse 1.8s ease-in-out infinite; }
@keyframes lb-pulse { 50% { opacity: .45; } }

.lb-controls { display: flex; gap: 1.2vmin; margin-top: 0.7vmin; cursor: auto; flex: none; }
.lb-controls .btn { font-size: 1.9vmin; padding: 1vmin 2vmin; min-height: 0; }

@media (orientation: portrait) {
  .lb-podium { gap: 2vw; }
  .lb-col { width: 29vw; }
}


/* ---------- Spelling practice ---------- */
.spell-hear { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.spell-hear .btn { flex: 1; min-width: 140px; }
.spell-input {
  width: 100%; text-align: center; letter-spacing: 0.06em;
  /* A spelling box must never be "helped": iPad autocorrect would quietly fix
     the very mistake we are trying to see. */
  text-transform: none;
}
.spell-input::placeholder { letter-spacing: normal; font-weight: 600; opacity: .45; }
.spell-input.spell-right { border-color: var(--green); background: var(--green-pale); }
.spell-input.spell-wrong { border-color: var(--red); background: var(--red-pale); }

.spell-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.spell-word { display: flex; align-items: center; gap: 8px; justify-content: center;
  padding: 14px 10px; min-height: var(--tap-min); border-radius: var(--radius);
  border: 2px solid var(--purple); background: #fff; font: 800 20px/1.1 'Nunito', system-ui, sans-serif;
  color: var(--ink); cursor: pointer; }
.spell-word:active { transform: scale(0.97); }
.hw-card.hw-late { border-color: var(--amber); margin-top: 10px; }

/* ---------- Phonics support ---------- */
.phonics-title { font-family: 'Baloo 2', system-ui, sans-serif; font-size: 26px; margin: 10px 0 12px; }
.phonics-text { font-size: 26px; line-height: 1.9; letter-spacing: 0.02em; margin-top: 14px; }
.phonics-text p { margin: 0 0 16px; }
.text-emoji { font-size: 64px; line-height: 1; text-align: center; margin: 8px 0 0; }
.opt-list .opt-btn { font-size: 20px; }
.build-slots { display: flex; gap: 8px; justify-content: center; margin: 6px 0 16px; flex-wrap: wrap; }
.build-slot { min-width: 46px; height: 58px; border-bottom: 4px solid var(--green-soft);
  display: flex; align-items: center; justify-content: center;
  font: 800 30px/1 'Nunito', system-ui, sans-serif; color: var(--ink); }
.build-tiles { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.build-tile { min-width: 56px; min-height: 56px; border-radius: 14px; border: 2px solid var(--purple);
  background: #fff; font: 800 26px/1 'Nunito', system-ui, sans-serif; color: var(--ink); cursor: pointer; }
.build-tile:disabled { opacity: .3; }

/* Ten frame for early counting */
.ten-frame { display: grid; grid-template-columns: repeat(5, 54px); grid-template-rows: repeat(2, 54px);
  border: 3px solid var(--ink); border-radius: 8px; overflow: hidden; margin: 6px auto; width: max-content; }
.tf-cell { border: 1.5px solid var(--ink-soft); display: flex; align-items: center; justify-content: center; background: #fff; }
.tf-dot { width: 38px; height: 38px; border-radius: 50%; background: var(--red); }
.tf-dot-b { background: #2f6fd6; }
/* Number line: one mark per number, each number directly under its mark. */
.num-line { display: block; width: 100%; max-width: 720px; height: auto; margin: 6px auto 0; overflow: visible; }
.num-line .nl-axis, .num-line .nl-tick { stroke: var(--ink-soft); stroke-width: 3; stroke-linecap: round; }
.num-line .nl-num { font-family: 'Nunito', system-ui, sans-serif; font-weight: 700; fill: var(--ink); }
.num-line .nl-q { fill: var(--red); font-weight: 800; }
.num-line .nl-arrow { fill: var(--red); }
.cmp-row { display: flex; gap: 26px; justify-content: center; align-items: flex-end; flex-wrap: wrap; }
.cmp-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cmp-num { font-size: 30px; font-weight: 800; }
.cmp-blocks { display: flex; gap: 8px; align-items: flex-end; }
.tf-gone { position: relative; background: #f3c4c4; }
.tf-gone::before, .tf-gone::after { content: ''; position: absolute; left: -4px; right: -4px; top: 50%; height: 5px; margin-top: -2.5px; background: #222; border-radius: 3px; transform: rotate(45deg); }
.tf-gone::after { transform: rotate(-45deg); }
.support-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.support-name { min-width: 110px; font-weight: 800; }
.support-maths { font-size: 13px; color: var(--ink-soft); display: inline-flex; gap: 4px; align-items: center; }

/* Decoding: the word with sound buttons, as marked in class */
.decode-word { display: flex; justify-content: center; gap: 6px; margin: 10px 0 6px; flex-wrap: wrap; }
.decode-g { background: none; border: none; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 6px; padding: 4px 6px; }
.decode-g:disabled { cursor: default; }
.decode-letters { font: 800 54px/1 'Nunito', system-ui, sans-serif; color: var(--ink); }
.sb-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); }
.sb-dash { width: 100%; min-width: 34px; height: 6px; border-radius: 3px; background: var(--red); }
.decode-choices { display: flex; gap: 10px; justify-content: center; }
.decode-choice { flex: 1; max-width: 160px; min-height: 64px; border-radius: 16px; border: 2px solid var(--green-soft);
  background: #fff; font: 800 22px/1 'Nunito', system-ui, sans-serif; cursor: pointer; }
.decode-choice.picked { border-color: var(--purple); background: #f3effb; }
.decode-choice.correct { border-color: var(--green); background: var(--green-pale); }
.decode-choice.incorrect { border-color: var(--red); background: var(--red-pale); }
.sounds-list h3 { margin: 14px 0 6px; }
.sound-row { display: grid; grid-template-columns: 80px 1fr auto auto 26px; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--green-pale); }
.sound-id { font: 800 26px/1 'Nunito', system-ui, sans-serif; }
.sound-hint { font-size: 14px; }
.sound-rec.recording { background: var(--red); color: #fff; }
.my-sounds { display: flex; flex-wrap: wrap; gap: 8px; }
.my-sound { min-width: 52px; height: 52px; border-radius: 12px; border: 2px solid var(--green-soft);
  background: #fff; font: 800 24px/1 'Nunito', system-ui, sans-serif; color: var(--ink-soft); cursor: pointer; }
.my-sound.new { border-color: var(--purple); color: var(--ink); background: #f3effb; }
.tile-locked { opacity: .5; }

.flag-low { color: var(--red); font-weight: 800; }


/* ---- Tap feedback ----
   Every tappable thing dips and dims the moment it is pressed, so a child
   knows the tap landed even when what happens next takes a second. */
.btn:active, .tile:active, .opt-btn:active, .book-card:active,
.keypad button:active, .spell-word:active, .char:active, .swatch:active {
  filter: brightness(0.93);
}
.btn:active { transform: scale(0.96); }
.tile:active, .book-card:active { transform: scale(0.97); }

/* Waiting for something to load: the control says so rather than looking dead. */
.is-busy { position: relative; pointer-events: none; opacity: 0.75; }
.is-busy::after {
  content: ''; position: absolute; right: 14px; top: 50%; width: 18px; height: 18px;
  margin-top: -9px; border: 3px solid rgba(0,0,0,0.15); border-top-color: var(--green, #00945e);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* A thin bar across the top whenever a screen is still loading. */
#loadbar {
  position: fixed; top: 0; left: 0; height: 4px; width: 0; z-index: 900;
  background: linear-gradient(90deg, #53d572, #00945e);
  transition: width 0.4s ease, opacity 0.3s ease; opacity: 0; pointer-events: none;
}
#loadbar.on { width: 85%; opacity: 1; transition: width 2.5s ease; }
#loadbar.done { width: 100%; opacity: 0; transition: width 0.2s ease, opacity 0.4s ease 0.1s; }

/* Teacher dashboard tabs */
.dash-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.dash-tab {
  background: white; border: 2px solid transparent; border-radius: 999px;
  padding: 10px 18px; font-size: 16px; font-weight: 700; color: var(--ink-soft);
  box-shadow: var(--shadow);
}
.dash-tab.chosen { color: var(--ink); border-color: var(--green, #00945e); }
.dash-panel > .card:first-child { margin-top: 10px; }

/* ---- Phonics lessons and the English builder ---- */
.pic-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 10px 0 4px; }
.pic-grid.small .pic-card { font-size: 44px; min-height: 76px; }
.pic-card { font-size: 64px; line-height: 1; min-height: 110px; border-radius: 20px; background: white;
  border: 3px solid var(--green-soft); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; }
.pic-card.picked { border-color: var(--green); background: var(--green-pale); transform: scale(1.04); }
.pic-card.correct { border-color: var(--green); background: var(--green-pale); }
.pic-card.incorrect { border-color: var(--red); background: var(--red-pale); }
.big-letter { display: block; margin: 6px auto 4px; min-width: 130px; padding: 4px 28px; font-size: 92px; line-height: 1.1;
  font-weight: 800; color: var(--green-dark); background: white; border: 3px solid var(--green-soft); border-radius: 24px; box-shadow: var(--shadow); }
.big-word { text-align: center; font-size: 46px; font-weight: 800; color: var(--green-dark); margin: 6px 0 2px; }
.q-picture { display: block; margin: 4px auto 8px; font-size: 96px; line-height: 1.1; background: none; border: 0; }
.letter-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 8px; }
.letter-choice { min-height: 96px; font-size: 54px; font-weight: 800; border-radius: 20px; background: white; color: var(--ink);
  border: 3px solid var(--green-soft); box-shadow: var(--shadow); }
.letter-choice.word { font-size: 24px; min-height: 76px; }
.letter-choice.picked { border-color: var(--green); background: var(--green-pale); }
.letter-choice.correct { border-color: var(--green); background: var(--green-pale); }
.letter-choice.incorrect { border-color: var(--red); background: var(--red-pale); }
.teach-card { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 6px 0 8px; }
.teach-letter { font-size: 110px; line-height: 1; font-weight: 800; color: var(--green-dark); background: white;
  border: 3px solid var(--green); border-radius: 26px; padding: 6px 30px; box-shadow: var(--shadow-lg); }
.teach-pic { display: flex; flex-direction: column; align-items: center; font-size: 84px; line-height: 1; background: none; border: 0; }
.teach-pic span { font-size: 20px; font-weight: 800; color: var(--green-dark); margin-top: 6px; }
.teach-tip { text-align: center; font-weight: 700; color: var(--green-dark); margin: 4px 0 10px; }
.sentence-line { min-height: 64px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; margin: 6px 0 12px;
  border: 2px dashed var(--green-soft); border-radius: 16px; background: var(--green-pale); font-size: 22px; font-weight: 700; }
.sentence-line .placed { background: white; border-radius: 10px; padding: 6px 10px; box-shadow: var(--shadow); }
.word-tiles { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.word-tile { min-height: var(--tap-min); padding: 8px 16px; font-size: 22px; font-weight: 700; border-radius: 14px; background: white;
  color: var(--ink); border: 2px solid var(--green-soft); box-shadow: var(--shadow); }
.word-tile:disabled { opacity: 0.3; }
.zh-btn { margin: 4px 0 4px auto; display: block; padding: 6px 14px; border-radius: 999px; border: 2px solid #f3b6b3;
  background: #fff5f4; color: var(--red-dark); font-weight: 800; font-size: 16px; }
.zh-text { text-align: center; font-size: 26px; font-weight: 700; color: var(--red-dark); margin: 2px 0 6px; }
.zh-sub { font-size: 16px; color: var(--ink-soft); font-weight: 700; }
.my-sound .pic { display: block; font-size: 22px; line-height: 1; margin-bottom: 2px; }
.my-sound.known { box-shadow: 0 0 0 3px var(--green-soft); }
.tile-lesson { grid-column: 1 / -1; border-color: var(--green); background: linear-gradient(120deg, #fffdf2, var(--green-pale)); }
.tile-lesson .tile-emoji { font-size: 44px; }
.rec-first { background: #fff8e1; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.sound-row.needed { background: #fff8e1; border-radius: 10px; }
.q-picture.tap-me { animation: tapme 1.2s ease-in-out infinite; }
@keyframes tapme { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.pic-card svg { max-width: 100%; height: auto; }

/* Spoken instructions: a speaker beside every phonics prompt. */
.prompt-say { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  width: 44px; height: 44px; margin-left: 6px; border-radius: 50%; border: 2px solid var(--green-soft);
  background: var(--green-pale); font-size: 22px; line-height: 1; cursor: pointer; }
.prompt-say:active { transform: scale(0.94); }
/* Sentences to read: big words, each one tappable for its sounds. */
.caption-ask { font-size: 18px; font-weight: 700; color: var(--ink-soft); margin: -8px 0 10px; }
.caption-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; margin: 6px 0 14px; }
.caption-word { font: 800 40px/1.15 'Nunito', system-ui, sans-serif; color: var(--ink); background: white;
  border: 2px solid var(--green-soft); border-radius: 14px; padding: 6px 12px; min-height: var(--tap-min, 44px); cursor: pointer; }
.caption-word:disabled { cursor: default; opacity: 1; }
.caption-word.correct { border-color: var(--green); background: var(--green-pale); }
.caption-word.incorrect { border-color: var(--red); background: var(--red-pale); }
/* The tricky part of a tricky word. */
.tricky-word mark { background: #ffe58a; color: inherit; border-radius: 4px; padding: 0 2px; }
/* A modelled blend on the teach card. */
.teach-blend-btn { display: flex; margin: 8px auto 0; font-size: 18px; }
/* The way to the next sounds, on the phonics hub. */
.journey { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.j-step { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%;
  background: #eef3f0; color: var(--ink-soft); font-weight: 800; font-size: 14px; }
.j-step.done { background: var(--green-pale); }
.j-step.here { background: var(--purple, #7a5cc4); color: #fff; box-shadow: 0 0 0 3px #e3daf6; }
.journey-msg { margin: 6px 0 2px; font-size: 16px; line-height: 1.45; }
.next-sounds { font: 800 18px/1 'Nunito', system-ui, sans-serif; color: var(--purple, #7a5cc4); letter-spacing: .04em; }

/* ---- Star practice: the look of a Star Reading test item ---- */
.star-bar { display: flex; justify-content: space-between; align-items: center; margin: 8px 2px 10px;
  font-weight: 800; color: var(--ink-soft); font-size: 15px; }
.star-clock { background: #fff; border: 2px solid var(--green-soft); border-radius: 999px; padding: 4px 12px;
  color: var(--ink); min-width: 74px; text-align: center; }
.star-clock.star-flash { border-color: var(--red); color: var(--red); animation: star-flash 1s steps(2, start) infinite; }
@keyframes star-flash { to { visibility: hidden; } }
.star-card { padding-top: 14px; }
.star-dir { font-size: 14px; color: var(--ink-soft); margin: 0 0 10px; font-weight: 700; }
.star-passage { background: #fffdf6; border: 1.5px solid #eee3c4; border-radius: 12px; padding: 12px 14px; margin: 0 0 12px;
  font-size: 19px; line-height: 1.55; }
.star-passage p { margin: 0 0 8px; }
.star-passage p:last-child { margin-bottom: 0; }
.star-passage .star-factbox { border: 2px solid #9cc3e6; background: #eef6fd; border-radius: 10px; padding: 8px 12px; margin-top: 10px; font-size: 17px; }
.star-factbox b { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: #2f6a9e; }
.star-q { font-size: 21px; font-weight: 700; line-height: 1.45; margin: 4px 0 14px; color: var(--ink); }
.star-q.small { font-size: 16px; margin: 6px 0; }
.star-blank { display: inline-block; min-width: 90px; border-bottom: 3px solid var(--ink); margin: 0 4px; }
.star-blank.filled { min-width: 0; padding: 0 6px; color: #1f5f99; font-weight: 800; }
.star-num { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--green-pale); color: var(--green-dark); font-weight: 800; font-size: 14px; margin-right: 8px; }
.star-opt.picked { border-color: var(--green); background: var(--green-pale); box-shadow: 0 0 0 2px var(--green) inset; }
.star-warn { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: #fdecea; color: var(--red); font-weight: 800; }
.star-review { border-top: 1px solid var(--green-pale); padding: 10px 0; font-size: 15px; line-height: 1.45; }
.star-review.miss { background: linear-gradient(90deg, #fff6f5, transparent); }
.star-review-top { display: flex; gap: 8px; align-items: baseline; }
.star-review details summary { cursor: pointer; color: var(--green-dark); font-weight: 700; margin: 4px 0; }
.star-review .star-passage { font-size: 15px; }

/* ---- Today's lessons: the class's lessons as iPad tasks, for a child on support ---- */
.lessons-card { background: #fff; border: 3px solid var(--amber); border-radius: var(--radius-lg); padding: 16px 18px;
  box-shadow: var(--shadow); margin: 0 0 6px; }
.lessons-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lessons-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 24px; flex: 1; line-height: 1.2; }
.lesson-rows { display: flex; flex-direction: column; gap: 10px; }
.lesson-row { display: flex; gap: 8px; align-items: stretch; }
.lr-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 10px 16px;
  border-radius: 18px; border: 2px solid var(--green-soft); background: #fff; text-align: left; box-shadow: var(--shadow); color: var(--ink); }
.lr-main:active { transform: scale(0.98); filter: brightness(0.95); }
.lesson-row.done .lr-main { background: var(--green-pale); border-color: var(--green); }
.lr-emoji { font-size: 40px; line-height: 1; flex-shrink: 0; }
.lr-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lr-subject { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); }
.lr-title { font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 19px; line-height: 1.2; }
.lr-mark { font-size: 28px; flex-shrink: 0; }
.lr-say { width: 62px; flex-shrink: 0; border-radius: 18px; border: 2px solid var(--green-soft); background: var(--green-pale); font-size: 26px; }
.lr-say:active, .lesson-line:active, .count-item:active, .lesson-pic:active { transform: scale(0.96); }
.lessons-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.lessons-week-link { font-size: 16px; min-height: 44px; padding: 8px 14px; }
.lessons-none { font-size: 20px; font-weight: 800; margin: 2px 0 12px; }
.lessons-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.lessons-day { margin-top: 18px; padding: 10px 10px 12px; border-radius: 16px; }
.lessons-day.today { background: #fffbea; }
.lessons-day.chosen { box-shadow: 0 0 0 3px var(--amber) inset; }
.lessons-dayname { font-weight: 800; font-size: 15px; color: var(--ink-soft); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .4px; }
.lessons-dash-day { margin-top: 5px; font-size: 13px; line-height: 1.9; }
.ldd-name { display: inline-block; width: 34px; font-weight: 800; color: var(--ink-soft); }

/* A step of a lesson */
.lesson-pic { display: flex; justify-content: center; align-items: center; margin: 2px auto 10px; padding: 0; background: none; border: 0;
  font-size: 96px; line-height: 1.1; max-width: 100%; color: var(--ink); }
.lesson-pic.wide { width: 100%; }
.lesson-pic .opt-emoji { font-size: 96px; line-height: 1.1; }
.lesson-intro .lesson-pic .opt-emoji { font-size: 120px; }
.lesson-pic .lesson-img { max-height: 240px; max-width: 100%; height: auto; display: block; }
.lesson-pic .opt-word { font-size: 34px; display: block; }
.lesson-lo { text-align: center; color: var(--ink-soft); font-size: 14px; margin: 0 0 6px; }
.lesson-sound { display: flex; margin: 0 auto 10px; }
.lesson-lines { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 6px; }
.lesson-line { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; border-radius: 16px;
  border: 2px solid var(--green-soft); background: #fff; font: 800 26px/1.3 'Nunito', system-ui, sans-serif; color: var(--ink); text-align: left; }
.ll-emoji { font-size: 36px; line-height: 1; }
.ll-text { flex: 1; }
.ll-say { font-size: 20px; opacity: .8; }
.lesson-opts.two { grid-template-columns: repeat(2, 1fr); }
.lesson-opt { flex-direction: column; gap: 6px; padding: 10px 6px; min-height: 120px; }
.lesson-opt .opt-emoji { font-size: 56px; line-height: 1; }
.opt-word { font: 800 22px/1.15 'Nunito', system-ui, sans-serif; color: var(--ink); text-align: center; }
.lesson-opt .lesson-img { max-width: 100%; max-height: 150px; height: auto; }
.lesson-opts.wide .lesson-opt svg { width: 100%; height: auto; }
.lesson-opt:disabled { opacity: 1; }
.silhouette { filter: brightness(0); opacity: .85; font-size: 64px; line-height: 1; }
.lesson-pic .silhouette { font-size: 96px; }
.glyph { height: 56px; width: auto; display: block; }
.glyph-card { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.glyph-letter { font: 800 20px/1 'Nunito', system-ui, sans-serif; color: var(--ink); }
.cartouche { position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 20px 20px;
  margin-bottom: 14px; border: 4px solid #b8860b; border-radius: 999px; background: #fffaf0; }
.cartouche::after { content: ''; position: absolute; left: 12%; right: 12%; bottom: -14px; height: 7px; background: #b8860b; border-radius: 4px; }
.cartouche .glyph { height: 46px; }
.lesson-word { font: 800 54px/1.1 'Nunito', system-ui, sans-serif; letter-spacing: .06em; color: var(--green-dark); }
.count-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: flex-end; margin: 8px 0; }
.count-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; min-width: 58px;
  border-radius: 14px; border: 3px dashed var(--green-soft); background: #fff; }
.count-item.counted { border-style: solid; border-color: var(--green); background: var(--green-pale); }
.count-num { font: 800 22px/1 'Nunito', system-ui, sans-serif; color: var(--green-dark); min-height: 22px; }
.count-emoji { font-size: 44px; line-height: 1; }
.lesson-slots .build-slot { min-width: 62px; height: 80px; }
.lesson-slots .build-slot.guide { color: #b7c4bf; font: 800 32px/1 'Nunito', system-ui, sans-serif; }
.lesson-slots .glyph { height: 44px; }
.lesson-slots .opt-emoji { font-size: 36px; line-height: 1; }
.lesson-slots .opt-word { font-size: 24px; }
.lesson-tile { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 12px; min-height: 64px; }
.lesson-tile .opt-emoji { font-size: 40px; line-height: 1; }
.lesson-tile.pic-tile { min-width: 84px; min-height: 84px; }
.lesson-tile.pic-tile .opt-emoji { font-size: 52px; }
.robot-wrap { display: flex; justify-content: center; margin: 4px 0 12px; }
.robot-svg { width: 100%; max-width: 380px; height: auto; display: block; }
.rb-sq { fill: #fff; stroke: #9aa8a3; stroke-width: 2; }
.rb-trail { fill: none; stroke: var(--amber); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.rb-emoji { font-size: 40px; }
.shadow-svg { width: 100%; max-width: 640px; height: auto; display: block; margin: 0 auto; }
.sh-light { fill: #fff1a8; opacity: .85; }
.sh-shade { fill: #39404d; opacity: .3; }
.sh-ray { stroke: #d49a17; stroke-width: 2; stroke-dasharray: 6 5; }
.sh-table { stroke: #8a6a3a; stroke-width: 6; stroke-linecap: round; }
.sh-wall { fill: #ece6d9; stroke: #b8b0a0; stroke-width: 1.5; }
.sh-on-wall { fill: #2b2f38; }
.sh-block { fill: #c98b4a; stroke: #8a5a2a; stroke-width: 2; }
.sh-torch { fill: #3b54a8; }
.sh-torch-head { fill: #7b93e0; }
.sh-sq { fill: #f4f0e6; stroke: #b0a894; stroke-width: 1.5; }
.sh-sq-dark { fill: #2b2f38; stroke: #555c68; }
.make-path { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 46px; margin: 6px 0 4px; }
.mp-arrow { font-size: 26px; color: var(--ink-soft); }
.lesson-adult { text-align: center; font-size: 13px; color: var(--ink-soft); margin: 4px 0; }
.lesson-done-btn { font-size: 22px; min-height: 68px; }
.tf-pair { justify-content: center; }
/* Counters to count go in rows of five, like a ten frame. */
.count-row.count-dot { display: grid; grid-template-columns: repeat(5, max-content); justify-content: center; }
.lesson-taps { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); }


/* ---------- Times tables: 60-second rounds ---------- */
.tile-tables { border-color: var(--blue); }
.tt-head .tt-rank { margin-bottom: 4px; }
.tt-rank { display: flex; align-items: center; gap: 12px; margin: 0; }
.tt-rank-icon { font-size: 34px; line-height: 1; }
.tt-stats { margin-top: 12px; }
.tt-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.tt-pick { background: white; border: 2px solid var(--blue-pale); border-radius: var(--radius); padding: 14px 12px; text-align: center; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-height: 84px; justify-content: center; }
.tt-pick.played { border-color: var(--blue); }
.tt-pick:active { transform: scale(0.96); }
.tt-pick-name { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 26px; color: var(--blue); line-height: 1.1; }
.tt-pick-best { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.tt-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; max-width: 560px; font-weight: 800; font-size: clamp(9px, 2.3vw, 13px); }
.tt-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 5px; }
.tt-cell.head { color: var(--ink-soft); }
.tt-cell.new { background: #eef2f1; color: #8a9590; }
.tt-cell.red { background: var(--red); color: #fff; }
.tt-cell.amber { background: #fcd34d; color: #3b2a00; }
.tt-cell.green { background: #bbf7d0; color: #14532d; }
.tt-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.tt-legend span { display: inline-flex; align-items: center; gap: 5px; }
.tt-legend i { width: 14px; height: 14px; display: inline-block; aspect-ratio: auto; }
.tt-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tt-chip { background: var(--blue-pale); color: var(--blue); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 14px; }
.tt-game { position: fixed; inset: 0; z-index: 50; display: flex; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(160deg, #0b4a34, #062f3a); color: #fff; touch-action: manipulation; user-select: none; -webkit-user-select: none; overflow-y: auto; }
.tt-inner { width: 100%; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.tt-top { display: flex; align-items: center; gap: 12px; }
.tt-close { width: 44px; height: 44px; border: 0; border-radius: 12px; background: rgba(255,255,255,0.18); color: #fff; font-size: 18px; }
.tt-secs { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 30px; min-width: 2em; text-align: center; font-variant-numeric: tabular-nums; }
.tt-secs.low { color: #fda4af; }
.tt-table { flex: 1; text-align: center; font-weight: 800; font-size: 15px; opacity: 0.9; }
.tt-score { min-width: 2.4em; text-align: center; background: var(--green-bright); color: #053726; font-weight: 900; font-size: 22px; border-radius: 12px; padding: 4px 12px; }
.tt-score.pop { animation: tt-pop 0.25s ease; }
@keyframes tt-pop { 50% { transform: scale(1.25); } }
.tt-bar { flex: none; height: 10px; border-radius: 99px; background: rgba(255,255,255,0.18); overflow: hidden; }
.tt-fill { height: 100%; width: 100%; border-radius: 99px; background: var(--green-bright); }
.tt-fill.low { background: #fb7185; }
.tt-q { flex: 1; min-height: 110px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: clamp(40px, 10vh, 76px); line-height: 1.15; }
.tt-ans { display: inline-block; min-width: 1.5em; border-bottom: 5px solid rgba(255,255,255,0.55); font-variant-numeric: tabular-nums; }
.tt-line.bad { color: #fda4af; }
.tt-count { font-size: 1.5em; color: var(--green-bright); }
.tt-note { font-size: 0.4em; font-weight: 700; }
.tt-pad { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tt-key { min-height: clamp(48px, 9.5vh, 78px); border: 0; border-radius: 16px; background: #fff; color: #053726; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: clamp(24px, 4.5vh, 34px); box-shadow: 0 4px 0 #86c9a8; }
.tt-key:active { transform: translateY(3px); box-shadow: 0 1px 0 #86c9a8; }
.tt-key.zero { grid-column: span 2; }
.tt-key.del { background: #e6f7ee; }
.tt-end .tt-inner { align-items: center; text-align: center; justify-content: center; min-height: min-content; }
.tt-end p { margin: 0; }
.tt-end .tt-table { flex: none; font-size: 17px; }
.tt-big { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 88px; line-height: 1; color: var(--green-bright); }
.tt-big-sub { font-weight: 800; font-size: 18px; }
.tt-banner { background: var(--green-bright); color: #053726; font-weight: 900; font-size: 20px; border-radius: 999px; padding: 8px 20px; }
.tt-banner.soft { background: rgba(255,255,255,0.18); color: #fff; font-weight: 700; font-size: 16px; }
.tt-end .tt-rank { justify-content: center; }
.tt-fix { width: 100%; color: var(--ink); text-align: left; }
.tt-fix h3 { margin: 0 0 8px; }
.tt-fix-list { display: flex; flex-wrap: wrap; gap: 6px 16px; font-weight: 800; }
.tt-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; margin-top: 6px; }
.tt-end .btn-ghost { color: #fff; }
