:root {
  --ink: #1F2A44;
  --ink-soft: #3B4766;
  --sky: #8ED1F0;
  --sky-light: #DDF2FB;
  --cream: #FFF8EC;
  --pink: #F9B4C4;
  --pink-dark: #F28BA5;
  --gold: #F6C445;
  --gold-light: #FFF3C4;
  --grass: #9BD77A;
  --red: #E04F3F;
  --green-ok: #2E8B4E;
  --card: #FFFFFF;
  --radius: 24px;
  --shadow: 0 6px 0 var(--ink);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 600;
  line-height: 1.45;
}
button { font: inherit; color: inherit; }
a { color: var(--ink); }
a:hover { color: #000; }
svg { display: block; width: 100%; height: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 4px solid var(--ink); outline-offset: 3px; border-radius: 12px; }

/* ---------- header ---------- */
.top {
  background: var(--sky);
  border-bottom: 4px solid var(--ink);
}
.top-inner {
  max-width: 760px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-pig { width: 52px; height: 44px; flex: none; }
.brand-name { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 22px; line-height: 1; }
.brand-name small { display: block; font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 12px; opacity: .85; margin-top: 3px; }
.top-spacer { flex: 1; }
.icon-btn {
  min-width: 48px; height: 48px; padding: 0 12px; border-radius: 16px;
  background: #fff; border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none; font-weight: 800; font-size: 15px;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

main { max-width: 760px; margin: 0 auto; padding: 18px 16px 48px; }

/* ---------- age tabs ---------- */
.ages {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  background: #fff; border: 3px solid var(--ink); border-radius: 22px; padding: 6px; margin: 4px 0 18px;
}
.age {
  border: 0; background: transparent; border-radius: 16px; padding: 10px 6px; cursor: pointer;
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 17px; line-height: 1.1;
}
.age span { display: block; font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 700; opacity: .8; }
.age[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.page-coin {
  width: 64px; height: 64px; flex: none; border-radius: 50%; background: var(--gold);
  border: 4px solid var(--ink); box-shadow: inset 0 0 0 5px var(--gold-light);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 24px; line-height: 1;
}
.page-coin span { font-size: 10px; font-family: 'Nunito', sans-serif; font-weight: 800; letter-spacing: .5px; }
.page-head h1 { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 28px; line-height: 1.1; margin: 0; }
.part-name { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 4px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 22px;
}
.card h2 { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 21px; margin: 0 0 8px; line-height: 1.2; }
.card-label {
  display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  background: var(--gold-light); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; margin-bottom: 10px;
}
.explain { font-size: 19px; font-weight: 700; margin: 0 0 12px; }
.tip { background: var(--sky-light); border-radius: 16px; padding: 12px 14px; font-size: 15px; margin: 12px 0 0; }
.tip b { font-weight: 800; }
.listen {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--pink); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink);
  padding: 8px 16px 8px 12px; font-weight: 800; font-size: 15px; min-height: 44px;
}
.listen svg { width: 22px; height: 22px; }
.listen:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- activity shared ---------- */
.act-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.act-q { font-size: 20px; font-weight: 800; margin: 0; }
.act-q.kid { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 24px; }
.say-btn {
  flex: none; width: 52px; height: 52px; border-radius: 50%; cursor: pointer;
  background: var(--pink); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  display: flex; align-items: center; justify-content: center;
}
.say-btn svg { width: 26px; height: 26px; }
.say-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.big-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.choice {
  background: #fff; border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 5px 0 var(--ink);
  padding: 12px; cursor: pointer; min-height: 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  transition: transform .12s, background .2s;
}
.choice:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.choice .pic { width: 100%; max-width: 110px; aspect-ratio: 1; }
.choice.num { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 52px; line-height: 1; min-height: 110px; }
.choice.right { background: #DDF5D0; }
.choice.wrong { animation: shake .45s; background: #FDE1DC; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }

/* objects to count */
.objs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 4px 0 18px; }
.obj {
  width: 74px; height: 74px; padding: 4px; border-radius: 20px; border: 3px dashed transparent;
  background: transparent; cursor: pointer; position: relative;
}
.obj.on { border-color: var(--ink); background: var(--gold-light); }
.obj .tag {
  position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); color: #fff; font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}

/* feed piggy */
.feed { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; justify-items: center; }
.feed-pig { width: 220px; height: 186px; position: relative; }
.feed-count {
  font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 40px; line-height: 1;
  background: var(--gold-light); border: 3px solid var(--ink); border-radius: 999px; padding: 6px 22px;
}
.tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tray-coin { width: 70px; height: 70px; border: 0; background: transparent; padding: 0; cursor: pointer; transition: transform .45s ease-in, opacity .45s; }
.tray-coin.gone { opacity: 0; pointer-events: none; }

/* more / match panels */
.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.panel {
  background: #fff; border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 5px 0 var(--ink);
  padding: 14px 8px; min-height: 150px; cursor: pointer;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 6px;
}
.panel .mini { width: 46px; height: 46px; }
.panel:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.panel.right { background: #DDF5D0; }
.panel.wrong { animation: shake .45s; background: #FDE1DC; }
.match-item { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 14px; }
.match-item .pic { width: 120px; height: 120px; }
.price-tag {
  display: flex; flex-wrap: wrap; gap: 4px; max-width: 150px; justify-content: center;
  background: var(--gold-light); border: 3px solid var(--ink); border-radius: 16px; padding: 8px;
}
.price-tag .mini { width: 34px; height: 34px; }
.groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.groups .panel { min-height: 120px; padding: 10px 6px; }
.groups .panel .mini { width: 34px; height: 34px; }

.die-wrap { width: 150px; height: 150px; margin: 0 auto 16px; }

/* tap to find */
.field {
  position: relative; height: 260px; border: 4px solid var(--ink); border-radius: 22px; overflow: hidden;
  background: var(--sky-light); margin-bottom: 8px;
}
.field::after { content: ''; position: absolute; left: -10%; right: -10%; bottom: -60px; height: 120px; border-radius: 50%; background: var(--grass); border-top: 4px solid var(--ink); }
.find { position: absolute; width: 64px; height: 64px; border: 0; padding: 0; background: transparent; cursor: pointer; z-index: 1; }
.find.on { animation: pop .4s; }
.find.on::before { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 4px solid var(--green-ok); }
@keyframes pop { 50% { transform: scale(1.3); } }

/* older kids */
.opts { display: grid; gap: 10px; }
.opt {
  text-align: left; background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink);
  padding: 12px 16px; cursor: pointer; font-weight: 800; font-size: 17px; min-height: 52px;
}
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.opt.right { background: #DDF5D0; }
.opt.wrong { background: #FDE1DC; animation: shake .45s; }
.num-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.num-in {
  flex: 1 1 160px; min-width: 0; font: inherit; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 26px;
  border: 3px solid var(--ink); border-radius: 16px; padding: 8px 14px; background: #fff; color: var(--ink);
}
.check {
  background: var(--gold); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink);
  padding: 10px 22px; cursor: pointer; font-weight: 800; font-size: 18px; min-height: 52px;
}
.check:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.ex-num { font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px; }
.hint-money { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

/* feedback */
.feedback { margin-top: 14px; border-radius: 16px; padding: 12px 14px; font-weight: 700; display: none; }
.feedback.show { display: block; }
.feedback.ok { background: #DDF5D0; }
.feedback.no { background: #FFF0D9; }
.feedback b { font-weight: 800; }
.again {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 6px 14px; font-weight: 800; min-height: 44px;
}
.again svg { width: 18px; height: 18px; }

.stars { display: flex; gap: 4px; color: var(--gold); }
.stars svg { width: 26px; height: 26px; stroke: var(--ink); stroke-width: 1.2; }
.stars .off { color: #E8E3D6; }

/* celebration */
.party { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.party .bit { position: absolute; top: -60px; width: 44px; height: 44px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(115vh) rotate(540deg); } }
.party-pig {
  position: fixed; left: 50%; bottom: 18px; width: 170px; height: 144px; transform: translateX(-50%) scale(.2);
  animation: hooray 1.7s ease-out forwards; z-index: 51; pointer-events: none;
}
@keyframes hooray { 20% { transform: translateX(-50%) scale(1.05); } 30%, 80% { transform: translateX(-50%) scale(1); } 100% { transform: translateX(-50%) scale(1) translateY(220px); } }
@media (prefers-reduced-motion: reduce) {
  .party .bit, .party-pig, .choice.wrong, .panel.wrong, .opt.wrong, .find.on { animation: none !important; }
}

/* ---------- pager ---------- */
.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 8px; }
.pager .icon-btn { width: 100%; }
.pager .mid { width: auto; }

/* ---------- home ---------- */
.hero {
  background: var(--sky); border: 4px solid var(--ink); border-radius: 28px; box-shadow: var(--shadow);
  padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 12px; align-items: center; margin-bottom: 24px;
}
.hero h1 { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 32px; line-height: 1.05; margin: 0 0 8px; }
.hero p { margin: 0; font-size: 16px; }
.hero-pig { width: 150px; height: 127px; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 26px; }
.step { background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 12px; font-size: 14px; }
.step b { display: block; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 18px; }
.book-title { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 26px; margin: 30px 0 4px; padding-top: 14px; border-top: 3px dashed var(--ink); }
.part-title { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 20px; margin: 16px 0 10px; }
.seq { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 0 0 16px; padding: 10px; background: var(--sky-light); border-radius: 18px; }
.seq-item { width: 52px; height: 52px; }
.seq-q { width: 52px; height: 52px; border: 3px dashed var(--ink); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 30px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  display: flex; align-items: center; gap: 10px; text-decoration: none; background: #fff;
  border: 3px solid var(--ink); border-radius: 16px; padding: 10px; min-height: 64px; box-shadow: 0 4px 0 var(--ink);
}
.tile:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tile .n {
  width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--gold); border: 3px solid var(--ink);
  display: flex; align-items: center; justify-content: center; font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 16px;
}
.tile.done .n { background: var(--grass); }
.tile .t { font-size: 13px; font-weight: 800; line-height: 1.2; }

.foot { margin-top: 30px; font-size: 13px; color: var(--ink-soft); text-align: center; }
.foot p { margin: 4px 0; }

@media (max-width: 520px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-pig { width: 120px; height: 102px; justify-self: center; grid-row: 1; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .brand-name small { display: none; }
  .page-head h1 { font-size: 23px; }
  .big-choices { gap: 8px; }
  .choice { padding: 8px; min-height: 84px; }
  .choice.num { font-size: 42px; min-height: 92px; }
  .groups .panel .mini { width: 26px; height: 26px; }
  .obj { width: 62px; height: 62px; }
  .pager .label { display: none; }
}
