/* Designed for 1920x1080 on a TV viewed from ~3 m, with a portrait layout for 1080x1920 at the end.
   1 --u = 1% of the 16:9 stage width (19.2px at 1080p), so it scales on any window.
   --stage-h is the stage height in --u (56.25 landscape, 100 portrait), for animations that cross it. */
:root {
  /* svh: the height that is always visible, with a phone's address bar showing (vh for older browsers).
     --u0 is the stage's unit; each screen's --u is --u0 shrunk by --fit when its content wouldn't fit (display.js). */
  --u0: min(1vw, 1.7778vh);
  --u0: min(1vw, 1.7778svh);
  --u: var(--u0);
  --stage-h: 56.25;
  --ink: #1d1747;
  --white: #ffffff;
  --yellow: #ffd23f;
  --green: #22c55e;
  --red: #ff4d6d;
  --blue: #4d7cff;
  --purple: #8b5cf6;
  --font: "Arial Rounded MT Bold", "Nunito", "Varela Round", "Comic Sans MS", "Trebuchet MS", "Noto Sans Bengali", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #120d33;
  overflow: hidden;
  font-family: var(--font);
  color: var(--white);
  cursor: none;
}

.stage {
  position: absolute;
  inset: 0;
  margin: auto;
  width: calc(var(--u) * 100);
  height: calc(var(--u) * var(--stage-h));
  overflow: hidden;
  background: linear-gradient(135deg, #6a3df0 0%, #3b82f6 55%, #06b6d4 100%);
  transition: background 0.4s;
}
body[data-screen="language"] .stage, body[data-screen="subject"] .stage, body[data-screen="pick"] .stage, body[data-screen="levels"] .stage { background: linear-gradient(135deg, #ff7a18 0%, #ff4d6d 60%, #c026d3 100%); }
body[data-screen="feedback"] .stage { background: linear-gradient(135deg, #16a34a, #22c55e 60%, #84cc16); }
body[data-screen="results"] .stage { background: linear-gradient(135deg, #7c3aed, #db2777 60%, #f59e0b); }
body[data-screen="expired"] .stage { background: linear-gradient(135deg, #334155, #1e293b); }
body[data-screen="feedback"][data-result="wrong"] .stage { background: linear-gradient(135deg, #f97316, #ef4444 70%, #be123c); }
body[data-screen="feedback"][data-result="exam"] .stage { background: linear-gradient(135deg, #6a3df0 0%, #3b82f6 55%, #06b6d4 100%); }

#app, .screen { width: 100%; height: 100%; }
/* A screen whose content is too big for the stage (a long question, a picture plus an explanation, the phone's
   keypad) is shrunk evenly to fit: display.js sets --fit below 1. */
#app > .screen { --u: calc(var(--u0) * var(--fit, 1)); }
/* No room for the owl's speech bubble on a screen that had to be shrunk. */
body.fitted .mascot-say { display: none !important; }

.screen {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 2);
  padding: calc(var(--u) * 3);
  text-align: center;
  text-shadow: 0 calc(var(--u) * 0.35) 0 rgba(0, 0, 0, 0.25);
}
.screen.enter { animation: screen-in 0.35s ease-out; }
@keyframes screen-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }

.heading { font-size: calc(var(--u) * 6); }
.hint { font-size: calc(var(--u) * 2.4); opacity: 0.9; }
.hint b { background: rgba(255,255,255,0.25); padding: 0 calc(var(--u) * 0.8); border-radius: calc(var(--u) * 0.8); }

/* ---------- attract ---------- */
.title {
  font-size: calc(var(--u) * 7.5);
  letter-spacing: calc(var(--u) * 0.3);
  z-index: 1;
}
.title span { display: inline-block; animation: bounce 1.6s ease-in-out infinite; }
.title span:nth-child(odd)  { color: var(--yellow); }
.title span:nth-child(3n)   { color: #ff9ad5; }
.title .gap { width: calc(var(--u) * 3); }
/* each letter's bounce delay is set inline by display.js */
/* The family's name above the title: smaller, white, each letter swaying and hopping in turn. */
.family-name {
  z-index: 1;
  font-size: calc(var(--u) * 3.6);
  font-weight: 700;
  color: #fff;
  letter-spacing: calc(var(--u) * 0.15);
  margin-bottom: calc(var(--u) * -1);
  max-width: 90%;
  overflow-wrap: anywhere;
}
.family-name span { display: inline-block; animation: letter-dance 1.4s ease-in-out infinite; }
.family-name .gap { width: calc(var(--u) * 1.2); animation: none; }
@keyframes letter-dance {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(calc(var(--u) * -0.9)) rotate(-10deg); }
  50% { transform: translateY(0) rotate(0); }
  75% { transform: translateY(calc(var(--u) * -0.5)) rotate(10deg); }
}
@media (prefers-reduced-motion: reduce) { .family-name span { animation: none; } }
@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(calc(var(--u) * -2)) rotate(-4deg); }
}

.cta {
  z-index: 1;
  font-size: calc(var(--u) * 4);
  background: var(--yellow);
  color: var(--ink);
  text-shadow: none;
  padding: calc(var(--u) * 1.2) calc(var(--u) * 4);
  border-radius: calc(var(--u) * 5);
  box-shadow: 0 calc(var(--u) * 0.6) 0 #c99a00;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

.floaters { position: absolute; inset: 0; pointer-events: none; }
.floaters span {
  position: absolute;
  bottom: -15%;
  opacity: 0.55;
  animation: float-up linear infinite;
}
.floaters .float-ico { opacity: 0.7; }
.floaters .float-ico img { display: block; width: 1em; height: 1em; }
@keyframes float-up {
  from { transform: translateY(0) rotate(0); }
  to   { transform: translateY(calc(var(--u) * var(--stage-h) * -1.33)) rotate(360deg); }
}

/* ---------- pick ---------- */
.cards { display: flex; gap: calc(var(--u) * 4); }
.card {
  width: calc(var(--u) * 36);
  padding: calc(var(--u) * 3);
  border-radius: calc(var(--u) * 3);
  background: var(--white);
  color: var(--ink);
  text-shadow: none;
  box-shadow: 0 calc(var(--u) * 0.9) 0 rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 2.5);
  animation: pop-in 0.5s cubic-bezier(.2,1.6,.4,1) both;
}
.card:nth-child(2) { animation-delay: 0.12s; }
.card:nth-child(3) { animation-delay: 0.24s; }
.badge {
  flex: none;
  width: calc(var(--u) * 10);
  height: calc(var(--u) * 10);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: calc(var(--u) * 7);
  color: var(--white);
}
.c0 .badge { background: var(--blue); }
.c1 .badge { background: var(--purple); }
.c2 .badge { background: var(--green); }
.c3 .badge { background: var(--red); }
.card-name { font-size: calc(var(--u) * 3.6); text-align: left; line-height: 1.15; }
.card-name small { display: block; font-size: 0.55em; color: #b91c1c; margin-top: calc(var(--u) * 0.5); }
.card-name { flex: 1; min-width: 0; }
/* Game cards: how many of the 10 levels the child has tried */
.levels-bar {
  height: calc(var(--u) * 1.3);
  margin-top: calc(var(--u) * 0.9);
  border-radius: calc(var(--u) * 0.7);
  background: #e2e8f0;
  overflow: hidden;
}
.levels-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #84cc16);
  animation: levels-grow 0.8s ease-out 0.3s both;
  transform-origin: left;
}
@keyframes levels-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.levels-label { font-size: 0.5em; color: #475569; margin-top: calc(var(--u) * 0.4); }
/* Game list: wider, flatter cards so the names stay on one line and the bars still fit on a TV */
.pick .cards.grid .card { width: calc(var(--u) * 40); padding: calc(var(--u) * 1.3) calc(var(--u) * 2.4); }
.pick .cards.grid .badge { width: calc(var(--u) * 7); height: calc(var(--u) * 7); font-size: calc(var(--u) * 4.8); }
.pick .card-name { font-size: calc(var(--u) * 3.1); }
.pick .heading { font-size: calc(var(--u) * 5); }
.cards.grid { display: grid; grid-template-columns: repeat(2, auto); gap: calc(var(--u) * 2.5) calc(var(--u) * 4); }
.cards.grid .card { padding: calc(var(--u) * 1.8) calc(var(--u) * 3); }
.cards.grid .badge { width: calc(var(--u) * 8); height: calc(var(--u) * 8); font-size: calc(var(--u) * 5.5); }
.card.locked { opacity: 0.45; filter: grayscale(0.8); }
@keyframes pop-in { from { opacity: 0; transform: scale(0.3); } to { opacity: 1; transform: none; } }

/* ---------- top bar (question/feedback) ---------- */
.topbar {
  position: absolute;
  top: calc(var(--u) * 2);
  left: calc(var(--u) * 3);
  right: calc(var(--u) * 3);
  display: flex;
  justify-content: space-between;
}
.pill {
  font-size: calc(var(--u) * 2.4);
  background: rgba(255, 255, 255, 0.22);
  padding: calc(var(--u) * 0.6) calc(var(--u) * 2);
  border-radius: calc(var(--u) * 3);
}
.pill.score { background: var(--yellow); color: var(--ink); text-shadow: none; }

/* ---------- question ---------- */
.prompt-wrap { position: relative; margin-top: calc(var(--u) * 4); max-width: 92%; }
/* The question pops in, spins once and settles, in lime-to-pink gradient text (from test.html). */
.prompt {
  line-height: 1.15;
  background: linear-gradient(135deg, #c6ff00, #ffea00 45%, #ff4081);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 calc(var(--u) * 0.35) 0 rgba(0, 0, 0, 0.35));
  opacity: 0;
  animation:
    prompt-pop 0.25s cubic-bezier(.34, 1.56, .64, 1) forwards,
    prompt-swirl 0.35s ease-out 0.25s forwards,
    prompt-settle 0.25s ease-out 0.6s forwards;
}
/* A long word problem wobbles instead of spinning, so it stays readable. */
.prompt.p-long {
  animation:
    prompt-pop 0.25s cubic-bezier(.34, 1.56, .64, 1) forwards,
    prompt-wobble 0.6s ease-out 0.25s forwards;
}
.prompt .frac .num { border-bottom-color: #ffea00; }
@keyframes prompt-pop    { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1.1); } }
@keyframes prompt-swirl  { from { opacity: 1; transform: scale(1.1) rotate(0); } to { opacity: 1; transform: scale(1.1) rotate(360deg); } }
@keyframes prompt-settle { from { opacity: 1; transform: scale(1.1) rotate(360deg); } to { opacity: 1; transform: none; } }
@keyframes prompt-wobble {
  0%   { opacity: 1; transform: scale(1.1) rotate(0); }
  30%  { transform: scale(1.1) rotate(-4deg); }
  60%  { transform: scale(1.05) rotate(3deg); }
  100% { opacity: 1; transform: none; }
}
.burst { position: absolute; inset: 0; pointer-events: none; }
.burst i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(var(--u) * 1.6);
  height: calc(var(--u) * 1.6);
  margin: calc(var(--u) * -0.8);
  border-radius: 50%;
  opacity: 0;
  animation: dot-burst 0.45s ease-out 0.55s forwards;
}
@keyframes dot-burst {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.4); }
  60%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.9); }
}
@media (prefers-reduced-motion: reduce) {
  .prompt, .prompt.p-long { animation: prompt-pop 0.25s ease-out forwards, prompt-settle 0.2s ease-out 0.25s forwards; }
}
.p-short  { font-size: calc(var(--u) * 11); }
.p-medium { font-size: calc(var(--u) * 7); }
.p-long   { font-size: calc(var(--u) * 5); }
.p-xlong  { font-size: calc(var(--u) * 4); }

/* Stacked fraction, e.g. 3 over 4 */
.frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  font-size: 0.78em;
  line-height: 1;
  margin: 0 0.12em;
  text-align: center;
}
.frac .num { border-bottom: 0.08em solid currentColor; padding: 0 0.1em; }

.answer-row { display: flex; align-items: center; gap: calc(var(--u) * 1.5); }
/* which panel is answering, just above the answer box or choices */
.answer-panel {
  z-index: 1;
  font-size: calc(var(--u) * 2);
  padding: calc(var(--u) * 0.3) calc(var(--u) * 1.4);
  border-radius: calc(var(--u) * 2);
  background: rgba(255, 255, 255, 0.2);
  margin-bottom: calc(var(--u) * -1);
}
.answer-panel.empty { visibility: hidden; } /* keeps its space, so the box doesn't jump on the first press */

/* ---------- Head to Head: one answer box per panel ---------- */
.race-area { z-index: 1; display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 1); }
.race-boxes {
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: calc(var(--u) * 2.5);
}
.racer-box { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 1.2); }
.racer-box .answer-panel { margin-bottom: 0; }
.race-boxes.n2 .entry { min-width: calc(var(--u) * 20); }
.race-boxes.n3 .entry, .race-boxes.n4 .entry {
  min-width: calc(var(--u) * 15); height: calc(var(--u) * 10); line-height: calc(var(--u) * 10);
  font-size: calc(var(--u) * 7); padding: 0 calc(var(--u) * 1.5);
}
.race-boxes.n3 .unit, .race-boxes.n4 .unit { font-size: calc(var(--u) * 5); }
.racer-box.locked .entry { opacity: 0.55; }
.racer-box.shake { animation: shake 0.45s; }
.racer-score {
  font-size: calc(var(--u) * 2);
  background: var(--yellow);
  color: var(--ink);
  text-shadow: none;
  padding: calc(var(--u) * 0.2) calc(var(--u) * 1.4);
  border-radius: calc(var(--u) * 2);
}
.big-word.race-win { font-size: calc(var(--u) * 6.5); line-height: 1.2; }
.race-win .race-pad { font-size: 0.7em; }
.race-join { z-index: 1; min-height: 1.3em; font-size: calc(var(--u) * 2); opacity: 0.85; }
.race-box .exam-note { font-size: calc(var(--u) * 2.2); line-height: 1.4; }

.leaderboard { z-index: 1; display: flex; flex-direction: column; gap: calc(var(--u) * 1.2); width: min(100%, calc(var(--u) * 60)); }
.leader-row {
  display: grid;
  grid-template-columns: calc(var(--u) * 5) 1fr auto auto;
  align-items: center;
  gap: calc(var(--u) * 2);
  padding: calc(var(--u) * 1) calc(var(--u) * 2);
  font-size: calc(var(--u) * 3);
  background: rgba(255, 255, 255, 0.15);
  border-radius: calc(var(--u) * 2);
  animation: pop-in 0.4s cubic-bezier(.2,1.6,.4,1) both;
  animation-delay: calc(var(--i) * 0.15s);
}
.leader-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader-row.first { background: var(--yellow); color: var(--ink); text-shadow: none; }
.leader-row small { font-size: 0.6em; opacity: 0.85; }
.leader-wins { font-size: 0.7em; opacity: 0.85; }
.leader-points { font-weight: bold; }
.unit { font-size: calc(var(--u) * 8); }
.entry {
  min-width: calc(var(--u) * 24);
  height: calc(var(--u) * 13);
  font-size: calc(var(--u) * 10);
  line-height: calc(var(--u) * 13);
  background: var(--white);
  color: var(--ink);
  text-shadow: none;
  border-radius: calc(var(--u) * 2.5);
  padding: 0 calc(var(--u) * 3);
  box-shadow: inset 0 calc(var(--u) * -0.7) 0 rgba(0,0,0,0.12), 0 calc(var(--u) * 0.6) 0 rgba(0,0,0,0.2);
}
.entry.bump { animation: bump 0.15s ease-out; }
@keyframes bump { 50% { transform: scale(1.06); } }
.caret { color: #c7c3e6; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.timer { display: flex; align-items: center; gap: calc(var(--u) * 2); width: 80%; }
.timer-track {
  flex: 1;
  height: calc(var(--u) * 2.6);
  background: rgba(0, 0, 0, 0.25);
  border-radius: calc(var(--u) * 2);
  overflow: hidden;
}
.timer-bar {
  height: 100%;
  background: var(--yellow);
  border-radius: inherit;
  transform-origin: left center;
}
.timer-bar.urgent { background: var(--red); }
.timer-secs { font-size: calc(var(--u) * 4); width: calc(var(--u) * 5); }
.timer-secs.urgent { color: #ffe1e6; animation: pulse 0.5s ease-in-out infinite; }

/* ---------- feedback ---------- */
.big-word { font-size: calc(var(--u) * 11); animation: pop-in 0.45s cubic-bezier(.2,1.6,.4,1) both; }
.sum { font-size: calc(var(--u) * 7); }
.points {
  font-size: calc(var(--u) * 5);
  background: var(--yellow);
  color: var(--ink);
  text-shadow: none;
  padding: calc(var(--u) * 0.6) calc(var(--u) * 3);
  border-radius: calc(var(--u) * 4);
  animation: pop-in 0.5s 0.25s cubic-bezier(.2,1.6,.4,1) both;
}
.wrong .big-word { animation: shake 0.5s ease-in-out; }
.wrong .sum {
  background: var(--white);
  color: var(--ink);
  text-shadow: none;
  padding: 0 calc(var(--u) * 3);
  border-radius: calc(var(--u) * 2.5);
}
.explain { font-size: calc(var(--u) * 3.4); max-width: 86%; line-height: 1.3; }
.question-recap { opacity: 0.9; max-width: 90%; }
.question-recap.p-short  { font-size: calc(var(--u) * 5); }
.question-recap.p-medium { font-size: calc(var(--u) * 4); }
.question-recap.p-long   { font-size: calc(var(--u) * 3.2); }
.question-recap.p-xlong  { font-size: calc(var(--u) * 2.8); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(calc(var(--u) * -2)); }
  40%, 80% { transform: translateX(calc(var(--u) * 2)); }
}

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -5%;
  width: calc(var(--u) * 1.2);
  height: calc(var(--u) * 2);
  border-radius: calc(var(--u) * 0.3);
  animation: fall ease-in forwards;
}
@keyframes fall {
  to { transform: translate(var(--drift), calc(var(--u) * var(--stage-h) * 1.1)) rotate(var(--spin)); opacity: 0.8; }
}

/* ---------- results ---------- */
.stars { display: flex; gap: calc(var(--u) * 2); }
.star {
  font-size: calc(var(--u) * 13);
  line-height: 1;
  animation: star-pop 0.6s cubic-bezier(.2,1.6,.4,1) both;
  animation-delay: calc(0.3s + var(--i) * 0.35s);
}
.star.on { color: var(--yellow); filter: drop-shadow(0 0 calc(var(--u) * 1.2) rgba(255, 220, 80, 0.8)); }
.star.off { color: rgba(255, 255, 255, 0.25); }
@keyframes star-pop { from { opacity: 0; transform: scale(0) rotate(-180deg); } to { opacity: 1; transform: none; } }
.final-score { font-size: calc(var(--u) * 9); }
.final-score small { font-size: 0.45em; }
.tally { font-size: calc(var(--u) * 3.6); }
.new-best {
  font-size: calc(var(--u) * 3.4);
  background: var(--yellow);
  color: var(--ink);
  text-shadow: none;
  padding: calc(var(--u) * 0.5) calc(var(--u) * 2.5);
  border-radius: calc(var(--u) * 3);
  animation: pulse 1s ease-in-out infinite;
}

/* ---------- levels & exam ---------- */
.levels { gap: calc(var(--u) * 1.6); }
.levels .heading { font-size: calc(var(--u) * 4.6); }
.levels-body { display: flex; align-items: center; gap: calc(var(--u) * 2); }
.level-table { display: grid; grid-template-columns: repeat(2, auto); grid-auto-flow: column; grid-template-rows: repeat(5, auto); gap: calc(var(--u) * 1) calc(var(--u) * 2); }
.level-row {
  display: grid;
  grid-template-columns: calc(var(--u) * 4.4) calc(var(--u) * 17) calc(var(--u) * 8) calc(var(--u) * 3.5);
  align-items: center;
  gap: calc(var(--u) * 1);
  padding: calc(var(--u) * 0.6) calc(var(--u) * 1.4) calc(var(--u) * 0.6) calc(var(--u) * 0.7);
  border-radius: calc(var(--u) * 3);
  background: var(--white);
  color: var(--ink);
  text-shadow: none;
  font-size: calc(var(--u) * 2.6);
  text-align: left;
  box-shadow: 0 calc(var(--u) * 0.5) 0 rgba(0,0,0,0.25);
  animation: pop-in 0.4s cubic-bezier(.2,1.6,.4,1) both;
  animation-delay: calc(var(--i) * 0.04s);
}
.level-row.locked { background: rgba(255,255,255,0.45); }
.level-row.next { outline: calc(var(--u) * 0.5) solid var(--yellow); }
.key {
  display: inline-grid;
  place-items: center;
  min-width: calc(var(--u) * 4.4);
  height: calc(var(--u) * 4.4);
  padding: 0 calc(var(--u) * 0.6);
  border-radius: calc(var(--u) * 2.2);
  background: var(--blue);
  color: var(--white);
  font-size: calc(var(--u) * 2.6);
}
.level-row.locked .key { background: #94a3b8; }
.lv-stars i { font-style: normal; color: #cbd5e1; }
.lv-stars i.on { color: #f59e0b; }
.lv-tries { font-size: 0.8em; color: #64748b; text-align: right; }

.exam-box {
  width: calc(var(--u) * 21);
  padding: calc(var(--u) * 1.6);
  border-radius: calc(var(--u) * 3);
  background: var(--ink);
  border: calc(var(--u) * 0.4) solid var(--yellow);
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 1.4);
  animation: pop-in 0.5s 0.4s cubic-bezier(.2,1.6,.4,1) both;
}
.exam-box.locked { border-color: rgba(255,255,255,0.3); opacity: 0.75; }
.exam-title { font-size: calc(var(--u) * 3.6); display: flex; align-items: center; justify-content: center; gap: calc(var(--u) * 1.2); }
.exam-title .key { background: var(--yellow); color: var(--ink); text-shadow: none; }
.exam-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: calc(var(--u) * 1); }
.slot {
  padding: calc(var(--u) * 0.8) calc(var(--u) * 0.4);
  border-radius: calc(var(--u) * 1.6);
  background: rgba(255,255,255,0.15);
  font-size: calc(var(--u) * 2.8);
}
.slot small { display: block; font-size: 0.6em; opacity: 0.85; }
.slot.pass { background: var(--green); }
.slot.fail { background: var(--red); }
.slot.wide { grid-column: 1 / -1; font-size: calc(var(--u) * 2.2); }
.exam-note { font-size: calc(var(--u) * 2.2); opacity: 0.9; }

.feedback.exam .big-word { opacity: 0.95; }

.exam-results { gap: calc(var(--u) * 1.2); }
.exam-results .heading { font-size: calc(var(--u) * 5); }
.exam-results .star { font-size: calc(var(--u) * 8); }
.review { display: grid; grid-template-columns: repeat(2, 1fr); gap: calc(var(--u) * 0.8) calc(var(--u) * 1.5); max-width: 96%; }
.review-title { grid-column: 1 / -1; font-size: calc(var(--u) * 2.6); }
.review-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 calc(var(--u) * 1);
  padding: calc(var(--u) * 0.5) calc(var(--u) * 1.4);
  border-radius: calc(var(--u) * 1.6);
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  text-shadow: none;
  font-size: calc(var(--u) * 2.2);
  text-align: left;
}
.review-row .r-a { font-weight: bold; color: #15803d; }
.review-row .r-a::before { content: '→ '; color: var(--ink); font-weight: normal; }
.review-row small { flex-basis: 100%; color: #64748b; font-size: 0.8em; }

/* ---------- expired ---------- */
.lock { font-size: calc(var(--u) * 12); }

/* ---------- connection overlay ---------- */
.offline {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--u) * 5);
  background: rgba(10, 6, 40, 0.85);
  z-index: 10;
}
.hidden { display: none; }

/* ---------- "press DEL 5 times to exit" during a round ---------- */
/* The two corner boxes, exit (bottom left) and "Scan to join" (bottom right), are the same size. */
.exit-badge, .join-card {
  --corner-w: calc(var(--u) * 12.8);
  --corner-h: calc(var(--u) * 12.4);
  box-sizing: border-box;
  width: var(--corner-w);
  height: var(--corner-h);
}
html.portrait .exit-badge, html.portrait .join-card {
  --corner-w: calc(var(--u) * 19.6);
  --corner-h: calc(var(--u) * 19.2);
}
.exit-badge {
  position: absolute;
  left: calc(var(--u) * 1.5);
  bottom: calc(var(--u) * 1.2);
  z-index: 5;
  display: flex;
  flex-direction: column;   /* the door on top, the words wrapped underneath, like the QR card */
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 0.5);
  padding: calc(var(--u) * 0.9);
  border-radius: calc(var(--u) * 1.2);
  background: rgba(10, 6, 40, 0.45);
  font-size: calc(var(--u) * 1.35);
  line-height: 1.25;
  text-align: center;
  opacity: 0.8;
  overflow: hidden;
  pointer-events: none;
}
html.portrait .exit-badge { font-size: calc(var(--u) * 2); }
.exit-badge.hidden { display: none; }
.exit-badge .exit-icon { font-size: 1.5em; line-height: 1; }
.exit-badge small { display: block; margin-top: 0.3em; font-size: 0.8em; opacity: 0.8; }
.exit-badge b { background: rgba(255,255,255,0.25); padding: 0 calc(var(--u) * 0.5); border-radius: calc(var(--u) * 0.6); }
/* Once an exit has started, make it obvious how many presses are left (same size box, so the words still fit). */
.exit-badge.counting {
  opacity: 1;
  background: var(--red);
  font-weight: bold;
  animation: exit-pulse 0.6s ease-in-out infinite alternate;
}
@keyframes exit-pulse { to { transform: scale(1.05); } }
/* Touch screens and small screens (.compact, set in display.js): just the door and "×3" (counting down), in a
   small pill that keeps clear of the game. */
.exit-badge .exit-count { display: none; }
.exit-badge.compact, html.portrait .exit-badge.compact {
  width: auto;
  height: auto;
  min-height: 44px;
  flex-direction: row;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 22px;
  font-size: 18px;
}
.exit-badge.compact .exit-icon { font-size: 1.3em; }
.exit-badge.compact .exit-count { display: inline; font-weight: bold; }
.exit-badge.compact .exit-words { display: none; }
/* The owl's speech bubble would cover the badge: hide it on the top menus and while an exit is counting. */
body[data-screen="language"] .mascot-say,
body[data-screen="subject"] .mascot-say,
.exit-badge.counting ~ .mascot .mascot-say { display: none !important; }
/* ---------- party games: "Scan to join" QR code, all through a game ---------- */
/* Party games: what the TV's own keyboard just did (answers are hidden, so a key would show nothing). */
.kb-note {
  position: absolute;
  left: 50%;
  bottom: calc(var(--u) * 1.2);
  transform: translateX(-50%);
  z-index: 7;
  max-width: 60%;
  padding: calc(var(--u) * 0.6) calc(var(--u) * 1.8);
  border-radius: calc(var(--u) * 2);
  background: var(--white);
  color: var(--ink);
  font-size: calc(var(--u) * 2);
  font-weight: bold;
  text-align: center;
  box-shadow: 0 calc(var(--u) * 0.4) calc(var(--u) * 1.2) rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
.kb-note.hidden { display: none; }
.kb-note.pop { animation: kb-pop 0.3s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes kb-pop { from { transform: translateX(-50%) scale(0.7); opacity: 0; } }
html.portrait .kb-note { bottom: calc(var(--u) * 24); font-size: calc(var(--u) * 2.4); }
/* Party games: "Top 5 so far" at a quarter, half and three quarters of a game. */
.standings-done { z-index: 1; font-size: calc(var(--u) * 2.4); opacity: 0.85; margin-top: calc(var(--u) * -1); }
.standings-board { width: min(100%, calc(var(--u) * 56)); }
html.portrait .standings-done { font-size: calc(var(--u) * 3); }
html.portrait .standings-board { width: 100%; }
/* Party menu: 10 or 20 questions (OK switches). */
.party-length { z-index: 1; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: calc(var(--u) * 0.8); font-size: calc(var(--u) * 2.4); cursor: pointer; }
.party-length span { min-width: calc(var(--u) * 5); padding: calc(var(--u) * 0.2) calc(var(--u) * 1); border-radius: calc(var(--u) * 1.5); border: calc(var(--u) * 0.25) solid rgba(255, 255, 255, 0.35); opacity: 0.6; }
.party-length span.on { background: var(--yellow); border-color: var(--yellow); color: var(--ink); opacity: 1; font-weight: bold; }
.party-length small { font-size: 0.75em; opacity: 0.85; }
.party-length b { background: rgba(255,255,255,0.25); padding: 0 calc(var(--u) * 0.5); border-radius: calc(var(--u) * 0.6); }
html.portrait .party-length { font-size: calc(var(--u) * 2.8); }
/* Party menu: who hosts the next game. */
.party-host { z-index: 1; font-size: calc(var(--u) * 2.4); padding: calc(var(--u) * 0.5) calc(var(--u) * 2); border-radius: calc(var(--u) * 3); background: rgba(255, 210, 63, 0.18); }
.party-host b { color: var(--yellow); }
html.portrait .party-host { font-size: calc(var(--u) * 2.8); }
/* Bottom-right corner, where the owl usually stands (he steps aside while it shows). */
.join-card {
  position: absolute;
  right: calc(var(--u) * 1.5);
  bottom: calc(var(--u) * 1.2);
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 0.4);
  padding: calc(var(--u) * 0.6);
  border-radius: calc(var(--u) * 1.2);
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 calc(var(--u) * 0.4) calc(var(--u) * 1.2) rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
.join-card.hidden { display: none; }
.join-card img { display: block; width: calc(var(--u) * 8); height: calc(var(--u) * 8); }
.join-text { text-align: center; line-height: 1.15; }
.join-text b { display: block; font-size: calc(var(--u) * 1.4); white-space: nowrap; }
.join-text small { display: block; font-size: calc(var(--u) * 1); opacity: 0.75; white-space: nowrap; }
body[data-join="1"] .mascot { display: none; }
/* Party menu: the hints keep clear of the card (padding both sides keeps them centred). */
html.landscape body[data-join="1"] .adults .hint { padding: 0 calc(var(--u) * 15); }
/* The timer is centred: narrow it so its right end (and the seconds) stay clear of the card. */
body[data-join="1"] .timer { width: min(80%, calc(100% - var(--u) * 26)); }
/* Portrait: plenty of height, so the screen's content just stops above the card instead. */
html.portrait body[data-join="1"] .timer { width: 80%; }
html.portrait body[data-join="1"] #app > .screen { padding-bottom: calc(var(--u) * 22); }
/* Portrait TV: a bigger code, easy to scan from the sofa. */
html.portrait .join-card img { width: calc(var(--u) * 13); height: calc(var(--u) * 13); }
html.portrait .join-text b { font-size: calc(var(--u) * 2.2); }
html.portrait .join-text small { font-size: calc(var(--u) * 1.6); }
/* Five subjects in two rows of three, so the log-out badge has room below them. */
html.landscape .subject .cards.grid { grid-template-columns: repeat(3, auto); gap: calc(var(--u) * 2.5) calc(var(--u) * 2.5); }
html.landscape .subject .cards.grid .card { width: calc(var(--u) * 29); padding: calc(var(--u) * 1.6) calc(var(--u) * 2); gap: calc(var(--u) * 1.5); }
html.landscape .subject .cards.grid .badge { width: calc(var(--u) * 6.5); height: calc(var(--u) * 6.5); font-size: calc(var(--u) * 4.5); flex-shrink: 0; }
html.landscape .subject .cards.grid .card-name { font-size: calc(var(--u) * 3); }

/* ---------- attract: first-run hint ---------- */
.setup-hint {
  position: absolute;
  bottom: calc(var(--u) * 2.5);
  font-size: calc(var(--u) * 1.9);
  opacity: 0.9;
  z-index: 1;
}

/* ---------- attract: "link your phone" QR code ---------- */
.phone-link {
  z-index: 1;
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  justify-items: center;
  column-gap: calc(var(--u) * 1.5);
  padding: calc(var(--u) * 1.2) calc(var(--u) * 2) calc(var(--u) * 1.2) calc(var(--u) * 1.2);
  background: var(--white);
  color: var(--ink);
  text-shadow: none;
  border-radius: calc(var(--u) * 1.8);
  box-shadow: 0 calc(var(--u) * 0.6) 0 rgba(0, 0, 0, 0.25);
}
.phone-link .phone-qr { grid-column: 1; grid-row: 1 / span 3; display: block; width: calc(var(--u) * 11); height: calc(var(--u) * 11); }
/* A picture of playing with the phone, next to the QR code: the phone picture (square) on small phones,
   the TV room picture (16:9) on tablets and up. Same height as the QR code. */
.phone-cartoon { grid-column: 3; grid-row: 1 / span 3; display: block; }
.phone-cartoon img { display: block; height: calc(var(--u) * 11); width: auto; max-width: none; border-radius: calc(var(--u) * 1); }
.phone-icon { font-size: calc(var(--u) * 4); line-height: 1; animation: phone-wiggle 2.4s ease-in-out infinite; }
.phone-link h3 { font-size: calc(var(--u) * 2.2); }
.phone-link small { font-size: calc(var(--u) * 1.1); opacity: 0.7; max-width: calc(var(--u) * 24); overflow-wrap: anywhere; }
@keyframes phone-wiggle {
  0%, 60%, 100% { transform: rotate(0); }
  70% { transform: rotate(-14deg); }
  80% { transform: rotate(12deg); }
  90% { transform: rotate(-6deg); }
}

/* ---------- who's playing (avatars) ---------- */
body[data-screen="who"] .stage, body[data-screen="pin"] .stage {
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 60%, #a855f7 100%);
}
.avatars {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: calc(var(--u) * 1.8);
  max-width: 94%;
}
.avatar-card {
  position: relative;
  width: calc(var(--u) * 15);
  padding: calc(var(--u) * 1.2) calc(var(--u) * 0.8);
  border-radius: calc(var(--u) * 2.4);
  background: var(--white);
  color: var(--ink);
  text-shadow: none;
  box-shadow: 0 calc(var(--u) * 0.7) 0 rgba(0,0,0,0.25);
  animation: pop-in 0.45s cubic-bezier(.2,1.6,.4,1) both;
}
.avatar-card:nth-child(2n) { animation-delay: 0.06s; }
.avatar-card:nth-child(3n) { animation-delay: 0.12s; }
.avatar-card.guest { background: rgba(255,255,255,0.75); }
.avatar-card.locked { opacity: 0.4; filter: grayscale(1); }
.avatar-num {
  position: absolute;
  top: calc(var(--u) * -1.2);
  left: calc(var(--u) * -1.2);
  width: calc(var(--u) * 5);
  height: calc(var(--u) * 5);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: calc(var(--u) * 3.2);
  background: var(--yellow);
  box-shadow: 0 calc(var(--u) * 0.3) 0 #c99a00;
}
.avatar-face { font-size: calc(var(--u) * 7.5); line-height: 1.1; }
.avatar-name {
  font-size: calc(var(--u) * 2.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.who-msg {
  font-size: calc(var(--u) * 2.6);
  background: rgba(0,0,0,0.25);
  padding: calc(var(--u) * 0.6) calc(var(--u) * 2);
  border-radius: calc(var(--u) * 2);
}

/* ---------- PIN ---------- */
.pin-face { font-size: calc(var(--u) * 13); line-height: 1; animation: bounce 2s ease-in-out infinite; }
.pin .heading { font-size: calc(var(--u) * 4.6); }
.pin-dots { display: flex; gap: calc(var(--u) * 3); }
.pin-dots.shake { animation: shake 0.5s ease-in-out; }
.dot {
  width: calc(var(--u) * 6);
  height: calc(var(--u) * 6);
  border-radius: 50%;
  border: calc(var(--u) * 0.6) solid var(--white);
  transition: background 0.15s, transform 0.15s;
}
.dot.on { background: var(--yellow); border-color: var(--yellow); transform: scale(1.1); }
.pin-msg { font-size: calc(var(--u) * 3); min-height: 1.3em; color: #ffe1e6; }

.greet { font-size: calc(var(--u) * 4); margin-bottom: calc(var(--u) * -1.5); }

/* ---------- mode themes (question + feedback) ---------- */
body[data-mode="times-tables"][data-screen="question"] .stage { background: linear-gradient(160deg, #0b1440 0%, #2e1a7a 55%, #6d28d9 100%); }
body[data-mode="number-facts"][data-screen="question"] .stage { background: linear-gradient(160deg, #172554 0%, #1d4ed8 55%, #0e7490 100%); }
body[data-mode="place-value"][data-screen="question"] .stage  { background: linear-gradient(160deg, #3b0764 0%, #7e22ce 55%, #be185d 100%); }
body[data-mode="fractions"][data-screen="question"] .stage    { background: linear-gradient(160deg, #052e16 0%, #166534 55%, #0f766e 100%); }
.floaters.faint span { opacity: 0.2; }


/* ---------- top bar extras ---------- */
.pill.streak {
  background: linear-gradient(90deg, #ff9100, #ff4081);
  animation: pop-in 0.4s cubic-bezier(.2,1.6,.4,1) both, pulse 1s ease-in-out 0.4s infinite;
}
.pill.score small { font-size: 0.8em; opacity: 0.75; }
.pill.bump { animation: bump 0.25s ease-out; }

/* ---------- racing timer ---------- */
.timer-lane { position: relative; flex: 1; display: flex; align-items: center; }
.racer {
  position: absolute;
  top: 50%;
  left: 0%; /* rides the end of the timer bar, left to right (set by startTimer) */
  font-size: calc(var(--u) * 4.5);
  line-height: 1;
  transform: translate(-50%, -55%);
  filter: drop-shadow(0 calc(var(--u) * 0.3) 0 rgba(0, 0, 0, 0.3));
}
.racer.urgent { animation: racer-wobble 0.3s ease-in-out infinite; }
@keyframes racer-wobble {
  0%, 100% { transform: translate(-50%, -55%) rotate(-10deg); }
  50% { transform: translate(-50%, -65%) rotate(10deg); }
}

/* ---------- correct answer extras ---------- */
.bonus-line {
  font-size: calc(var(--u) * 3);
  background: rgba(0, 0, 0, 0.2);
  padding: calc(var(--u) * 0.5) calc(var(--u) * 2);
  border-radius: calc(var(--u) * 2);
  animation: pop-in 0.5s 0.4s cubic-bezier(.2,1.6,.4,1) both;
}
.flyers { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.flyers i {
  position: absolute;
  top: 50%;
  left: 50%;
  font-style: normal;
  font-size: calc(var(--u) * 4);
  margin: calc(var(--u) * -2.5);
  opacity: 0;
  animation: fly-to-score 0.6s cubic-bezier(.5, -0.3, .7, 1) forwards;
}
@keyframes fly-to-score {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.5); }
  20%  { opacity: 1; transform: translate(0, calc(var(--u) * -3)) scale(1.4); }
  100% { opacity: 0.2; transform: translate(var(--tx), var(--ty)) scale(0.5); }
}

/* fireworks */
.fireworks, .balloons, .emoji-rain { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.firework { position: absolute; }
.firework i {
  position: absolute;
  width: calc(var(--u) * 1.1);
  height: calc(var(--u) * 1.1);
  margin: calc(var(--u) * -0.55);
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 calc(var(--u) * 1) var(--c);
  opacity: 0;
  animation: spark 1s ease-out forwards;
}
@keyframes spark {
  0%   { opacity: 1; transform: translate(0, 0) scale(1.2); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), calc(var(--dy) + var(--u) * 3)) scale(0.4); }
}
/* balloons */
.balloons span {
  position: absolute;
  bottom: -15%;
  font-size: calc(var(--u) * 7);
  animation: balloon-up ease-in forwards;
}
@keyframes balloon-up {
  0%   { transform: translate(0, 0) rotate(-6deg); }
  50%  { transform: translate(calc(var(--u) * 2), calc(var(--u) * var(--stage-h) * -0.6)) rotate(6deg); }
  100% { transform: translate(calc(var(--u) * -1), calc(var(--u) * var(--stage-h) * -1.3)) rotate(-6deg); }
}
/* themed emoji rain */
.emoji-rain span {
  position: absolute;
  top: -10%;
  font-size: calc(var(--u) * 4.5);
  animation: emoji-fall ease-in forwards;
}
@keyframes emoji-fall { to { transform: translateY(calc(var(--u) * var(--stage-h) * 1.2)) rotate(var(--spin)); } }

/* ---------- picture explanations ---------- */
.visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 1);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  text-shadow: none;
  padding: calc(var(--u) * 1.5) calc(var(--u) * 2.5);
  border-radius: calc(var(--u) * 2.5);
  box-shadow: 0 calc(var(--u) * 0.6) 0 rgba(0, 0, 0, 0.2);
  animation: slide-up 0.5s 0.3s cubic-bezier(.2,1.4,.4,1) both;
  max-width: 92%;
}
@keyframes slide-up { from { opacity: 0; transform: translateY(calc(var(--u) * 6)); } to { opacity: 1; transform: none; } }
.v-caption { font-size: calc(var(--u) * 2.2); opacity: 0.8; }
.v-array { height: calc(var(--u) * 14); max-width: calc(var(--u) * 40); }
.v-array circle { animation: pop-in 0.3s ease-out both; transform-box: fill-box; transform-origin: center; }
.v-bar { display: flex; width: calc(var(--u) * 50); max-width: 100%; height: calc(var(--u) * 7); gap: calc(var(--u) * 0.3); }
.v-seg {
  flex: 1;
  display: grid;
  place-items: center;
  font-size: calc(var(--u) * 2.2);
  background: #e7e5f5;
  border-radius: calc(var(--u) * 0.8);
  animation: pop-in 0.3s ease-out both;
}
.v-seg.on { background: var(--yellow); box-shadow: inset 0 calc(var(--u) * -0.5) 0 #e0a800; }
.v-pie { width: calc(var(--u) * 14); height: calc(var(--u) * 14); }
.v-pie path, .v-pie circle { fill: #e7e5f5; stroke: #fff; stroke-width: 1.5; }
.v-pie .on { fill: #ff7ac6; }
.v-pie path { animation: pop-in 0.3s ease-out both; transform-box: view-box; transform-origin: 50% 50%; }
.v-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: calc(var(--u) * 0.2);
  width: calc(var(--u) * 14);
  height: calc(var(--u) * 14);
}
.v-grid span { background: #e7e5f5; border-radius: calc(var(--u) * 0.15); }
.v-grid span.on { background: #4d7cff; }
.v-cols { display: flex; gap: calc(var(--u) * 0.6); }
.v-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: calc(var(--u) * 5.5);
  border-radius: calc(var(--u) * 1);
  background: #e7e5f5;
  padding: calc(var(--u) * 0.6) calc(var(--u) * 0.4);
}
.v-col b { font-size: calc(var(--u) * 1.8); opacity: 0.7; }
.v-col span { font-size: calc(var(--u) * 5); line-height: 1.1; }
.v-col.on { background: var(--yellow); transform: scale(1.12); box-shadow: 0 calc(var(--u) * 0.4) 0 #e0a800; animation: pulse 1s ease-in-out infinite; }
.v-line { width: calc(var(--u) * 56); max-width: 100%; height: calc(var(--u) * 20); }
.v-line .axis { stroke: var(--ink); stroke-width: 0.6; stroke-linecap: round; }
.v-line .tick { stroke: var(--ink); stroke-width: 0.5; }
.v-line .hop {
  fill: none;
  stroke: #ff4081;
  stroke-width: 0.9;
  stroke-dasharray: 120;
  stroke-dashoffset: 120;
  animation: draw-hop 0.8s 0.6s ease-out forwards;
}
@keyframes draw-hop { to { stroke-dashoffset: 0; } }
.v-line .from { fill: #4d7cff; }
.v-line .to { fill: #ff4081; }
.v-line text { font-size: 4px; text-anchor: middle; fill: var(--ink); font-family: var(--font); }
.v-line .lbl { opacity: 0.6; }
.v-line .lbl-from { fill: #2952cc; }
.v-line .lbl-to { fill: #d6005c; font-size: 4.8px; }
.v-total { font-size: calc(var(--u) * 2.6); }
.v-split { display: flex; width: calc(var(--u) * 50); max-width: 100%; height: calc(var(--u) * 7); gap: calc(var(--u) * 0.3); }
.v-split span {
  display: grid;
  place-items: center;
  flex-basis: 0;
  min-width: calc(var(--u) * 7);
  font-size: calc(var(--u) * 3);
  border-radius: calc(var(--u) * 1);
  animation: pop-in 0.35s ease-out both;
}
.v-split .have { background: #9db5ff; }
.v-split .need { background: var(--yellow); animation-delay: 0.3s; }

/* In landscape there isn't room for the question recap as well as a picture. */
.feedback.has-visual .question-recap { display: none; }
.feedback.has-visual .big-word { font-size: calc(var(--u) * 7); }
.feedback.has-visual .sum { font-size: calc(var(--u) * 5.5); }
.feedback.has-visual { gap: calc(var(--u) * 1.4); padding-top: calc(var(--u) * 6); }

/* ---------- results: badges ---------- */
.streak-line { font-size: calc(var(--u) * 3); animation: pop-in 0.5s 1.4s cubic-bezier(.2,1.6,.4,1) both; }
.new-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: calc(var(--u) * 1.5);
}
.new-badges-title { flex-basis: 100%; font-size: calc(var(--u) * 3); }
.sticker {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: calc(var(--u) * 14);
  gap: calc(var(--u) * 0.3);
  background: var(--white);
  color: var(--ink);
  text-shadow: none;
  padding: calc(var(--u) * 0.8) calc(var(--u) * 0.8);
  border-radius: calc(var(--u) * 2);
  border: calc(var(--u) * 0.4) dashed #ffb400;
  animation: sticker-slap 0.5s cubic-bezier(.2,1.6,.4,1) both;
  animation-delay: calc(1.5s + var(--i) * 0.3s);
}
.sticker span { font-size: calc(var(--u) * 4); line-height: 1.1; }
.sticker b { font-size: calc(var(--u) * 1.7); line-height: 1.15; }
/* With badges to show, everything else on the results screen shrinks to make room. */
.results.has-badges { gap: calc(var(--u) * 0.8); padding: calc(var(--u) * 1.5) calc(var(--u) * 3); }
.results.has-badges .heading { font-size: calc(var(--u) * 4.2); }
.results.has-badges .star { font-size: calc(var(--u) * 7); }
.results.has-badges .final-score { font-size: calc(var(--u) * 6); line-height: 1.1; }
.results.has-badges .hint { font-size: calc(var(--u) * 2); }
.results.has-badges .tally, .results.has-badges .streak-line { font-size: calc(var(--u) * 2.8); }
.results.has-badges .new-best { font-size: calc(var(--u) * 2.8); }
.results.has-badges .new-badges-title { flex-basis: auto; font-size: calc(var(--u) * 2.8); }
@keyframes sticker-slap { from { opacity: 0; transform: scale(2.5) rotate(-20deg); } to { opacity: 1; transform: rotate(-3deg); } }

/* ---------- mascot: Professor Hoot ---------- */
.mascot {
  position: absolute;
  right: calc(var(--u) * 2);
  bottom: calc(var(--u) * 1.5);
  z-index: 6;
  display: flex;
  align-items: flex-end;
  gap: calc(var(--u) * 0.6);
  pointer-events: none;
}
.mascot-face {
  font-size: calc(var(--u) * 7);
  line-height: 1;
  filter: drop-shadow(0 calc(var(--u) * 0.4) 0 rgba(0, 0, 0, 0.25));
  animation: hoot-idle 2.4s ease-in-out infinite;
}
.mascot-say {
  position: relative;
  max-width: calc(var(--u) * 22);
  margin-bottom: calc(var(--u) * 4);
  font-size: calc(var(--u) * 2.2);
  color: var(--ink);
  background: var(--white);
  padding: calc(var(--u) * 0.7) calc(var(--u) * 1.4);
  border-radius: calc(var(--u) * 2);
  box-shadow: 0 calc(var(--u) * 0.4) 0 rgba(0, 0, 0, 0.2);
}
.mascot-say::after {
  content: '';
  position: absolute;
  right: calc(var(--u) * -1);
  bottom: calc(var(--u) * 1);
  border: calc(var(--u) * 0.6) solid transparent;
  border-left-color: var(--white);
}
.mascot.talk .mascot-say { animation: pop-in 0.35s cubic-bezier(.2,1.6,.4,1) both; }
.mascot[data-mood="correct"] .mascot-face,
.mascot[data-mood="streak"] .mascot-face,
.mascot[data-mood="results"] .mascot-face { animation: hoot-dance 0.8s ease-in-out infinite; }
.mascot[data-mood="wrong"] .mascot-face { animation: hoot-nod 1s ease-in-out 2; }
.mascot[data-mood="pin"] .mascot-face { transform: scaleX(-1); animation: none; }
@keyframes hoot-idle { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(calc(var(--u) * -0.6)) rotate(-4deg); } }
@keyframes hoot-jump { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(calc(var(--u) * -3)) scale(1.1, 0.95); } }
@keyframes hoot-dance { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg) translateY(calc(var(--u) * -1)); } }
@keyframes hoot-nod { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-10deg); } 60% { transform: rotate(8deg); } }
/* Hide the speech bubble where the bottom of the screen is busy. */
body[data-visual="1"] .mascot-say,
body[data-screen="question"] .mascot-say,
body[data-screen="results"] .mascot-say { display: none; }
body[data-screen="attract"] .mascot-say { display: none; }
body[data-screen="attract"] .mascot-face { font-size: calc(var(--u) * 9); }

@media (prefers-reduced-motion: reduce) {
  .mascot-face, .racer.urgent, .pill.streak, .phone-icon { animation: none; }
}

/* ---------- portrait monitor (designed for 1080x1920) ----------
   The stage turns 9:16. --u stays 19.2px at 1080x1920, so text is the same size as on a 1080p TV;
   the stage is 56.25u wide and 100u tall, so wide rows are restacked to use the height instead. */
/* ---------- word games: multiple-choice options ---------- */
.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(var(--u) * 1.4) calc(var(--u) * 2);
  width: 88%;
  z-index: 1;
}
.choices.long { grid-template-columns: 1fr; width: 80%; gap: calc(var(--u) * 0.9); }
.choice {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 1.4);
  padding: calc(var(--u) * 0.8) calc(var(--u) * 1.6) calc(var(--u) * 0.8) calc(var(--u) * 0.8);
  border-radius: calc(var(--u) * 2.2);
  background: var(--white);
  color: var(--ink);
  text-shadow: none;
  text-align: left;
  font-size: calc(var(--u) * 3.4);
  box-shadow: 0 calc(var(--u) * 0.5) 0 rgba(0,0,0,0.25);
  animation: pop-in 0.4s cubic-bezier(.2,1.6,.4,1) both;
  transition: transform 0.15s, outline-color 0.15s;
  outline: calc(var(--u) * 0.5) solid transparent;
}
.choice:nth-child(2) { animation-delay: 0.06s; }
.choice:nth-child(3) { animation-delay: 0.12s; }
.choice:nth-child(4) { animation-delay: 0.18s; }
.choices.long .choice { font-size: calc(var(--u) * 2.5); padding-top: calc(var(--u) * 0.6); padding-bottom: calc(var(--u) * 0.6); }
.choice .key { flex: none; background: var(--purple); }
.choice.chosen { outline-color: var(--yellow); transform: scale(1.04); }
.choice.chosen .key { background: var(--yellow); color: var(--ink); }
.c-text { overflow-wrap: anywhere; }
/* "Not quite!": the right option ticked, the child's choice crossed, the rest faded */
.review-choices .choice { opacity: 0.55; animation: none; }
.review-choices .choice.right { opacity: 1; outline-color: var(--green); }
.review-choices .choice.right .key { background: var(--green); }
.review-choices .choice.right .c-text::after { content: '  ✓'; color: var(--green); font-weight: bold; }
.review-choices .choice.picked { opacity: 0.9; text-decoration: line-through; text-decoration-color: #dc2626; }
.review-choices .choice.picked .key { background: #dc2626; }
.review-choices { font-size: 0.9em; }
.feedback.wrong .choices { width: 80%; }
/* word prompts are sentences: plain white text reads better than the big gradient */
.prompt.p-words { line-height: 1.25; }

/* Portrait rules apply when <html> has class "portrait": set from the window shape, or forced with
   ?layout=portrait (see index.html), so the Pi's portrait layout can be previewed on a laptop. */
html.portrait {
  --u0: min(1.7778vw, 1vh);
  --u0: min(1.7778vw, 1svh);
  --u: var(--u0);
  --stage-h: 100;
}
html.portrait .stage { width: calc(var(--u) * 56.25); }
html.portrait .screen { gap: calc(var(--u) * 3); padding: calc(var(--u) * 4) calc(var(--u) * 2.5); }

html.portrait .heading { font-size: calc(var(--u) * 5.5); line-height: 1.15; }
html.portrait .hint { font-size: calc(var(--u) * 2.6); line-height: 1.6; }

/* "Magic" over "Maths" */
html.portrait .title { display: flex; flex-wrap: wrap; justify-content: center; font-size: calc(var(--u) * 11.5); line-height: 1.1; }
html.portrait .title .gap { flex-basis: 100%; height: 0; }
html.portrait .cta { font-size: calc(var(--u) * 3.6); padding: calc(var(--u) * 1.5) calc(var(--u) * 3); white-space: nowrap; }
/* Head to Head: 3 or 4 boxes as a 2 × 2 grid on the tall screen */
html.portrait .race-boxes.n3, html.portrait .race-boxes.n4 { display: grid; grid-template-columns: 1fr 1fr; }
html.portrait .race-boxes .entry { min-width: calc(var(--u) * 20); }
html.portrait .leader-row { font-size: calc(var(--u) * 3.6); }
html.portrait .big-word.race-win { font-size: calc(var(--u) * 7); }

/* the phone QR card stacks: icon, heading, code, address */
html.portrait .phone-link { display: flex; flex-direction: column; gap: calc(var(--u) * 0.6); padding: calc(var(--u) * 1.6); border-radius: calc(var(--u) * 2.5); }
html.portrait .phone-icon { font-size: calc(var(--u) * 4.5); }
html.portrait .phone-link h3 { font-size: calc(var(--u) * 2.4); }
html.portrait .phone-link .phone-qr { width: calc(var(--u) * 17); height: calc(var(--u) * 17); }
/* Tall screens: the picture goes under the QR code, as wide as it. */
html.portrait .phone-cartoon img { width: calc(var(--u) * 17); height: auto; }
html.portrait .phone-link small { font-size: calc(var(--u) * 1.3); max-width: calc(var(--u) * 19); }
html.portrait .setup-hint { left: calc(var(--u) * 3); right: calc(var(--u) * 3); bottom: calc(var(--u) * 4); font-size: calc(var(--u) * 2.2); }

/* levels: one column of 10, exam box underneath */
html.portrait .levels { gap: calc(var(--u) * 2); padding-bottom: calc(var(--u) * 12); }
html.portrait .levels .heading { font-size: calc(var(--u) * 5); }
html.portrait .levels-body { flex-direction: column; gap: calc(var(--u) * 2.5); }
html.portrait .level-table { grid-template-columns: 1fr; grid-auto-flow: row; grid-template-rows: none; gap: calc(var(--u) * 1.1); }
html.portrait .level-row { grid-template-columns: calc(var(--u) * 5) calc(var(--u) * 23) calc(var(--u) * 10) calc(var(--u) * 4); font-size: calc(var(--u) * 3.1); padding: calc(var(--u) * 0.7) calc(var(--u) * 2) calc(var(--u) * 0.7) calc(var(--u) * 0.8); }
html.portrait .key { min-width: calc(var(--u) * 5); height: calc(var(--u) * 5); font-size: calc(var(--u) * 3); }
html.portrait .exam-box { width: calc(var(--u) * 46); }
html.portrait .exam-title { font-size: calc(var(--u) * 4); }
html.portrait .slot { font-size: calc(var(--u) * 3.2); }

/* exam results: one column of answers to look at again */
html.portrait .exam-results { padding-bottom: calc(var(--u) * 12); gap: calc(var(--u) * 1.8); }
html.portrait .exam-results .star { font-size: calc(var(--u) * 10); }
html.portrait .review { grid-template-columns: 1fr; max-width: 100%; gap: calc(var(--u) * 1); }
html.portrait .review-row { font-size: calc(var(--u) * 2.8); }

/* games: one column */
html.portrait .cards.grid { grid-template-columns: 1fr; gap: calc(var(--u) * 2.5); }
html.portrait .cards.grid .card { width: calc(var(--u) * 48); padding: calc(var(--u) * 2.2) calc(var(--u) * 3); }
html.portrait .cards.grid .card-name { font-size: calc(var(--u) * 4); }
/* five subjects plus the log-out badge: tighter cards so the hint stays clear of both */
html.portrait .subject .cards.grid { gap: calc(var(--u) * 1.6); }
html.portrait .subject .cards.grid .card { padding-top: calc(var(--u) * 1.4); padding-bottom: calc(var(--u) * 1.4); }
html.portrait .subject .cards.grid .card-name { font-size: calc(var(--u) * 3.6); }

/* who's playing: 3 per row (9 children + guest = 4 rows) */
html.portrait .avatars { max-width: 100%; gap: calc(var(--u) * 2.5) calc(var(--u) * 2.2); }
html.portrait .avatar-card { width: calc(var(--u) * 15.5); }

/* top bar: game name on its own line, question count and score below */
html.portrait .topbar { top: calc(var(--u) * 3); flex-wrap: wrap; justify-content: center; gap: calc(var(--u) * 1.5); }
html.portrait .topbar .pill { font-size: calc(var(--u) * 2.6); }
html.portrait .topbar .pill:first-child { flex-basis: 100%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* question: prompts wrap onto more lines rather than shrinking */
html.portrait .prompt-wrap { margin-top: calc(var(--u) * 6); max-width: 100%; }
html.portrait .p-short { font-size: calc(var(--u) * 10); }
html.portrait .p-medium { font-size: calc(var(--u) * 6.5); }
html.portrait .p-long { font-size: calc(var(--u) * 5); }
html.portrait .p-xlong { font-size: calc(var(--u) * 4.2); }
html.portrait .answer-row { flex-wrap: wrap; justify-content: center; max-width: 100%; }
html.portrait .unit { font-size: calc(var(--u) * 7); }
html.portrait .entry { min-width: calc(var(--u) * 26); height: calc(var(--u) * 12); font-size: calc(var(--u) * 9); line-height: calc(var(--u) * 12); padding: 0 calc(var(--u) * 2); }
html.portrait .timer { width: 92%; }

/* feedback */
html.portrait .big-word { font-size: calc(var(--u) * 9); line-height: 1.1; }
html.portrait .sum { font-size: calc(var(--u) * 6.5); line-height: 1.2; }
html.portrait .explain { font-size: calc(var(--u) * 3.6); max-width: 100%; }
html.portrait .question-recap { max-width: 100%; }

/* results */
html.portrait .star { font-size: calc(var(--u) * 14); }
html.portrait .final-score { font-size: calc(var(--u) * 10); }
html.portrait .tally { font-size: calc(var(--u) * 4); }

/* PIN */
html.portrait .pin-face { font-size: calc(var(--u) * 16); }
html.portrait .pin .heading { font-size: calc(var(--u) * 5); }
html.portrait .dot { width: calc(var(--u) * 7.5); height: calc(var(--u) * 7.5); }

/* engagement extras */
html.portrait .racer { font-size: calc(var(--u) * 5.5); }
html.portrait .bonus-line { font-size: calc(var(--u) * 3.2); }
html.portrait .mascot { right: calc(var(--u) * 2); bottom: calc(var(--u) * 2.5); }
html.portrait .mascot-face { font-size: calc(var(--u) * 9); }
html.portrait .mascot-say { font-size: calc(var(--u) * 2.8); max-width: calc(var(--u) * 30); }
html.portrait body[data-screen="attract"] .mascot-face { font-size: calc(var(--u) * 9); } /* clear of the phone QR card */
/* portrait has room below the hints for the speech bubble */
html.portrait body[data-screen="question"] .mascot-say { display: block; }

/* portrait has room for the recap as well as the picture */
html.portrait .feedback.has-visual .question-recap.p-short { display: block; }
html.portrait .feedback.has-visual .big-word { font-size: calc(var(--u) * 8); }
html.portrait .feedback.has-visual .sum { font-size: calc(var(--u) * 5); }
html.portrait .feedback.has-visual .explain { font-size: calc(var(--u) * 3.3); }
html.portrait .feedback.has-visual { gap: calc(var(--u) * 2.2); padding-top: calc(var(--u) * 11); padding-bottom: calc(var(--u) * 12); }
html.portrait .v-bar, html.portrait .v-split { height: calc(var(--u) * 9); }
html.portrait .v-seg { font-size: calc(var(--u) * 3); }
html.portrait .visual { max-width: 100%; }
html.portrait .v-array { height: calc(var(--u) * 20); max-width: calc(var(--u) * 46); }
html.portrait .v-bar, html.portrait .v-split { width: calc(var(--u) * 46); }
html.portrait .v-pie, html.portrait .v-grid { width: calc(var(--u) * 20); height: calc(var(--u) * 20); }
html.portrait .v-line { width: calc(var(--u) * 46); height: calc(var(--u) * 17); }
html.portrait .v-cols { max-width: 100%; }
html.portrait .v-col { min-width: calc(var(--u) * 6); }
html.portrait .v-col b { font-size: calc(var(--u) * 2.2); }
html.portrait .v-col span { font-size: calc(var(--u) * 6); }
html.portrait .v-caption { font-size: calc(var(--u) * 2.6); }

html.portrait .results.has-badges { gap: calc(var(--u) * 2); padding: calc(var(--u) * 4) calc(var(--u) * 2.5) calc(var(--u) * 12); }
html.portrait .results.has-badges .hint { font-size: calc(var(--u) * 2.6); }
html.portrait .results.has-badges .heading { font-size: calc(var(--u) * 5); }
html.portrait .results.has-badges .star { font-size: calc(var(--u) * 11); }
html.portrait .results.has-badges .final-score { font-size: calc(var(--u) * 9); }
html.portrait .results.has-badges .tally, html.portrait .results.has-badges .streak-line { font-size: calc(var(--u) * 3.4); }
html.portrait .results.has-badges .new-best { font-size: calc(var(--u) * 3.2); }
html.portrait .results.has-badges .new-badges-title { flex-basis: 100%; font-size: calc(var(--u) * 3.4); }
html.portrait .sticker { width: calc(var(--u) * 11.5); }
html.portrait .sticker span { font-size: calc(var(--u) * 5); }
html.portrait .sticker b { font-size: calc(var(--u) * 2); }


/* level names under "Level N" */
.lv-name small { display: block; font-size: 0.62em; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* word games on the portrait monitor: one option per row */
html.portrait .choices { grid-template-columns: 1fr; width: 100%; gap: calc(var(--u) * 1.3); }
html.portrait .choice { font-size: calc(var(--u) * 3.8); padding: calc(var(--u) * 1.1) calc(var(--u) * 2) calc(var(--u) * 1.1) calc(var(--u) * 1); }
html.portrait .choices.long .choice { font-size: calc(var(--u) * 3); }

/* Levels screen on a landscape TV: compact rows so 2 columns of 5 levels (with names) and the exam box fit
   inside the 16:9 stage, with room for the hint underneath. */
html.landscape .levels { gap: calc(var(--u) * 1.2); padding: calc(var(--u) * 2) calc(var(--u) * 3); }
html.landscape .levels .heading { font-size: calc(var(--u) * 4); }
html.landscape .level-table { gap: calc(var(--u) * 0.8) calc(var(--u) * 1.4); }
html.landscape .level-row {
  grid-template-columns: calc(var(--u) * 3.6) calc(var(--u) * 15) calc(var(--u) * 7) calc(var(--u) * 2.6);
  gap: calc(var(--u) * 0.8);
  padding: calc(var(--u) * 0.45) calc(var(--u) * 1.1) calc(var(--u) * 0.45) calc(var(--u) * 0.5);
  font-size: calc(var(--u) * 2.2);
}
html.landscape .level-row .key { min-width: calc(var(--u) * 3.6); height: calc(var(--u) * 3.6); font-size: calc(var(--u) * 2.1); }
html.landscape .exam-box { width: calc(var(--u) * 20); padding: calc(var(--u) * 1.4); gap: calc(var(--u) * 1); }
html.landscape .exam-title { font-size: calc(var(--u) * 3); }
html.landscape .exam-title .key { min-width: calc(var(--u) * 3.6); height: calc(var(--u) * 3.6); font-size: calc(var(--u) * 1.9); }
html.landscape .slot { font-size: calc(var(--u) * 2.2); padding: calc(var(--u) * 0.6) calc(var(--u) * 0.2); }
html.landscape .slot small { white-space: nowrap; }
html.landscape .exam-note { font-size: calc(var(--u) * 1.8); }
html.landscape .levels .hint { font-size: calc(var(--u) * 2); }

/* Levels screen on the portrait monitor: one line per level ("Level 3  6 times table"), so all ten,
   the exam box and the hint fit in the height. The owl sits this screen out to leave room. */
html.portrait .levels { gap: calc(var(--u) * 1.5); padding: calc(var(--u) * 3) calc(var(--u) * 2.5) calc(var(--u) * 4); }
html.portrait .levels .heading { font-size: calc(var(--u) * 4.2); }
html.portrait .levels-body { gap: calc(var(--u) * 1.8); width: 100%; }
html.portrait .level-table { gap: calc(var(--u) * 0.7); width: 100%; }
html.portrait .level-row {
  grid-template-columns: calc(var(--u) * 3.8) minmax(0, 1fr) calc(var(--u) * 8.5) calc(var(--u) * 3);
  font-size: calc(var(--u) * 2.5);
  padding: calc(var(--u) * 0.3) calc(var(--u) * 1.2) calc(var(--u) * 0.3) calc(var(--u) * 0.4);
}
html.portrait .level-row .key { min-width: calc(var(--u) * 3.8); height: calc(var(--u) * 3.8); font-size: calc(var(--u) * 2.3); }
html.portrait .lv-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.portrait .lv-name small { display: inline; margin-left: calc(var(--u) * 1); font-size: 0.75em; }
html.portrait .exam-box { width: 100%; padding: calc(var(--u) * 1.2) calc(var(--u) * 1.6); gap: calc(var(--u) * 0.8); }
html.portrait .exam-title { font-size: calc(var(--u) * 3.2); }
html.portrait .slot { font-size: calc(var(--u) * 2.6); padding: calc(var(--u) * 0.5); }
html.portrait .exam-note { font-size: calc(var(--u) * 2); }
html.portrait .levels .hint { font-size: calc(var(--u) * 2.2); line-height: 1.5; }
html.portrait body[data-screen="levels"] .mascot { display: none; }
/* the owl's speech bubble would cover the hint on the Levels screen */
body[data-screen="levels"] .mascot-say { display: none; }

/* ---------- Clock Watch: clock faces and timetables ---------- */
.v-clock { width: calc(var(--u) * 18); height: calc(var(--u) * 18); filter: drop-shadow(0 calc(var(--u) * 0.5) 0 rgba(0,0,0,0.25)); }
.v-clock .rim { fill: var(--ink); }
.v-clock .face { fill: #fffdf5; }
.v-clock .tick { stroke: #94a3b8; stroke-width: 0.6; }
.v-clock .tick5 { stroke: var(--ink); stroke-width: 1.4; }
.v-clock text { font-size: 8.5px; font-weight: bold; fill: var(--ink); text-anchor: middle; dominant-baseline: central; text-shadow: none; }
.v-clock text.roman { font-size: 6.5px; font-family: Georgia, "Times New Roman", serif; }
.v-clock .hour { stroke: var(--red); stroke-width: 3.6; stroke-linecap: round; }
.v-clock .minute { stroke: var(--blue); stroke-width: 2.4; stroke-linecap: round; }
.v-clock .pin { fill: var(--ink); }

.v-table { background: var(--white); color: var(--ink); text-shadow: none; border-radius: calc(var(--u) * 1.6); padding: calc(var(--u) * 0.8) calc(var(--u) * 1.2); box-shadow: 0 calc(var(--u) * 0.5) 0 rgba(0,0,0,0.25); }
.v-table-title { font-size: calc(var(--u) * 2); font-weight: bold; margin-bottom: calc(var(--u) * 0.4); }
.v-table table { border-collapse: collapse; font-size: calc(var(--u) * 2); }
.v-table th, .v-table td { padding: calc(var(--u) * 0.3) calc(var(--u) * 1); border-bottom: 1px solid #e2e8f0; text-align: center; white-space: nowrap; }
.v-table thead th { background: var(--blue); color: var(--white); }
.v-table tbody th { text-align: left; }

/* A question with a picture on a landscape TV: the picture on the left, the question on the right. */
html.landscape .question.has-picture {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "pic prompt" "pic answer" "pic timer" "hint hint";
  align-content: center;
  align-items: center;
  column-gap: calc(var(--u) * 4);
  row-gap: calc(var(--u) * 1.8);
  padding-top: calc(var(--u) * 9);
}
html.landscape .question.has-picture .q-picture { grid-area: pic; }
html.landscape .question.has-picture .prompt-wrap { grid-area: prompt; margin-top: 0; }
html.landscape .question.has-picture .answer-row,
html.landscape .question.has-picture .choices { grid-area: answer; width: 100%; }
html.landscape .question.has-picture .choices { grid-template-columns: 1fr 1fr; }
html.landscape .question.has-picture .timer { grid-area: timer; width: 100%; }
/* …with the "Scan to join" card in the corner, the timer and its seconds stop short of it. */
html.landscape body[data-join="1"] .question.has-picture .timer { width: auto; margin-right: calc(var(--u) * 12); }
html.landscape .question.has-picture .hint { grid-area: hint; }
html.landscape .question.has-picture .prompt { font-size: calc(var(--u) * 4.4); }
html.landscape .question.has-picture .v-clock { width: calc(var(--u) * 30); height: calc(var(--u) * 30); }
html.landscape .question.has-picture .choice { font-size: calc(var(--u) * 2.6); }

/* Portrait: everything in one column, with a big clock. */
html.portrait .question.has-picture .prompt { font-size: calc(var(--u) * 4.6); }
html.portrait .question.has-picture .prompt-wrap { margin-top: calc(var(--u) * 5); }
html.portrait .q-picture .v-clock { width: calc(var(--u) * 30); height: calc(var(--u) * 30); }
html.portrait .v-table table { font-size: calc(var(--u) * 2.5); }
html.portrait .question.has-picture { gap: calc(var(--u) * 2.2); }
/* a clock or timetable question fills the portrait screen: the owl keeps quiet so the hint shows */
html.portrait body[data-picture="1"] .mascot-say { display: none; }
/* clock on the "Not quite!" screen: small enough to fit under the explanation on a TV, big on the portrait monitor */
html.landscape .feedback .v-clock { width: calc(var(--u) * 15); height: calc(var(--u) * 15); }
html.landscape .feedback.has-visual .explain { font-size: calc(var(--u) * 2.8); }
html.portrait .feedback .v-clock { width: calc(var(--u) * 28); height: calc(var(--u) * 28); }
/* units that are words ("minutes") sit small beside the answer box */
.unit.unit-word { font-size: calc(var(--u) * 3.6); align-self: center; }
html.portrait .unit.unit-word { font-size: calc(var(--u) * 4); }
/* long questions with a picture: smaller text and a shorter answer box so it all fits the portrait screen */
html.portrait .question.has-picture .prompt.p-long { font-size: calc(var(--u) * 3.6); }
html.portrait .question.has-picture .prompt-wrap { margin-top: calc(var(--u) * 8); }
html.portrait .question.has-picture .entry { height: calc(var(--u) * 9); line-height: calc(var(--u) * 9); font-size: calc(var(--u) * 7); }
html.portrait .question.has-picture .answer-row { flex-wrap: nowrap; }
html.portrait body[data-picture="1"] .mascot { display: none; }
html.landscape .question.has-picture .prompt.p-long { font-size: calc(var(--u) * 3.4); }

/* ---------- Maths pictures (shapes, angles, grids, scales, charts): server/modes/_figures.js ---------- */
.v-figure { width: calc(var(--u) * 32); max-height: calc(var(--u) * 30); aspect-ratio: var(--fig-ratio); overflow: visible; }
html.portrait .v-figure { width: calc(var(--u) * 52); max-height: calc(var(--u) * 46); }
html.landscape .question.has-picture .v-figure { width: calc(var(--u) * 40); max-height: calc(var(--u) * 40); }
.feedback .v-figure { width: calc(var(--u) * 24); max-height: calc(var(--u) * 22); }
html.portrait .feedback .v-figure { width: calc(var(--u) * 40); max-height: calc(var(--u) * 34); }
.v-figure text { fill: #1f2a44; font-weight: 700; stroke: none; dominant-baseline: auto; }
.v-figure .small { fill: #374151; font-weight: 600; }
.v-figure .muted { fill: #6b7280; }
.v-figure .shape { fill: #ffd6ec; stroke: #7c3aed; stroke-width: 1.3; stroke-linejoin: round; }
.v-figure .shape2 { fill: #cdeefe; stroke: #1d4ed8; stroke-width: 1.3; stroke-linejoin: round; }
.v-figure .shape3 { fill: #f6d7a7; stroke: #92400e; stroke-width: 1; }
.v-figure .face1 { fill: #ffd6ec; stroke: #7c3aed; stroke-width: 1.1; stroke-linejoin: round; }
.v-figure .face2 { fill: #ffeaf5; stroke: #7c3aed; stroke-width: 1.1; stroke-linejoin: round; }
.v-figure .face3 { fill: #f2b8d9; stroke: #7c3aed; stroke-width: 1.1; stroke-linejoin: round; }
.v-figure .outline { fill: none; stroke: #1f2a44; stroke-width: 1; }
.v-figure .outline.thin, .v-figure .thin { stroke-width: 0.45; }
.v-figure .ray { fill: none; stroke: #1f2a44; stroke-width: 1.3; stroke-linecap: round; }
.v-figure .arc { fill: none; stroke: #ff4fa3; stroke-width: 1.1; }
.v-figure .hi { stroke: #ff4fa3; stroke-width: 1.5; }
.v-figure .dot { fill: #1f2a44; }
.v-figure .dot.hi { fill: #ff4fa3; }
.v-figure .grid { stroke: #c9d2e3; stroke-width: 0.4; }
.v-figure .axis { stroke: #1f2a44; stroke-width: 0.7; }
.v-figure .dash { stroke-dasharray: 2.5 1.8; }
.v-figure .water { fill: #7cc8ff; }
.v-figure .arrow { stroke: #ff4fa3; stroke-width: 1.8; stroke-linecap: round; }
.v-figure .fig-arrowhead { fill: #ff4fa3; }
.v-figure .b1 { fill: #ff7ac6; } .v-figure .b2 { fill: #4dd8ff; } .v-figure .b3 { fill: #7ed957; }
.v-figure .b4 { fill: #ffd23f; } .v-figure .b5 { fill: #ffb067; } .v-figure .b6 { fill: #c4a3ff; }
.v-figure rect.b1, .v-figure rect.b2, .v-figure rect.b3, .v-figure rect.b4, .v-figure rect.b5, .v-figure rect.b6,
.v-figure path.b1, .v-figure path.b2, .v-figure path.b3, .v-figure path.b4, .v-figure path.b5, .v-figure path.b6 { stroke: #1f2a44; stroke-width: 0.45; }

/* ---------- Reading Detective: a passage to read, then the question about it ---------- */
.v-passage { background: #fffdf5; color: #1f2a44; border-radius: calc(var(--u) * 1.6); padding: calc(var(--u) * 1.6) calc(var(--u) * 2.4);
  box-shadow: 0 calc(var(--u) * 0.6) 0 rgba(0,0,0,0.15); text-align: left; font-size: calc(var(--u) * 2.6); line-height: 1.45; }
.v-passage h3 { margin: 0 0 calc(var(--u) * 0.6); font-size: 1.15em; color: #6d28d9; }
.v-passage p { margin: 0 0 calc(var(--u) * 0.6); }
.v-passage p:last-child { margin-bottom: 0; }
.v-passage.short { font-size: calc(var(--u) * 4); text-align: center; }
.v-passage.long { font-size: calc(var(--u) * 2.2); }
.v-passage.xlong { font-size: calc(var(--u) * 1.9); line-height: 1.4; }
/* Poems keep their lines; a blank line separates verses. */
.v-passage.poem p { margin: 0; }
.v-passage.poem p:empty { height: 0.7em; }
.v-passage.poem { font-style: italic; }
body[data-passage="1"] .mascot { display: none; }
html.landscape .question.has-passage { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
html.landscape .question.has-passage .q-picture { align-self: center; }
html.landscape .question.has-passage .prompt { font-size: calc(var(--u) * 3.4); }
html.landscape .question.has-passage .choices { grid-template-columns: 1fr; }
html.portrait .question.has-passage .q-picture { order: -1; width: 92%; margin-top: calc(var(--u) * 6); }
html.portrait .question.has-passage .prompt-wrap { margin-top: 0; }
html.portrait .question.has-passage .prompt { font-size: calc(var(--u) * 3.8); }
html.portrait .v-passage { font-size: calc(var(--u) * 3.4); }
html.portrait .v-passage.long { font-size: calc(var(--u) * 3); }
html.portrait .v-passage.xlong { font-size: calc(var(--u) * 2.6); }
html.portrait .v-passage.short { font-size: calc(var(--u) * 4.6); }

/* ---------- grown-ups' picture games (Fluent Emoji icons, flag-icons flags) ---------- */
body[data-screen="adults"] .stage,
body[data-mode="odd-one-out"] .stage, body[data-mode="flags"] .stage,
body[data-mode="memory-flash"] .stage, body[data-mode="emoji-riddles"] .stage {
  background: linear-gradient(160deg, #0f172a 0%, #312e81 55%, #9d174d 100%);
}
body[data-screen="feedback"][data-result="correct"] .stage { background: linear-gradient(135deg, #16a34a, #22c55e 60%, #84cc16); }
body[data-screen="feedback"][data-result="wrong"] .stage { background: linear-gradient(135deg, #f97316, #ef4444 70%, #be123c); }
/* Grown-ups: a small QR code in the top-left corner that opens the admin page on their phone. */
.admin-link {
  position: absolute;
  top: calc(var(--u) * 2);
  left: calc(var(--u) * 2);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 1);
  padding: calc(var(--u) * 0.8);
  padding-right: calc(var(--u) * 1.2);
  background: var(--white);
  color: var(--ink);
  text-shadow: none;
  border-radius: calc(var(--u) * 1.2);
  box-shadow: 0 calc(var(--u) * 0.4) 0 rgba(0, 0, 0, 0.25);
  text-align: left;
}
.admin-text { display: flex; flex-direction: column; align-items: flex-start; gap: calc(var(--u) * 0.6); }
.admin-link img { display: block; width: calc(var(--u) * 7); height: calc(var(--u) * 7); }
.admin-link span { font-size: calc(var(--u) * 1.6); font-weight: 700; line-height: 1.2; }
.admin-link small { display: block; font-size: calc(var(--u) * 1.1); font-weight: 400; opacity: 0.7; }
/* The settings cog: tells parents this box is where the settings are. Turns slowly; still if motion is reduced. */
.admin-link .admin-cog {
  display: inline-block;
  font-size: 1.2em;
  line-height: 1;
  vertical-align: -0.1em;
  animation: cog-spin 6s linear infinite;
}
@keyframes cog-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .admin-link .admin-cog { animation: none; } }
/* Sign the family out of this TV: quiet until tapped once, then red to confirm. */
.tv-signout {
  font: inherit;
  font-size: calc(var(--u) * 1.15);
  font-weight: 700;
  color: var(--ink);
  background: #eef0f7;
  border: 0;
  border-radius: calc(var(--u) * 0.8);
  padding: calc(var(--u) * 0.45) calc(var(--u) * 0.8);
  cursor: pointer;
}
.tv-signout.armed { background: #dc2626; color: #fff; }
.tv-signout:disabled { opacity: 0.6; cursor: default; }
html.portrait .admin-link { top: calc(var(--u) * 1.5); left: calc(var(--u) * 1.5); flex-direction: column; gap: calc(var(--u) * 0.4); padding: calc(var(--u) * 0.8); text-align: center; }
html.portrait .admin-text { align-items: center; gap: calc(var(--u) * 0.4); }
html.portrait .admin-link img { width: calc(var(--u) * 8); height: calc(var(--u) * 8); }
html.portrait .tv-signout { font-size: calc(var(--u) * 1.1); max-width: calc(var(--u) * 10); }

/* The phone card and the party games card side by side, the same height. */
.attract-cards { z-index: 1; display: flex; align-items: stretch; justify-content: center; gap: calc(var(--u) * 2.5); }

/* Family party games: a card like "Link your phone", in the grown-ups' party colours, gently glowing. */
.grownups-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 0.8);
  padding: calc(var(--u) * 1.2) calc(var(--u) * 2.5);
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  border: calc(var(--u) * 0.3) solid rgba(255,255,255,0.85);
  border-radius: calc(var(--u) * 1.8);
  box-shadow: 0 calc(var(--u) * 0.6) 0 #6b21a8, 0 0 calc(var(--u) * 2.5) rgba(236,72,153,0.6);
  animation: party-glow 2.2s ease-in-out infinite;
}
.party-icon { font-size: calc(var(--u) * 4); line-height: 1; animation: phone-wiggle 2.4s ease-in-out 1.2s infinite; }
.party-pic { display: block; height: calc(var(--u) * 11); width: auto; max-width: 100%; object-fit: contain; }
.grownups-cta h3 { font-size: calc(var(--u) * 3.2); white-space: nowrap; }
.party-key { font-size: calc(var(--u) * 2.6); font-weight: 700; white-space: nowrap; }
/* The OK looks like the key to press. */
.party-key b {
  display: inline-block;
  margin-left: calc(var(--u) * 0.4);
  font-size: 1.3em;
  background: var(--yellow);
  color: var(--ink);
  text-shadow: none;
  padding: 0 calc(var(--u) * 1.4);
  border-radius: calc(var(--u) * 1);
  box-shadow: 0 calc(var(--u) * 0.4) 0 #c99a00;
}
.grownups-cta small { font-size: calc(var(--u) * 1.4); opacity: 0.9; }
/* Out of step with the yellow "Press any button" pulse, so the two don't throb together. */
@keyframes party-glow {
  0%, 100% { transform: scale(1); box-shadow: 0 calc(var(--u) * 0.6) 0 #6b21a8, 0 0 calc(var(--u) * 1.5) rgba(236,72,153,0.45); }
  50% { transform: scale(1.03); box-shadow: 0 calc(var(--u) * 0.6) 0 #6b21a8, 0 0 calc(var(--u) * 3.5) rgba(236,72,153,0.85); }
}
/* Two equal-width cards side by side. */
html.portrait .attract-cards { gap: calc(var(--u) * 2); display: grid; grid-template-columns: 1fr 1fr; }
html.portrait .grownups-cta { padding: calc(var(--u) * 1.6) calc(var(--u) * 2); border-radius: calc(var(--u) * 2.5); }
html.portrait .party-icon { font-size: calc(var(--u) * 6); }
html.portrait .party-pic { width: 100%; height: auto; }
html.portrait .grownups-cta h3 { font-size: calc(var(--u) * 3.4); white-space: normal; text-align: center; line-height: 1.1; }
html.portrait .party-key { font-size: calc(var(--u) * 2.8); }
/* room under the two cards for the owl, so it doesn't sit on the party card */
html.portrait .screen.attract { gap: calc(var(--u) * 1.8); padding-top: calc(var(--u) * 3); padding-bottom: calc(var(--u) * 10); }
html.portrait .family-name { font-size: calc(var(--u) * 3.2); margin-bottom: calc(var(--u) * -0.5); }
html.portrait .screen.attract .title { font-size: calc(var(--u) * 10.5); }
@media (prefers-reduced-motion: reduce) { .grownups-cta, .party-icon { animation: none; } }

/* Icons inside text scale with it; flags keep their 4:3 shape. */
img.ico { width: 1.3em; height: 1.3em; vertical-align: -0.28em; }
img.flag { height: 1em; width: auto; vertical-align: -0.12em; border-radius: 0.08em; box-shadow: 0 0 0 1px rgba(0,0,0,0.2); }

/* Pictures shown with the question (riddle icons, the flag to name) */
.v-icons { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: calc(var(--u) * 2); z-index: 1; }
.v-icons span { animation: pop-in 0.45s cubic-bezier(.2,1.6,.4,1) both; animation-delay: calc(var(--i) * 0.12s); }
.v-icons img.ico { width: calc(var(--u) * 9); height: calc(var(--u) * 9); }
.v-icons img.flag { height: calc(var(--u) * 9); }
.v-icons.big img.ico { width: calc(var(--u) * 12); height: calc(var(--u) * 12); }
/* A question pack's emoji picture (plain emoji text, e.g. 🦁 for "What animal is this?"): big enough to name. */
.v-icons.big span { font-size: calc(var(--u) * 15); line-height: 1.1; }
html.landscape .question.has-picture .v-icons.big span { font-size: calc(var(--u) * 13); }
.v-icons.big img.flag { height: calc(var(--u) * 15); }
/* Phonics Pals: the sound being learnt, picked out inside a word. */
b.ph { color: #ff4fa3; -webkit-text-fill-color: #ff4fa3; background: rgba(255, 255, 255, 0.85); border-radius: 0.25em; padding: 0 0.12em; font-weight: 800; }
/* Counting pictures in rows (Reception): --per-row on a line, the rows lined up on the left like a ten frame. */
.v-icons.rows { display: grid; grid-template-columns: repeat(var(--per-row), auto); justify-content: center; justify-items: center; }

/* Options that are all pictures: four big tiles with the number in the corner. */
.choices.icon-choices { grid-template-columns: repeat(4, minmax(0, 1fr)); width: 90%; }
.icon-choices .choice { position: relative; flex-direction: column; justify-content: center; padding: calc(var(--u) * 1.4); }
.icon-choices .choice .key { position: absolute; top: calc(var(--u) * 0.6); left: calc(var(--u) * 0.6); }
.icon-choices img.ico { width: calc(var(--u) * 10); height: calc(var(--u) * 10); vertical-align: middle; }
.icon-choices img.flag { height: calc(var(--u) * 7.5); max-width: 100%; vertical-align: middle; }
.review-choices.icon-choices .choice.picked { text-decoration: none; outline-color: #dc2626; }

/* Memory Flash: the pictures to remember */
.memorise-grid { display: grid; grid-template-columns: repeat(3, auto); gap: calc(var(--u) * 2.5) calc(var(--u) * 4); z-index: 1; }
.memorise-grid.n4 { grid-template-columns: repeat(4, auto); }
.memorise-grid span { animation: pop-in 0.45s cubic-bezier(.2,1.6,.4,1) both; animation-delay: calc(var(--i) * 0.08s); }
.memorise-grid img.ico { width: calc(var(--u) * 12); height: calc(var(--u) * 12); }

/* Up to 8 players: small tiles (name, ❌ once wrong, score) */
.race-boxes.compact { gap: calc(var(--u) * 1.2); }
.race-boxes.compact .racer-box { gap: calc(var(--u) * 0.5); }
.race-boxes.compact .answer-panel { font-size: calc(var(--u) * 1.8); }
.race-boxes.compact .entry {
  min-width: calc(var(--u) * 7); height: calc(var(--u) * 6); line-height: calc(var(--u) * 6);
  font-size: calc(var(--u) * 3.5); padding: 0 calc(var(--u) * 1);
}
.race-boxes.compact .racer-score { font-size: calc(var(--u) * 1.6); }

html.portrait .choices.icon-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
html.portrait .icon-choices img.ico { width: calc(var(--u) * 14); height: calc(var(--u) * 14); }
html.portrait .icon-choices img.flag { height: calc(var(--u) * 10); }
html.portrait .memorise-grid, html.portrait .memorise-grid.n4 { grid-template-columns: repeat(2, auto); }
html.portrait .memorise-grid img.ico { width: calc(var(--u) * 15); height: calc(var(--u) * 15); }
html.portrait .race-boxes.compact { display: grid; grid-template-columns: repeat(4, auto); }

.mascot.hidden { display: none; } /* .mascot sets display, so plain .hidden can't hide the owl */

/* The grown-ups' question screen holds pictures, 4 tiles and up to 8 player tiles: a smaller prompt
   and tighter spacing so it all fits the portrait monitor. */
body[data-adult="1"] .prompt { font-size: calc(var(--u) * 5); }
body[data-adult="1"] .screen.question { gap: calc(var(--u) * 1.4); }
html.portrait body[data-adult="1"] .prompt { font-size: calc(var(--u) * 4.4); line-height: 1.15; }
html.portrait body[data-adult="1"] .icon-choices img.ico { width: calc(var(--u) * 11); height: calc(var(--u) * 11); }
html.portrait body[data-adult="1"] .icon-choices img.flag { height: calc(var(--u) * 8); }
html.portrait body[data-adult="1"] .v-icons.big img.ico { width: calc(var(--u) * 11); height: calc(var(--u) * 11); }
html.portrait body[data-adult="1"] .v-icons.big img.flag { height: calc(var(--u) * 13); }

/* Grown-ups' quiz: how many have answered (never what), the fastest after each question, and a
   two-column leaderboard for big groups (up to 20). */
.quiz-count { z-index: 1; font-size: calc(var(--u) * 3.2); background: rgba(255,255,255,0.15); padding: calc(var(--u) * 0.6) calc(var(--u) * 2.4); border-radius: calc(var(--u) * 3); }
.quiz-count b { font-size: 1.4em; color: var(--yellow); }
.fastest { z-index: 1; display: flex; flex-direction: column; gap: calc(var(--u) * 0.8); width: min(100%, calc(var(--u) * 50)); }
.fastest-title { font-size: calc(var(--u) * 2.4); opacity: 0.9; }
.fast-row {
  display: grid; grid-template-columns: calc(var(--u) * 5) 1fr auto auto; align-items: center; gap: calc(var(--u) * 1.5);
  background: var(--white); color: var(--ink); text-shadow: none; border-radius: calc(var(--u) * 2);
  padding: calc(var(--u) * 0.6) calc(var(--u) * 1.6); font-size: calc(var(--u) * 2.8); text-align: left;
  animation: pop-in 0.4s cubic-bezier(.2,1.6,.4,1) both; animation-delay: calc(var(--i) * 0.1s);
}
.fast-row .fast-time { opacity: 0.7; }
.fast-row .leader-points { font-weight: bold; color: #15803d; }
.feedback.quiz .big-word { font-size: calc(var(--u) * 6); }
.leaderboard.many { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * 0.6) calc(var(--u) * 1.2); width: min(100%, calc(var(--u) * 90)); }
.leaderboard.many .leader-row { font-size: calc(var(--u) * 1.9); padding-top: calc(var(--u) * 0.3); padding-bottom: calc(var(--u) * 0.3); }
html.portrait .leaderboard.many { width: 100%; }
html.portrait .leaderboard.many .leader-row { font-size: calc(var(--u) * 1.7); }
html.portrait body[data-adult="1"] .screen.question { gap: calc(var(--u) * 1.1); }
html.portrait body[data-adult="1"] .v-icons.big img.ico { width: calc(var(--u) * 8.5); height: calc(var(--u) * 8.5); }
html.portrait body[data-adult="1"] .v-icons.big img.flag { height: calc(var(--u) * 11); }
html.portrait body[data-adult="1"] .question .hint { font-size: calc(var(--u) * 2.2); line-height: 1.4; }
html.portrait body[data-adult="1"] .race-join { font-size: calc(var(--u) * 1.8); }

/* Leaderboard on the portrait screen, and the two-column board for big groups: "1 right" moves under
   the name so the name gets most of the row. */
html.portrait .leader-row, .leaderboard.many .leader-row {
  grid-template-columns: calc(var(--u) * 4) minmax(0, 1fr) auto;
  grid-template-areas: "medal name points" "medal wins points";
  column-gap: calc(var(--u) * 1.2);
  row-gap: 0;
  padding: calc(var(--u) * 0.6) calc(var(--u) * 1.4);
}
html.portrait .leader-row .medal, .leaderboard.many .leader-row .medal { grid-area: medal; }
html.portrait .leader-row .leader-name, .leaderboard.many .leader-row .leader-name { grid-area: name; }
html.portrait .leader-row .leader-wins, .leaderboard.many .leader-row .leader-wins { grid-area: wins; font-size: 0.6em; line-height: 1.1; }
html.portrait .leader-row .leader-points, .leaderboard.many .leader-row .leader-points { grid-area: points; }
html.portrait .leaderboard { width: 100%; }
.leader-name { text-align: left; }
html.portrait .leader-row .pad-ico { display: none; } /* every player is on a pad: room for the name instead */
html.portrait .leader-row:not(.leaderboard.many *) { font-size: calc(var(--u) * 3.2); }
/* Portrait, big groups: one full-width column of one-line rows (20 fit the tall screen). */
html.portrait .leaderboard.many { display: flex; flex-direction: column; gap: calc(var(--u) * 0.4); }
html.portrait .leaderboard.many .leader-row {
  grid-template-columns: calc(var(--u) * 3.5) minmax(0, 1fr) auto auto;
  grid-template-areas: "medal name wins points";
  font-size: calc(var(--u) * 2.1);
  padding: calc(var(--u) * 0.35) calc(var(--u) * 1.4);
}
html.portrait .leaderboard.many .leader-row .leader-wins { font-size: 0.8em; }
html.portrait .race-results:has(.leaderboard.many) { gap: calc(var(--u) * 1.2); }
html.portrait .race-results:has(.leaderboard.many) .heading { font-size: calc(var(--u) * 4); }
/* Landscape TV, big groups: two columns of one-line rows, so 20 players (10 a column) fit the height. */
html.landscape .leaderboard.many .leader-row {
  grid-template-columns: calc(var(--u) * 3) minmax(0, 1fr) auto auto;
  grid-template-areas: "medal name wins points";
  font-size: calc(var(--u) * 2);
  padding: calc(var(--u) * 0.3) calc(var(--u) * 1.2);
}
html.landscape .leaderboard.many .leader-row .leader-wins { font-size: 0.75em; }
html.landscape .race-results:has(.leaderboard.many) { gap: calc(var(--u) * 1); }
html.landscape .race-results:has(.leaderboard.many) .heading { font-size: calc(var(--u) * 3.6); }

/* ---------- final scoreboard: the animal podium for the top 3, then places 4-13 ---------- */
/* The stage (public/display/podium.js) is 680 x 470. Each player's name and score sit on the front of their block,
   so the labels are placed in the stage's own proportions and sized in cqw (1% of the stage's width). */
.animal-podium {
  position: relative; z-index: 1; flex: none; width: min(100%, calc(var(--u) * 62));
  container-type: inline-size; border-radius: calc(var(--u) * 1.2); overflow: hidden;
  box-shadow: 0 calc(var(--u) * 0.6) calc(var(--u) * 2) rgba(0, 0, 0, 0.25);
  background: linear-gradient(#fff8e6, #f6f5f0); /* the light stage the artwork was drawn for */
  animation: pop-in 0.6s cubic-bezier(.2,1.4,.4,1) both;
}
.animal-podium-art { display: block; width: 100%; height: auto; text-shadow: none; }
.podium-label {
  position: absolute; width: calc(140 / 680 * 100%); padding: 0.6cqw 0.5cqw; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 0.3cqw;
  overflow: hidden; color: var(--ink); text-shadow: none; line-height: 1.1;
  animation: pop-in 0.5s cubic-bezier(.2,1.6,.4,1) both; animation-delay: calc(0.4s + var(--i) * 0.25s);
}
/* The fronts of the blocks: 2nd x 95-235, y 300-400; 1st x 265-405, y 260-400; 3rd x 435-575, y 330-400.
   The top of each is "1st", "2nd" or "3rd" (drawn in podium.js), so the labels start under it. */
.podium-label.p2 { left: calc(95 / 680 * 100%); top: calc(330 / 470 * 100%); height: calc(70 / 470 * 100%); }
.podium-label.p1 { left: calc(265 / 680 * 100%); top: calc(292 / 470 * 100%); height: calc(108 / 470 * 100%); }
.podium-label.p3 { left: calc(435 / 680 * 100%); top: calc(356 / 470 * 100%); height: calc(44 / 470 * 100%); padding-top: 0.2cqw; gap: 0; }
.podium-label.p3 .podium-name { font-size: 2.8cqw; }
.podium-label.p3 .podium-points { font-size: 2.4cqw; }
.podium-name {
  max-width: 100%; font-size: 3.2cqw; overflow-wrap: anywhere; text-align: center;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.podium-name small { font-size: 0.75em; opacity: 0.85; }
.podium-label.p1 .podium-name { font-size: 3.6cqw; }
.podium-label.p2 .podium-name, .podium-label.p3 .podium-name { -webkit-line-clamp: 1; }
.podium-points { font-size: 2.8cqw; font-weight: bold; white-space: nowrap; }
.podium-points small { font-size: 0.8em; font-weight: normal; opacity: 0.85; }
.leaderboard.rest .medal { font-size: 0.85em; opacity: 0.85; text-align: right; }
.more-players { z-index: 1; font-size: calc(var(--u) * 1.9); opacity: 0.85; margin-top: calc(var(--u) * -0.6); }
.race-results { gap: calc(var(--u) * 1.4); }
/* Portrait TV first: the stage across the whole width. */
html.portrait .animal-podium { width: 100%; }
html.portrait .race-results .heading { font-size: calc(var(--u) * 4.4); }
/* Landscape is only 56u tall: a smaller stage when places 4-13 are listed under it. */
html.landscape .race-results { gap: calc(var(--u) * 0.9); padding-top: calc(var(--u) * 1.5); padding-bottom: calc(var(--u) * 1.5); }
html.landscape .race-results .heading { font-size: calc(var(--u) * 3.4); }
html.landscape .animal-podium { width: min(100%, calc(var(--u) * 58)); }
html.landscape .race-results:has(.leaderboard.rest) .animal-podium { width: min(100%, calc(var(--u) * 42)); }
html.landscape .race-results .hint { font-size: calc(var(--u) * 1.9); }
/* A race (or the grown-ups' "answered" count) with a picture: its own row under the answers. */
html.landscape .question.has-picture:has(.race-area) { grid-template-areas: "pic prompt" "pic answer" "pic race" "pic timer" "hint hint"; row-gap: calc(var(--u) * 1.2); }
html.landscape .question.has-picture .race-area { grid-area: race; }
html.landscape body[data-adult="1"] .question.has-picture .quiz-count { font-size: calc(var(--u) * 2.4); }
/* Grown-ups' answer screen on a landscape TV: the answer and 5 fastest must fit under the top bar. */
html.landscape .feedback.quiz { gap: calc(var(--u) * 1); padding-top: calc(var(--u) * 7); }
html.landscape .feedback.quiz .big-word { font-size: calc(var(--u) * 4.4); }
html.landscape .feedback.quiz .sum { font-size: calc(var(--u) * 3.6); }
html.landscape .feedback.quiz .fastest { width: min(100%, calc(var(--u) * 56)); gap: calc(var(--u) * 0.5); }
html.landscape .feedback.quiz .fastest-title { font-size: calc(var(--u) * 1.9); }
html.landscape .feedback.quiz .fast-row { font-size: calc(var(--u) * 2.1); padding: calc(var(--u) * 0.3) calc(var(--u) * 1.4); }
html.landscape .feedback.quiz .hint { font-size: calc(var(--u) * 1.9); }
html.portrait .feedback.quiz .fast-row { font-size: calc(var(--u) * 2.6); }
/* Portrait grown-ups' question with a picture (flag to name, riddle icons): smaller text answers so
   the prompt clears the top bar and the hint clears the exit badge. */
html.portrait body[data-adult="1"] .question.has-picture .prompt-wrap { margin-top: calc(var(--u) * 6); }
html.portrait body[data-adult="1"] .question.has-picture .v-icons.big img.flag { height: calc(var(--u) * 9); }
html.portrait body[data-adult="1"] .question.has-picture .v-icons.big img.ico { width: calc(var(--u) * 8); height: calc(var(--u) * 8); }
html.portrait body[data-adult="1"] .choices:not(.icon-choices) .choice { font-size: calc(var(--u) * 3.2); padding-top: calc(var(--u) * 0.7); padding-bottom: calc(var(--u) * 0.7); }
html.portrait body[data-adult="1"] .choices { gap: calc(var(--u) * 1); }
html.portrait body[data-adult="1"] .question { padding-bottom: calc(var(--u) * 6); } /* room for the exit badge */

/* Answer cards 1-4 match the colour pad on phones (and carry its shapes for colour-blind players).
   :where keeps these weak, so the chosen (yellow) and review (green/red) badges still win. */
.choice:where([data-n="1"]) .key { background: #e21b3c; }
.choice:where([data-n="2"]) .key { background: #1368ce; }
.choice:where([data-n="3"]) .key { background: #d89e00; }
.choice:where([data-n="4"]) .key { background: #26890c; }
.choice:where([data-n="1"]) .key::after { content: ' ▲'; }
.choice:where([data-n="2"]) .key::after { content: ' ◆'; }
.choice:where([data-n="3"]) .key::after { content: ' ●'; }
.choice:where([data-n="4"]) .key::after { content: ' ■'; }
.choice .key::after { font-size: 0.7em; }
/* The grown-ups' menu is picked with the colour pad too: badges in the same colours and shapes. */
.adults .card:nth-child(1) .badge { background: #e21b3c; }
.adults .card:nth-child(2) .badge { background: #1368ce; }
.adults .card:nth-child(3) .badge { background: #d89e00; }
.adults .card:nth-child(4) .badge { background: #26890c; }
.adults .card:nth-child(1) .badge::after { content: '▲'; }
.adults .card:nth-child(2) .badge::after { content: '◆'; }
.adults .card:nth-child(3) .badge::after { content: '●'; }
.adults .card:nth-child(4) .badge::after { content: '■'; }
.adults .card .badge { position: relative; }
.adults .card .badge::after { position: absolute; right: -0.35em; bottom: -0.3em; font-size: 0.45em; color: #fff; text-shadow: 0 0 0.15em rgba(0,0,0,0.6); }
.choice .key { grid-auto-flow: column; column-gap: 0.15em; } /* the shape sits beside the number */
.choice:where([data-n]) .key { min-width: calc(var(--u) * 6.4); padding: 0 calc(var(--u) * 0.9); column-gap: 0.3em; }
.choice .key::after { font-size: 0.8em; }
/* Menu badges: the shape in a small chip of the same colour on the badge's corner. */
.adults .card .badge::after {
  display: grid; place-items: center; width: 1.25em; height: 1.25em; right: -0.25em; bottom: -0.25em;
  font-size: 0.42em; line-height: 1; border-radius: 50%; background: inherit; border: 0.1em solid #fff; text-shadow: none;
}

/* Shown until the browser allows sound (needs a click, tap or key press on the TV page). */
.sound-note {
  position: absolute; top: calc(var(--u) * 1.2); right: calc(var(--u) * 1.2); z-index: 9;
  /* just the icon, in a round button, top-right */
  display: flex; align-items: center; justify-content: center;
  width: calc(var(--u) * 5); height: calc(var(--u) * 5);
  font-size: calc(var(--u) * 2.8); line-height: 1;
  border-radius: 50%; background: rgba(10, 6, 40, 0.75); cursor: pointer;
}
.sound-note.hidden { display: none; }

/* Touch mode: a round icon top-right that switches to the phone pad (never shown on the wall TV). */
.to-pad {
  display: none; position: absolute; top: calc(var(--u) * 1.2); right: calc(var(--u) * 1.2); z-index: 9;
  align-items: center; justify-content: center;
  width: calc(var(--u) * 5); height: calc(var(--u) * 5);
  font-size: calc(var(--u) * 2.8); line-height: 1; text-decoration: none;
  border-radius: 50%; background: rgba(10, 6, 40, 0.75); cursor: pointer;
}
body.touch .to-pad { display: flex; }
body.touch .sound-note { right: calc(var(--u) * 7.4); }

/* "Terms & Conditions" in the bottom-right corner of the start and "Who's playing?" screens. */
.terms-link {
  position: absolute; left: calc(var(--u) * 1.5); bottom: calc(var(--u) * 1.2); z-index: 3;
  color: rgba(255, 255, 255, 0.8); font-size: calc(var(--u) * 1.2); text-decoration: underline;
}
.terms-link:hover { color: #fff; }

/* ---------- Arabic (Noto Naskh Arabic, bundled so it works offline; licence in /fonts) ---------- */
@font-face {
  font-family: 'Noto Naskh Arabic';
  src: url('/fonts/NotoNaskhArabic.ttf') format('truetype');
  font-weight: 400 700;
  font-display: swap;
}
.ar, .v-ar, .v-ar-form span { font-family: 'Noto Naskh Arabic', serif; font-weight: 500; }
.ar { font-size: 1.35em; line-height: 1.2; unicode-bidi: isolate; }
.choice .c-text .ar { font-size: 1.9em; line-height: 1.1; }
.v-ar { font-size: calc(var(--u) * 17); line-height: 1.35; padding: 0 calc(var(--u) * 2); }
.v-ar-forms { display: flex; gap: calc(var(--u) * 1.5); direction: rtl; }
.v-ar-form {
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.3);
  min-width: calc(var(--u) * 9); padding: calc(var(--u) * 0.6) calc(var(--u) * 1);
  border-radius: calc(var(--u) * 1.2); background: #eef2ff; text-shadow: none;
  animation: pop-in 0.4s cubic-bezier(.2,1.6,.4,1) both; animation-delay: calc(var(--i) * 0.1s);
}
.v-ar-form span { font-size: calc(var(--u) * 7); line-height: 1.3; }
.v-ar-form small { font-size: calc(var(--u) * 1.8); opacity: 0.7; direction: ltr; }
html.portrait .v-ar { font-size: calc(var(--u) * 15); }
html.portrait .v-ar-form { min-width: calc(var(--u) * 10); }
/* Portrait: the big letter leaves room for the question, 4 answers and the timer. */
html.portrait .question.has-picture .v-ar { font-size: calc(var(--u) * 11); line-height: 1.25; }
/* Six subjects on the portrait menu: tighter cards so the hint stays clear of the log-out badge. */
html.portrait .subject .cards.grid { gap: calc(var(--u) * 1.1); }
html.portrait .subject .cards.grid .card { padding-top: calc(var(--u) * 1); padding-bottom: calc(var(--u) * 1); }
html.portrait .subject .cards.grid .card-name { font-size: calc(var(--u) * 3.3); }
html.portrait .subject .cards.grid .badge { width: calc(var(--u) * 6.5); height: calc(var(--u) * 6.5); font-size: calc(var(--u) * 4.5); }
html.portrait .screen.subject { padding-bottom: calc(var(--u) * 6); }
html.portrait .choice .c-text .ar { font-size: 1.55em; }
html.portrait .choices:has(.ar) .choice { padding-top: calc(var(--u) * 0.5); padding-bottom: calc(var(--u) * 0.5); }

/* ---------- Bangla (Noto Sans Bengali, bundled so it works offline; licence in /fonts) ---------- */
@font-face {
  font-family: 'Noto Sans Bengali';
  src: url('/fonts/NotoSansBengali-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
.bn, .v-bn, .v-bn-letter .big { font-family: 'Noto Sans Bengali', sans-serif; }
.bn { font-size: 1.3em; line-height: 1.25; unicode-bidi: isolate; }
.choice .c-text .bn { font-size: 1.8em; line-height: 1.15; }
.v-bn { font-size: calc(var(--u) * 15); line-height: 1.3; padding: 0 calc(var(--u) * 2); white-space: nowrap; }
.v-bn.long { font-size: calc(var(--u) * 9); }
html.portrait .v-bn { font-size: calc(var(--u) * 13); }
html.portrait .v-bn.long { font-size: calc(var(--u) * 8); }
html.portrait .question.has-picture .v-bn { font-size: calc(var(--u) * 10); line-height: 1.25; }
html.portrait .question.has-picture .v-bn.long { font-size: calc(var(--u) * 7); }
html.portrait .choice .c-text .bn { font-size: 1.5em; }
/* The "Not quite!" card: the letter big, its name, and vowel or consonant. */
.v-bn-letter {
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.4);
  padding: calc(var(--u) * 0.8) calc(var(--u) * 3); border-radius: calc(var(--u) * 1.2); background: #eef2ff;
  animation: pop-in 0.4s cubic-bezier(.2,1.6,.4,1) both;
}
.v-bn-letter .big { font-size: calc(var(--u) * 9); line-height: 1.3; }

/* ---------- Urdu (Noto Nastaliq Urdu, bundled so it works offline; licence in /fonts) ---------- */
/* Nastaliq is tall and slanted: generous line height so dots and tails aren't clipped. */
@font-face {
  font-family: 'Noto Nastaliq Urdu';
  src: url('/fonts/NotoNastaliqUrdu-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
.ur, .v-ur, .v-ur-letter .big { font-family: 'Noto Nastaliq Urdu', 'Noto Naskh Arabic', serif; }
.ur { font-size: 1.2em; line-height: 1.9; unicode-bidi: isolate; }
.choice .c-text .ur { font-size: 1.6em; line-height: 1.7; }
.v-ur { font-size: calc(var(--u) * 12); line-height: 2; padding: 0 calc(var(--u) * 2); white-space: nowrap; }
.v-ur.long { font-size: calc(var(--u) * 7.5); }
html.portrait .v-ur { font-size: calc(var(--u) * 11); }
html.portrait .v-ur.long { font-size: calc(var(--u) * 6.5); }
html.portrait .question.has-picture .v-ur { font-size: calc(var(--u) * 8.5); line-height: 1.9; }
html.portrait .question.has-picture .v-ur.long { font-size: calc(var(--u) * 6); }
html.portrait .choice .c-text .ur { font-size: 1.35em; }
.v-ur-letter {
  display: flex; flex-direction: column; align-items: center;
  padding: 0 calc(var(--u) * 3); border-radius: calc(var(--u) * 1.2); background: #eef2ff;
  animation: pop-in 0.4s cubic-bezier(.2,1.6,.4,1) both;
}
.v-ur-letter .big { font-size: calc(var(--u) * 8); line-height: 2; }

/* Calm style for Qur'an content: no confetti, bursts or flying stars. */
body[data-calm="1"] .confetti, body[data-calm="1"] .flyers, body[data-calm="1"] .burst,
body[data-calm="1"] .celebrate, body[data-calm="1"] .floaters { display: none !important; }
.credit { z-index: 1; font-size: calc(var(--u) * 1.6); opacity: 0.75; }

/* Indo-Pak Nastaleeq (KFGQPC Nastaleeq, via Tarteel QUL; personal use only, see /fonts) for
   Qur'an Words when it uses the Indo-Pak text. The other Arabic games keep Noto Naskh. */
@font-face {
  font-family: 'IndoPak Nastaleeq';
  src: url('/fonts/IndoPakNastaleeq.ttf') format('truetype');
  font-display: swap;
}
body[data-arfont="indopak"] .ar, body[data-arfont="indopak"] .v-ar, body[data-arfont="indopak"] .v-ar-form span {
  font-family: 'IndoPak Nastaleeq', 'Noto Naskh Arabic', serif;
  font-weight: normal;
  line-height: 1.9;
}

/* ---------- click / tap to play (on-screen controls in touch mode) ---------- */
body.pointer { cursor: auto; }
body.pointer [data-press]:not([data-press="none"]) { cursor: pointer; }
.exit-badge { pointer-events: auto; }
[data-press].pressed { animation: tap-press 0.18s ease-out; }
@keyframes tap-press { 50% { transform: scale(0.95); filter: brightness(0.92); } }
.touch-controls { position: absolute; inset: 0; pointer-events: none; z-index: 7; }
.touch-controls button { pointer-events: auto; font-family: inherit; border: 0; color: #fff; cursor: pointer; touch-action: manipulation; }
.t-back {
  position: absolute; top: calc(var(--u) * 1.2); left: calc(var(--u) * 1.2);
  font-size: calc(var(--u) * 2.2); padding: calc(var(--u) * 0.6) calc(var(--u) * 1.6);
  border-radius: calc(var(--u) * 2); background: rgba(10, 6, 40, 0.55);
}
.t-pad {
  position: absolute; display: grid; grid-template-columns: repeat(3, calc(var(--u) * 7));
  gap: calc(var(--u) * 1); right: calc(var(--u) * 2); top: 50%; transform: translateY(-45%);
}
.t-key {
  height: calc(var(--u) * 6.4); border-radius: calc(var(--u) * 1.4); font-size: calc(var(--u) * 3.2);
  background: #4d7cff; box-shadow: 0 calc(var(--u) * 0.4) 0 #2d4fb8;
}
.t-key:active { transform: translateY(calc(var(--u) * 0.3)); box-shadow: 0 calc(var(--u) * 0.1) 0 #2d4fb8; }
.t-key.del { background: #ef4444; box-shadow: 0 calc(var(--u) * 0.4) 0 #a61b1b; font-size: calc(var(--u) * 2.2); }
.t-key.ok { background: #22c55e; box-shadow: 0 calc(var(--u) * 0.4) 0 #147a38; font-size: calc(var(--u) * 2.4); }
.t-key.sym { background: #8b5cf6; box-shadow: 0 calc(var(--u) * 0.4) 0 #5b33b5; }
.t-pad.full .t-key.ok { grid-column: span 2; }
/* The room kept for the keypad is in --u0, the keypad's own unit: a screen shrunk to fit (--fit, a picture
   question) must not shrink this room too, or its answer box slides under the keypad. */
/* Landscape: the keypad sits on the right; the question moves left to make room. */
html.landscape body.touch-keypad .screen.question, html.landscape body.touch-keypad .screen.pin { padding-right: calc(var(--u0) * 27); }
/* Portrait: the keypad sits under the question, above the exit badge. */
html.portrait .t-pad {
  top: auto; transform: none; right: auto; left: 50%; translate: -50% 0; bottom: calc(var(--u) * 7);
  grid-template-columns: repeat(3, calc(var(--u) * 11));
}
html.portrait .t-key { height: calc(var(--u) * 7); font-size: calc(var(--u) * 4); }
html.portrait body.touch-keypad .screen.question, html.portrait body.touch-keypad .screen.pin {
  justify-content: flex-start; padding-top: calc(var(--u) * 15); padding-bottom: calc(var(--u0) * 40); gap: calc(var(--u) * 1.4);
}
/* Above the keypad every bit of height counts: the question starts straight under the top bar. */
html.portrait body.touch-keypad .question .prompt-wrap { margin-top: 0; }
/* A keypad with − or . has a fifth row. */
html.portrait body.touch-keypad-full .screen.question { padding-bottom: calc(var(--u0) * 48); }
body.touch-keypad .question .hint, body.touch-keypad .pin .hint { display: none; }
body.touch-keypad .mascot { display: none; }

/* Juz Amma: ayahs, shown large and right-to-left; long ayah options get one per row. */
.v-ayah { font-family: 'Noto Naskh Arabic', serif; font-size: calc(var(--u) * 4.6); line-height: 1.9; max-width: calc(var(--u) * 60); padding: 0 calc(var(--u) * 1.5); text-align: center; }
.v-more { opacity: 0.55; }
body[data-arfont="indopak"] .v-ayah { font-family: 'IndoPak Nastaleeq', 'Noto Naskh Arabic', serif; }
body[data-mode="juz-amma"] .choices { grid-template-columns: 1fr; width: min(92%, calc(var(--u) * 70)); gap: calc(var(--u) * 0.9); }
body[data-mode="juz-amma"] .choice .c-text:has(.ar) { width: 100%; text-align: right; } /* ayahs right-aligned; surah names stay left */
body[data-mode="juz-amma"] .choice .c-text .ar { font-size: 1.15em; line-height: 1.7; }
html.portrait body[data-mode="juz-amma"] .v-ayah { font-size: calc(var(--u) * 4.4); max-width: 100%; }
html.portrait body[data-mode="juz-amma"] .choice { font-size: calc(var(--u) * 3); }

.waqf { font-size: 0.42em; vertical-align: 1.4em; opacity: 0.7; font-family: 'Noto Naskh Arabic', serif; }
body[data-mode="juz-amma"] .choice .c-text .ar { font-size: 1.45em; line-height: 1.8; }
html.portrait body[data-mode="juz-amma"] .choice { font-size: calc(var(--u) * 3.2); }

/* Qur'an recitation (public/display/recite.js): a "hear again" button, a big speaker for listening questions,
   and the Listen & Repeat screen. The speaker pulses gently while a recitation plays. */
.q-picture .listen-btn { display: block; margin: calc(var(--u) * 1.2) auto 0; }
.listen-btn {
  font: inherit; font-size: calc(var(--u) * 2.4); padding: calc(var(--u) * 0.8) calc(var(--u) * 1.8);
  border: 0; border-radius: 999px; background: rgba(255,255,255,0.9); color: #2b2250; cursor: pointer;
}
.listen-btn b { margin-left: 0.4em; padding: 0 0.4em; border-radius: 0.3em; background: #ffe066; }
.listen-big { font-size: calc(var(--u) * 14); line-height: 1; cursor: pointer; text-align: center; }
body[data-reciting="1"] .listen-big, body[data-reciting="1"] .recite-ear { animation: recite-pulse 1.4s ease-in-out infinite; display: inline-block; }
@keyframes recite-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: 0.75; } }
.screen.recite { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: calc(var(--u) * 1.4); height: 100%; padding: calc(var(--u) * 5) calc(var(--u) * 3) calc(var(--u) * 9); text-align: center; box-sizing: border-box; }
.screen.recite .heading { margin: 0; font-size: calc(var(--u) * 5); }
.recite-count { font-size: calc(var(--u) * 2.6); color: #fff; opacity: 0.9; }
.recite-ayah { max-width: 92%; flex: none; }
.recite-ayah .v-ayah { font-size: calc(var(--u) * 5); }
.recite-tip { font-size: calc(var(--u) * 2.8); color: #fff; margin: 0; }
.recite-keys { display: flex; gap: calc(var(--u) * 2); }
.recite-keys button { font: inherit; font-size: calc(var(--u) * 2.4); padding: calc(var(--u) * 1) calc(var(--u) * 2.4); border: 0; border-radius: 999px; background: rgba(255,255,255,0.9); color: #2b2250; cursor: pointer; }
.recite-keys b { margin-left: 0.4em; padding: 0 0.4em; border-radius: 0.3em; background: #ffe066; }
.recite-sub { font-size: calc(var(--u) * 4); color: #fff; }
.screen.recite .credit { font-size: calc(var(--u) * 1.6); color: #fff; opacity: 0.8; margin: 0; }

/* ---------- Language menu: four languages in two rows of two, each with its own first letter ---------- */
html.landscape .language .cards.grid { grid-template-columns: repeat(2, auto); }
.lang-letter { display: inline-block; min-width: 1.6em; text-align: center; font-weight: 700; }
.lang-arabic { font-family: 'Noto Naskh Arabic', serif; font-size: 1.3em; line-height: 1; }
.lang-urdu { font-family: 'Noto Nastaliq Urdu', 'Noto Naskh Arabic', serif; font-size: 1.1em; line-height: 1; }
/* Bangla: Noto Sans Bengali, bundled (see the Bangla section below). */
.lang-bangla { font-family: 'Noto Sans Bengali', sans-serif; }

/* ---------- Party games: the Rude Quiz sits on its own below the numbered games (key 0) ---------- */
.adults .rude-card {
  margin-top: calc(var(--u) * 2.5); width: calc(var(--u) * 40); padding: calc(var(--u) * 1.3) calc(var(--u) * 2.4);
  background: #1f1b2e; color: #fff; border: calc(var(--u) * 0.4) dashed #f472b6;
}
.adults .card.rude-card:nth-child(n) .badge { background: #db2777; width: calc(var(--u) * 7); height: calc(var(--u) * 7); font-size: calc(var(--u) * 4.8); }
.adults .card.rude-card:nth-child(n) .badge::after { content: none; }
.adults .rude-card .card-name { font-size: calc(var(--u) * 3.1); }
.adults .rude-card small { display: block; font-size: 0.55em; opacity: 0.8; }

/* Listen & Repeat: the word being recited, like a highlighter pen (display.js followRecitation). */
.recite-ayah .w { border-radius: 0.2em; transition: background-color 0.15s, box-shadow 0.15s; }
.recite-ayah .w.reading { background: #ffe066; box-shadow: 0 0 0 0.08em #ffe066; }
/* ...and the bar under the ayah: how far through the surah (right to left, like the ayah). */
.recite-progress { width: min(80%, calc(var(--u) * 60)); height: calc(var(--u) * 1.2); border-radius: 999px; background: rgba(255, 255, 255, 0.3); overflow: hidden; direction: rtl; flex: none; }
.recite-progress-fill { height: 100%; width: 0; border-radius: inherit; background: #ffe066; }

/* ---------- Learn first: the button on a game's levels screen, and the lesson shown full screen ---------- */
.learn-first {
  font: inherit; font-weight: 800; font-size: calc(var(--u) * 3); cursor: pointer; border: 0; border-radius: 999px;
  padding: calc(var(--u) * 1.2) calc(var(--u) * 6); background: #ffd23f; color: #1d1747; box-shadow: 0 calc(var(--u) * 0.5) 0 #b8901a;
  animation: pop-in 0.5s 0.4s cubic-bezier(.2,1.6,.4,1) both;
}
body[data-screen="learn"] .mascot, body[data-screen="review"] .mascot { display: none; }

/* ---------- Learn Mode: lesson cards, the "learn first?" offer, Try it, Show me and the second look ---------- */
.learn-badge {
  display: inline-block; margin-left: 0.5em; padding: 0.05em 0.55em; border-radius: 999px; vertical-align: middle;
  font-size: 0.62em; background: var(--yellow); color: var(--ink); white-space: nowrap;
}
.v-image { display: block; max-width: 100%; max-height: calc(var(--u) * 22); object-fit: contain; margin: 0 auto; }
.learn-badge.start-badge { background: var(--green); color: var(--white); }
.learn-badge.members-badge { background: var(--purple); color: var(--white); }
/* A level whose lesson is done (it can still be opened again with Learn first). */
.learn-badge.learnt-badge { background: var(--white); color: #15803d; box-shadow: inset 0 0 0 0.12em var(--green); }
.lesson-offer {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 5;
  background: rgba(29, 23, 71, 0.55); animation: fade-in 0.25s both;
}
.offer-card, .lesson-card {
  background: var(--white); color: var(--ink); text-align: center;
  border-radius: calc(var(--u) * 3); box-shadow: 0 calc(var(--u) * 0.8) 0 rgba(0, 0, 0, 0.25);
  text-shadow: none; /* dark text on a white card: the screen's drop shadow made it look blurry */
}
.offer-card {
  width: min(88%, calc(var(--u) * 70)); padding: calc(var(--u) * 3);
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 1.4);
  animation: pop-in 0.4s cubic-bezier(.2,1.6,.4,1) both;
}
.offer-card h3 { margin: 0; font-size: calc(var(--u) * 4); }
.offer-card p { margin: 0; font-size: calc(var(--u) * 2.8); }
.offer-card .hint { color: #64748b; font-size: calc(var(--u) * 2.2); }
.offer-icon { font-size: calc(var(--u) * 8); line-height: 1; }
.offer-keys, .learn-keys { display: flex; gap: calc(var(--u) * 1.6); flex-wrap: wrap; justify-content: center; }
.offer-btn, .show-me, .next-step {
  font: inherit; font-weight: 800; cursor: pointer; border: 0; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 0.5em;
  padding: calc(var(--u) * 1) calc(var(--u) * 2.4); font-size: calc(var(--u) * 2.8);
  background: #e2e8f0; color: var(--ink); box-shadow: 0 calc(var(--u) * 0.45) 0 #94a3b8;
}
.offer-btn.go, .next-step { background: var(--yellow); box-shadow: 0 calc(var(--u) * 0.45) 0 #b8901a; }
.offer-btn .key, .show-me .key, .next-step .key { min-width: calc(var(--u) * 3.6); height: calc(var(--u) * 3.6); font-size: calc(var(--u) * 2); }
.show-me { margin-top: calc(var(--u) * 1); background: var(--yellow); box-shadow: 0 calc(var(--u) * 0.45) 0 #b8901a; animation: pop-in 0.4s 0.6s cubic-bezier(.2,1.6,.4,1) both; }
.next-steps { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 1.2); }

.screen.learn, .screen.review {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 2.2); height: 100%;
}
.dots { display: flex; gap: calc(var(--u) * 0.8); }
.dots i { width: calc(var(--u) * 1.6); height: calc(var(--u) * 1.6); border-radius: 50%; background: rgba(255, 255, 255, 0.35); }
.dots i.done { background: rgba(255, 255, 255, 0.85); }
.dots i.on { background: var(--yellow); transform: scale(1.25); }
.lesson-card {
  width: min(92%, calc(var(--u) * 120)); padding: calc(var(--u) * 3) calc(var(--u) * 4);
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 1.8);
  animation: slide-in 0.4s cubic-bezier(.2,.9,.3,1) both;
}
.screen.learn.calm .lesson-card { animation: fade-in 0.6s both; }
.card-title { margin: 0; font-size: calc(var(--u) * 4.6); color: var(--purple); }
.card-text { margin: 0; font-size: calc(var(--u) * 4.2); line-height: 1.3; }
.card-pictures { display: flex; gap: calc(var(--u) * 3); justify-content: center; font-size: calc(var(--u) * 9); line-height: 1; }
.card-pictures img { height: calc(var(--u) * 14); width: auto; object-fit: contain; }
.card-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: calc(var(--u) * 0.8); font-size: calc(var(--u) * 4); }
/* Steps not reached yet stay readable (the user couldn't read them at 0.12), the ones done are clear, and the
   current step is full strength, bigger and blue. */
.card-steps li { opacity: 0.45; transition: opacity 0.35s, transform 0.35s; }
.card-steps li.shown { opacity: 0.85; }
.card-steps li.now { opacity: 1; transform: scale(1.06); color: var(--blue); }
.card-arabic { display: flex; flex-direction: column; gap: calc(var(--u) * 1.4); }
.ar-line { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.3); }
/* Several short words (the five prayers): side by side, in the same order as the card's text, wrapping if needed. */
.card-arabic.ar-grid {
  display: grid; width: 100%; gap: calc(var(--u) * 1.2);
  grid-template-columns: repeat(min(var(--n), 5), minmax(0, 1fr));
}
.card-arabic.ar-grid .ar-line.ar-wide { grid-column: 1 / -1; } /* a long phrase takes a whole row */
.card-arabic.ar-grid .ar { font-size: calc(var(--u) * 4.6); line-height: 1.5; }
.card-arabic.ar-grid .ar-say { font-size: calc(var(--u) * 2.4); }
.card-arabic.ar-grid .ar-mean { font-size: calc(var(--u) * 2.1); line-height: 1.2; }
html.portrait .card-arabic.ar-grid { grid-template-columns: repeat(min(var(--n), 3), minmax(0, 1fr)); }
.ar-line .ar { font-family: "Amiri Quran", "Noto Naskh Arabic", serif; font-size: calc(var(--u) * 5.6); line-height: 1.6; }
.ar-line .ar-say { font-size: calc(var(--u) * 2.8); font-style: italic; color: #475569; }
.ar-line .ar-mean { font-size: calc(var(--u) * 2.6); color: #64748b; }
/* Juz Amma lessons: the ayahs side by side, flowing right to left and wrapping like the lines of a Mushaf, in the
   Qur'an font (.v-ayah). Each is recited in turn; the one being recited has a soft gold background. Calm: no bounce. */
/* The ayahs run on like text: a long ayah carries on to the next line, and its number follows its last word. */
.card-ayahs {
  display: block; direction: rtl; text-align: center; width: 100%;
  font-size: calc(var(--u) * 5.2); line-height: 2.1;
}
.card-ayahs.n4, .card-ayahs.n5 { font-size: calc(var(--u) * 4.6); }
.card-ayahs.n6, .card-ayahs.n7 { font-size: calc(var(--u) * 4.2); }
.card-ayah {
  display: inline; padding: calc(var(--u) * 0.2) calc(var(--u) * 0.5); border-radius: calc(var(--u) * 1.2);
  -webkit-box-decoration-break: clone; box-decoration-break: clone; /* a wrapped ayah's highlight on each line */
  transition: background 0.4s;
}
.card-ayah.now { background: rgba(255, 210, 63, 0.35); }
.card-ayah .visual { display: inline; margin: 0; padding: 0; background: none; box-shadow: none; border: 0; max-width: none; } /* no picture bubble */
.card-ayah .v-ayah { display: inline; font-size: 1em; line-height: inherit; max-width: none; padding: 0; color: var(--ink); }
.ayah-num {
  /* right to left, so it comes after the ayah, on its left: where the ayah ends, as in a Mushaf */
  display: inline-flex; vertical-align: middle; margin: 0 calc(var(--u) * 0.6); direction: ltr; width: calc(var(--u) * 3.4); height: calc(var(--u) * 3.4); border-radius: 50%;
  align-items: center; justify-content: center; line-height: 1;
  font-size: calc(var(--u) * 1.8); font-weight: bold; color: var(--purple); border: calc(var(--u) * 0.25) solid currentColor;
}
.card-done { font-size: calc(var(--u) * 3.4); color: var(--green); animation: pop-in 0.5s cubic-bezier(.2,1.6,.4,1) both; }
.hint-card {
  padding: calc(var(--u) * 1.6) calc(var(--u) * 3); border-radius: calc(var(--u) * 2); background: var(--white); color: var(--ink);
  font-size: calc(var(--u) * 3.6); animation: pop-in 0.4s cubic-bezier(.2,1.6,.4,1) both;
}
.try-results { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 2.4); height: 100%; }
@keyframes slide-in { from { opacity: 0; transform: translateX(8%); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Portrait TV: the card takes the width, the keys stack. */
html.portrait .lesson-card { width: 96%; padding: calc(var(--u) * 3); }
html.portrait .screen.learn, html.portrait .screen.review { padding-top: calc(var(--u) * 12); }
html.portrait .card-text { font-size: calc(var(--u) * 4.8); }
html.portrait .card-title { font-size: calc(var(--u) * 5.2); }
html.portrait .offer-btn, html.portrait .next-step, html.portrait .show-me { font-size: calc(var(--u) * 3.2); }
html.landscape .lesson-card { gap: calc(var(--u) * 1.2); padding: calc(var(--u) * 2) calc(var(--u) * 3); }
html.landscape .screen.learn, html.landscape .screen.review { padding-top: calc(var(--u) * 7); }
html.landscape .card-text, html.landscape .card-steps { font-size: calc(var(--u) * 3.2); }
html.landscape .card-title { font-size: calc(var(--u) * 3.4); }
html.landscape .card-pictures { font-size: calc(var(--u) * 6); }
html.landscape .offer-btn, html.landscape .next-step, html.landscape .show-me { font-size: calc(var(--u) * 2.2); }

/* ---------- Stories of Morals: the whole story, a page at a time ---------- */
/* Laid out like a lesson card; calm: pages fade in, no bounce. The progress bar fills left to right. */
.screen.story {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 2); height: 100%;
}
.screen.story .lesson-card { animation: fade-in 0.8s both; }
.story-progress { direction: ltr; }
.story-progress .recite-progress-fill { transition: width 0.8s; }
.screen.story.done { gap: calc(var(--u) * 2.4); text-align: center; padding: 0 calc(var(--u) * 4); }
.story-end-emoji { font-size: calc(var(--u) * 12); line-height: 1; animation: fade-in 1s both; }
.story-moral {
  margin: 0; max-width: calc(var(--u) * 110); padding: calc(var(--u) * 2.4) calc(var(--u) * 4); border-radius: calc(var(--u) * 2.4);
  background: var(--white); color: var(--purple); font-size: calc(var(--u) * 4.4); line-height: 1.3; animation: fade-in 1.2s 0.4s both;
}
html.portrait .screen.story { padding-top: calc(var(--u) * 12); }
html.portrait .story-moral { font-size: calc(var(--u) * 5); }
html.landscape .screen.story { padding-top: calc(var(--u) * 7); gap: calc(var(--u) * 1.4); }
html.landscape .story-moral { font-size: calc(var(--u) * 3.4); }

/* Animated story scenes (server/content/story-scenes.js): one 680x400 SVG per chapter, above the page's card. */
.story-scene {
  width: min(96%, calc(var(--u) * 100)); aspect-ratio: 680 / 400; border-radius: calc(var(--u) * 1.6);
  overflow: hidden; background: #0d1a26; line-height: 0; flex: none;
  box-shadow: 0 calc(var(--u) * 0.6) calc(var(--u) * 2.4) rgba(0, 0, 0, 0.35); animation: fade-in 0.8s both;
}
.story-scene svg { width: 100%; height: 100%; display: block; }
.story-scene .scene-ayah { font-family: 'Noto Naskh Arabic', serif; }
body[data-arfont="indopak"] .story-scene .scene-ayah { font-family: 'IndoPak Nastaleeq', 'Noto Naskh Arabic', serif; }
html.landscape .story-scene { width: auto; height: 52vh; max-width: 92%; }
html.landscape .screen:has(> .story-scene) .lesson-card { padding-top: calc(var(--u) * 1.2); padding-bottom: calc(var(--u) * 1.2); }
@media (prefers-reduced-motion: reduce) {
  .story-scene * { animation-duration: 1ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
}

/* ---------- No one signed in on this TV yet ---------- */
.screen.signin { display: block; height: 100%; padding: 0; text-align: center; }

/* The family's splash scene behind the sign-in card (display.js SPLASH): pictures placed in the splash's own
   1920×1080 (wide) and 1080×2200 (tall) layouts, as fractions of the stage. */
body[data-screen="signin"] { background: #13277a url("/display/splash/bg-wide.jpg") center / cover no-repeat; }
html.portrait body[data-screen="signin"] { background-image: url("/display/splash/bg-tall.jpg"); }
body[data-screen="signin"] .stage { background: #13277a url("/display/splash/bg-wide.jpg") center / cover no-repeat; }
html.portrait body[data-screen="signin"] .stage { background-image: url("/display/splash/bg-tall.jpg"); }
.splash { position: absolute; inset: 0; overflow: hidden; }
/* On the start and "Who's playing?" screens the pictures sit behind everything else on the screen. */
.screen.attract, .screen.who { isolation: isolate; }
.screen.attract > .splash, .screen.who > .splash { z-index: -1; }
.sp-piece {
  position: absolute; cursor: pointer;
  left: calc(var(--l) / 1920 * 100%); top: calc(var(--t) / 1080 * 100%); width: calc(var(--w) / 1920 * 100%);
  animation: sp-pop 0.6s cubic-bezier(.3,1.6,.5,1) both; animation-delay: calc(var(--i) * 0.04s);
}
/* Portrait: the splash's 1080×2200 layout shrunk to fit the 1080×1920 stage (×0.873), centred across. */
html.portrait .sp-piece {
  left: calc((var(--pl) * 0.873 + 68.6) / 1080 * 100%); top: calc(var(--pt) / 2200 * 100%); width: calc(var(--pw) * 0.873 / 1080 * 100%);
}
html.landscape .sp-piece.no-wide, html.portrait .sp-piece.no-tall { display: none; }
.sp-piece img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.sp-bob { animation: sp-bob 3s ease-in-out infinite; }
.sp-wiggle { animation: sp-wiggle 2.6s ease-in-out infinite; transform-origin: 50% 90%; }
.sp-waddle { animation: sp-waddle 1.4s ease-in-out infinite; transform-origin: 50% 100%; }
.sp-pulse { animation: sp-pulse 1.8s ease-in-out infinite; }
.sp-float { animation: sp-float 6s ease-in-out infinite; }
.sp-shake { animation: sp-shake 2.2s ease-in-out infinite; transform-origin: 85% 85%; }
.sp-hover { animation: sp-hover 2.4s ease-in-out infinite; }
.sp-twinkle { animation: sp-twinkle 2.2s ease-in-out infinite; }
.sp-sway { animation: sp-sway 4s ease-in-out infinite; transform-origin: 50% 0; }
.sp-title-dance { animation: sp-title-dance 3.4s ease-in-out infinite; transform-origin: 50% 60%; }
.sp-boing { animation: sp-boing 0.7s cubic-bezier(.3,1.6,.5,1) !important; }
@keyframes sp-bob { 50% { transform: translateY(-1.3%); } }
@keyframes sp-wiggle { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes sp-waddle { 25% { transform: rotate(-5deg) translateY(-2%); } 75% { transform: rotate(5deg) translateY(-2%); } }
@keyframes sp-pulse { 50% { transform: scale(1.07); } }
@keyframes sp-float { 25% { transform: translate(5%, -10%) rotate(3deg); } 75% { transform: translate(-5%, -4%) rotate(-3deg); } }
@keyframes sp-shake { 0%, 60%, 100% { transform: rotate(0); } 66% { transform: rotate(-10deg); } 72% { transform: rotate(8deg); } 78% { transform: rotate(-6deg); } 84% { transform: rotate(4deg); } }
@keyframes sp-hover { 50% { transform: translateY(-8%) rotate(2deg); } }
@keyframes sp-twinkle { 50% { transform: scale(0.72) rotate(18deg); opacity: 0.75; } }
@keyframes sp-sway { 50% { transform: rotate(2.5deg); } }
@keyframes sp-title-dance { 0%, 100% { transform: rotate(-1.5deg) scale(1); } 50% { transform: rotate(1.5deg) scale(1.04); } }
@keyframes sp-pop { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes sp-boing { 0% { transform: scale(1); } 30% { transform: scale(1.18, 0.86); } 55% { transform: scale(0.92, 1.1); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .sp-piece, .sp-piece .sp-move, .sp-boing { animation: none !important; }
}

/* The sign-in card, where the splash had "Press any button to play". */
.signin-card {
  position: absolute; z-index: 2; left: 35.5%; width: 29%; top: 61%;
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 1.1);
  padding: calc(var(--u) * 1.6) calc(var(--u) * 1.8); border-radius: calc(var(--u) * 2.4);
  background: rgba(19, 39, 122, 0.82); border: calc(var(--u) * 0.3) solid #ffd84a;
  box-shadow: 0 calc(var(--u) * 0.6) 0 rgba(10, 20, 80, 0.45);
  animation: sp-pop 0.6s 0.9s cubic-bezier(.3,1.6,.5,1) both;
}
.signin-card .heading { font-size: calc(var(--u) * 2.6); color: #ffd84a; line-height: 1.15; }
.signin-card .hint { font-size: calc(var(--u) * 1.4); }
.signin-card .small-print { font-size: calc(var(--u) * 1.2); opacity: 0.8; }
html.landscape .signin-card .signin-btn { font-size: calc(var(--u) * 2.2); padding: calc(var(--u) * 0.9) calc(var(--u) * 4); }
html.portrait .signin-card { left: 22%; width: 56%; top: 72%; gap: calc(var(--u) * 1.4); padding: calc(var(--u) * 2.6) calc(var(--u) * 2.4); }
html.portrait .signin-card .heading { font-size: calc(var(--u) * 4.8); }
html.portrait .signin-card .hint { font-size: calc(var(--u) * 2.9); }
html.portrait .signin-card .small-print { font-size: calc(var(--u) * 2.5); }
/* "Demo · Press DEL" on the sign-in screen: big, rainbow, bouncing, with a shine sweeping across. */
.demo-btn {
  position: absolute; z-index: 3; right: 3%; top: 4%;
  display: flex; align-items: center; gap: calc(var(--u) * 1.2);
  padding: calc(var(--u) * 1.2) calc(var(--u) * 2.8); border: calc(var(--u) * 0.35) solid #fff; border-radius: 999px;
  font: inherit; font-weight: 900; color: #fff; cursor: pointer; overflow: hidden;
  background: linear-gradient(90deg, #ff3d7f, #ff9f1c, #ffe94a, #3ddc84, #2ec4ff, #8b5cf6, #ff3d7f);
  background-size: 300% 100%;
  box-shadow: 0 calc(var(--u) * 0.7) 0 rgba(10, 20, 80, 0.45), 0 0 calc(var(--u) * 3) rgba(255, 233, 74, 0.6);
  text-shadow: 0 calc(var(--u) * 0.25) 0 rgba(0, 0, 0, 0.35);
  animation: demo-rainbow 4s linear infinite, demo-bounce 1.6s ease-in-out infinite, sp-pop 0.6s 1.2s cubic-bezier(.3,1.6,.5,1) both;
}
.demo-btn::after { /* the shine */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.65) 50%, transparent 65%);
  transform: translateX(-120%); animation: demo-shine 2.8s ease-in-out infinite;
}
.demo-btn-icon { font-size: calc(var(--u) * 4.4); line-height: 1; animation: demo-wiggle 1.6s ease-in-out infinite; }
.demo-btn-text { display: flex; flex-direction: column; align-items: flex-start; font-size: calc(var(--u) * 3.6); line-height: 1; }
.demo-btn-text small { font-size: calc(var(--u) * 1.8); margin-top: calc(var(--u) * 0.5); }
.demo-btn-text b { background: #1d1747; border-radius: calc(var(--u) * 0.5); padding: 0 calc(var(--u) * 0.6); }
/* Top left of the sign-in screen, just right of the hot-air balloon (the user's choice); in portrait, above the title. */
html.landscape .demo-btn { right: auto; left: 14%; top: 4%; padding: calc(var(--u) * 0.9) calc(var(--u) * 1.9); }
html.landscape .demo-btn-icon { font-size: calc(var(--u) * 3.2); }
html.landscape .demo-btn-text { font-size: calc(var(--u) * 2.7); }
html.landscape .demo-btn-text small { font-size: calc(var(--u) * 1.4); }
html.portrait .demo-btn { right: auto; left: 22%; top: 1.1%; padding: calc(var(--u) * 0.8) calc(var(--u) * 2.4); }
html.portrait .demo-btn-icon { font-size: calc(var(--u) * 3.8); }
html.portrait .demo-btn-text { font-size: calc(var(--u) * 3.1); }
html.portrait .demo-btn-text small { font-size: calc(var(--u) * 1.6); }
/* The start screen (the user's choice): at the left edge, beside "Press any button to play!" on a wide screen and
   just above it on the portrait TV (its own line there, so it doesn't cover the title). The line stays centred:
   the row is three columns, the button in the first. */
.screen.attract .cta-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.screen.attract .cta-row .cta { grid-column: 2; }
html .screen.attract .cta-row .demo-btn {
  grid-column: 1; justify-self: start; position: relative; top: auto; left: auto; right: auto; translate: none;
}
html.portrait .screen.attract .cta-row .demo-btn { grid-column: 1 / -1; grid-row: 1; margin-bottom: calc(var(--u) * 0.8); }
html.portrait .screen.attract .cta-row .cta { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
@keyframes demo-rainbow { to { background-position: 300% 0; } }
@keyframes demo-bounce { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(calc(var(--u) * -0.8)) scale(1.04); } }
@keyframes demo-shine { 0%, 40% { transform: translateX(-120%); } 80%, 100% { transform: translateX(120%); } }
@keyframes demo-wiggle { 0%, 100% { rotate: -8deg; } 50% { rotate: 8deg; } }
/* The demo itself: a question screen with a strip on top, and the answer's explanation at the end. */
.screen.demo .demo-bar { display: flex; gap: calc(var(--u) * 1); justify-content: center; flex-wrap: wrap; }
.screen.demo .demo-stop b { background: #ffd23f; color: #1d1747; border-radius: calc(var(--u) * 0.4); padding: 0 calc(var(--u) * 0.5); }
.demo-answer {
  font-size: calc(var(--u) * 3.2); font-weight: 800; color: #fff; text-align: center; max-width: 90%;
  background: rgba(22, 163, 74, 0.85); border-radius: calc(var(--u) * 2); padding: calc(var(--u) * 1.2) calc(var(--u) * 2.4);
  animation: sp-pop 0.5s cubic-bezier(.3,1.6,.5,1) both;
}
.screen.demo.demo-reveal .entry { color: #16a34a; }

/* Two ways to sign in, side by side: the button (OK) here, or the QR code for a phone (server/tv-link.js). */
.signin-ways { display: flex; align-items: center; justify-content: center; gap: calc(var(--u) * 2.4); width: 100%; }
.signin-here { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.8); }
.signin-qr { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.5); }
.signin-qr img {
  width: calc(var(--u) * 11); height: calc(var(--u) * 11); background: #fff;
  padding: calc(var(--u) * 0.6); border-radius: calc(var(--u) * 1);
}
.signin-qr img[hidden] { display: none; }
html.landscape .signin-card { left: 30%; width: 40%; }
/* Portrait: the card sits below the splash pictures, so it is kept compact to fit above the bottom edge. */
html.portrait .signin-card { top: 71%; gap: calc(var(--u) * 1); padding: calc(var(--u) * 1.5) calc(var(--u) * 2); }
html.portrait .signin-card .heading { font-size: calc(var(--u) * 4); }
html.portrait .signin-card .hint { font-size: calc(var(--u) * 2.4); line-height: 1.25; }
html.portrait .signin-card .small-print { font-size: calc(var(--u) * 2.2); }
html.portrait .signin-card .signin-btn { font-size: calc(var(--u) * 3); padding: calc(var(--u) * 1) calc(var(--u) * 4.5); }
html.portrait .signin-qr img { width: calc(var(--u) * 11); height: calc(var(--u) * 11); }
html.portrait .signin-ways { gap: calc(var(--u) * 1.6); }
html.portrait .signin-qr .small-print { font-size: calc(var(--u) * 2); max-width: calc(var(--u) * 21); line-height: 1.2; }
html.portrait .signin-here .small-print { font-size: calc(var(--u) * 2); line-height: 1.2; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.signin-btn { font-weight: 800; font-size: calc(var(--u) * 3.4); text-decoration: none; padding: calc(var(--u) * 1.4) calc(var(--u) * 6); border-radius: 999px; background: #ffd23f; color: #1d1747; box-shadow: 0 calc(var(--u) * 0.6) 0 #b8901a; }

/* ---------- About the app: the web page below the sign-in screen (index.html #about) ----------
   Only while nobody is signed in. The body scrolls; the stage stays the first screenful (the hero), and the page
   starts just below it (top: 100% of the body), so a TV that never scrolls looks exactly as before. Ordinary web
   sizes (rem), not the TV's --u. */
.about { display: none; }
body[data-screen="signin"] { position: relative; overflow-x: hidden; overflow-y: auto; scroll-behavior: smooth; }
body[data-screen="signin"] .about {
  display: block; position: absolute; top: 100%; left: 0; right: 0;
  cursor: auto; color: #1d1747; font-size: clamp(1rem, 0.9rem + 0.4vw, 1.25rem); line-height: 1.5;
}
.about a { color: inherit; }
/* "Find out more": a bouncing pill on the bottom edge of the hero, for browsers with a mouse or a touch screen. */
.about-cue {
  position: absolute; top: -1.3rem; right: 4%; z-index: 5; display: none;
  padding: 0.45em 1.3em; border-radius: 999px; background: #fff; color: #1d1747 !important; text-decoration: none;
  font-weight: 900; font-size: clamp(0.95rem, 0.8rem + 0.4vw, 1.2rem); white-space: nowrap;
  box-shadow: 0 0.3rem 0 #b8901a, 0 0 1.2rem rgba(255, 233, 74, 0.7);
  animation: about-cue 1.6s ease-in-out infinite;
}
@media (hover: hover), (pointer: coarse) { .about-cue { display: block; } }
/* The portrait TV itself (1080×1920 and up): no cue. */
@media (orientation: portrait) and (min-height: 1800px) and (hover: none) { .about-cue { display: none; } }
@keyframes about-cue { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-0.4rem); } }
.about-rainbow { height: 0.6rem; background: linear-gradient(90deg, #ff3d7f, #ff9f1c, #ffe94a, #3ddc84, #2ec4ff, #8b5cf6); }

/* The bands: each its own bright gradient, with a scalloped bottom edge that bites into the next band. */
.about-band {
  --scallop: 2.4rem;
  position: relative; text-align: center; padding: 4rem 1.25rem calc(4rem + var(--scallop) / 2);
  display: flex; flex-direction: column; align-items: center; gap: 1.6rem;
}
.about-band::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: calc(var(--scallop) / -2 + 1px); height: calc(var(--scallop) / 2); z-index: 3;
  background: radial-gradient(circle calc(var(--scallop) / 2) at 50% 0, var(--edge) 96%, transparent 100%)
    0 0 / var(--scallop) calc(var(--scallop) / 2) repeat-x;
  pointer-events: none;
}
.band-inside { --edge: #4f6ef7; background: linear-gradient(160deg, #8b5cf6 0%, #4f6ef7 60%, #4f6ef7 100%); }
.band-how { --edge: #ff4f8a; background: linear-gradient(160deg, #ff9f1c 0%, #ff4f8a 70%); }
.band-prices { --edge: #ffb627; background: linear-gradient(160deg, #ffe94a 0%, #ffb627 70%); }
.band-safe { --edge: #10b981; background: linear-gradient(160deg, #2ec4ff 0%, #10b981 70%); }
.band-faq { --edge: #8b5cf6; background: linear-gradient(160deg, #c026d3 0%, #8b5cf6 70%); }
.about-band > * { position: relative; z-index: 2; max-width: 72rem; }

.about-title {
  font-size: clamp(2rem, 1.4rem + 2.6vw, 3.6rem); line-height: 1.1; font-weight: 900; color: #ffe94a;
  text-shadow: 0 0.06em 0 #1d1747, 0.04em 0.04em 0 #1d1747, -0.04em 0.04em 0 #1d1747, 0.04em -0.03em 0 #1d1747,
    -0.04em -0.03em 0 #1d1747, 0 0.14em 0 rgba(29, 23, 71, 0.35);
  animation: sp-title-dance 4s ease-in-out infinite;
}
.band-prices .about-title { color: #fff; }
.about-lead { max-width: 46rem; color: #fff; font-size: 1.15em; text-shadow: 0 0.08em 0 rgba(29, 23, 71, 0.35); }
.band-prices .about-lead, .band-prices .about-small { color: #1d1747; text-shadow: none; }
.about-small { color: #fff; font-size: 0.9em; }

/* Chunky white cards with a coloured stripe on top, a little tilt, and a boing on hover. */
.about-cards { display: grid; gap: 1.4rem; width: 100%; }
.about-cards.five { grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr)); }
.about-cards.three { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.about-card {
  --c: #4d7cff;
  background: #fff; border-radius: 1.6rem; padding: 1.4rem 1.2rem 1.5rem; border-top: 0.6rem solid var(--c);
  box-shadow: 0 0.45rem 0 rgba(29, 23, 71, 0.22), 0 1rem 2rem rgba(29, 23, 71, 0.18);
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem; transform: rotate(-1.2deg);
}
.about-card:nth-child(even) { transform: rotate(1.2deg); }
.about-card:hover { animation: about-boing 0.6s cubic-bezier(.3,1.6,.5,1); }
.about-card h3 { font-size: 1.35em; line-height: 1.2; color: var(--c-ink, #1d1747); }
.about-card p { font-size: 0.95em; }
.about-card-pic {
  width: 6.5rem; height: 6.5rem; object-fit: contain; padding: 0.8rem; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 28%, #fff); animation: sp-bob 3s ease-in-out infinite;
}
.about-card:nth-child(2n) .about-card-pic { animation-delay: -1s; }
.about-card:nth-child(3n) .about-card-pic { animation-delay: -2s; }
.about-card.calm .about-card-pic { animation: none; } /* calm, as in the Arabic section */
.c-pink { --c: #ff4f8a; } .c-blue { --c: #4d7cff; } .c-green { --c: #22c55e; } .c-teal { --c: #14b8a6; }
.c-orange { --c: #ff9f1c; } .c-yellow { --c: #ffd23f; } .c-purple { --c: #8b5cf6; }
@keyframes about-boing { 0% { scale: 1; } 30% { scale: 1.06 0.94; } 55% { scale: 0.97 1.04; } 100% { scale: 1; } }

/* How it works: 1–2–3 as big keypad buttons. */
.about-steps { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1.4rem; width: 100%; }
.about-step { background: rgba(255, 255, 255, 0.95); border-radius: 1.6rem; padding: 2.6rem 1.2rem 1.4rem; position: relative; margin-top: 2rem;
  box-shadow: 0 0.45rem 0 rgba(29, 23, 71, 0.22); }
.about-step h3 { font-size: 1.3em; margin-bottom: 0.3rem; }
.step-key {
  position: absolute; top: -2rem; left: 50%; translate: -50% 0; width: 4rem; height: 4rem; border-radius: 1.1rem;
  display: grid; place-items: center; font-size: 2.2rem; font-weight: 900; color: #fff;
  box-shadow: 0 0.35rem 0 rgba(29, 23, 71, 0.4); text-shadow: 0 0.1rem 0 rgba(0, 0, 0, 0.3);
  animation: sp-bob 2.4s ease-in-out infinite;
}
.k1 { background: #22c55e; } .k2 { background: #4d7cff; animation-delay: -0.8s; } .k3 { background: #8b5cf6; animation-delay: -1.6s; }

/* Prices: colourful tickets. */
.about-prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1.4rem; width: 100%; }
.ticket {
  --c: #4d7cff;
  position: relative; background: #fff; border-radius: 1.4rem; padding: 1.6rem 1rem 1.3rem; border: 0.3rem dashed var(--c);
  box-shadow: 0 0.45rem 0 rgba(29, 23, 71, 0.22); transform: rotate(-1.5deg);
}
.ticket:nth-child(even) { transform: rotate(1.5deg); }
.ticket:hover { animation: about-boing 0.6s cubic-bezier(.3,1.6,.5,1); }
.ticket h3 { font-size: 1.25em; color: var(--c); }
.ticket-price { font-size: 2.6em; font-weight: 900; line-height: 1.1; }
.t-green { --c: #16a34a; } .t-blue { --c: #2563eb; } .t-purple { --c: #7c3aed; } .t-pink { --c: #db2777; }
.ticket.best { border-style: solid; box-shadow: 0 0.45rem 0 rgba(29, 23, 71, 0.22), 0 0 0 0.35rem #fff, 0 0 1.6rem rgba(219, 39, 119, 0.6); }
.ticket-badge {
  position: absolute; top: -1rem; left: 50%; translate: -50% 0; white-space: nowrap;
  background: #db2777; color: #fff; font-weight: 900; font-size: 0.85em; padding: 0.2em 0.9em; border-radius: 999px;
  animation: sp-pulse 1.8s ease-in-out infinite;
}

.about-btn {
  display: inline-block; font-weight: 900; font-size: 1.3em; text-decoration: none; padding: 0.7em 2em; border-radius: 999px;
  background: #ffd23f; color: #1d1747 !important; box-shadow: 0 0.35rem 0 #b8901a; border: 0.2rem solid #fff;
  animation: sp-pulse 2.2s ease-in-out infinite;
}
.band-prices .about-btn { background: #db2777; color: #fff !important; box-shadow: 0 0.35rem 0 #9d174d; }
.about-btn:active { translate: 0 0.25rem; box-shadow: none; }

/* Questions: pill-shaped rows that open. */
.about-faq { width: 100%; max-width: 48rem; display: flex; flex-direction: column; gap: 0.8rem; text-align: left; }
.about-faq details { background: #fff; border-radius: 1.6rem; box-shadow: 0 0.3rem 0 rgba(29, 23, 71, 0.25); overflow: hidden; }
.about-faq summary { cursor: pointer; font-weight: 800; padding: 0.9rem 1.4rem; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.about-faq summary::-webkit-details-marker { display: none; }
.about-faq summary::after { content: '+'; font-weight: 900; color: #8b5cf6; font-size: 1.3em; line-height: 1; transition: rotate 0.2s; }
.about-faq details[open] summary::after { rotate: 45deg; }
.about-faq details p { padding: 0 1.4rem 1rem; }

.about-footer { background: #1d1747; color: #fff; text-align: center; padding: 2.6rem 1rem 2rem; display: flex; flex-direction: column; gap: 0.8rem; }
.about-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem 1.6rem; }
.about-footer a { color: #ffe94a; }

/* Floating splash pictures in the bands' corners (animals and things only: no people below the hero). */
.about-deco { position: absolute !important; z-index: 1 !important; pointer-events: none; height: auto; }
.deco-a { width: 4rem; top: 1.5rem; left: 6%; }
.deco-b { width: 7rem; top: 2rem; right: 5%; }
.deco-c { width: 3.5rem; bottom: 3rem; left: 10%; }
.deco-d { width: 5rem; top: 2rem; right: 6%; }
.deco-e { width: 4rem; top: 2.5rem; left: 7%; }
.deco-f { width: 5rem; top: 1.5rem; left: 5%; }
.deco-g { width: 4rem; top: 2rem; right: 8%; }
.deco-h { width: 8rem; bottom: 1.5rem; right: 3%; }
@media (max-width: 700px) {
  .about-cue { top: 1.1rem; } /* below the hero's edge: the sign-in card reaches the bottom on a phone */
  .about-deco { opacity: 0.55; transform-origin: center; }
  .deco-b, .deco-h { width: 4.5rem; }
  .about-band { padding-top: 3.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .about *, .about-cue { animation: none !important; }
  body[data-screen="signin"] { scroll-behavior: auto; }
}

/* Family party games: six games and the Rude Quiz. Three columns on a TV and two on the portrait monitor, so the
   menu fits without shrinking. */
html.landscape .adults .cards.grid { grid-template-columns: repeat(3, auto); gap: calc(var(--u) * 2) calc(var(--u) * 2.5); }
html.landscape .adults .cards.grid .card { width: calc(var(--u) * 29); padding: calc(var(--u) * 1.4) calc(var(--u) * 2); gap: calc(var(--u) * 1.5); }
html.landscape .adults .cards.grid .badge { width: calc(var(--u) * 6.5); height: calc(var(--u) * 6.5); font-size: calc(var(--u) * 4.5); flex-shrink: 0; }
html.landscape .adults .cards.grid .card-name { font-size: calc(var(--u) * 3); }
html.portrait .adults .cards.grid { grid-template-columns: repeat(2, 1fr); gap: calc(var(--u) * 1.6); }
html.portrait .adults .cards.grid .card { width: calc(var(--u) * 25); padding: calc(var(--u) * 1.6); gap: calc(var(--u) * 1.2); }
html.portrait .adults .cards.grid .badge { width: calc(var(--u) * 6); height: calc(var(--u) * 6); font-size: calc(var(--u) * 4.2); flex-shrink: 0; }
html.portrait .adults .cards.grid .card-name { font-size: calc(var(--u) * 3.1); text-align: left; }

/* "Grown-ups: please verify your email": a warning bubble in the top-right corner of the start and "Who's playing?"
   screens, left of where the sound icon can appear. */
/* The grown-ups' bubbles share one corner: top-right (left of the sound icon), or bottom-left in portrait. */
.tv-bubbles {
  position: absolute; top: calc(var(--u) * 1.5); right: calc(var(--u) * 7.5); z-index: 3;
  display: flex; flex-direction: column; align-items: stretch; gap: calc(var(--u) * 0.8);
  width: calc(var(--u) * 26);
}
html.portrait .tv-bubbles { top: auto; bottom: calc(var(--u) * 1.5); right: auto; left: calc(var(--u) * 1.5); width: calc(var(--u) * 33); }
.tv-verify {
  padding: calc(var(--u) * 1) calc(var(--u) * 1.4);
  background: #fff7e6; color: #5c3b00; text-shadow: none; text-align: left;
  border: calc(var(--u) * 0.25) solid #f59e0b; border-radius: calc(var(--u) * 1.2);
  box-shadow: 0 calc(var(--u) * 0.5) calc(var(--u) * 1.5) rgba(0, 0, 0, 0.3);
  font-size: calc(var(--u) * 1.25); line-height: 1.3;
  animation: tv-verify-pop 0.5s cubic-bezier(.2, 1.4, .4, 1) both, tv-verify-nudge 4s ease-in-out 1s infinite;
}
.tv-verify-title { font-weight: 700; font-size: calc(var(--u) * 1.45); margin-bottom: calc(var(--u) * 0.3); padding-right: calc(var(--u) * 2.5); }
.tv-verify { position: relative; }
/* The × to close a bubble: big enough to tap on a touch screen. */
.tv-bubble-close {
  position: absolute; top: calc(var(--u) * 0.3); right: calc(var(--u) * 0.3);
  width: calc(var(--u) * 3); height: calc(var(--u) * 3); padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: inherit;
  font: inherit; font-size: calc(var(--u) * 2.2); line-height: 1; cursor: pointer;
}
.tv-bubble-close:hover, .tv-bubble-close:focus-visible { background: rgba(0, 0, 0, 0.08); outline: none; }
.tv-verify-by { margin-top: calc(var(--u) * 0.3); color: #9a3412; }
@keyframes tv-verify-pop { from { opacity: 0; transform: translateY(calc(var(--u) * -1.5)) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes tv-verify-nudge { 0%, 88%, 100% { transform: none; } 92% { transform: rotate(-2deg); } 96% { transform: rotate(2deg); } }
html.portrait .tv-verify { font-size: calc(var(--u) * 1.5); } /* the owl is bottom-right */
/* Free days: the same bubble in green, without the attention-grabbing wiggle. */
.tv-verify.tv-trial { background: #ecfdf3; color: #14532d; border-color: #16a34a; animation: tv-verify-pop 0.5s cubic-bezier(.2, 1.4, .4, 1) 0.15s both; }
.tv-trial .tv-verify-by { color: #166534; }
html.portrait .tv-verify-title { font-size: calc(var(--u) * 1.7); }
@media (prefers-reduced-motion: reduce) { .tv-verify { animation: none; } }
/* While the verify warning shows, the owl stays quiet so its speech bubble can't cover it. */
body:has(.tv-bubbles) .mascot-say { display: none !important; }
/* Portrait start screen: room under the two cards for the verify warning. */
html.portrait .screen.attract:has(.tv-verify) { padding-bottom: calc(var(--u) * 15); }
html.portrait .screen.attract:has(.tv-verify + .tv-verify) { padding-bottom: calc(var(--u) * 27); } /* two bubbles */

/* Free plan: minutes left today, a small pill at the bottom-centre of the start and "Who's playing?" screens. */
.free-badge {
  position: absolute; bottom: calc(var(--u) * 1.5); left: 50%; transform: translateX(-50%); z-index: 3;
  padding: calc(var(--u) * 0.5) calc(var(--u) * 1.6);
  background: rgba(10, 6, 40, 0.6); color: #fff; border-radius: calc(var(--u) * 3);
  font-size: calc(var(--u) * 1.5); font-weight: 700; white-space: nowrap;
}
html.portrait .free-badge { bottom: auto; top: calc(var(--u) * 1.5); left: auto; right: calc(var(--u) * 1.5); transform: none; font-size: calc(var(--u) * 1.4); }
.small-print { font-size: calc(var(--u) * 1.4); opacity: 0.6; }

/* Start screen: room for the verify warning (top-right) and the Free plan pill (bottom) so neither covers anything. */
html.landscape .screen.attract:has(.tv-verify) { padding-top: calc(var(--u) * 9); }
html.landscape .screen.attract:has(.tv-verify + .tv-verify) { padding-top: calc(var(--u) * 18); } /* two bubbles */
/* "Who's playing?": room for the grown-ups' bubbles too, so they don't cover the heading. */
html.landscape .screen.who:has(.tv-verify) { padding-top: calc(var(--u) * 11); }
html.landscape .screen.who:has(.tv-verify + .tv-verify) { padding-top: calc(var(--u) * 19); }
html.portrait .screen.who:has(.tv-verify) { padding-bottom: calc(var(--u) * 15); }
html.portrait .screen.who:has(.tv-verify + .tv-verify) { padding-bottom: calc(var(--u) * 24); }
html.landscape .screen.attract:has(.free-badge) { padding-bottom: calc(var(--u) * 6); }
html.portrait .screen.attract:has(.free-badge) { padding-top: calc(var(--u) * 5); }

/* Start screen: the "Magic Whizz Kids!" logo turning slowly in the top-right corner. */
.cta-row { position: static; z-index: 1; width: 100%; display: flex; justify-content: center; align-items: center; }
.spin-logo {
  position: absolute; top: calc(var(--u) * 1.5); right: calc(var(--u) * 1.5); z-index: 0; /* behind the title and buttons */
  width: calc(var(--u) * 18); pointer-events: none;
}
/* The grown-ups' bubbles move left of the logo on the start screen (landscape; in portrait they're bottom-left). */
html.landscape .screen.attract .tv-bubbles { right: calc(var(--u) * 21); }
.spin-logo img {
  display: block; width: 100%; height: auto;
  filter: drop-shadow(0 calc(var(--u) * 0.5) calc(var(--u) * 0.6) rgba(0, 0, 0, 0.3));
  animation: logo-spin 12s linear infinite;
}
@keyframes logo-spin { to { transform: rotate(360deg); } }
html.portrait .spin-logo { width: calc(var(--u) * 16); }
@media (prefers-reduced-motion: reduce) { .spin-logo img { animation: none; } }
/* The title, play button and cards stay in front of the turning logo. */
.screen.attract .title, .screen.attract .family-name, .screen.attract .cta, .screen.attract .attract-cards { position: relative; z-index: 1; }
/* The Grown-ups card can be tapped or clicked to open the grown-ups' pages (they ask for the password first). */
.admin-link { cursor: pointer; }

/* "See it on the big screen": real TV screens in a coverflow carousel (about-carousel.js), with TV frames. */
.band-screens { --edge: #1d4ed8; background: linear-gradient(160deg, #22d3ee 0%, #3b82f6 55%, #1d4ed8 100%); }
.band-screens > .ac-row { width: 100%; max-width: 80rem; }
/* The carousel, with the phone floating in front of it over the left-hand TVs. */
.ac-row { position: relative; }
.ac-row > .app-carousel { width: 100%; }

/* A child's phone pad: the four coloured answer buttons (1-4, with their shapes) and DEL / OK, floating, with a tap
   that moves from button to button. */
.phone-mock {
  position: absolute; z-index: 10; left: 3%; bottom: 2.2rem; width: min(6rem, 10vw); pointer-events: none;
  display: flex; flex-direction: column; align-items: center; animation: pm-float 4s ease-in-out infinite; }
.pm-body {
  width: 100%; aspect-ratio: 9 / 17; border-radius: 1.05rem; padding: 0.4rem; background: #1d1747; position: relative;
  display: flex; flex-direction: column; gap: 0.32rem;
  box-shadow: inset 0 0 0 0.18rem #3d3577, 0 1.4rem 2.6rem rgba(29, 23, 71, 0.45);
  transform: rotate(-6deg); animation: pm-tilt 4s ease-in-out infinite;
}
.pm-notch { width: 34%; height: 0.48rem; margin: 0 auto; border-radius: 0 0 0.6rem 0.6rem; background: #0d0a26; }
.pm-top { display: flex; justify-content: space-between; align-items: center; gap: 0.3rem; color: #fff; font-size: 0.4rem; font-weight: 900; padding: 0 0.1rem; }
.pm-team { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-score { white-space: nowrap; opacity: 0.85; }
.pm-score b { color: #ffe94a; }
.pm-pad { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr 0.45fr; gap: 0.26rem; }
.pm-pad b { position: absolute; top: 0.18rem; left: 0.28rem; font-size: 0.45rem; opacity: 0.9; }
.pm-pad .pm-small { background: #3d3577; box-shadow: 0 0.2rem 0 #0d0a26; font-size: 0.42rem; font-weight: 900; }
.pm-pad .pm-small.ok { background: #ffe94a; color: #1d1747; box-shadow: 0 0.2rem 0 #b59a00; }
.pm-pad span {
  display: grid; place-items: center; border-radius: 0.45rem; color: #fff; font-size: 1.1rem; line-height: 1; position: relative;
  animation: pm-tap 9s ease-in-out infinite; animation-delay: calc(var(--i) * 1.5s);
}
.pm-pad .c1 { background: #e21b3c; box-shadow: 0 0.3rem 0 #8f0f25; } .pm-pad .c2 { background: #1368ce; box-shadow: 0 0.3rem 0 #0b3f7d; }
.pm-pad .c3 { background: #d89e00; box-shadow: 0 0.3rem 0 #8a6500; } .pm-pad .c4 { background: #26890c; box-shadow: 0 0.3rem 0 #165207; }
.pm-pad .c3 { font-size: 1.5rem; }
.pm-shadow { width: 70%; height: 0.6rem; margin-top: 0.8rem; border-radius: 50%; background: rgba(29, 23, 71, 0.35); filter: blur(4px); animation: pm-shadow 4s ease-in-out infinite; }
@keyframes pm-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-0.9rem); } }
@keyframes pm-tilt { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(-3deg); } }
@keyframes pm-shadow { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.75); opacity: 0.6; } }
/* Each button's turn lasts 1.5 s of the 9 s (six buttons: four colours, DEL and OK): pressed in, outlined in white, then back. */
@keyframes pm-tap {
  0%, 12%, 100% { transform: none; outline: 0 solid transparent; }
  2% { transform: translateY(0.2rem) scale(0.92); outline: 0.22rem solid #fff; outline-offset: -0.22rem; }
  9% { transform: none; outline: 0.22rem solid #fff; outline-offset: -0.22rem; }
}
/* The second phone, over the lower right: tilted the other way, and half a bob out of step with the first. */
.phone-mock.pm-right { left: auto; right: 3%; animation-delay: -2s; }
.pm-right .pm-body { transform: rotate(6deg); animation-name: pm-tilt-r; animation-delay: -2s; }
.pm-right .pm-shadow { animation-delay: -2s; }
@keyframes pm-tilt-r { 0%, 100% { transform: rotate(6deg); } 50% { transform: rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { .phone-mock, .pm-body, .pm-shadow, .pm-pad span { animation: none; } }
/* Narrower screens: a smaller phone, over the bottom-left corner of the TV in front. */
@media (max-width: 900px) {
  .phone-mock { width: 3.8rem; left: 1%; top: auto; bottom: 7.2rem; }
  .phone-mock.pm-right { left: auto; right: 1%; }
  .pm-body { border-radius: 0.9rem; padding: 0.32rem; gap: 0.25rem; }
  .pm-notch { height: 0.4rem; }
  .pm-pad { gap: 0.22rem; }
  .pm-pad span { font-size: 0.7rem; border-radius: 0.35rem; }
  .pm-pad .c3 { font-size: 0.95rem; }
  .pm-pad b { display: none; }
  .pm-pad .pm-small { font-size: 0.3rem; }
  .pm-top { display: none; }
  .pm-shadow { margin-top: 0.8rem; height: 0.6rem; }
}

.deco-i { width: 4rem; top: 1.8rem; left: 6%; }
.deco-j { width: 5rem; top: 2rem; right: 6%; }
.app-carousel {
  --ac-w: min(42rem, 62vw);                /* the TV in front */
  --ac-h: calc(var(--ac-w) * 9 / 16 + 1.6rem); /* the stage: the TV and its stand */
  --ac-step: 58%;                          /* how far the neighbours sit from the middle */
  --ac-angle: 38deg;                       /* how much they turn away */
  position: relative; min-width: 0; outline: none; overflow: hidden; padding: 1.2rem 0 0.2rem;
}
.app-carousel:focus-visible { box-shadow: 0 0 0 0.25rem rgba(255, 233, 74, 0.8); border-radius: 1.4rem; }
.ac-stage { position: relative; height: var(--ac-h); perspective: 1600px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.ac-slide {
  --offset: 0; margin: 0; position: absolute; top: 0; left: 50%; width: var(--ac-w); margin-left: calc(var(--ac-w) / -2);
  transform: translateX(calc(var(--offset) * var(--ac-step))) rotateY(calc(var(--offset) * -1 * var(--ac-angle))) scale(0.78);
  transition: transform 0.6s cubic-bezier(0.22, 0.8, 0.3, 1), opacity 0.6s, filter 0.6s;
  opacity: 0; visibility: hidden; cursor: pointer; z-index: 1;
}
/* A TV: a dark bezel, and a little stand under it. */
.tv-mock {
  position: relative; padding: 0.55rem; border-radius: 1rem; background: #1d1747;
  box-shadow: 0 0.9rem 2rem rgba(29, 23, 71, 0.35);
}
.tv-mock::after {
  content: ''; position: absolute; left: 50%; bottom: -1.1rem; transform: translateX(-50%);
  width: 22%; height: 1.1rem; border-radius: 0 0 0.6rem 0.6rem; background: #1d1747;
}
.tv-mock img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 0.5rem; pointer-events: none; }
.ac-slide[data-abs="0"] { opacity: 1; visibility: visible; z-index: 5; cursor: default; transform: translateX(0) rotateY(0) scale(1); }
.ac-slide[data-abs="0"] .tv-mock { box-shadow: 0 1.2rem 3rem rgba(29, 23, 71, 0.45); }
.ac-slide[data-abs="1"] { opacity: 0.92; visibility: visible; z-index: 4; filter: brightness(0.9); }
.ac-slide[data-abs="2"] {
  opacity: 0.5; visibility: visible; z-index: 3; filter: brightness(0.85);
  transform: translateX(calc(var(--offset) * var(--ac-step) * 0.88)) rotateY(calc(var(--offset) * -0.5 * var(--ac-angle))) scale(0.6);
}
.ac-caption {
  text-align: center; font-weight: 900; color: #fff; font-size: 1.2em; min-height: 1.6em; margin: 1.6rem 0 0.8rem;
  text-shadow: 0 0.08em 0 rgba(29, 23, 71, 0.4);
}
.ac-controls { display: flex; align-items: center; justify-content: center; gap: 0.9rem; }
.ac-arrow {
  width: 2.8rem; height: 2.8rem; border-radius: 50%; border: 0; background: #fff; color: var(--ink);
  font: inherit; font-size: 1.7rem; font-weight: 900; line-height: 1; cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 0.25rem 0 rgba(29, 23, 71, 0.3); transition: background 0.2s, transform 0.2s;
}
.ac-arrow:hover { background: #ffe94a; transform: translateY(-2px); }
.ac-dots { display: flex; gap: 0.5rem; }
.ac-dots button {
  width: 0.65rem; height: 0.65rem; padding: 0; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.5);
  cursor: pointer; transition: width 0.3s, background 0.3s;
}
.ac-dots button[aria-current="true"] { width: 1.6rem; background: #ffe94a; }
@media (max-width: 700px) {
  .app-carousel { --ac-w: 78vw; --ac-step: 46%; --ac-angle: 30deg; }
  .ac-caption { font-size: 1.05em; padding: 0 0.5rem; }
}
