/* Shared look for the PN practice games (games 3 to 8): bold-outline cartoon UI, the little wooden table,
   the parent card and the grown-up check button. Each game sets its own palette tokens and scene on top of this.
   One deliberate sunny look, so there is no dark variant. */
:root {
  --ink: #2b2347;
  --ink-soft: #5c5480;
  --paper: #ffffff;
  --cream: #fffaf0;
  --wood: #d9944f;
  --wood-light: #f0b878;
  --wood-dark: #a8662c;
  --accent: #ff6f61;
  --accent-ink: #ffffff;
  --go: #2fc86b;
  --check: #ff6f91;
  --sun: #ffd93b;
  --glow: #ffe45c;
  --bg-top: #fff3c4;
  --bg-bottom: #ffd98a;
  --font-display: "Baloo 2", "Noto Sans HK", "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif;
  --font-body: "Nunito", "Noto Sans HK", ui-rounded, system-ui, -apple-system, sans-serif;
  --font-hk: "Noto Sans HK", "PingFang HK", "Heiti TC", sans-serif;
  color-scheme: light;
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--font-body); overflow: hidden; overscroll-behavior: none;
  background: linear-gradient(to bottom, var(--bg-top) 0 72%, var(--bg-bottom) 72%);
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; padding: 0; }
button:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }
.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 6; pointer-events: none; }
.flyer { position: fixed; z-index: 7; pointer-events: none; }

