/* Reading practice, laid out for an iPad Air (834 x 1112 points) held either
   way: big type, 56px+ touch targets, no hover states, no scrolling while reading. */

/* Book print, never handwriting: the typefaces of children's reading books (js/reader/fonts.js). */
@font-face { font-family: 'Andika'; src: url('../fonts/andika.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'Lexend'; src: url('../fonts/lexend.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('../fonts/atkinson.woff2') format('woff2'); font-display: block; }

:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --ink: #1d2433;
  --muted: #5b6577;
  --line: #e4dfd4;
  --accent: #2f5fb3;
  --accent-soft: #e9effa;
  --heart: #e0457b;
  --right: #1f9d55;
  --wrong: #d64545;
  --helped: #fff1c9;
  --now: #c8dafb;
  --shadow: 0 1px 2px rgb(29 36 51 / 0.08), 0 8px 24px rgb(29 36 51 / 0.1);
  --ui: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --book: 'Andika', var(--ui);
  /* How far the font's descent reaches below its deepest tail (g j p q y), in em.
     Sound marks hang from the descent, so this lifts them back up under the tail. */
  --tail-gap: 0.152em;
}
:root[data-font="lexend"] { --book: 'Lexend', var(--ui); --tail-gap: 0.02em; }
:root[data-font="atkinson"] { --book: 'Atkinson Hyperlegible', var(--ui); --tail-gap: 0.098em; }

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body.reader {
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.4 var(--ui);
  overscroll-behavior: none;
  /* A book, not a document: no text selection or long-press menus. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

/* Beginners need clear gaps between words, as in their reading books. */
.bar-title, .book-title, .text, .question, .answer, .how-step, .how h2, .done h2 { word-spacing: 0.2em; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.message { grid-row: 1 / -1; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 24px; text-align: center; font-size: 22px; }

/* ---- Bars and buttons ---- */

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.bar-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: 400 32px/1.2 var(--book);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.round {
  flex: none;
  width: 56px;
  height: 56px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 26px;
  line-height: 1;
  text-decoration: none;
}

.round.spacer { visibility: hidden; }
.round:disabled { opacity: 0.3; }
.round.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.big-round { width: 92px; height: 92px; font-size: 54px; }
/* Listen is the button a child reaches for most, so it is the biggest one. */
.big.listen { min-height: 84px; padding: 0 40px; border-radius: 42px; font-size: 30px; }

.big {
  min-height: 64px;
  padding: 0 28px;
  border: 2px solid var(--line);
  border-radius: 32px;
  background: #fff;
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
}

.big.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Every tap shows at once: the button sinks and darkens while the finger is down. */
.round:active:not(:disabled), .big:active, .book-card:active, .answer:active:not(:disabled), .how-step:active,
.coach-say:active, .font-choice:active, .level-chip:active {
  transform: scale(0.93);
  filter: brightness(0.9);
}

/* While a tap's sound plays, its button stays lit and pulses, so the child waits for it. */
.big.saying, .round.saying, .coach-say.saying {
  border-color: var(--accent);
  background: var(--now);
  color: var(--ink);
  animation: saying 1s ease-in-out infinite;
}
@keyframes saying { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 22%, transparent); } }

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.controls.empty { padding: 0; border: 0; }
.middle { display: flex; align-items: center; gap: 24px; }
.dots { display: flex; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--accent); }

.coach { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--muted); font-size: 20px; font-weight: 600; }
.coach-say {
  flex: none;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  font-size: 22px;
}

/* ---- Shelf ---- */

.shelf { overflow-y: auto; padding: 0 24px 32px; }

/* The switch between the shelves (Stories, Science) stands in the bar where a title would be. */
.shelf-switch { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 10px; }
.shelf-switch button {
  height: 56px;
  padding: 0 22px;
  border: 2px solid var(--line);
  border-radius: 28px;
  background: #fff;
  font: 400 28px/1 var(--book);
  white-space: nowrap;
}
.shelf-switch button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.shelf-switch button:active { transform: scale(0.93); filter: brightness(0.9); }

/* The level buttons stay at the top while the shelf scrolls. */
.level-jump {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 -24px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.level-chip {
  min-width: 56px;
  height: 56px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 28px;
  background: #fff;
  font: 400 30px/1 var(--book);
}

.level-group { scroll-margin-top: 84px; }
.level-head { display: flex; align-items: baseline; gap: 14px; margin: 18px 4px 12px; }
.level-name { font: 400 36px/1.1 var(--book); }
.level-note { color: var(--muted); font-size: 18px; font-weight: 600; }

.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }

.book-card {
  position: relative;
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 10px 10px 14px;
  border: 0;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: left;
}

.book-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 14px; background: var(--accent-soft); }
.done-chip {
  position: absolute;
  top: 18px;
  right: 18px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--right);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}
.book-title { padding: 2px 4px 0; font: 400 28px/1.15 var(--book); }
.book-stars { padding: 0 4px; color: var(--muted); font-size: 16px; font-weight: 600; }

/* ---- Reading a page: picture above the text, or beside it when the iPad is landscape ---- */

.page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 16px 24px;
  touch-action: pan-y; /* horizontal swipes turn the page */
}

.page figure { flex: 1 1 auto; min-height: 140px; margin: 0; display: grid; place-items: center; }
.page figure img { width: 100%; height: 100%; object-fit: contain; }
.reading { flex: none; display: grid; gap: 4px; max-height: 100%; overflow-y: auto; }

/* The bottom padding leaves room for the marks under the last line. */
.text { margin: 0; padding-bottom: 0.1em; font: 400 var(--size, 44px)/2.2 var(--book); text-align: center; }
.level-a { --size: 58px; }
.level-b { --size: 52px; }
.level-c { --size: 44px; }
.level-d { --size: 40px; }
.level-e { --size: 36px; }
.level-f { --size: 34px; }
.level-g { --size: 32px; }
.level-h { --size: 30px; }
.level-k { --size: 29px; }
.level-l { --size: 28px; }
.level-m { --size: 27px; }
.level-n { --size: 26px; }
.level-o { --size: 25px; }
.level-p { --size: 24px; }

@media (orientation: landscape) {
  .page { flex-direction: row; align-items: center; gap: 28px; padding: 16px 28px; }
  .page figure { flex: 1 1 54%; height: 100%; }
  .reading { flex: 0 1 46%; }
  .text { text-align: left; }
}

/* A word is a button. First tap shows its sound buttons, second tap says it. */
.word {
  position: relative;
  display: inline-block;
  margin: 0;
  padding: 0 0.08em;
  border: 0;
  border-radius: 0.18em;
  background: transparent;
  font: inherit;
  line-height: 1.3;
}
.word:active { transform: scale(0.92); }
/* First tap: the word lifts into a soft box and its sound marks pop in. */
.text .word.sounds { background: var(--accent-soft); animation: word-tap 0.25s ease-out; }
@keyframes word-tap { 40% { transform: scale(1.12); } }
.text .word.helped { background: var(--helped); }
/* Being said (Listen, or the second tap): lit up until the voice moves on. */
.lit-word { border-radius: 0.2em; transition: background-color 0.1s; }
.lit-word.now { background: var(--now); box-shadow: inset 0 -0.07em var(--accent); }
.text .word.now, .word.saying, .text .word.saying { background: var(--now); box-shadow: inset 0 -0.07em var(--accent); }

/* Sound marks hang below the tails of g, j, p, q and y. .g and .split stay
   inline (not inline-block) so their marks are placed against the font's full
   height, ascent to descent, whatever the line height: top: 100% is the
   descent at every text size, and --tail-gap lifts the mark to just under the tail. */
.g, .split { position: relative; }

.sounds .g::after { position: absolute; left: 50%; transform: translateX(-50%); animation: mark-in 0.3s ease-out; }
.sounds .split::after { animation: mark-in 0.3s ease-out; }
@keyframes mark-in { from { scale: 0; opacity: 0; } }
.sounds .g[data-mark="dot"]::after {
  content: '';
  top: calc(100% + 0.055em - var(--tail-gap));
  width: 0.17em;
  height: 0.17em;
  border-radius: 50%;
  background: var(--accent);
}
.sounds .g[data-mark="bar"]::after {
  content: '';
  top: calc(100% + 0.085em - var(--tail-gap));
  width: 82%;
  height: 0.1em;
  border-radius: 0.05em;
  background: var(--accent);
}
.sounds .g[data-mark="heart"]::after {
  content: '♥';
  /* em here is the heart's own size, 0.42 of the letter's: divide to get back to letter em. */
  top: calc(100% + (0.066em - var(--tail-gap)) / 0.42);
  color: var(--heart);
  font: 700 0.42em/1 var(--ui);
}
.sounds .split::after {
  content: '';
  position: absolute;
  left: 0.12em;
  right: 0.12em;
  top: calc(100% + 0.225em - var(--tail-gap));
  height: 0.2em;
  border: 0.06em solid var(--accent);
  border-top: 0;
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
}

