/* Fonts are bundled so the game looks the same offline (all SIL Open Font License, from Google Fonts). */
@font-face { font-family: "Andika"; font-weight: 700; font-display: swap; src: url("../assets/fonts/andika-700-latin.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 300 700; font-display: swap; src: url("../assets/fonts/fredoka-latin.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 600 800; font-display: swap; src: url("../assets/fonts/nunito-latin.woff2") format("woff2"); }

/* "Learning Path" look: soft surfaces and shadows instead of outlines; Pier's art supplies the character. */
:root {
  --bg: #F3F6FB;
  --surface: #FFFFFF;
  --ink: #1E2A47;          /* text and icons */
  --muted: #5B6785;
  --faint: #8A93AB;
  --line: #D9E0EC;
  --blue: #2F6FE0;
  --blue-soft: #E5EFFF;
  --green: #22A06B;
  --green-soft: #E3F6EC;
  --coral: #F2643D;
  --coral-soft: #FFEDE6;
  --purple: #7C5CF5;
  --purple-soft: #EFEAFF;
  --sun: #FFC83D;
  --sun-soft: #FFF3CF;
  --shadow-sm: 0 2px 8px rgba(30, 42, 71, .08);
  --shadow: 0 10px 28px rgba(30, 42, 71, .10);
  --shadow-lg: 0 16px 36px rgba(30, 42, 71, .12);
  --display: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --ui: "Nunito", "Fredoka", system-ui, sans-serif;
  --letter: "Andika", "Fredoka", "Comic Sans MS", system-ui, sans-serif;
  --gap: clamp(10px, 2.4vmin, 24px);
  --radius: clamp(20px, 3.4vmin, 32px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

img { -webkit-user-drag: none; user-select: none; pointer-events: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; }

#app { position: fixed; inset: 0; }

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-size: cover;
  background-position: center;
  animation: fadeIn .3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
/* A scene keeps its illustration, washed back so the play pieces stand out. */
.screen.scene::before { content: ""; position: absolute; inset: 0; background: rgba(243, 246, 251, .5); pointer-events: none; }
.screen.scene > :not(.overlay) { position: relative; }
.screen.bg-drop { background-position: center bottom; background-repeat: no-repeat; background-color: var(--sky); }

.topbar {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.6vmin, 16px);
  padding: calc(var(--gap) + env(safe-area-inset-top)) calc(var(--gap) * 1.4 + env(safe-area-inset-right)) var(--gap) calc(var(--gap) * 1.4 + env(safe-area-inset-left));
  position: relative;
  z-index: 5;
}
.topbar .spacer { flex: 1; }

.round-btn {
  width: clamp(52px, 8.6vmin, 72px);
  height: clamp(52px, 8.6vmin, 72px);
  border-radius: 50%;
  border: 0;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  line-height: 1;
  transition: transform .12s;
  flex: none;
  padding: 0;
}
.round-btn:active { transform: scale(.94); }
.round-btn svg { width: 46%; height: 46%; }
.round-btn.small { width: clamp(44px, 7vmin, 56px); height: clamp(44px, 7vmin, 56px); }
.round-btn.off { opacity: .45; }

.gem-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  height: clamp(44px, 7vmin, 56px);
  background: var(--surface);
  border-radius: 999px;
  padding: 0 18px 0 8px;
  font-weight: 800;
  font-size: clamp(17px, 3vmin, 22px);
  box-shadow: var(--shadow-sm);
}
.gem-counter img { width: clamp(28px, 4.6vmin, 36px); }
.gem-counter.bump { animation: bump .4s ease; }
@keyframes bump { 50% { transform: scale(1.18); } }

.wordmark { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 600; font-size: clamp(22px, 3.8vmin, 30px); letter-spacing: -.01em; }
.wordmark img { width: 1.6em; height: 1.6em; object-fit: contain; }

/* Curious Crumb's cream, forest and coral palette follows Pier through every screen. */
.studio-theme {
  --bg: #F7F4EC;
  --surface: #FFFCF6;
  --ink: #173F3A;
  --muted: #52675F;
  --faint: #7D8980;
  --line: #DCDDD0;
  --blue: #173F3A;
  --blue-soft: #E6EDE3;
  --green: #3F7660;
  --green-soft: #E4ECDD;
  --coral: #FF715B;
  --coral-ink: #BC4B38;
  --coral-soft: #FAE5DB;
  --purple: #765779;
  --purple-soft: #EDE4ED;
  --sun: #E8C76D;
  --sun-soft: #F6EBCB;
  --sky-soft: #DFEDF0;
  --shadow-sm: 0 2px 6px rgba(23, 63, 58, .04);
  --shadow: 0 8px 24px rgba(23, 63, 58, .04);
  --shadow-lg: 0 12px 28px rgba(23, 63, 58, .09);
  --display: Georgia, "Times New Roman", serif;
  color: var(--ink);
  font-family: var(--ui);
}
.studio-theme .topbar { flex: none; }
.studio-theme .wordmark { font-weight: 500; letter-spacing: -.035em; }
.studio-credit { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .16em; white-space: nowrap; }
.studio-theme .round-btn, .studio-theme .gem-counter { border: 1px solid var(--line); box-shadow: none; }
.studio-theme .round-btn [stroke="#5B6785"] { stroke: var(--ink); }
.studio-theme .round-btn [stroke="#1E2A47"] { stroke: var(--ink); }
.studio-theme .round-btn [fill="#5B6785"] { fill: var(--ink); }
.studio-theme button:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

/* ---------- Splash ---------- */
.splash-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vmin, 28px);
  padding: 0 calc(var(--gap) * 1.4 + env(safe-area-inset-right)) calc(var(--gap) * 1.4 + env(safe-area-inset-bottom)) calc(var(--gap) * 1.4 + env(safe-area-inset-left));
}
.splash-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  gap: clamp(16px, 4vmin, 40px);
  width: min(100%, 1120px);
  min-height: 0;
  flex: none;
}
.splash-copy { padding: clamp(8px, 2.8vmin, 28px) 0; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.splash-copy h1 { max-width: 12ch; margin: 18px 0; font-size: clamp(44px, 8.7vmin, 86px); font-weight: 500; line-height: .98; letter-spacing: -.055em; }
.splash-copy h1 em { display: block; color: #CC523F; font-weight: 400; }
.splash-note { max-width: 28ch; margin: 0; color: var(--muted); font-size: clamp(15px, 2.4vmin, 20px); font-weight: 700; line-height: 1.5; }
.splash-pier { position: relative; min-height: clamp(220px, 45vmin, 470px); display: grid; place-items: center; }
.splash-pier .blob { position: absolute; inset: 4% 0 4% 4%; border-radius: 48% 52% 45% 55% / 52% 45% 55% 48%; background: #B7D5DE; transform: rotate(-5deg); }
.splash-pier::before, .splash-pier::after { content: ""; position: absolute; width: clamp(22px, 4vmin, 40px); aspect-ratio: 1; background: var(--coral); clip-path: polygon(50% 0, 65% 35%, 100% 50%, 65% 65%, 50% 100%, 35% 65%, 0 50%, 35% 35%); transform: rotate(12deg); }
.splash-pier::before { top: 9%; left: 0; }
.splash-pier::after { bottom: 10%; right: 0; width: clamp(16px, 3vmin, 28px); background: var(--sun); }
.splash .hero { position: absolute; width: 86%; height: 92%; max-height: 52vh; object-fit: contain; animation: idle 2.4s ease-in-out infinite; transform-origin: bottom center; }
.play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: clamp(64px, 10vmin, 80px);
  margin-top: clamp(24px, 4.4vmin, 36px);
  padding: 12px 28px 12px 16px;
  border-radius: 999px;
  border: 0;
  background: var(--coral);
  color: var(--ink);
  font-family: var(--ui);
  font-size: clamp(22px, 3.4vmin, 28px);
  font-weight: 800;
  box-shadow: 0 7px 18px rgba(204, 82, 63, .13);
  transition: transform .12s, background .15s;
}
.splash-play-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgba(23, 63, 58, .1); }
.play-btn svg { width: 46%; height: 46%; margin-left: 6%; }
.splash-play-icon path { fill: currentColor; }
.play-btn:hover { background: #FF846F; }
.play-btn:focus-visible { outline: 4px solid var(--ink); outline-offset: 5px; }
.play-btn:active { transform: scale(.97); }
.splash-subjects { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(8px, 1.6vmin, 14px); padding-top: clamp(14px, 3vmin, 24px); width: min(100%, 1120px); border-top: 1px solid var(--line); }
.splash-subject { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: clamp(12px, 1.8vmin, 15px); font-weight: 800; }

@media (max-width: 600px) and (min-height: 501px) {
  .splash-card { grid-template-columns: 1fr; gap: 12px; }
  .splash-pier { grid-row: 1; min-height: 0; height: clamp(138px, 24vh, 210px); margin: 0 14%; }
  .splash .hero { height: 94%; max-height: 100%; }
  .splash-copy { align-items: center; text-align: center; padding: 0 8px; }
  .splash-copy h1 { max-width: 13ch; font-size: clamp(38px, 9.3vmin, 52px); margin: 12px 0; }
  .splash-note { max-width: 26ch; }
  .play-btn { margin-top: 20px; }
  .splash-subject { padding: 6px 10px; }
  .splash .studio-credit { display: none; }
}
@media (max-height: 700px) {
  .splash-main { gap: 12px; }
  .splash-copy { padding: 4px 0; }
  .splash-copy h1 { margin: 10px 0; }
  .splash .play-btn { min-height: 60px; margin-top: 18px; padding-top: 8px; padding-bottom: 8px; }
  .splash-subject { padding: 6px 12px; }
  .splash-subjects { padding-top: 12px; }
}
@media (max-width: 600px) and (min-height: 501px) and (max-height: 650px) {
  .splash-pier { height: 122px; }
  .splash-card { gap: 8px; }
  .splash-copy h1 { font-size: 36px; margin: 10px 0; }
  .splash .play-btn { margin-top: 14px; }
  .splash-subjects { gap: 6px; }
  .splash-subject { font-size: 11px; padding: 5px 9px; }
}
@media (max-height: 500px) {
  .splash-copy h1 { font-size: clamp(32px, 9vmin, 44px); margin: 8px 0; }
  .splash-note { font-size: 14px; }
  .splash-pier { min-height: 170px; }
  .splash .hero { max-height: 54vh; }
  .splash .studio-credit { display: none; }
}
.splash .wordmark span { display: inline; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* ---------- Home ---------- */
.hub-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  touch-action: pan-y;
  padding: 0 calc(var(--gap) * 1.4 + env(safe-area-inset-right)) calc(var(--gap) * 1.4 + env(safe-area-inset-bottom)) calc(var(--gap) * 1.4 + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.6vmin, 24px);
}
.today {
  display: flex;
  flex: none;
  min-height: clamp(220px, 34vmin, 300px);
  border-radius: calc(var(--radius) * 1.1);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}
.today-main { flex: 1; min-width: 0; padding: clamp(18px, 3.6vmin, 36px) clamp(18px, 4vmin, 40px); display: flex; flex-direction: column; gap: 8px; }
.eyebrow { font-size: clamp(11px, 1.7vmin, 13px); font-weight: 800; letter-spacing: .12em; color: var(--blue); }
.today-title { margin: 0; max-width: 24ch; font-size: clamp(28px, 4.8vmin, 44px); font-weight: 500; letter-spacing: -.035em; line-height: 1.1; }
.today-path { margin-top: auto; padding-top: 12px; display: flex; align-items: flex-start; }
.path-step { display: flex; flex-direction: column; align-items: center; gap: 8px; width: clamp(92px, 15vmin, 150px); text-align: center; }
.path-dot {
  width: clamp(54px, 8vmin, 66px);
  height: clamp(54px, 8vmin, 66px);
  margin-top: clamp(7px, 1vmin, 9px);
  border-radius: 50%;
  border: 1px solid var(--line);
  padding: 0;
  background: #F0EEE4;
  display: grid;
  place-items: center;
  transition: transform .12s;
}
.path-dot:active { transform: scale(.94); }
.path-dot img { width: 62%; height: 62%; object-fit: contain; }
.path-dot svg { width: 46%; height: 46%; }
.path-dot.done { background: var(--green); border-color: var(--green); }
.path-dot.next { width: clamp(68px, 10.4vmin, 86px); height: clamp(68px, 10.4vmin, 86px); margin-top: 0; background: var(--blue); border-color: var(--blue); box-shadow: 0 0 0 clamp(6px, 1vmin, 8px) var(--coral-soft); animation: pulse 1.8s ease-in-out infinite; }
.path-dot.next svg { width: 44%; height: 44%; margin-left: 6%; }
.path-name { font-weight: 700; font-size: clamp(13px, 2vmin, 16px); color: var(--muted); line-height: 1.15; }
.path-step.next .path-name { color: var(--ink); font-weight: 800; }
.path-line { flex: 0 1 56px; min-width: 12px; height: 4px; border-radius: 3px; background: var(--line); margin-top: clamp(37px, 5.4vmin, 43px); }
.path-line.done { background: var(--green); }
.today-pier { position: relative; width: clamp(180px, 30vmin, 330px); flex: none; background: #E9EFE6; display: grid; place-items: center; overflow: hidden; }
.today-pier .blob { position: absolute; width: 92%; aspect-ratio: 1; border-radius: 47% 53% 44% 56%; background: #B7D5DE; right: -8%; bottom: -12%; transform: rotate(-8deg); }
.hub-pier { position: relative; width: 74%; background: none; border: 0; padding: 0; }
.hub-pier img { width: 100%; animation: idle 2.4s ease-in-out infinite; transform-origin: bottom center; }
.hub-pier.wiggle img { animation: wiggle .5s ease; }
@keyframes idle { 50% { transform: scale(1.03, .97); } }

.explore-head { display: flex; align-items: baseline; gap: 12px; padding: 4px 4px 0; }
.explore-head h2 { margin: 0; font-size: clamp(28px, 4vmin, 34px); font-weight: 500; letter-spacing: -.035em; }
.explore-head span { font-weight: 700; font-size: clamp(13px, 2vmin, 15px); color: var(--muted); }
.subjects { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(10px, 2vmin, 18px); align-items: start; }
.subject { border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--soft) 30%, var(--surface)); padding: clamp(10px, 1.8vmin, 16px); display: flex; flex-direction: column; gap: 4px; }
.subject-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); font-weight: 800; font-size: clamp(14px, 2.2vmin, 16px); }
.subject-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.game-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 6px;
  border: 0;
  border-radius: 14px;
  background: none;
  text-align: left;
  font-weight: 700;
  font-size: clamp(14px, 2.1vmin, 16px);
  transition: background .15s, transform .12s;
}
.game-row:hover { background: var(--soft); }
.game-row:active { transform: scale(.98); background: var(--soft); }
.game-row.next { background: var(--soft); }
.game-icon { width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--soft); display: grid; place-items: center; }
.game-icon img { width: 78%; height: 78%; object-fit: contain; }

