/* Letter Pups — joyful, rounded, big. Every letter keeps its own colour (set inline). */

@font-face {
  font-family: "Andika";
  src: url("../fonts/Andika-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Andika";
  src: url("../fonts/Andika-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --cream: #FFF6E5;
  --ink: #3B2E5A;
  --orange: #FF8F00;
  --green: #2ECC40;
  --sky: #4FC3F7;
  --radius: 28px;
  --font-kid: "Andika", ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ui: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --bar: clamp(72px, 12vmin, 116px);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-kid);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

img { -webkit-user-drag: none; user-select: none; pointer-events: none; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:focus { outline: none; }
button:focus-visible { outline: 4px solid var(--sky); outline-offset: 4px; }

.hidden { display: none !important; }

#app { position: fixed; inset: 0; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 1000; overflow: hidden; }

.glyph {
  font-family: "Andika", var(--font-kid);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
}

/* ---------- screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(var(--sat) + 10px) calc(var(--sar) + 16px) calc(var(--sab) + 12px) calc(var(--sal) + 16px);
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,.75) 0 7%, transparent 7.2%),
    radial-gradient(circle at 88% 82%, rgba(255,255,255,.6) 0 9%, transparent 9.2%),
    var(--world-bg, linear-gradient(160deg, #FFF3D6 0%, #FFE6F0 55%, #E3F2FD 100%));
  overflow: hidden;
  animation: screen-in .35s ease-out;
}
.screen-loading { align-items: center; justify-content: center; }
.loading-paw { font-size: 22vmin; animation: pulse 1.2s ease-in-out infinite; }
.boot-error { display: grid; place-items: center; height: 100%; font-size: 6vmin; }

@keyframes screen-in { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- top bar ---------- */

.topbar {
  flex: 0 0 auto;
  height: var(--bar);
  display: grid;
  grid-template-columns: minmax(var(--bar), auto) 1fr minmax(var(--bar), auto);
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 5;
}
.tb-left { display: flex; align-items: center; gap: 12px; }
.tb-center { display: flex; justify-content: center; align-items: center; min-width: 0; }
.tb-right { display: flex; justify-content: flex-end; }

.replay-btn {
  width: var(--bar); height: var(--bar);
  border-radius: 50%;
  font-size: calc(var(--bar) * .5);
  background: radial-gradient(circle at 35% 30%, #FFF59D, #FFCA28 60%, #FFB300);
  box-shadow: 0 6px 0 #E69500, 0 10px 22px rgba(0,0,0,.18);
  display: grid; place-items: center;
  transition: transform .12s;
}
.replay-btn:active { transform: translateY(4px) scale(.96); box-shadow: 0 2px 0 #E69500; }

.icon-btn {
  width: calc(var(--bar) * .9); height: calc(var(--bar) * .9);
  border-radius: 50%;
  font-size: calc(var(--bar) * .45);
  background: #fff;
  box-shadow: 0 5px 0 #E2D8F0, 0 8px 18px rgba(0,0,0,.12);
  display: grid; place-items: center;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #E2D8F0; }

.gear {
  --p: 0;
  width: 64px; height: 64px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 26px;
  opacity: .45;
  background: conic-gradient(var(--orange) calc(var(--p) * 360deg), rgba(255,255,255,.55) 0);
  touch-action: none;
  transition: opacity .2s;
}
.gear span { width: 50px; height: 50px; border-radius: 50%; background: var(--cream); display: grid; place-items: center; }
.gear.holding { opacity: 1; }

/* mid-mission home: hold ~1 s, ring fills (stray taps don't end the mission) */
.hold-exit { --p: 0; touch-action: none; background: conic-gradient(var(--orange) calc(var(--p) * 360deg), #fff 0); }
.hold-exit span { width: 80%; height: 80%; border-radius: 50%; background: #fff; display: grid; place-items: center; pointer-events: none; }
.hold-exit.holding { transform: scale(1.08); }

.hello { font-size: clamp(22px, 4.5vmin, 40px); font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.paws { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-width: 100%; }
.paw-dot { font-size: clamp(14px, 2.6vmin, 26px); opacity: .22; filter: grayscale(1); transition: all .3s; }
.paw-dot.on { opacity: 1; filter: none; }
.paw-dot.now { opacity: .8; filter: none; animation: pulse 1.2s ease-in-out infinite; }

/* ---------- splash ---------- */

.splash {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3vmin;
}
.logo {
  font-family: var(--font-kid);
  font-weight: 700;
  font-size: clamp(48px, 11vmin, 120px);
  color: #E53935;
  text-shadow: 0 5px 0 #fff, 0 9px 0 rgba(0,0,0,.08);
  line-height: 1;
}
.logo span { color: #1E88E5; }
.crew-img { width: min(92vw, 760px); height: auto; aspect-ratio: 4 / 1; }
.crew-img.dance { animation: hop 1s ease-in-out infinite; }

.big-paw {
  width: min(40vmin, 330px); height: min(40vmin, 330px);
  border-radius: 50%;
  font-size: min(20vmin, 165px);
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 28%, #FFD180, #FF9800 55%, #F57C00);
  box-shadow: 0 12px 0 #D65F00, 0 22px 40px rgba(245,124,0,.45), inset 0 -8px 0 rgba(0,0,0,.08);
  animation: pulse 1.6s ease-in-out infinite;
}
.big-paw:active { transform: translateY(8px) scale(.97); box-shadow: 0 4px 0 #D65F00; animation: none; }

/* ---------- home ---------- */

.home {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
  gap: 2vmin;
}
.crew-row { display: flex; gap: clamp(8px, 3vmin, 36px); justify-content: center; align-items: flex-end; }
.crew-member { display: flex; flex-direction: column; align-items: center; animation: hop 2.4s ease-in-out infinite; }
.crew-member:nth-child(2) { animation-delay: .3s; }
.crew-member:nth-child(3) { animation-delay: .6s; }
.crew-member:nth-child(4) { animation-delay: .9s; }
.crew-pup { width: clamp(70px, 17vmin, 160px); height: auto; aspect-ratio: 1; }
.pup-fallback { display: grid; place-items: center; font-size: clamp(48px, 11vmin, 110px); }
.vehicle { font-size: clamp(26px, 5vmin, 52px); margin-top: -1vmin; }
.home-actions { display: flex; gap: clamp(24px, 6vmin, 72px); }
.action-btn {
  width: clamp(104px, 17vmin, 150px); height: clamp(104px, 17vmin, 150px);
  border-radius: 34px;
  font-size: clamp(52px, 9vmin, 84px);
  display: grid; place-items: center;
  background: #fff;
  box-shadow: 0 8px 0 #DCCFF0, 0 14px 26px rgba(0,0,0,.12);
}
.book-btn { background: linear-gradient(160deg, #E1F5FE, #B3E5FC); box-shadow: 0 8px 0 #81D4FA, 0 14px 26px rgba(0,0,0,.12); }
.play-btn { background: linear-gradient(160deg, #F1F8E9, #C5E1A5); box-shadow: 0 8px 0 #9CCC65, 0 14px 26px rgba(0,0,0,.12); }
.action-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 rgba(0,0,0,.15); }

/* ---------- world chooser ---------- */

.world-pick {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 4vmin, 40px);
  padding: 2vmin clamp(0px, 6vw, 80px) 1vmin;
}
.world-btn {
  border-radius: 36px;
  width: 100%; height: 100%;
  background: var(--bg);
  border: 6px solid var(--c);
  box-shadow: 0 8px 0 var(--c), 0 14px 26px rgba(0,0,0,.12);
  display: flex; align-items: center; justify-content: center; gap: 2vmin;
  flex-wrap: wrap;
  min-height: 120px;
  position: relative;
  animation: pop-in .45s backwards;
}
.world-btn:nth-child(2) { animation-delay: .08s; }
.world-btn:nth-child(3) { animation-delay: .16s; }
.world-btn:nth-child(4) { animation-delay: .24s; }
.world-btn.picked { animation: bounce .6s; }
.world-pup { width: clamp(80px, 18vmin, 170px); height: auto; aspect-ratio: 1; }
.world-vehicle { font-size: clamp(44px, 9vmin, 90px); }
.world-friends { position: absolute; bottom: 8px; right: 16px; font-size: clamp(20px, 4vmin, 36px); opacity: .8; }

/* ---------- stage & shared choices ---------- */

.stage {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  z-index: 2;
}
.decor { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.decor span { position: absolute; font-size: clamp(36px, 8vmin, 80px); opacity: .28; }
.decor-0 { left: 2%; top: 14%; transform: rotate(-12deg); }
.decor-1 { right: 3%; top: 18%; transform: rotate(10deg); }
.decor-2 { left: 4%; bottom: 4%; transform: rotate(8deg); }
.decor-3 { right: 4%; bottom: 3%; transform: rotate(-8deg); }

.mission-intro { animation: pop-in .5s; }
.intro-pup { width: min(40vmin, 320px); height: auto; aspect-ratio: 1; animation: hop 1.2s ease-in-out infinite; }

.choices {
  display: flex; flex-wrap: wrap;
  justify-content: center; align-items: flex-end;
  gap: clamp(22px, 5vmin, 56px);
  width: 100%;
}
.choice { animation: pop-in .45s backwards; position: relative; }
.choice.locked { pointer-events: none; }
.choice.soft-no { opacity: .3; transform: scale(.88); transition: opacity .4s, transform .4s; pointer-events: none; }
.wiggle-glow { animation: wiggle .5s ease-in-out 3 !important; filter: drop-shadow(0 0 14px #FFD600) drop-shadow(0 0 28px #FFEA00); z-index: 3; }

/* Sound Hunt balloons */
.hunt { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.balloon-wrap {
  width: clamp(112px, 21vmin, 210px);
  display: flex; flex-direction: column; align-items: center;
}
.balloon-wrap:nth-child(odd) .balloon { animation: float 3.2s ease-in-out infinite; }
.balloon-wrap:nth-child(even) .balloon { animation: float 3.6s ease-in-out infinite reverse; }
.balloon {
  width: 100%;
  aspect-ratio: 0.86;
  border-radius: 50% 50% 47% 47% / 56% 56% 44% 44%;
  background: radial-gradient(circle at 30% 26%, rgba(255,255,255,.95) 0 7%, transparent 7.5%), #fff;
  background: radial-gradient(circle at 30% 26%, rgba(255,255,255,.95) 0 7%, transparent 7.5%), color-mix(in srgb, var(--c) 20%, white);
  border: clamp(5px, 1vmin, 8px) solid var(--c);
  display: grid; place-items: center;
  box-shadow: inset -10px -14px 0 rgba(0,0,0,.05), 0 10px 20px rgba(0,0,0,.1);
  position: relative;
}
.balloon::after {
  content: ""; position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%);
  border: 9px solid transparent; border-top-color: var(--c); border-bottom-width: 0;
}
.balloon .glyph { font-size: clamp(66px, 13.5vmin, 140px); }
.balloon-string { width: 3px; height: clamp(18px, 4vmin, 40px); background: #9E9E9E; border-radius: 2px; margin-top: 12px; }
.balloon-pup { width: 74%; height: auto; aspect-ratio: 1; margin-top: -4px; }
.balloon.pop { animation: balloon-pop .55s ease-out forwards; background: transparent; border-color: transparent; box-shadow: none; }
.balloon.pop::after { display: none; }
.pop-emoji { font-size: clamp(70px, 14vmin, 140px); line-height: 1; grid-area: 1 / 1; transform: translateY(-14%); }
.pop-pair { grid-area: 1 / 1; align-self: end; font-size: clamp(28px, 5vmin, 54px); }

/* Big & Little */
.match {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
  gap: 2vmin;
}
.big-pup { display: flex; align-items: center; gap: 2vmin; }
.match-pup { width: clamp(100px, 25vmin, 230px); height: auto; aspect-ratio: 1; animation: hop 2s ease-in-out infinite; }
.big-tag {
  min-width: clamp(120px, 27vmin, 250px);
  height: clamp(120px, 27vmin, 250px);
  padding: 0 3vmin;
  border-radius: 36px;
  background: #fff;
  border: 7px solid var(--c);
  display: flex; align-items: center; justify-content: center; gap: 1vmin;
  box-shadow: 0 8px 0 var(--c);
}
.big-tag .glyph { font-size: clamp(84px, 20vmin, 190px); }
.big-tag .little-slot:empty { display: none; }
.big-tag.joined { animation: bounce .6s; }
.big-tag.joined .little-slot { animation: pop-in .4s; }
.houses { align-items: flex-end; }
.house { width: clamp(110px, 23vmin, 210px); display: flex; flex-direction: column; align-items: center; }
.roof {
  width: 112%;
  aspect-ratio: 2.1;
  background: var(--c);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  margin-bottom: -2px;
}
.house-body {
  width: 92%;
  aspect-ratio: 1.05;
  background: #FFF8EC;
  border: 6px solid var(--c);
  border-top: 0;
  border-radius: 0 0 22px 22px;
  display: flex; align-items: flex-end; justify-content: center;
  box-shadow: 0 8px 16px rgba(0,0,0,.1);
}
.door {
  width: 74%; height: 84%;
  background: #fff;
  border: 4px solid var(--c);
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  display: grid; place-items: center;
}
.door .glyph { font-size: clamp(56px, 13vmin, 124px); }
.house.picked { animation: bounce .6s; }

/* Meet the Letter */
.meet { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; gap: 4vmin; position: relative; }
.meet-wrap { position: relative; }
.meet-card {
  width: min(56vmin, 470px);
  aspect-ratio: 0.82;
  max-height: calc(100vh - var(--bar) - 70px);
  max-height: calc(100dvh - var(--bar) - 70px);
  perspective: 1400px;
  display: block;
}
.meet-card.pulse .meet-inner { animation: breathe 1.8s ease-in-out infinite; }
.meet-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.3,1.4,.5,1);
}
.meet-card.flipped .meet-inner { transform: rotateY(180deg); animation: none; }
.meet-face {
  position: absolute; inset: 0;
  border-radius: 44px;
  background: #fff;
  border: 10px solid var(--c);
  box-shadow: 0 12px 0 var(--c), 0 22px 40px rgba(0,0,0,.14);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.meet-back { transform: rotateY(180deg); background: color-mix(in srgb, var(--c) 12%, white); }
.meet-pair { font-size: min(27vmin, 230px); display: flex; align-items: baseline; gap: .04em; }
.meet-pair .lo { font-size: .82em; }
.meet-corner { position: absolute; right: 22px; bottom: 16px; font-size: min(9vmin, 72px); }
.meet-emoji { font-size: min(30vmin, 250px); line-height: 1; }
.meet-word { font-size: min(8vmin, 64px); font-weight: 700; margin-top: 2vmin; color: var(--ink); }
.meet-card.fly-away { animation: fly-away .3s ease-in forwards; }
.tap-hint { position: absolute; left: -7vmin; bottom: -3vmin; font-size: min(12vmin, 96px); animation: tap 1.2s ease-in-out infinite; pointer-events: none; }

.next-btn {
  width: clamp(100px, 16vmin, 140px); height: clamp(100px, 16vmin, 140px);
  border-radius: 50%;
  font-size: clamp(48px, 8vmin, 72px);
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #B9F6CA, #2ECC40 60%, #1E9E32);
  box-shadow: 0 8px 0 #188A2A, 0 14px 26px rgba(0,0,0,.18);
  animation: pop-in .4s, pulse 1.4s ease-in-out .4s infinite;
  flex: 0 0 auto;
}
.next-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #188A2A; }

/* Trace It */
.trace { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; gap: 3vmin; }
.trace-box {
  position: relative;
  height: 100%;
  max-height: 100%;
  aspect-ratio: 112 / 128;
  max-width: calc(100vw - 48px - var(--sal) - var(--sar));
  background: #fff;
  border-radius: 40px;
  border: 8px solid var(--c);
  box-shadow: 0 10px 0 var(--c), 0 18px 34px rgba(0,0,0,.12);
  overflow: hidden;
}
.trace-svg { width: 100%; height: 100%; display: block; touch-action: none; transition: transform .6s cubic-bezier(.5,-0.4,.6,1), opacity .6s; }
.guide { stroke: #E3DDF0; stroke-width: .6; stroke-dasharray: 2 2; }
.guide-baseline { stroke: #CFC6E4; stroke-width: .9; stroke-dasharray: none; }
.track-path { fill: none; stroke: #EFEBF7; stroke-width: 22; stroke-linecap: round; stroke-linejoin: round; }
.track-dot { fill: #EFEBF7; }
.center-path { fill: none; stroke-width: 1.3; stroke-dasharray: 1.5 3.5; stroke-linecap: round; opacity: .55; }
.ink, .demo-ink { fill: none; stroke-width: 11; stroke-linecap: round; stroke-linejoin: round; }
.demo-ink { opacity: .75; }
.demo { transition: opacity .3s; }
.demo.fade { opacity: 0; }
.pen { stroke: #fff; stroke-width: 2; filter: drop-shadow(0 1px 1px rgba(0,0,0,.3)); }
.start-dot { fill: var(--green); stroke: #fff; stroke-width: 2.2; transform-box: fill-box; transform-origin: center; animation: dot-pulse 1.1s ease-in-out infinite; }
.start-dot.bounce { animation: dot-bounce .5s ease-in-out 2; }
.badge circle { fill: #3B2E5A; stroke: #fff; stroke-width: 1.2; }
.badge text { fill: #fff; font-size: 8.5px; font-weight: 700; font-family: var(--font-ui); }
.arrow { fill: #3B2E5A; opacity: .8; }
.trace-emoji {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: min(42vmin, 340px);
  transform: scale(0) rotate(-20deg);
  opacity: 0;
  transition: transform .6s cubic-bezier(.3,1.6,.5,1) .25s, opacity .3s .25s;
  pointer-events: none;
}
.trace-box.morph .trace-svg { transform: scale(.2) rotate(15deg); opacity: 0; }
.trace-box.morph .trace-emoji { transform: none; opacity: 1; }
.trace-side { display: flex; flex-direction: column; align-items: center; }
.trace-mini { font-size: clamp(60px, 12vmin, 120px); opacity: .9; }

/* Twin Detective */
.twins { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vmin; }
.twins-show { display: flex; align-items: center; gap: 4vmin; }
.twins-vs { font-size: clamp(44px, 9vmin, 90px); animation: hop 1.6s ease-in-out infinite; }
.twin-card {
  width: clamp(130px, 30vmin, 280px);
  border-radius: 36px; background: #fff;
  border: 8px solid var(--c);
  box-shadow: 0 8px 0 var(--c);
  display: flex; flex-direction: column; align-items: center; padding: 2vmin 0;
}
.twin-card .glyph { font-size: clamp(90px, 20vmin, 200px); }
.twin-hint { width: 60%; height: auto; aspect-ratio: 100 / 120; }
.twin-track { fill: none; stroke: #EFEBF7; stroke-width: 14; stroke-linecap: round; stroke-linejoin: round; }
.twin-ink { fill: none; stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 100; stroke-dashoffset: 100; animation: draw .9s ease-in-out forwards; }
.card-choice {
  width: clamp(130px, 28vmin, 260px); aspect-ratio: 1;
  border-radius: 40px; background: #fff;
  border: 8px solid var(--c);
  box-shadow: 0 10px 0 var(--c), 0 16px 30px rgba(0,0,0,.12);
  display: grid; place-items: center;
}
.card-choice .glyph { font-size: clamp(90px, 19vmin, 190px); }
.card-choice.picked { animation: bounce .6s; }

/* ---------- mission end ---------- */

.mission-end {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
  gap: 2vmin;
}
.end-letters, .end-stickers { display: flex; flex-wrap: wrap; justify-content: center; gap: 2vmin; }
.mini-card {
  min-width: clamp(76px, 12vmin, 120px); padding: 1vmin 2vmin;
  border-radius: 24px; background: #fff; border: 5px solid var(--c);
  display: grid; place-items: center;
  animation: pop-in .45s backwards;
}
.mini-card .glyph { font-size: clamp(36px, 7vmin, 70px); }
.end-friend:empty { display: none; }
.friend-pop { font-size: clamp(80px, 16vmin, 150px); display: inline-block; animation: friend-pop 1s cubic-bezier(.3,1.6,.5,1); }
.mission-end .home-btn.pulse { animation: pulse 1.4s ease-in-out infinite; width: 120px; height: 120px; font-size: 60px; }

/* ---------- sticker book ---------- */

.tabs { display: flex; gap: 16px; }
.tab {
  width: clamp(80px, 13vmin, 110px); height: clamp(72px, 11vmin, 96px);
  border-radius: 26px; font-size: clamp(36px, 6vmin, 54px);
  background: rgba(255,255,255,.55); display: grid; place-items: center;
  box-shadow: 0 5px 0 rgba(0,0,0,.08);
}
.tab.on { background: #fff; box-shadow: 0 5px 0 #FFB300; transform: translateY(-3px); }

.book { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 1vmin 0 3vmin; touch-action: pan-y; }
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(100px, 15vmin, 140px), 1fr));
  gap: clamp(12px, 2.4vmin, 22px);
}
.sticker {
  aspect-ratio: 0.9;
  border-radius: 26px;
  background: #fff;
  border: 5px solid var(--c);
  box-shadow: 0 6px 0 var(--c);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  position: relative;
}
.sticker.got { animation: pop-in .4s backwards; }
.sticker.locked { background: #F1EFF6; border-color: #DCD8E6; box-shadow: 0 6px 0 #DCD8E6; }
.sticker-emoji { font-size: clamp(40px, 7.5vmin, 68px); line-height: 1; }
.sticker-emoji.ghost { filter: brightness(0); opacity: .12; }
.sticker .glyph { font-size: clamp(28px, 5vmin, 46px); }
.sticker.new { width: clamp(120px, 18vmin, 170px); animation: sticker-in .8s cubic-bezier(.3,1.6,.5,1) backwards; }

.world-pages { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 3vmin; }
.world-page { background: var(--bg); border: 6px solid var(--c); border-radius: 32px; padding: 2vmin; box-shadow: 0 6px 0 var(--c); }
.world-head { display: flex; align-items: center; justify-content: center; gap: 2vmin; }
.world-pup-sm { width: clamp(64px, 12vmin, 110px); height: auto; aspect-ratio: 1; }
.friend-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1vmin; margin-top: 1vmin; }
.friend { font-size: clamp(30px, 5.5vmin, 52px); text-align: center; line-height: 1.2; background: rgba(255,255,255,.6); border-radius: 16px; }
.friend.locked { filter: brightness(0); opacity: .12; }
.friend.got { animation: pop-in .4s backwards; }

/* ---------- free play ---------- */

.free-grid {
  flex: 1; min-height: 0;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  gap: clamp(20px, 4vmin, 44px);
}
.free-tile {
  width: clamp(120px, 24vmin, 210px); aspect-ratio: 1;
  border-radius: 40px;
  font-size: clamp(56px, 11vmin, 100px);
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  box-shadow: 0 9px 0 rgba(0,0,0,.12), 0 16px 26px rgba(0,0,0,.1);
  animation: pop-in .4s backwards;
}
.free-tile small { font-size: .6em; }
.tile-meet { background: linear-gradient(160deg, #FFF8E1, #FFE082); }
.tile-hunt { background: linear-gradient(160deg, #FCE4EC, #F8BBD0); }
.tile-trace { background: linear-gradient(160deg, #E3F2FD, #90CAF9); }
.tile-match { background: linear-gradient(160deg, #F1F8E9, #AED581); }
.tile-twins { background: linear-gradient(160deg, #EDE7F6, #B39DDB); }
.free-tile:active { transform: translateY(6px); }
.letter-pick { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(110px, 17vmin, 160px), 1fr)); gap: 2.4vmin; align-content: start; padding: 2vmin 0; touch-action: pan-y; }
.pick-card { aspect-ratio: 1; border-radius: 30px; background: #fff; border: 6px solid var(--c); box-shadow: 0 7px 0 var(--c); display: grid; place-items: center; }
.pick-card .glyph { font-size: clamp(48px, 9vmin, 84px); }
.free-done { display: flex; flex-direction: column; align-items: center; gap: 2vmin; }
.free-done .sticker-emoji { font-size: 16vmin; animation: friend-pop 1s; }

/* ---------- parent gate ---------- */

.gate-overlay {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(40, 30, 70, .55);
  display: grid; place-items: center;
  padding: 16px;
  animation: screen-in .2s;
}
.gate {
  background: #fff; border-radius: 28px; padding: 28px 28px 32px;
  width: min(520px, 100%);
  text-align: center; position: relative;
  font-family: var(--font-ui);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.gate.shake { animation: wiggle .4s; }
.gate-title { margin: 0; font-size: 18px; color: #7A6F96; }
.gate-q { margin: 8px 0 20px; font-size: 34px; font-weight: 700; }
.gate-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.gate-num { height: 84px; border-radius: 20px; font-size: 36px; font-weight: 700; background: #F3EEFB; box-shadow: 0 5px 0 #DCD1EE; }
.gate-num:active { transform: translateY(4px); box-shadow: 0 1px 0 #DCD1EE; }
.gate-close { position: absolute; top: 10px; right: 12px; width: 52px; height: 52px; border-radius: 50%; font-size: 22px; background: #F3EEFB; }

/* ---------- parent mode (text is fine here) ---------- */

.screen-parent { padding: 0; background: #F7F5FB; }
.parent.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; user-select: text; -webkit-user-select: text; }
.parent-page {
  max-width: 980px; margin: 0 auto;
  padding: calc(var(--sat) + 18px) calc(var(--sar) + 18px) calc(var(--sab) + 40px) calc(var(--sal) + 18px);
  font-family: var(--font-ui);
  font-size: 17px; line-height: 1.45;
  color: #2D2640;
}
.p-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.p-head h1 { font-size: 26px; margin: 0; }
.p-section { background: #fff; border-radius: 20px; padding: 18px 20px; margin: 16px 0; box-shadow: 0 2px 8px rgba(40,30,70,.06); }
.p-section h2 { margin: 0 0 10px; font-size: 21px; }
.p-section h3 { margin: 18px 0 6px; font-size: 17px; }
.p-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.p-input { font: inherit; font-size: 20px; padding: 10px 14px; border-radius: 12px; border: 2px solid #D9D2EA; min-width: 0; flex: 1 1 180px; max-width: 320px; user-select: text; -webkit-user-select: text; }
.p-note { color: #6E6585; font-size: 15px; }
.p-warn { color: #A04000; }
.p-label { font-weight: 600; margin: 12px 0 6px; }
.p-btn { font-family: var(--font-ui); font-size: 16px; padding: 10px 16px; border-radius: 12px; background: #EFEAF8; color: #2D2640; min-height: 44px; }
.p-btn:disabled { opacity: .4; }
.p-btn:active { background: #E1D8F2; }
.p-primary { background: #FF8F00; color: #fff; font-weight: 700; }
.p-small { padding: 6px 12px; font-size: 15px; min-height: 40px; }
.p-danger { background: #D32F2F; color: #fff; font-weight: 700; }
.p-danger-outline { border: 2px solid #D32F2F; color: #D32F2F; background: #fff; }
.p-confirm { margin-top: 12px; padding: 14px; border-radius: 14px; background: #FFEBEE; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.p-confirm p { margin: 0; flex: 1 1 100%; }
.p-seg { display: flex; flex-wrap: wrap; gap: 8px; }
.p-seg-btn { padding: 10px 16px; border-radius: 12px; background: #EFEAF8; font-family: var(--font-ui); font-size: 16px; min-height: 44px; }
.p-seg-btn.on { background: #3B2E5A; color: #fff; }
.p-checks { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.p-check { display: flex; align-items: center; gap: 6px; min-height: 44px; font-size: 17px; }
.p-check input { width: 24px; height: 24px; }
.p-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; }
.p-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.p-table th, .p-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #EEE9F6; white-space: nowrap; }
.p-table th { color: #6E6585; font-weight: 600; }
.p-table tr.row-m td { background: #FFFBEA; }
.p-glyph { font-size: 26px; }
.rec-group { border: 1px solid #EEE9F6; border-radius: 14px; margin: 10px 0; padding: 4px 12px; }
.rec-group summary { font-weight: 700; padding: 10px 0; cursor: pointer; min-height: 44px; display: list-item; }
.rec-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid #F3F0F9; }
.rec-row.has-rec .rec-text span:first-child { color: #1B7F2A; }
.rec-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 260px; }
.rec-text code { font-size: 12px; color: #9A91B0; }
.rec-mark { font-size: 13px; color: #1B7F2A; }
.rec-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.p-rec.recording { background: #D32F2F; color: #fff; animation: pulse 1s infinite; }
.rec-status { font-size: 13px; color: #6E6585; }
.parent code { font-family: ui-monospace, Menlo, monospace; font-size: .9em; }

/* ---------- celebrations ---------- */

.fx-paw, .fx-dot {
  position: fixed;
  transform: translate(-50%, -50%);
  animation: burst 1.3s cubic-bezier(.2,.7,.3,1) forwards;
  will-change: transform, opacity;
}
.fx-paw { font-size: 34px; }
.fx-dot { width: 12px; height: 18px; border-radius: 4px; }

@keyframes burst {
  0% { transform: translate(-50%, -50%) scale(.3) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(var(--rot)); opacity: 0; }
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6%); } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0) scale(1.06); } 25% { transform: rotate(-7deg) scale(1.1); } 75% { transform: rotate(7deg) scale(1.1); } }
@keyframes bounce { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 70% { transform: scale(.95); } 100% { transform: scale(1); } }
@keyframes pop-in { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes balloon-pop { 0% { transform: scale(1); } 30% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes fly-away { to { transform: translateX(-30vw) scale(.6) rotate(-10deg); opacity: 0; } }
@keyframes tap { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-12px, -14px); } }
@keyframes dot-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@keyframes dot-bounce { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.6); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes sticker-in { from { transform: scale(0) rotate(-30deg); } to { transform: none; } }
@keyframes friend-pop { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: none; } }

/* ---------- orientation & size tweaks ---------- */

/* four choices: a balanced 2x2 instead of 3+1 where a single row doesn't fit */
.houses.n4 { max-width: calc(2 * clamp(110px, 23vmin, 210px) + 2 * clamp(22px, 5vmin, 56px)); }
@media (orientation: portrait) {
  .balloons.n4 { max-width: calc(2 * clamp(112px, 21vmin, 210px) + 2 * clamp(22px, 5vmin, 56px)); }
}

@media (orientation: landscape) {
  .match { flex-direction: row; justify-content: center; gap: 5vmin; }
  .match .big-pup { flex-direction: column; }
  .match .houses { width: auto; flex: 0 1 auto; }
  .match .houses:not(.n4) { max-width: 66%; }
  .home { flex-direction: column; }
}
@media (orientation: portrait) {
  .trace-box { height: auto; width: 100%; max-height: 100%; }
  .trace { flex-direction: column; }
  .trace-side { display: none; }
  .meet { flex-direction: column; }
  .world-pick { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  :root { --bar: 66px; }
  .gear { width: 52px; height: 52px; }
  .gear span { width: 40px; height: 40px; }
  .choices { gap: 16px; }
  .balloons.n4, .houses.n4 { max-width: 340px; }
  .world-btn { border-radius: 26px; }
  .hello { font-size: 20px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  :root { --bar: 60px; }
  .balloon-pup { display: none; }
  .crew-pup { width: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