/* ---- Warm-up, questions, well done ---- */

.warmup, .done, .quiz {
  display: grid;
  /* "safe": when there is more than fits, it starts at the top and scrolls, rather than
     spilling off both ends where the top could never be reached. */
  align-content: safe center;
  justify-items: center;
  gap: 20px;
  padding: 24px;
  overflow-y: auto;
  text-align: center;
}

.warm-card {
  min-width: min(80vw, 520px);
  padding: 28px 48px 64px;
  border-radius: 28px;
  background: #fff;
  box-shadow: var(--shadow);
  font: 400 104px/1.3 var(--book);
}
.warm-count, .quiz-count { margin: 0; color: var(--muted); font-weight: 700; }

.quiz { justify-items: stretch; width: min(100%, 860px); margin: 0 auto; text-align: left; }
.question { display: flex; align-items: center; gap: 16px; margin: 0; font: 400 42px/1.25 var(--book); }
.options { display: grid; gap: 14px; }
.option { display: flex; align-items: center; gap: 12px; }
.answer {
  flex: 1;
  min-height: 80px;
  padding: 8px 24px;
  border: 3px solid var(--line);
  border-radius: 24px;
  background: #fff;
  font: 400 38px/1.2 var(--book);
  text-align: left;
}
.answer.right { border-color: var(--right); background: #e6f6ec; }
.answer.right::after { content: '  ✓'; color: var(--right); font-family: var(--ui); font-weight: 800; }
.answer.wrong { border-color: var(--wrong); opacity: 0.45; animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.star { font-size: 120px; line-height: 1; animation: pop 0.6s ease-out; }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } }
.done h2 { margin: 0; font: 400 56px/1.1 var(--book); }
.done-note { margin: 0; font-size: 22px; color: var(--muted); }
.practise { display: grid; justify-items: center; gap: 12px; }
.practise h3 { margin: 8px 0 0; font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.practise-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; font: 400 54px/2 var(--book); }
.practise-word { padding: 0 0.3em 0.15em; border-radius: 18px; background: #fff; box-shadow: var(--shadow); }

@media (prefers-reduced-motion: reduce) {
  .star, .answer.wrong, .saying, .text .word.sounds, .sounds .g::after, .sounds .split::after { animation: none; }
}

.debug-log {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 96px;
  z-index: 10;
  max-height: 34vh;
  margin: 0;
  padding: 8px 10px;
  overflow: auto;
  border-radius: 10px;
  background: rgb(0 0 0 / 0.8);
  color: #9ef0a8;
  font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  pointer-events: none;
}

/* ---- How I read ---- */

.how {
  width: min(92vw, 580px);
  padding: 28px;
  border: 0;
  border-radius: 28px;
  box-shadow: 0 20px 60px rgb(29 36 51 / 0.3);
}
.how::backdrop { background: rgb(29 36 51 / 0.45); }
.how h2 { margin: 0 0 14px; font: 400 44px/1.1 var(--book); text-align: center; }
.how ul { display: grid; gap: 10px; margin: 0 0 20px; padding: 0; list-style: none; }
.how-step {
  width: 100%;
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 18px;
  border: 0;
  border-radius: 20px;
  background: var(--accent-soft);
  font: 400 30px/1.2 var(--book);
  text-align: left;
}
.how-step.saying { background: var(--now); box-shadow: inset 0 0 0 3px var(--accent); }
.how-icon { flex: none; width: 48px; font: 34px/1 var(--ui); text-align: center; }
.how-text { flex: 1; }
.how-say { flex: none; font: 22px/1 var(--ui); opacity: 0.6; }
.how-icon.heart { color: var(--heart); font-weight: 800; }
.how .big { width: 100%; }

/* ---- Letters (font choice) ---- */

.font-choices { display: grid; gap: 10px; margin: 0 0 20px; }
.font-choice {
  display: grid;
  gap: 2px;
  min-height: 76px;
  padding: 10px 18px;
  border: 3px solid transparent;
  border-radius: 20px;
  background: var(--accent-soft);
  text-align: left;
}
.font-choice[aria-pressed="true"] { border-color: var(--accent); background: #fff; }
.font-sample { font-size: 34px; line-height: 1.25; word-spacing: 0.2em; }
.font-name { color: var(--muted); font-size: 16px; }
.font-name b { color: var(--ink); }
.font-choice[aria-pressed="true"] .font-name b::after { content: '  ✓'; color: var(--accent); }
.round.letters { font: 700 22px/1 var(--book); }

/* ---- Phones: held upright (narrow) or on their side (short) ---- */

@media (max-width: 600px), (max-height: 500px) {
  .bar { gap: 8px; padding: 8px 10px; }
  .bar .round.spacer { display: none; }
  .bar-title { font-size: 24px; }
  .round { width: 46px; height: 46px; font-size: 22px; }
  .round.letters { font-size: 18px; }
  .big-round { width: 64px; height: 64px; font-size: 38px; }
  .big { min-height: 52px; padding: 0 18px; font-size: 18px; }
  .big.listen { min-height: 64px; padding: 0 24px; font-size: 22px; }

  .controls { flex-wrap: wrap; justify-content: center; gap: 10px; padding: 8px 12px; }
  .controls > .big { flex: 1 1 auto; }
  .middle { flex: 1; min-width: 0; justify-content: center; gap: 10px; }
  .dots { flex-wrap: wrap; justify-content: center; gap: 5px; min-width: 0; }
  .dot { width: 9px; height: 9px; }
  .coach { gap: 8px; font-size: 16px; }
  .coach-say { width: 40px; height: 40px; font-size: 18px; }

  .shelf { padding: 0 14px 24px; }
  .shelf-switch button { height: 46px; padding: 0 14px; font-size: 20px; }
  .level-jump { flex-wrap: nowrap; gap: 8px; margin: 0 -14px; padding: 10px 14px; overflow-x: auto; scrollbar-width: none; }
  .level-chip { flex: none; }
  .level-chip { min-width: 46px; height: 46px; padding: 0 10px; font-size: 22px; }
  .level-group { scroll-margin-top: 70px; }
  .level-head { flex-wrap: wrap; gap: 4px 10px; margin: 14px 2px 10px; }
  .level-name { font-size: 28px; }
  .level-note { font-size: 15px; }
  .books { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .book-card { gap: 4px; padding: 8px 8px 10px; border-radius: 16px; }
  .book-card img { border-radius: 10px; }
  .done-chip { top: 12px; right: 12px; padding: 2px 8px; font-size: 13px; }
  .book-title { font-size: 20px; }
  .book-stars { font-size: 14px; }

  .page { gap: 8px; padding: 10px 14px; }
  .page figure { position: relative; min-height: 110px; }
  .page figure img { position: absolute; inset: 0; }
  .text { font-size: calc(var(--size, 44px) * 0.72); }

  .warmup, .done, .quiz { gap: 14px; padding: 16px 14px; }
  .warm-card { min-width: min(80vw, 420px); padding: 16px 24px 40px; font-size: 68px; }
  .question { gap: 10px; font-size: 28px; }
  .options { gap: 10px; }
  .answer { min-height: 60px; padding: 6px 16px; border-radius: 18px; font-size: 24px; }
  .star { font-size: 84px; }
  .done h2 { font-size: 38px; }
  .done-note { font-size: 18px; }
  .practise-words { gap: 6px 12px; font-size: 36px; }

  .how { width: min(94vw, 580px); max-height: 92dvh; padding: 18px; border-radius: 22px; }
  .how h2 { margin-bottom: 10px; font-size: 32px; }
  .how ul { gap: 8px; margin-bottom: 14px; }
  .how-step { min-height: 56px; gap: 10px; padding: 6px 12px; border-radius: 16px; font-size: 22px; }
  .how-icon { width: 36px; font-size: 26px; }
  .font-choice { min-height: 60px; padding: 8px 14px; }
  .font-sample { font-size: 26px; }
}

/* Upright phone: the shelf switch gets its own row under the bar. */
@media (max-width: 600px) {
  .bar:has(.shelf-switch) { flex-wrap: wrap; }
  .bar .shelf-switch { order: 1; flex: 1 1 100%; }
  .bar:has(.shelf-switch) > .round:first-child { margin-right: auto; }
}

/* Phone on its side: little height, so the bars get thin and the page text smaller. */
@media (max-height: 500px) {
  .bar { padding: 4px 10px; }
  .controls { padding: 4px 12px; }
  .page { padding: 6px 16px; gap: 16px; }
  .text { font-size: calc(var(--size, 44px) * 0.6); line-height: 2; }
  .warm-card { padding: 8px 24px 28px; font-size: 56px; }
  .star { font-size: 60px; }
}

/* ---- KidStudy: Kobi is the way home, waits while things load and cheers at the end ---- */

.bar a.round[href="./"] { font-size: 0; border-color: var(--ks-blue); background: var(--ks-blue) url('../icons/icon-192.png') center / cover; }
.message::before { content: ''; width: 150px; aspect-ratio: 582 / 640; background: url('../brand/kobi-main.webp') center / contain no-repeat; }
.done::before { content: ''; width: min(170px, 30vh); aspect-ratio: 586 / 640; background: url('../brand/kobi-cheer.webp') center / contain no-repeat; animation: pop 0.6s ease-out; }
@media (prefers-reduced-motion: reduce) { .done::before { animation: none; } }

/* iPad on its side: too short for everything in one column, so the cheer sits on the
   left and the words to practise on the right. */
@media (orientation: landscape) and (min-width: 601px) and (min-height: 501px) {
  .done:has(.practise) { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); grid-auto-flow: dense; column-gap: 40px; row-gap: 14px; }
  .done:has(.practise)::before, .done:has(.practise) > .star, .done:has(.practise) > h2, .done:has(.practise) > .done-note { grid-column: 1; }
  .done:has(.practise)::before { width: min(150px, 22vh); }
  .done:has(.practise) > .star { font-size: 84px; }
  .done > .practise { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  .done > .write-words { grid-column: 2; grid-row: 4; }
  .done .practise-words { font-size: 46px; }
}

/* ---- Phonics: the Ready mark, "Learning now", recording a page, writing the words ---- */

/* A book the child can read with the sounds of the set they are learning. */
.ready-chip {
  position: absolute;
  top: 18px;
  left: 18px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}
.ready-chip.inline { position: static; display: inline-block; padding: 1px 9px; font-size: 14px; }

/* For the grown-up, so in small print at the end of the level buttons. */
.learning-chip {
  flex: none;
  height: 56px;
  margin-left: auto;
  padding: 0 18px;
  border: 2px dashed var(--line);
  border-radius: 28px;
  background: #fff;
  color: var(--ink);
  font: 700 17px/1 var(--ui);
  white-space: nowrap;
}
.learning-label { color: var(--muted); font-weight: 600; }
.learning-chip:active { transform: scale(0.93); filter: brightness(0.9); }

.how.learning { width: min(94vw, 760px); max-height: 92dvh; overflow-y: auto; }
.learning-note { margin: 0 0 14px; color: var(--muted); font-size: 18px; text-align: center; }
.set-year h3 { margin: 14px 0 8px; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.set-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.set-choice {
  display: grid;
  gap: 2px;
  align-content: center;
  min-height: 64px;
  padding: 6px 10px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: var(--accent-soft);
  text-align: left;
}
.set-choice b { font-size: 16px; }
.set-sounds { font: 400 22px/1.15 var(--book); word-spacing: 0.15em; }
.set-choice[aria-pressed="true"] { border-color: var(--accent); background: #fff; }
.set-choice:active { transform: scale(0.95); }
.learning-actions { display: flex; gap: 12px; margin-top: 18px; }
.learning-actions .big { flex: 1; }

/* Record my reading, then hear it. */
.recording-controls { display: flex; gap: 12px; }
.round.record.on { border-color: var(--wrong); background: var(--wrong); color: #fff; animation: saying 1s ease-in-out infinite; }
.round.play-mine[hidden] { display: none; }
.big:disabled { opacity: 0.4; }

a.big { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; }
.write-words { margin-top: 4px; }

@media (max-width: 600px), (max-height: 500px) {
  .ready-chip { top: 12px; left: 12px; padding: 2px 8px; font-size: 13px; }
  .learning-chip { height: 46px; padding: 0 12px; font-size: 15px; }
  .recording-controls { gap: 8px; }
  .set-choices { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .set-sounds { font-size: 18px; }
}

/* Upright phone: the level buttons scroll sideways, so "Learning now" comes first,
   and the page dots get their own line above the buttons. */
@media (max-width: 600px) {
  .learning-chip { order: -1; margin-left: 0; }
  /* Three shelves only fit side by side without their pictures. */
  .shelf-switch { gap: 6px; }
  .shelf-switch button { min-width: 0; padding: 0 12px; }
  .shelf-switch:has(button:nth-child(3)) button > span { display: none; }
  .middle { flex-wrap: wrap; row-gap: 6px; }
  .middle .dots { flex: 1 1 100%; }
}

/* A phone held upright has no room for the picture and the whole text: the page scrolls,
   rather than the text running on under the buttons at the bottom. (On its side the text
   sits beside the picture and scrolls by itself.) */
@media (max-width: 600px) and (orientation: portrait) {
  .page { overflow-y: auto; }
  .reading { max-height: none; }
}