@media (max-width: 900px) {
  .subjects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .today { flex-direction: column-reverse; }
  .today-pier { width: auto; height: 150px; }
  .hub-pier { width: auto; height: 136px; }
  .hub-pier img { width: auto; height: 136px; }
  .path-step { width: min(28%, 88px); flex: 1 1 0; }
  .wordmark span { display: none; }
  .subjects { grid-template-columns: 1fr; }
  .subject { padding: 12px; }
  .subject-head { padding-bottom: 10px; }
  .game-row { min-height: 64px; font-size: 16px; }
  .today-title { font-size: 30px; }
  .today-main { padding: 20px 16px; }
}

/* ---------- Game ---------- */
.game.studio-theme.scene::before { background: rgba(247, 244, 236, .74); }
.game.studio-theme > .topbar { background: rgba(247, 244, 236, .94); border-bottom: 1px solid var(--line); margin-bottom: clamp(6px, 1.5vmin, 12px); }
.game > .topbar .round-btn [fill="#2F6FE0"] { fill: var(--ink); }
.game > .topbar .round-btn [stroke="#2F6FE0"] { stroke: var(--ink); }
.game-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: clamp(7px, 1.3vmin, 11px); }
.game-title { margin: 0; font-size: clamp(18px, 3.4vmin, 28px); font-weight: 500; letter-spacing: -.025em; line-height: 1.1; text-align: center; }
.progress { width: 100%; min-width: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: clamp(5px, 1.1vmin, 8px); max-width: 640px; margin: 0 auto; }
.progress span { height: clamp(7px, 1.4vmin, 11px); border: 1px solid var(--line); border-radius: 999px; background: #E9E6DA; transition: background .3s, border-color .3s; }
.progress span.now:not(.done) { background: var(--coral); border-color: var(--coral); }
.progress span.done { background: var(--green); border-color: var(--green); animation: bump .4s ease; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 0 var(--gap) calc(var(--gap) + env(safe-area-inset-bottom));
}

.big-letter { font-family: var(--letter); font-weight: 700; }

.wiggle { animation: wiggle .5s ease; }
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2vmin); }
}
@keyframes wiggle {
  20% { transform: rotate(-8deg); }
  40% { transform: rotate(8deg); }
  60% { transform: rotate(-5deg); }
  80% { transform: rotate(4deg); }
}
.hint { animation: hint 1s ease-in-out infinite; }
@keyframes hint { 50% { filter: drop-shadow(0 0 2vmin rgba(255, 200, 61, .95)) brightness(1.05); transform: scale(1.07); } }