.app {
  position: relative; z-index: 2; height: 100%; box-sizing: border-box; display: flex; flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(10px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-bottom, 0px));
}
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* start screen */
.start { align-items: center; gap: clamp(12px, 2.4vh, 22px); text-align: center; overflow-y: auto; padding-block: 8px; touch-action: pan-y; }
.start > :first-child { margin-top: auto; }
.start > :last-child { margin-bottom: auto; }
@media (max-height: 700px), (max-width: 600px) { .start { padding-top: 64px; } }
.hero { display: flex; align-items: flex-end; justify-content: center; gap: 1vmin; height: clamp(120px, 24vmin, 200px);; flex-shrink: 0; }  /* never squash the picture when the start screen scrolls */
.hero > * { height: 100%; aspect-ratio: 1; max-width: 100%; }
.start h1 {
  font-family: var(--font-display); font-weight: 800; margin: 0; font-size: clamp(42px, 9vmin, 86px); line-height: .95; text-wrap: balance;
  color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink);
}
.start .sub { margin: -6px 0 0; font-family: var(--font-hk); font-weight: 900; font-size: clamp(20px, 4vmin, 30px); }
.play {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(30px, 6vmin, 48px);
  background: var(--accent); color: var(--accent-ink); padding: .25em 1.6em .2em; border-radius: 999px; border: 4px solid var(--ink);
  box-shadow: 0 7px 0 var(--ink); transition: transform .1s; animation: pn-breathe 2.2s ease-in-out infinite;
}
.play:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--ink); animation: none; }
@keyframes pn-breathe { 50% { transform: scale(1.05); } }
.parent-card {
  background: var(--cream); border: 3px solid var(--ink); border-radius: 24px; padding: 16px 20px;
  width: min(540px, 100%); box-sizing: border-box; display: grid; gap: 12px; text-align: left; box-shadow: 0 6px 0 var(--ink);
}
.parent-card h2 { margin: 0; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); font-weight: 800; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row > span { font-weight: 700; font-size: 16px; }
.seg { display: inline-flex; flex-wrap: wrap; background: color-mix(in srgb, var(--ink) 10%, transparent); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { min-width: 48px; min-height: 40px; padding: 0 14px; border-radius: 999px; font-weight: 800; font-size: 16px; color: var(--ink-soft); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 2px 0 var(--ink); }
.tip { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-soft); max-width: 62ch; }
.tip b { color: var(--ink); }
.back-link {
  position: fixed; z-index: 3; top: max(12px, env(safe-area-inset-top, 0px)); left: max(16px, env(safe-area-inset-left, 0px));
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px 0 12px; border-radius: 999px;
  background: var(--paper); border: 3px solid var(--ink); color: var(--ink); text-decoration: none; font-weight: 800; font-size: 16px; box-shadow: 0 3px 0 var(--ink);
}
.back-link svg { width: 20px; height: 20px; }
.app:has(#gameScreen:not([hidden])) .back-link { display: none; }

/* game frame */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; }
.icon-btn {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none; position: relative;
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); box-sizing: border-box;
}
.icon-btn svg { width: 24px; height: 24px; }
.dots { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); display: block; transition: background .3s, transform .3s; }
.dots i.on { background: var(--sun); transform: scale(1.15); }
.dots i.now { background: var(--accent); }
.prompt {
  margin: 8px auto 0; width: min(720px, 100%); box-sizing: border-box; background: var(--paper); border: 3px solid var(--ink); border-radius: 20px;
  box-shadow: 0 5px 0 var(--ink); padding: 8px 14px 6px; text-align: center; min-height: 56px; display: grid; place-content: center;
}
.prompt .q { font-family: var(--font-display); font-weight: 800; font-size: clamp(22px, 5vmin, 40px); line-height: 1.1; text-wrap: balance; }
.prompt .q small { display: block; font-family: var(--font-hk); font-weight: 700; font-size: .62em; color: var(--ink-soft); margin-top: 2px; }
.prompt .q b { color: var(--accent); }
.prompt .q.pop { animation: pn-qpop .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pn-qpop { from { transform: scale(.85); opacity: .3; } }
.ptip { margin: 4px auto 0; width: min(720px, 100%); font-family: var(--font-hk); font-size: 14px; font-weight: 500; color: var(--ink-soft); text-align: center; min-height: 1.4em; }
.ptip::before { content: "家長："; font-weight: 700; color: var(--ink); }
.stage { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto; gap: 4px; padding-top: 6px; }
.view { min-height: 0; position: relative; container-type: size; display: grid; place-items: center; }

/* the little wooden table */
.table-area { position: relative; padding: 0 2% 14px; }
.tabletop {
  position: relative; margin: 0 auto; width: min(760px, 100%); box-sizing: border-box; min-height: clamp(92px, 16vh, 146px);
  background: linear-gradient(to bottom, var(--wood-light), var(--wood) 70%); border: 4px solid var(--ink); border-radius: 22px;
  box-shadow: 0 10px 0 var(--wood-dark), 0 10px 0 4px var(--ink);
  display: flex; align-items: flex-end; justify-content: space-evenly; gap: 4px; padding: 6px 8px 12px; flex-wrap: wrap;
}
.tabletop::before { content: ""; position: absolute; left: 6%; right: 6%; top: 16%; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .35); }
.titem { position: relative; width: clamp(64px, 19vw, 120px); max-height: 16vh; aspect-ratio: 1; display: grid; place-items: end center; animation: pn-pop-in .45s cubic-bezier(.3, 1.6, .5, 1) backwards; }
.tabletop[data-n="2"] .titem { width: clamp(96px, 30vw, 156px); max-height: 19vh; }
.titem:nth-child(2) { animation-delay: .06s; } .titem:nth-child(3) { animation-delay: .12s; } .titem:nth-child(4) { animation-delay: .18s; } .titem:nth-child(5) { animation-delay: .24s; } .titem:nth-child(6) { animation-delay: .3s; }
@keyframes pn-pop-in { from { transform: scale(0) translateY(30%); } }
.titem > svg { width: 86%; height: 86%; display: block; overflow: visible; }
.titem .lbl { position: absolute; left: 50%; bottom: -4px; transform: translate(-50%, 50%); font-family: var(--font-display); font-weight: 800; font-size: 15px; background: #fff; border: 2.5px solid var(--ink); border-radius: 999px; padding: 0 .55em; white-space: nowrap; }
.titem .lbl small { font-family: var(--font-hk); }
.titem.sel { transform: translateY(-14%) scale(1.1); filter: drop-shadow(0 0 8px var(--glow)); transition: transform .2s; }
.check-row { display: grid; place-items: center; min-height: 62px; }
.check-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 54px; padding: 0 22px; border-radius: 999px; border: 3.5px solid var(--ink);
  background: var(--check); color: #fff; font-family: var(--font-hk); font-weight: 900; font-size: 20px; box-shadow: 0 5px 0 var(--ink);
  animation: pn-pop-in .4s cubic-bezier(.3, 1.6, .5, 1);
}
.check-btn svg { width: 26px; height: 26px; }
.check-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.again, .big-btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 64px; padding: 0 30px; border-radius: 999px; border: 4px solid var(--ink);
  font-family: var(--font-display); font-weight: 800; font-size: 30px; background: var(--go); color: #fff; box-shadow: 0 6px 0 var(--ink);
  animation: pn-pop-in .5s cubic-bezier(.3, 1.6, .5, 1) backwards; align-self: center;
}
.again:active, .big-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }

/* feedback motions */
.glow { animation: pn-glow 1.1s ease-in-out infinite; }
@keyframes pn-glow { 0%, 100% { filter: drop-shadow(0 0 0 rgba(255, 228, 92, 0)); transform: scale(1); } 50% { filter: drop-shadow(0 0 10px var(--glow)) drop-shadow(0 0 4px #fff); transform: scale(1.08); } }
.shake { animation: pn-shake .5s ease-in-out; }
@keyframes pn-shake { 20% { transform: rotate(-8deg); } 40% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 80% { transform: rotate(3deg); } }
.bounce { animation: pn-bounce .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pn-bounce { 30% { transform: translateY(-14%) scale(1.06); } }
.say {
  position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, 0) scale(0); transform-origin: bottom center; z-index: 8;
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); font-family: var(--font-display); font-weight: 800; white-space: nowrap;
  font-size: clamp(18px, 4vmin, 32px); padding: .06em .5em 0; border-radius: 18px; box-shadow: 0 4px 0 var(--ink);
  transition: transform .3s cubic-bezier(.3, 1.6, .5, 1); pointer-events: none;
}
.say small { font-family: var(--font-hk); font-weight: 700; margin-left: .3em; }
.say.show { transform: translate(-50%, 0) scale(1); }

/* the cartoon animals shared with Who's Hungry? */
.ani { width: 100%; height: 100%; overflow: visible; display: block; --fur: #ccc; --muz: #fff; --inner: #ffb3c7; --ear: #a86b3c; --mane: #5b3418; }
.ani-bear { --fur: #b8743c; --muz: #f3d6ad; --inner: #f3d6ad; }
.ani-cat { --fur: #ffa94d; --muz: #fff4e3; --inner: #ffb3c7; }
.ani-dog { --fur: #f5e6cc; --muz: #ffffff; --ear: #a86b3c; }
.ani-horse { --fur: #c8844f; --muz: #efc39c; --mane: #5b3418; }
.ani-duck { --fur: #ffd23f; --muz: #fff3b0; }
.ani-monkey { --fur: #8d5a3b; --muz: #f6d2a6; --inner: #f6d2a6; }
.ani-panda { --fur: #ffffff; --muz: #ffffff; --inner: #ff9fbc; }
.a-fur { fill: var(--fur); stroke: var(--ink); stroke-width: 3.5; stroke-linejoin: round; }
.a-dark { fill: #2f2b3e; stroke: var(--ink); stroke-width: 3.5; stroke-linejoin: round; }
.a-belly { fill: var(--muz); }
.a-inner { fill: var(--inner); }
.a-muz { fill: var(--muz); stroke: var(--ink); stroke-width: 3; }
.a-nose { fill: var(--ink); }
.a-nose.pink { fill: #ff7aa2; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.a-nostril { fill: var(--ink); }
.a-ear2 { fill: var(--ear); stroke: var(--ink); stroke-width: 3.5; }
.a-spot { fill: var(--ear); opacity: .45; }
.a-mane { fill: var(--mane); stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
.a-stripe { fill: none; stroke: #d9772a; stroke-width: 3.5; stroke-linecap: round; }
.a-whisk { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; opacity: .7; }
.a-tuft { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.a-tail-o { fill: none; stroke: var(--ink); stroke-width: 11; stroke-linecap: round; }
.a-tail { fill: none; stroke: var(--fur); stroke-width: 6; stroke-linecap: round; }
.bill-top { fill: #ff9a1f; stroke: var(--ink); stroke-width: 3; }
.bill-bot { fill: #ff7300; stroke: var(--ink); stroke-width: 3; transform-box: fill-box; transition: transform .15s; }
.a-white { fill: #fff; stroke: var(--ink); stroke-width: 2.5; }
.a-pupil { fill: var(--ink); }
.a-glint { fill: #fff; }
.a-lid { fill: var(--fur); stroke: var(--ink); stroke-width: 2.5; opacity: 0; transform-box: fill-box; transform-origin: 50% 0; }
.a-blush { fill: #ff8fb3; opacity: .7; }
.m-smile, .m-frown, .m-flat { fill: none; stroke: var(--ink); stroke-width: 3.2; stroke-linecap: round; }
.m-open ellipse:first-child { fill: #c2185b; stroke: var(--ink); stroke-width: 2.5; }
.m-open .tongue { fill: #ff8fb3; }
.a-brow { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; opacity: 0; }
.a-brow-x { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; opacity: 0; }
.a-tear { fill: #8fd8ff; stroke: var(--ink); stroke-width: 1.5; opacity: 0; }
.m-frown, .m-open, .m-flat { opacity: 0; }
.sad .m-smile { opacity: 0; } .sad .m-frown, .sad .a-brow { opacity: 1; }
.sad .a-tear { opacity: 1; animation: pn-tear 1.8s ease-in infinite; }
@keyframes pn-tear { 0% { transform: translateY(0); opacity: 1; } 80% { transform: translateY(12px); opacity: 1; } 100% { transform: translateY(14px); opacity: 0; } }
.sad .a-pupil { transform: translateY(1.5px); }
.scared .m-smile { opacity: 0; } .scared .m-open, .scared .a-brow { opacity: 1; }
.scared .a-pupil { transform: scale(.65); transform-box: fill-box; transform-origin: center; }
.scared .ani-body { animation: pn-tremble .12s linear infinite; }
@keyframes pn-tremble { 50% { transform: translateX(1.5px); } }
.talk .m-open { opacity: 1; } .talk .m-smile, .talk .m-frown { opacity: 0; }
.talk .bill-bot, .chew .bill-bot { transform: translateY(5px); }
.chew .m-open { animation: pn-chewO .3s steps(1) infinite; }
.chew .m-smile { animation: pn-chewS .3s steps(1) infinite; }
@keyframes pn-chewO { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes pn-chewS { 0% { opacity: 0; } 50% { opacity: 1; } }
.blink .a-lid { animation: pn-blink .24s ease-in-out; }
@keyframes pn-blink { 0% { opacity: 1; transform: scaleY(.1); } 50% { opacity: 1; transform: scaleY(1); } 100% { opacity: 1; transform: scaleY(.1); } }
.f-o { stroke: var(--ink); stroke-width: 3.5; stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- she counts: number floats up from what she tapped ---------- */
.pn-num {
  position: fixed; z-index: 9; transform: translate(-50%, -50%); pointer-events: none;
  font-family: var(--font-display); font-weight: 800; font-size: 54px; line-height: 1; color: #fff;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink);
  animation: pn-num 1.25s cubic-bezier(.2, 1.4, .4, 1) forwards;
}
@keyframes pn-num { 0% { transform: translate(-50%, -20%) scale(.3); opacity: 0; } 25% { transform: translate(-50%, -70%) scale(1.25); opacity: 1; } 75% { opacity: 1; } 100% { transform: translate(-50%, -150%) scale(1); opacity: 0; } }
.bump { animation: pn-bump .45s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes pn-bump { 40% { transform: scale(1.18) translateY(-8%); } }
