/* Layout: one bright card per screen on a candy-sky background, a rainbow stepping-stone path of 15 stones on top, a colourful number pad below. Deliberately one bright look in every theme. */
:root {
  --sky1: #fff1b8;
  --sky2: #ffd3e7;
  --sky3: #c9f6e4;
  --sky-mid: #ffe4f1;
  --surface: #ffffff;
  --ink: #4a1638;
  --muted: #8c4f74;
  --accent: #ff3f9b;
  --accent2: #d23a8e;
  --accent-ink: #ffffff;
  --sun: #ffd23f;
  --leaf: #12c9a8;
  --leaf-soft: #d2fbf1;
  --sun-soft: #fff4c2;
  --pink-soft: #ffe3f1;
  --lilac-soft: #ffe6f2;
  --stone: #ffffffaa;
  --line: #ffd0e5;
  --shadow: 0 7px 0 #f2a6c9, 0 12px 22px rgba(160, 30, 100, .22);
  --shadow-press: 0 3px 0 #f2a6c9, 0 5px 10px rgba(160, 30, 100, .2);
  --r1: #ff5c8a; --r2: #ff9f43; --r3: #ffd23f; --r4: #2ed3a0; --r5: #49c6ff; --r6: #b36bff;
  --display: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, .slot { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html {
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  min-height: 100%;
  background-color: var(--sky2);
}
body { margin: 0; background: transparent;
  color: var(--ink);
  font-family: var(--body); font-size: 18px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
/* Layers, back to front: the colour (on html), the gradient, the floating stars and hearts, then the game.
   Both background layers are fixed and as tall as the largest viewport, so they also sit under Safari's bars and never scroll. */
.backdrop, .sparkles { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100lvh; pointer-events: none; }
.backdrop {
  z-index: -2;
  /* Top and bottom edges are exactly --sky2, the colour Safari paints its bars with, so the bars blend into the page */
  background:
    linear-gradient(180deg, var(--sky2) 0%, transparent 14%, transparent 80%, var(--sky2) 96%),
    radial-gradient(ellipse 90% 32% at 12% 28%, var(--sky1) 0, transparent 70%),
    radial-gradient(ellipse 80% 30% at 92% 55%, var(--sky3) 0, transparent 70%),
    radial-gradient(ellipse 70% 18% at 28% 74%, var(--sky1) 0, transparent 70%),
    linear-gradient(180deg, var(--sky2) 0%, var(--sky-mid) 50%, var(--sky2) 100%);
}
.sparkles { z-index: -1; overflow: hidden; }
.sparkles span { position: absolute; display: block; line-height: 0; animation: float var(--dur, 12s) ease-in-out infinite; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(6px, -16px) rotate(8deg); }
  66% { transform: translate(-5px, -8px) rotate(-6deg); }
}
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.app {
  position: relative;
  max-width: 440px; margin: 0 auto; min-height: 100%; min-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  padding-inline: 16px; padding-block: 10px 14px;
  display: flex; flex-direction: column; gap: 12px;
}
#screen { flex: 1; display: flex; flex-direction: column; gap: 18px; padding-bottom: 28px; }
.bottom { margin-top: auto; display: flex; flex-direction: column; gap: 18px; }
.nav { display: flex; align-items: center; gap: 12px; }
.nav .btn { flex: 0 1 auto; white-space: nowrap; }
.nav .next { margin-left: auto; padding-inline: 34px; }
.nav.even .btn { flex: 1 1 0; padding-inline: 12px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand {
  font-family: var(--display); font-weight: 800; font-size: clamp(.9rem, 4vw, 1.15rem); letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
  background: linear-gradient(90deg, var(--r1), var(--r2), var(--r6)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ghost {
  font: 800 .95rem var(--body); color: var(--accent2); background: var(--surface);
  border: 2px solid var(--line); border-radius: 999px; padding: 7px 18px; cursor: pointer;
  box-shadow: 0 4px 0 #f2a6c9, 0 7px 12px rgba(160, 30, 100, .18);
}
.topbtns { display: flex; gap: 10px; flex: none; }
.ghost.round { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }
.ghost.round svg { width: 22px; height: 22px; display: block; }
.path { display: flex; gap: 5px; align-items: center; }
.stone {
  flex: 1; height: 14px; border-radius: 999px; background: var(--stone);
  transition: background .3s, transform .3s;
}
.stone.gap { flex: 0 0 8px; background: transparent; }
.stone.ok:nth-child(6n+1) { background: var(--r1); } .stone.ok:nth-child(6n+2) { background: var(--r2); }
.stone.ok:nth-child(6n+3) { background: var(--r3); } .stone.ok:nth-child(6n+4) { background: var(--r4); }
.stone.ok:nth-child(6n+5) { background: var(--r5); } .stone.ok:nth-child(6n) { background: var(--r6); }
.stone.help { background: var(--sun); }
.stone.skip { background: var(--muted); opacity: .35; }
.stone.now { background: var(--accent); transform: scaleY(1.5); box-shadow: 0 0 0 3px var(--surface); }

.card {
  background: var(--surface); border-radius: 28px; box-shadow: var(--shadow);
  border: 3px solid var(--line);
  padding: 18px 18px; display: flex; flex-direction: column; gap: 14px;
}
.eyebrow { font-weight: 800; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent2); }
h1, h2 { font-family: var(--display); font-weight: 800; margin: 0; line-height: 1.1; text-wrap: balance; color: var(--ink); }
h1 { font-size: clamp(2.2rem, 9vw, 3rem); }
h2 { font-size: clamp(1.6rem, 6.5vw, 2.1rem); }
p { margin: 0; }
.lead { color: var(--muted); font-size: 1.05rem; }

.qnum {
  width: 46px; height: 46px; border-radius: 50%; color: #fff;
  background: conic-gradient(var(--r1), var(--r2), var(--r3), var(--r4), var(--r5), var(--r6), var(--r1));
  font: 800 1.3rem/46px var(--display); text-align: center; flex: none; text-shadow: 0 2px 0 #0003;
}
/* The read-aloud button sits in the card corner so the question text gets the full width */
.card { position: relative; }
.qhead { display: flex; gap: 14px; align-items: center; padding-right: 44px; }
.qhead .say { position: absolute; top: 14px; right: 14px; }
.qtext { font-family: var(--display); font-weight: 600; font-size: clamp(1.35rem, 5.6vw, 1.7rem); line-height: 1.2; text-wrap: balance; }
.qtext.long { font-size: clamp(1.15rem, 4.9vw, 1.4rem); text-wrap: pretty; }

.expr {
  font-family: var(--display); font-weight: 800; font-size: clamp(1.9rem, 9vw, 2.5rem); color: var(--accent2);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px;
  font-variant-numeric: tabular-nums;
}
.slot {
  min-width: 2.4em; padding: 0 .3em; height: 1.35em; border-radius: 18px;
  border: 3px dashed var(--accent2); display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); background: var(--surface); font: inherit; cursor: pointer;
}
.slot.active { border-color: var(--accent2); background: var(--pink-soft); }
.expr.split { font-size: clamp(1.7rem, 8vw, 2.2rem); flex-wrap: nowrap; gap: 8px; }
.expr.split .slot { min-width: 2em; }
.expr.seq { font-size: clamp(1.45rem, 7vw, 2.1rem); flex-wrap: nowrap; gap: 6px; white-space: nowrap; }
.expr.seq .slot { min-width: 1.9em; }
.caret { display: inline-block; width: 3px; height: .9em; margin-left: 2px; border-radius: 2px; background: var(--accent2); animation: blink 1.8s ease-in-out infinite; }
@keyframes blink { 0%, 45% { opacity: 1; } 60%, 85% { opacity: .15; } 100% { opacity: 1; } }
.slot.right { border-style: solid; border-color: var(--leaf); background: var(--leaf-soft); }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding-bottom: 6px; }
.choice {
  font: 800 clamp(2.4rem, 12vw, 3.2rem) var(--display); color: #fff;
  border: 3px solid transparent; border-radius: 24px;
  padding: 14px 0; cursor: pointer; transition: transform .12s; box-shadow: var(--shadow); text-shadow: 0 2px 0 #0002;
}
.choice:nth-child(1) { background: linear-gradient(150deg, var(--r1), var(--r2)); }
.choice:nth-child(2) { background: linear-gradient(150deg, var(--r5), var(--r6)); }
.choice.right { background: linear-gradient(150deg, var(--r4), var(--leaf)); border-color: var(--surface); box-shadow: 0 0 0 4px var(--leaf); }

.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.key {
  font: 800 1.7rem var(--display); color: var(--ink); background: var(--surface);
  border: none; border-radius: 20px; padding: clamp(8px, 1.4dvh, 14px) 0; box-shadow: var(--shadow); cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.key:nth-child(6n+1) { background: #ffd1e0; } .key:nth-child(6n+2) { background: #ffe1c4; }
.key:nth-child(6n+3) { background: #fff1b3; } .key:nth-child(6n+4) { background: #c9f5e4; }
.key:nth-child(6n+5) { background: #cfeaff; } .key:nth-child(6n) { background: #e3d6ff; }
.key:active, .btn:active, .choice:active { transform: translateY(4px); box-shadow: var(--shadow-press); }
.key.ok { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--accent-ink); font-size: 1.3rem; }
.key.del { font-size: 1.15rem; color: var(--muted); background: var(--surface); }

.btn {
  font: 800 1.15rem var(--body); border: none; border-radius: 999px; padding: 16px 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--accent-ink); cursor: pointer; box-shadow: var(--shadow);
}
.btn.soft { background: var(--surface); color: var(--accent2); border: 3px solid var(--line); }
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row .btn { flex: 1 1 auto; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.bubble {
  border-radius: 20px; padding: 14px 16px; font-weight: 800;
  background: var(--sun-soft); color: var(--ink);
}
.bubble.good { background: var(--leaf-soft); font-size: 1.2rem; }
.think { display: flex; flex-direction: column; gap: 8px; padding-left: 0; margin: 0; list-style: none; }
.hintbtn { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 4px 0 #f2a6c9; }
.bubble.hint { background: var(--lilac-soft); }
.bubble.hint p { margin: 4px 0 0; }
.hintlabel { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--accent2); }
.bubble .more { margin-top: 10px; box-shadow: none; }
.think li { background: var(--surface); border-radius: 14px; padding: 8px 12px; font-weight: 700; line-height: 1.3; }

.mascot {
  font-family: var(--display); font-weight: 800; font-size: 3.2rem; line-height: 1;
  background: linear-gradient(90deg, var(--r1), var(--r2), var(--r3), var(--r4), var(--r5), var(--r6));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.dots { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
/* Sweets in the questions */
.sparkles svg, .candy { display: block; width: 100%; height: auto; }
.candies { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.candies.add { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 10px; }
.cgroup { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 2px dashed var(--line); border-radius: 16px; }
.cplus { font: 800 2rem var(--display); color: var(--accent2); }
.candyrow { display: flex; gap: 6px; justify-content: center; }
.candy { width: 52px; filter: drop-shadow(0 2px 0 rgba(160, 30, 100, .2)); }
.candies.add .candy { width: 40px; }
.candy.gone { opacity: .25; filter: grayscale(1); }
.dot { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); }
.tv { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin-top: 10px; }
.tv .dot { width: 16px; height: 16px; }
.tv .dot.gone { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); opacity: .5; }
.tv .ten { display: flex; gap: 5px; padding: 4px; border-radius: 12px; background: var(--surface); }
.expr .tight { margin-left: -8px; }
.lesson.soon { grid-template-columns: auto 1fr; }
.group { display: flex; gap: 4px; padding: 6px; border: 2px dashed var(--accent2); border-radius: 14px; background: var(--lilac-soft); }
.dot.b { background: var(--r5); }
.coin { width: 30px; height: 30px; border-radius: 50%; background: var(--sun); color: #5a3a00; font: 800 .75rem/30px var(--body); text-align: center; }
.coin.ten { width: 38px; height: 38px; line-height: 38px; background: #f7b733; }

.summary { display: flex; flex-direction: column; gap: 8px; }
.srow { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; background: var(--surface); border-radius: 14px; padding: 8px 12px; }
.srow > span { min-width: 0; }
.srow b { font-variant-numeric: tabular-nums; }
.pill { font-size: .8rem; font-weight: 800; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.pill.ok { background: var(--leaf-soft); }
.pill.help { background: var(--sun-soft); }
.pill.skip { background: var(--line); }
.small { font-size: .95rem; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 8px; }
details { background: var(--lilac-soft); border-radius: 16px; padding: 12px 14px; }
summary { font-weight: 800; cursor: pointer; color: var(--accent2); }
.pop { animation: pop .4s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { from { transform: scale(.9); } to { transform: scale(1); } }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
/* The capybara dance, rebuilt from the video: 6 poses in one small image.
   Every quarter second a new pose; kick poses pop up from a squash, the others sink slightly, like in the video. */
.capy-wrap { align-self: center; animation: capy-in .6s cubic-bezier(.3, 1.5, .5, 1) both; }
.capy {
  width: min(220px, 58vw); aspect-ratio: 1; max-width: 100%; transform-origin: 50% 100%;
  background: url("capybara-dans.webp") 0 0 / 600% 100% no-repeat;
  animation: capy-frames 2s steps(1, end) infinite, capy-move .5s infinite;
}
@keyframes capy-in { from { transform: translateY(60px) scale(.6); opacity: 0; } }
@keyframes capy-frames {
  0.0% { background-position-x: 0%; }
  12.5% { background-position-x: 80%; }
  25.0% { background-position-x: 60%; }
  37.5% { background-position-x: 40%; }
  50.0% { background-position-x: 100%; }
  62.5% { background-position-x: 80%; }
  75.0% { background-position-x: 20%; }
  87.5% { background-position-x: 40%; }
}
@keyframes capy-move {
  0% { transform: translateY(3px) scale(1.035, .955); animation-timing-function: cubic-bezier(.2, .8, .3, 1); }
  49.9% { transform: none; }
  50% { transform: none; animation-timing-function: ease-in; }
  99.9% { transform: translateY(4px) scale(1, .985); }
}
.map { display: flex; flex-direction: column; gap: 18px; }
.lessons { display: flex; flex-direction: column; gap: 16px; }
.lesson {
  background: var(--surface); border: 3px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
  padding: 14px 16px; display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: center;
}
.lesson.locked { opacity: .62; grid-template-columns: auto 1fr auto; }
.lnum {
  width: 46px; height: 46px; border-radius: 50%; color: #fff; text-align: center; font: 800 1.3rem/46px var(--display);
  background: conic-gradient(var(--r1), var(--r2), var(--r3), var(--r4), var(--r5), var(--r6), var(--r1)); text-shadow: 0 2px 0 #0003;
}
.lesson.locked .lnum { background: var(--line); color: var(--muted); text-shadow: none; }
.practice .lnum { background: linear-gradient(135deg, var(--sun), var(--r2)); }
.linfo { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ltitle { font: 800 1.25rem/1.15 var(--display); }
.lname { font-weight: 800; color: var(--accent2); }
.lbtns { grid-column: 1 / -1; display: flex; gap: 10px; justify-content: flex-end; padding-bottom: 4px; }
.btn.mini { padding: 11px 20px; font-size: 1rem; }
.lock { width: 28px; height: 28px; color: var(--muted); }
.stars { display: inline-flex; gap: 2px; font-size: 1.3rem; line-height: 1; color: var(--line); }
.stars .on { color: var(--sun); text-shadow: 0 1px 0 #e0a800; }
.hero-center .stars { font-size: 2rem; }
.adult { margin-bottom: 4px; }
details.sub { background: var(--surface); padding: 10px 12px; }
.adult .note { font-style: italic; }
.overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  padding-inline: 16px; padding-block: env(safe-area-inset-top, 0px) env(safe-area-inset-bottom, 0px);
  background: rgba(58, 29, 92, .35); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.dialog {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: 28px; border: 3px solid var(--line);
  box-shadow: var(--shadow); padding: 22px 20px; display: flex; flex-direction: column; gap: 14px;
  text-align: center; align-items: center;
}
.dialog .nav { align-self: stretch; padding-bottom: 6px; }
.dialog .btn { padding-inline: 22px; font-size: 1.05rem; white-space: nowrap; }
.avatar {
  border-radius: 50%; padding: 5px; flex: none; display: block;
  background: conic-gradient(var(--r1), var(--r2), var(--r3), var(--r4), var(--r5), var(--r6), var(--r1));
  box-shadow: var(--shadow);
}
.avatar img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 4px solid var(--surface); }
.avatar.xl { width: min(200px, 52vw, 24dvh); aspect-ratio: 1; max-width: 100%; align-self: center; animation: bob 3.5s ease-in-out infinite; }
.avatar.md { width: 120px; height: 120px; align-self: center; }
.avatar.sm { width: 64px; height: 64px; padding: 3px; box-shadow: none; }
.avatar.sm img { border-width: 2px; }
.avatar.xs { width: 40px; height: 40px; padding: 2px; box-shadow: none; }
.avatar.xs img { border-width: 2px; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-3deg); } }
.brandrow { display: flex; align-items: center; gap: 10px; min-width: 0; background: none; border: none; padding: 4px 8px 4px 0; border-radius: 999px; cursor: pointer; font: inherit; text-align: left; }
.brandrow:active { transform: scale(.97); }
.cheer { display: flex; align-items: center; gap: 12px; }
.hero-center { text-align: center; align-items: center; }
.hero-center details, .hero-center .row, .hero-center .nav { text-align: left; align-self: stretch; }
/* Shorter screens, like an iPhone 13 in Safari with its bars showing: tighten spacing so the keypad fits */
@media (max-height: 720px) {
  .app { gap: 8px; padding-block: 6px 10px; }
  #screen { gap: 12px; padding-bottom: 20px; }
  .bottom { gap: 12px; }
  .card { padding: 14px 16px; gap: 10px; }
  .qnum { width: 40px; height: 40px; font-size: 1.15rem; line-height: 40px; }
  .expr { font-size: clamp(1.7rem, 8vw, 2.2rem); }
  .pad { gap: 9px; }
  .key { font-size: 1.5rem; padding: 7px 0; }
  .btn { padding: 13px 24px; }
  .bubble { padding: 10px 14px; }
  .hero-center .avatar.md { width: 96px; height: 96px; }
}
@media (prefers-reduced-motion: reduce) { .pop, .shake, .sparkles span, .avatar.xl { animation: none; } .capy-wrap { animation: none; } .capy { animation: capy-frames 2s steps(1, end) infinite; } .caret { animation: none; } .stone { transition: none; } }
