:root {
  --sea: #1597ad; --sea-deep: #0c7391; --sea-light: #7cdcdc;
  --sand: #fff1d0; --sand-2: #ffdf9e; --paper: #fffaf0; --line: #eddcb6;
  --ink: #17385a; --muted: #6b7f92;
  --vowel: #e23c2a; --cons: #1c68cc;
  --good: #27a35e; --good-d: #1b7e47; --sun: #ffc234; --coral: #ff7a59;
  --read: 'Nunito', 'Segoe UI', sans-serif;
  --ui: 'Nunito', 'Segoe UI', sans-serif;
}
/* Everything is sized in rem, so the whole screen scales to the tablet and never scrolls. */
html { font-size: min(1.56vw, 2.08vh); }
@media (orientation: portrait) { html { font-size: min(2.08vw, 1.56vh); } }
@media (max-width: 600px) { html { font-size: min(3.3vw, 1.7vh); } }

* { box-sizing: border-box; margin: 0; }
html, body, #app { height: 100%; overflow: hidden; }
body {
  font-family: var(--ui); font-weight: 800; color: var(--ink); background: var(--sea);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: .25rem solid var(--sun); outline-offset: .15rem; }
.ico { width: 1.5em; height: 1.5em; flex: none; }
.v, b.v { color: var(--vowel); }
.c, b.c { color: var(--cons); }
.pic svg { display: block; width: 100%; height: 100%; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 4rem; padding: .5rem 1.6rem; border-radius: 1.3rem; font-size: 1.45rem; font-weight: 900;
  color: #fff; background: var(--good); box-shadow: 0 .35rem 0 var(--good-d); transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(.3rem); box-shadow: 0 .05rem 0 var(--good-d); }
.btn.ghost { color: var(--ink); background: #fff; box-shadow: 0 .35rem 0 var(--line); }
.btn.soft { color: var(--ink); background: var(--sand-2); box-shadow: 0 .35rem 0 #e5bd6b; }
.btn.big { font-size: 1.7rem; min-height: 4.6rem; }
.hidden { visibility: hidden; }

/* Pick a child */
.pick, .map, .finish {
  position: relative; height: 100%;
  background: radial-gradient(120% 90% at 50% 10%, #2fbcc6 0%, var(--sea) 45%, var(--sea-deep) 100%);
}
.pick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.6rem; }
.pick h1 { color: #fff; font-size: 3rem; font-weight: 900; text-align: center; text-shadow: 0 .2rem 0 rgba(0, 60, 80, .35); }
.pick-row { display: flex; gap: 2.4rem; }
.hero-card {
  display: flex; flex-direction: column; align-items: center; gap: .9rem; width: 17rem; padding: 1.7rem 1rem 1.3rem;
  font-size: 2rem; font-weight: 900; background: var(--paper); border-radius: 2.2rem; box-shadow: 0 .6rem 0 #d9c28d;
  transition: transform .1s;
}
.hero-card:active { transform: translateY(.4rem); }
.hero-pic { width: 11rem; animation: bob 2.6s ease-in-out infinite; }
.hero-card:nth-child(2) .hero-pic { animation-delay: -1.3s; }
.hero-pic svg, .chip-pic svg, .boat-hero svg, .say-hero svg, .finish-hero svg { display: block; width: 100%; }

/* Map */
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.wave { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; opacity: .28; animation: drift 5s ease-in-out infinite; }
.wave.w1 { animation-delay: -1.6s; } .wave.w2 { animation-delay: -3.2s; }
.route { fill: none; stroke: #fff; stroke-width: 5; stroke-dasharray: 2 17; stroke-linecap: round; opacity: .8; }
.isl { cursor: pointer; }
.isl-shallow { fill: #5fd1cf; opacity: .55; }
.isl-sand { fill: var(--sand-2); }
.isl-grass { fill: #6cc877; }
.isl-plate { fill: #fff; stroke: #e7c47c; stroke-width: 4; }
.isl-letter { font-family: var(--read); font-weight: 800; font-size: 46px; }
.isl-letter.v { fill: var(--vowel); }
.isl-letter.c { fill: var(--cons); }
.isl.locked { filter: saturate(.25) brightness(1.04); opacity: .72; }
.isl-pulse { fill: none; stroke: var(--sun); stroke-width: 7; transform-box: fill-box; transform-origin: center; animation: pulse 1.7s ease-out infinite; }
.isl.now .isl-plate { stroke: var(--sun); stroke-width: 6; }
.boat { position: absolute; display: flex; flex-direction: column-reverse; width: 7.6rem; transform: translate(-50%, -70%); pointer-events: none; animation: rock 3.2s ease-in-out infinite; transform-origin: 50% 80%; }
.hull { display: block; width: 100%; position: relative; z-index: 1; margin-top: -1.3rem; }
.boat-hero { display: block; width: 4.6rem; margin: 0 auto; }
.map-top { position: absolute; inset: 1rem 1.2rem auto; display: flex; justify-content: space-between; pointer-events: none; }
.chip {
  pointer-events: auto; display: flex; align-items: center; gap: .55rem; min-height: 3.5rem; padding: .35rem 1.1rem .35rem .45rem;
  font-size: 1.15rem; font-weight: 900; background: var(--paper); border-radius: 2rem; box-shadow: 0 .25rem 0 rgba(0, 50, 70, .3);
}
.chip.parents { padding: .35rem 1.2rem; color: var(--muted); font-size: 1rem; }
.chip-pic { display: block; width: 2.8rem; flex: none; }
.map-say { position: absolute; inset: auto 0 1rem; justify-content: center; pointer-events: none; }
.map-say .bubble::before { display: none; }
.map-say .bubble { flex: none; max-width: 90%; }

/* Lesson frame */
.lesson {
  height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: .8rem 1.2rem .6rem;
  background: linear-gradient(180deg, var(--paper) 0%, var(--sand) 100%);
}
.bar { display: flex; align-items: center; gap: .9rem; }
.round {
  flex: none; display: grid; place-items: center; width: 3.7rem; height: 3.7rem; font-size: 1.15rem; color: var(--ink);
  background: #fff; border-radius: 50%; box-shadow: 0 .25rem 0 var(--line);
}
.round:active { transform: translateY(.2rem); box-shadow: none; }
.steps { flex: 1; display: flex; justify-content: center; gap: .4rem; min-width: 0; }
.step {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; flex: 0 1 6.4rem; min-width: 0; height: 3.9rem;
  font-size: 1.15rem; color: #9fa9b2; background: rgba(23, 56, 90, .05); border-radius: 1rem;
}
.step span { font-size: .78rem; line-height: 1.1; }
.step b { font-family: var(--read); font-size: 1.55rem; line-height: 1.2; }
.step.past { color: var(--good-d); background: #dcf3e2; }
.step.cur { color: var(--ink); background: var(--sun); box-shadow: 0 .22rem 0 #dd9d16; }

.stage { position: relative; display: flex; flex-direction: column; min-height: 0; padding: .5rem 0; }
.beads { display: flex; justify-content: center; gap: .5rem; height: 1rem; flex: none; }
.beads i { width: .85rem; height: .85rem; border-radius: 50%; background: var(--line); }
.beads i.on { background: var(--good); }
.beads i.cur { background: var(--sun); box-shadow: 0 0 0 .22rem rgba(255, 194, 52, .3); }

.say { display: flex; align-items: center; gap: .9rem; min-height: 5.4rem; }
.say-hero { width: 4.9rem; flex: none; animation: bob 2.6s ease-in-out infinite; }
.bubble {
  position: relative; flex: 0 1 auto; padding: .75rem 1.3rem; font-size: 1.4rem; font-weight: 800; line-height: 1.25;
  background: #fff; border-radius: 1.2rem; box-shadow: 0 .2rem 0 var(--line);
}
.bubble:empty { visibility: hidden; }
.bubble::before {
  content: ''; position: absolute; left: -.7rem; top: 50%; margin-top: -.55rem;
  border: .55rem solid transparent; border-right-color: #fff; border-left: 0;
}
.novoice { margin-left: auto; flex: none; padding: .35rem .75rem; font-size: .85rem; color: var(--muted); background: rgba(23, 56, 90, .07); border-radius: 1rem; }

/* Meet the letter */
.intro { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1.6fr; grid-template-rows: auto auto; align-content: center; gap: 1.2rem 1.5rem; }
.letter-card {
  grid-row: span 2; display: grid; place-items: center; font-family: var(--read); font-weight: 800;
  font-size: 11.5rem; line-height: 1; color: var(--cons); background: #fff; border-radius: 2.2rem; box-shadow: 0 .5rem 0 #cfe0f5;
  transition: transform .1s;
}
.letter-card small { font-size: .72em; margin-left: .12em; }
.letter-card:active { transform: scale(.97); }
.words { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
.word-card {
  display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: .9rem .6rem .8rem;
  background: #fff; border-radius: 1.6rem; box-shadow: 0 .35rem 0 var(--line); transition: transform .1s, box-shadow .1s;
}
.word-card:active { transform: translateY(.25rem); box-shadow: none; }
.word-card.seen { box-shadow: 0 .35rem 0 #9fdcb6; }
.word-card .pic { width: 100%; aspect-ratio: 1; }
.w { font-family: var(--read); font-weight: 800; font-size: 2.5rem; line-height: 1.1; }
.intro .next { justify-self: end; }
.next .ico { width: 1.25em; height: 1.25em; }

/* Hear */
.hear { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.2rem; }
.big-speaker {
  display: grid; place-items: center; width: 8rem; height: 8rem; font-size: 2.7rem; color: #fff; background: var(--coral); border-radius: 50%;
  box-shadow: 0 .45rem 0 #d5573a; animation: breathe 2s ease-in-out infinite;
}
.opts { display: flex; gap: 1.7rem; }
.opt {
  display: grid; place-items: center; width: 12rem; height: 12rem; font-family: var(--read); font-weight: 800; font-size: 7.5rem; line-height: 1;
  background: #fff; border-radius: 2rem; box-shadow: 0 .5rem 0 var(--line); transition: transform .1s;
}
.opt.syl { width: 14rem; font-size: 5.6rem; }
.opt:active { transform: translateY(.25rem); }
.opt.right { background: #d9f5e3; box-shadow: 0 .5rem 0 #9fdcb6; animation: hop .5s; }

/* Trace */
.trace { flex: 1; min-height: 0; display: flex; justify-content: center; }
.trace-svg { height: 100%; max-width: 100%; aspect-ratio: 1; background: #fff; border-radius: 2.2rem; box-shadow: 0 .5rem 0 var(--line); touch-action: none; cursor: pointer; }
.t-guide, .t-ink, .t-dash { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.t-guide { stroke: #e3edf9; stroke-width: 58; }
.t-dash { stroke: #fff; stroke-width: 5; stroke-dasharray: 3 15; }
.t-ink { stroke: var(--cons); stroke-width: 44; }
.t-head { fill: var(--sun); stroke: #fff; stroke-width: 6; animation: breathe 1.3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.t-head.held { animation: none; fill: var(--coral); }
.t-ghost { fill: var(--coral); opacity: .55; }
.finished .t-ink { stroke: var(--good); transition: stroke .3s; }

/* Merge */
.merge { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.m-track {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: min(47rem, 94%); min-height: 15rem; padding: 1.2rem;
  background: rgba(23, 56, 90, .05); border: .2rem dashed #dcc99c; border-radius: 2.4rem;
}
.m-track:has(.joined) { justify-content: center; }
.m-hint { font-size: 2.2rem; color: var(--coral); animation: nudge 1.2s ease-in-out infinite; }
.tile {
  display: grid; place-items: center; width: 6.2rem; height: 6.2rem; font-family: var(--read); font-weight: 800; font-size: 4.2rem; line-height: 1;
  background: #fff; border-radius: 1.3rem; box-shadow: 0 .4rem 0 var(--line); transition: transform .15s, opacity .15s;
}
.tile.xl { width: 12rem; height: 12rem; font-size: 8.5rem; border-radius: 2rem; box-shadow: 0 .55rem 0 var(--line); }
.tile.drag { position: relative; z-index: 2; touch-action: none; cursor: grab; box-shadow: 0 .55rem 0 #bcd4f2; transition: transform .25s cubic-bezier(.3, 1.5, .5, 1); }
.tile.drag.held { cursor: grabbing; box-shadow: 0 1rem 1rem rgba(23, 56, 90, .25); }
.tile.joined { display: block; width: auto; min-width: 20rem; padding: 1.7rem 2.4rem; height: 12rem; line-height: 1; text-align: center; background: #fff; box-shadow: 0 .55rem 0 #9fdcb6; animation: hop .5s; }

/* Build */
.build { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); gap: 1.7rem; align-items: center; }
.build-pic { display: block; height: min(100%, 22rem); width: 100%; padding: 1rem; background: #fff; border-radius: 2rem; box-shadow: 0 .5rem 0 var(--line); }
.build-right { display: flex; flex-direction: column; align-items: center; gap: 2.4rem; }
.slots, .tiles { display: flex; gap: .85rem; flex-wrap: wrap; justify-content: center; }
.slot {
  display: grid; place-items: center; width: 7rem; height: 8rem; font-family: var(--read); font-weight: 800; font-size: 5.2rem; line-height: 1;
  background: rgba(23, 56, 90, .05); border: .22rem dashed #d6c497; border-radius: 1.3rem;
}
.slot.filled { background: #fff; border: .22rem solid #9fdcb6; animation: hop .35s; }
.tile.used { opacity: .18; box-shadow: none; }

/* Read */
.read { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.1rem; }
.read-word { font-family: var(--read); font-weight: 800; font-size: 10rem; line-height: 1.1; letter-spacing: .02em; padding: 1rem 3rem; background: #fff; border-radius: 2.2rem; box-shadow: 0 .5rem 0 var(--line); }
.adult { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .9rem; padding: .7rem 1rem; border-radius: 1.5rem; background: rgba(23, 56, 90, .06); }
.adult-label { font-size: 1.05rem; color: var(--muted); }

/* Finish */
.finish { display: grid; place-items: center; overflow: hidden; padding: 1rem; }
.finish-card { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1.8rem 3.4rem 2rem; background: var(--paper); border-radius: 2.6rem; box-shadow: 0 .7rem 0 #d9c28d; }
.finish-hero { width: 8.5rem; animation: hop 1.1s ease-in-out infinite; }
.finish h1 { font-size: 2.8rem; font-weight: 900; }
.finish h1 .c { font-family: var(--read); }
.stars { display: flex; gap: .4rem; }
.stars svg { width: 3.2rem; display: block; animation: pop-in .5s backwards; }
.stars svg:nth-child(2) { animation-delay: .12s; } .stars svg:nth-child(3) { animation-delay: .24s; }
.stars svg:nth-child(4) { animation-delay: .36s; } .stars svg:nth-child(5) { animation-delay: .48s; }
.found { display: flex; align-items: center; gap: .8rem; padding: .5rem 1.2rem .5rem .6rem; font-size: 1.35rem; background: #fff; border-radius: 1.4rem; }
.found .pic { width: 4.2rem; height: 4.2rem; }
.confetti i { position: absolute; top: -3%; width: .9rem; height: 1.4rem; border-radius: .2rem; animation: fall 3.2s linear infinite; }

/* Parents */
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 1rem; background: rgba(10, 40, 60, .55); }
.modal-card { width: min(36rem, 100%); max-height: 94%; overflow: auto; padding: 1.5rem 1.7rem; font-weight: 700; font-size: 1.1rem; background: var(--paper); border-radius: 1.8rem; }
.modal-card h2 { margin-bottom: .7rem; font-size: 1.7rem; font-weight: 900; }
.p-row { display: flex; gap: .9rem; padding: .7rem 0; border-top: .12rem solid var(--line); }
.p-row ul { padding-left: 1.1rem; margin-top: .2rem; }
.p-row p, .p-row li { font-size: 1rem; line-height: 1.35; }
.muted { color: var(--muted); }
.modal-actions { display: flex; justify-content: space-between; gap: .7rem; margin-top: .9rem; }
.modal-actions .btn { min-height: 3.2rem; font-size: 1.1rem; }

.spark { position: fixed; z-index: 20; width: 1.7rem; margin: -.85rem; pointer-events: none; animation: spark .7s ease-out forwards; }
.spark svg { display: block; width: 100%; }
.shake { animation: shake .4s; }

@keyframes bob { 50% { transform: translateY(-.35rem); } }
@keyframes rock { 0%, 100% { rotate: -2.5deg; } 50% { rotate: 2.5deg; } }
@keyframes drift { 50% { transform: translateX(14px); } }
@keyframes pulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes breathe { 50% { transform: scale(1.06); } }
@keyframes nudge { 50% { transform: translateX(.6rem); } }
@keyframes hop { 40% { transform: translateY(-.9rem) scale(1.04); } }
@keyframes shake { 20%, 60% { transform: translateX(-.55rem); } 40%, 80% { transform: translateX(.55rem); } }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.3) rotate(120deg); opacity: 0; } }
@keyframes pop-in { from { transform: scale(0); } 70% { transform: scale(1.25); } }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); } }

/* Tall tablet held upright */
@media (orientation: portrait) {
  .intro { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .letter-card { grid-row: auto; padding: 1rem; }
  .build { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .build-pic { width: auto; aspect-ratio: 1; justify-self: center; }
  .opts { gap: 1rem; }
  .opt { width: 10rem; height: 10rem; font-size: 6.5rem; }
  .opt.syl { width: 11rem; font-size: 4.8rem; }
  .pick-row { gap: 1.2rem; }
  .hero-card { width: 15rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
}