/* A small Pier in the corner of games that have no Pier of their own. */
.companion {
  position: absolute !important;
  left: calc(var(--gap) + env(safe-area-inset-left));
  bottom: calc(var(--gap) * .6 + env(safe-area-inset-bottom));
  width: clamp(84px, 15vmin, 150px);
  z-index: 4;
  animation: idle 2.4s ease-in-out infinite;
  transform-origin: bottom center;
}
@media (orientation: portrait), (max-height: 500px) { .companion { display: none; } }

/* Generic picture/answer tile */
.tile {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: grid;
  place-items: center;
  padding: 6%;
  transition: transform .12s, box-shadow .2s, opacity .2s;
}
.tile:active { transform: scale(.96); }
.tile img { position: absolute; left: 12%; top: 12%; width: 76%; height: 76%; object-fit: contain; }
.tile.right { border-color: var(--green); box-shadow: 0 0 0 6px var(--green), var(--shadow-lg); }
.tile.dim { opacity: .35; }

/* Drag */
.dragging { z-index: 50 !important; transition: none !important; filter: drop-shadow(0 12px 12px rgba(23, 63, 58, .18)); }
.snapback { transition: transform .3s cubic-bezier(.3, 1.6, .5, 1) !important; }

/* ---------- Overlay (reward + parents) ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(23, 63, 58, .38);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  animation: fadeIn .3s ease;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 1.2);
  box-shadow: var(--shadow-lg);
  padding: 4vmin 6vmin;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6vmin;
  max-width: 92vw;
  max-height: 92vh;
}
.reward .hero { width: clamp(130px, 28vmin, 280px); animation: hop 1.2s ease-in-out infinite; }
.reward h2 { margin: 0; font-size: clamp(30px, 7vmin, 64px); font-weight: 500; letter-spacing: -.035em; line-height: 1; }
.reward .earned { display: flex; align-items: center; gap: 1vmin; padding: .2em .7em .2em .4em; border: 1px solid var(--line); border-radius: 999px; background: var(--sun-soft); font-family: var(--ui); font-weight: 800; font-size: clamp(24px, 5vmin, 44px); color: var(--ink); }
.reward .earned img { width: clamp(36px, 7vmin, 64px); }
.reward .unlock { font-family: var(--ui); font-size: clamp(18px, 3.4vmin, 28px); font-weight: 800; color: var(--coral-ink); }
.reward .row { display: flex; gap: 3vmin; margin-top: 1vmin; }
.reward .round-btn { width: clamp(76px, 13vmin, 112px); height: clamp(76px, 13vmin, 112px); }
.reward .again { background: var(--blue); }
.reward .home { background: var(--bg); }

/* "Go home?" when the X is tapped during a game */
.leave .hero { width: clamp(110px, 22vmin, 200px); }
.leave h2 { margin: 0; font-size: clamp(28px, 6vmin, 52px); font-weight: 500; letter-spacing: -.035em; }
.leave .row { display: flex; gap: 5vmin; margin-top: 1vmin; }
.leave .choice { display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 800; font-size: clamp(15px, 2.4vmin, 19px); color: var(--muted); }
.leave .round-btn { width: clamp(76px, 13vmin, 112px); height: clamp(76px, 13vmin, 112px); }
.leave .stay { background: var(--blue); }
.leave .stay svg { margin-left: 6%; }
.leave .home { background: var(--bg); }

/* Parent area */
.parents { width: min(720px, 94vw); align-items: stretch; overflow-y: auto; touch-action: pan-y; user-select: text; padding: 4vmin 5vmin; gap: 14px; }
.parents h2 { margin: 0; font-size: 28px; }
.parents p.note { margin: 0; font-size: 14px; color: var(--muted); }
.parents label { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 17px; font-weight: 700; }
.parents input[type=text], .parents select {
  font: 700 16px var(--ui);
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  min-width: 0;
  width: 55%;
  color: var(--ink);
}
.parents input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--blue); }
.parents .btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.parents .btn { font: 800 16px var(--ui); padding: 11px 20px; border: 0; border-radius: 999px; background: var(--blue); color: #fff; }
.parents .btn.quiet { background: var(--bg); color: var(--ink); }
.parents .btn.danger { background: #FDE8E8; color: #B42318; }
.parents .stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.parents .stats div { border-radius: 10px; text-align: center; padding: 4px 0; font: 700 20px var(--letter); background: var(--bg); }
.parents .stats div small { display: block; font: 700 11px var(--ui); color: var(--muted); }
.parents .stats .known { background: var(--green-soft); }
.parents .stats .learning { background: var(--sun-soft); }
.parents h3 { margin: 8px 0 0; font-size: 18px; }

.hold-ring { position: absolute; inset: -5px; pointer-events: none; }
.hold-ring circle { fill: none; stroke: var(--blue); stroke-width: 7; stroke-dasharray: 289; stroke-dashoffset: 289; transform: rotate(-90deg); transform-origin: center; }
.holding .hold-ring circle { transition: stroke-dashoffset var(--hold, 2s) linear; stroke-dashoffset: 0; }
.rewarding > .topbar { visibility: hidden; pointer-events: none; }

/* ---------- FX ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.confetti { position: absolute; width: 1.6vmin; height: 2.4vmin; border-radius: 3px; animation: confetti 1.4s ease-out forwards; }
@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; }
}
.fly-gem { position: absolute; width: 8vmin; transition: transform .9s cubic-bezier(.5, -0.4, .6, 1), opacity .9s; }
.star-burst { position: absolute; font-size: 7vmin; animation: burst .8s ease-out forwards; }
@keyframes burst { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.8) translateY(-6vmin); opacity: 0; } }

/* ================= Games ================= */

/* ---------- Letter Bubbles ---------- */
.bubbles-field {
  position: absolute;
  inset: 0 var(--gap) var(--gap);
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: clamp(10px, 4vmin, 48px);
}
.bubble {
  --s: clamp(120px, 27vmin, 250px);
  width: var(--s);
  height: var(--s);
  border: 0;
  border-radius: 50%;
  background: url(../assets/img/prek/bubble.webp) center / contain no-repeat;
  display: grid;
  place-items: center;
  font-size: calc(var(--s) * .52);
  color: var(--ink);
  -webkit-text-stroke: calc(var(--s) * .018) var(--surface);
  paint-order: stroke fill;
  animation: bob 3.2s ease-in-out infinite;
  padding: 0 0 .1em;
}
@keyframes bob { 50% { transform: translateY(-3vmin) scale(1.03, .97); } }
.bubble.popped { animation: popped .35s ease-out forwards; }
@keyframes popped { to { transform: scale(1.5); opacity: 0; } }
.bubble.hint { animation: hint 1s ease-in-out infinite; }
.game-bubbles { background-color: var(--bg); }
.bubbles-pier { position: absolute; left: clamp(95px, 16vw, 240px); bottom: 1.5vmin; width: clamp(100px, 20vmin, 220px); }
.bubbles-pier.cheer { animation: hop .9s ease-in-out infinite; }

/* ---------- Trace ---------- */
.trace-modes { position: absolute; top: 0; left: var(--gap); display: flex; flex-direction: column; gap: 8px; z-index: 2; padding: 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.trace-chip {
  font: 700 clamp(16px, 3vmin, 26px) var(--letter);
  padding: .35em .7em;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}
.trace-chip.on { background: var(--ink); color: var(--surface); box-shadow: var(--shadow-sm); }
.trace-wrap { height: 100%; display: flex; align-items: center; justify-content: center; gap: 3vmin; }
.trace-paper {
  height: min(calc(100% - 10px), 76vw);
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 1.1);
  box-shadow: var(--shadow-lg);
  touch-action: none;
}
.trace-board { width: 100%; height: 100%; display: block; touch-action: none; }
.trace-line { stroke: #C9D9D4; stroke-width: .8; }
.trace-line.mid { stroke-dasharray: 3 3; }
.trace-guide { fill: none; stroke: #E0E9E2; stroke-width: 15; stroke-linecap: round; stroke-linejoin: round; }
.trace-center { fill: none; stroke: #8DA69B; stroke-width: 1.2; stroke-dasharray: 2.5 3; stroke-linecap: round; }
.trace-ink { fill: none; stroke: var(--blue); stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; transition: stroke .4s; }
.trace-ink.demo { stroke: var(--coral-ink); opacity: .85; }
.traced .trace-ink { stroke: var(--green); }
.trace-start circle { fill: var(--green); stroke: var(--surface); stroke-width: 1.4; animation: dotpulse 1s ease-in-out infinite; }
.trace-start.hint circle { fill: var(--green); stroke-width: 2; }
.trace-arrow { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes dotpulse { 50% { r: 9.5px; } }
.trace-pen { pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.trace-pen[hidden], .trace-start[hidden] { display: none; }
.trace-reward {
  width: 0;
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 1vmin;
  transition: width .4s ease;
}
.trace-reward.show { width: clamp(120px, 30vmin, 300px); }
.trace-reward img { max-width: 100%; max-height: 40vmin; animation: bump .5s ease; }
.trace-reward img[src*="gem"] { width: 28%; }
.trace-zero { font: 700 20vmin var(--letter); }

/* ---------- First Sounds ---------- */
.sound-wrap { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vmin; }
.sound-card {
  font-size: clamp(70px, 18vmin, 180px);
  line-height: 1;
  padding: .08em .45em .14em;
  background: var(--sky-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 0 0 clamp(8px, 1.4vmin, 14px) var(--surface), var(--shadow-lg);
  color: var(--blue);
}
.sound-row { display: flex; gap: clamp(14px, 4vmin, 40px); }
.sound-tile { width: clamp(80px, 25vmin, 250px); aspect-ratio: 1; }

/* ---------- Build a Word ---------- */
.spell-wrap {
  --n: 3;
  --box: min(15vmin, calc((94vw - var(--n) * 2vmin) / var(--n)));
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
}
.spell-pic { width: clamp(100px, 24vmin, 240px); aspect-ratio: 1; }
.spell-slots, .spell-tray { display: flex; gap: 2vmin; justify-content: center; }
.spell-tray { min-height: calc(var(--box) * 1.12); flex-wrap: wrap; }
.spell-slot {
  width: var(--box);
  height: calc(var(--box) * 1.12);
  border: 3px dashed #95ABA0;
  border-radius: 20px;
  background: rgba(255, 252, 246, .88);
  display: grid;
  place-items: center;
  font-size: calc(var(--box) * .72);
}
.spell-slot > * { grid-area: 1 / 1; }
.spell-slot .ghost { color: rgba(23, 63, 58, .22); }
.spell-tile {
  width: var(--box);
  height: calc(var(--box) * 1.12);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: calc(var(--box) * .72);
  color: var(--blue);
  cursor: grab;
  position: relative;
  z-index: 1;
}
.spell-slot .spell-tile { width: calc(100% + 6px); height: calc(100% + 6px); box-shadow: var(--shadow-sm); transition: background .2s, transform .2s; }
.spell-slot.read .spell-tile { background: var(--sun); transform: scale(1.08); }

/* ---------- Count ---------- */
.count-wrap { height: 100%; display: flex; gap: 3vmin; align-items: stretch; }
.count-field {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 1vmin;
  padding: 2vmin;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, .94);
  border-radius: calc(var(--radius) * 1.1);
  box-shadow: var(--shadow);
  min-height: 0;
}
.count-thing {
  background: none;
  border: 0;
  padding: 7%;
  width: var(--size, 80px);
  height: var(--size, 80px);
  place-self: center;
  position: relative;
  border-radius: 50%;
  transform: rotate(var(--tilt)) translateY(var(--nudge));
  transition: background .2s;
}
.count-thing img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 3px rgba(23, 63, 58, .12)); }
.count-thing[data-n] { background: radial-gradient(circle, rgba(255, 200, 61, .35), transparent 70%); }
.count-num {
  position: absolute;
  right: 0;
  top: 0;
  min-width: 1.6em;
  height: 1.6em;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 0 0 3px var(--surface), var(--shadow-sm);
  font: 700 clamp(16px, 3.6vmin, 30px) var(--letter);
  transform: rotate(calc(var(--tilt) * -1));
  animation: bump .35s ease;
}
/* Space for the answers is kept from the start so the things never jump. */
.count-answers { display: flex; flex-direction: column; justify-content: center; gap: 3vmin; min-width: clamp(90px, 18vmin, 170px); min-height: clamp(90px, 18vmin, 170px); }
.count-answers.show { animation: fadeIn .3s; }
.count-answer { width: clamp(90px, 18vmin, 170px); aspect-ratio: 1; font-size: clamp(50px, 12vmin, 120px); padding: 0; color: var(--ink); }
.count-answer.placeholder { opacity: .5; color: var(--muted); background: rgba(255, 252, 246, .6); box-shadow: none; border: 1px dashed #95ABA0; pointer-events: none; }

/* ---------- Feed Pier ---------- */
.feed-wrap { height: 100%; display: flex; gap: 3vmin; align-items: center; }
.feed-basket {
  flex: 1 1 45%;
  align-self: center;
  min-height: 68%;
  max-height: 88%;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 1.5vmin;
  padding: 2.5vmin;
  border-radius: calc(var(--radius) * 1.1);
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, .94);
  box-shadow: var(--shadow);
}
.feed-food { width: clamp(72px, 18vmin, 170px); aspect-ratio: 1; display: grid; place-items: center; cursor: grab; position: relative; }
.feed-food img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 3px rgba(23, 63, 58, .12)); }
.feed-table { flex: 1 1 50%; height: 100%; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.feed-pier { height: min(48vmin, 62%); transform-origin: bottom center; }
.feed-pier.munch { animation: hop .8s ease-in-out infinite; }
.feed-plate {
  width: min(44vmin, 100%);
  min-height: 13vmin;
  margin-top: -13vmin; /* held out in front of Pier, not under his feet */
  padding: 2vmin 4vmin;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: .5vmin;
  border-radius: 50%;
  background: radial-gradient(ellipse, var(--surface) 55%, #D6E2DB 56%, var(--surface) 70%);
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.feed-basket.many .feed-food { width: clamp(60px, 14vmin, 140px); }
.feed-done {
  position: absolute; right: 2vmin; bottom: 3vmin; z-index: 2;
  width: clamp(64px, 12vmin, 104px); height: clamp(64px, 12vmin, 104px);
  background: var(--green); box-shadow: 0 0 0 6px var(--surface), var(--shadow);
  visibility: hidden; transform: scale(.6); opacity: 0;
  transition: transform .25s cubic-bezier(.3, 1.6, .5, 1), opacity .2s;
}
.feed-done svg { width: 54%; height: 54%; }
.feed-done.show { visibility: visible; transform: none; opacity: 1; }
.feed-plate .feed-food { width: clamp(30px, 6.5vmin, 64px); animation: bump .3s ease; }
.feed-plate.eaten .feed-food { transition: transform .6s ease, opacity .6s; transform: scale(0) !important; opacity: 0; }
.feed-ask {
  position: absolute;
  top: 4vmin;
  right: 3vmin;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px 28px 28px 8px;
  box-shadow: var(--shadow);
  padding: 1vmin 3vmin 2vmin;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}
.feed-ask .big-letter { font-size: clamp(54px, 13vmin, 130px); line-height: 1; color: var(--coral-ink); }
.feed-dots { display: flex; gap: .8vmin; }
.feed-dots.many { display: grid; grid-template-columns: repeat(5, auto); }
.feed-dots i { width: clamp(12px, 2.4vmin, 22px); aspect-ratio: 1; border-radius: 50%; background: var(--coral-ink); }

/* ---------- Pier's Patterns ---------- */
.pattern-wrap { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; }
.pattern-row {
  --cell: min(14vmin, calc((92vw - var(--n) * 1.2vmin - 5vmin) / var(--n)));
  display: flex;
  gap: 1.2vmin;
  padding: 2vmin;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, .94);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pattern-cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  display: grid;
  place-items: center;
  background: var(--bg);
  border-radius: 18px;
  transition: transform .15s, background .15s;
}
.pattern-cell img { position: absolute; left: 10%; top: 10%; width: 80%; height: 80%; object-fit: contain; }
.pattern-cell.missing { background: var(--surface); box-shadow: inset 0 0 0 3px #95ABA0; animation: pulse 1.4s ease-in-out infinite; }
.pattern-cell.missing span { font: 700 calc(var(--cell) * .7) var(--letter); color: var(--ink); }
.pattern-cell.say { transform: translateY(-1.5vmin) scale(1.12); background: var(--sun-soft); }
.pattern-choices { display: flex; gap: 4vmin; }
.pattern-choice { width: clamp(90px, 20vmin, 200px); aspect-ratio: 1; }

/* ---------- Big & Little ---------- */
.match-wrap {
  --box: min(20vmin, calc((92vw - var(--n) * 3vmin) / var(--n)));
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
}
.match-cards, .match-tray { display: flex; gap: 3vmin; justify-content: center; }
.match-tray { min-height: calc(var(--box) * .72 + 12px); }
.match-card {
  width: var(--box);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1vmin;
  padding: 1vmin 1vmin 1.6vmin;
  transition: box-shadow .3s;
}
.match-card.matched { box-shadow: 0 0 0 5px var(--green), var(--shadow); }
.match-big { font-size: calc(var(--box) * .62); line-height: 1.05; color: var(--blue); }
.match-pocket {
  width: calc(var(--box) * .72);
  aspect-ratio: 1;
  border: 3px dashed #95ABA0;
  border-radius: 18px;
  display: grid;
  place-items: center;
}
.match-tile {
  width: calc(var(--box) * .72);
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: calc(var(--box) * .5);
  line-height: 1;
  color: var(--coral-ink);
  cursor: grab;
  position: relative;
  z-index: 1;
}
.match-pocket .match-tile { width: calc(100% + 6px); box-shadow: var(--shadow-sm); }

/* ---------- Shape Cookies ---------- */
.cookie-wrap { height: 100%; display: flex; align-items: center; gap: 3vmin; }
.cookie-pier { height: min(48vmin, 70%); align-self: flex-end; flex: none; transform-origin: bottom center; }
.cookie-pier.munch { animation: hop .8s ease-in-out infinite; }
.cookie-tray {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 3vmin;
  padding: 3vmin;
  min-height: 55%;
  border: 1px solid #DDC99D;
  background: #F3E7CC; /* a warm baking tray; the cookie icing keeps its teaching colors */
  border-radius: calc(var(--radius) * 1.1);
  box-shadow: var(--shadow), inset 0 0 0 10px rgba(255, 255, 255, .45);
}
.cookie {
  width: clamp(110px, 27vmin, 260px);
  aspect-ratio: 1;
  background: none;
  border: 0;
  padding: 0;
  transition: transform .5s ease, opacity .35s ease .3s;
}
.cookie svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 6px 4px rgba(23, 63, 58, .14)); }
.cookie.dim { opacity: .35; }
.cookie.eaten { opacity: 0; }

@media (orientation: portrait) {
  .cookie-wrap { flex-direction: column; }
  .cookie-pier { align-self: center; height: 30%; }
  .count-wrap, .feed-wrap { flex-direction: column; }
  .count-answers { flex-direction: row; justify-content: center; }
  .feed-basket { flex: 1 1 40%; align-self: stretch; min-height: 0; max-height: 46%; gap: 1vmin; padding: 2vmin; }
  .feed-basket .feed-food { width: clamp(48px, 12vmin, 110px); }
  .feed-basket.many .feed-food { width: clamp(44px, 10vmin, 96px); }
  .feed-table { flex: 1 1 54%; min-height: 0; align-self: stretch; }
  .feed-pier { height: min(40vmin, 58%); }
  .trace-wrap { flex-direction: column; }
  .trace-modes { flex-direction: row; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
