/* Phonics look: a sunny meadow for ages 4–7. Sky, puffy clouds and green hills; soft "jelly" buttons; Pip the guide.
   Fredoka for the UI; Andika (single-story a and g, made for new readers) for every letter and word a child reads.
   Used by /phonics/ and every phonics game. */
:root {
  --sky1: #8fd5ff; --sky2: #e6f7ff; --grass: #7fd160; --grass2: #5cbb44;
  --ink: #24324a; --soft: #5d6b82; --card: #ffffff; --shadow: rgba(36, 50, 74, .18);
  --pink: #ff6b9d; --blue: #3fa9f5; --yellow: #ffc93c; --green: #4cc38a; --purple: #9b7bff;
  --orange: #ff9f43; --red: #ff6b6b; --teal: #2ec4b6;
  --c: var(--blue);        /* this page's accent, set per game */
  --f-ui: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --f-read: "Andika", "Fredoka", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font-family: var(--f-ui); font-weight: 500; font-size: 18px; line-height: 1.35;
  background-color: var(--sky2);
  background-image:
    radial-gradient(ellipse 64px 26px at 12% 15%, #fff 97%, transparent),
    radial-gradient(ellipse 40px 24px at 15.5% 12%, #fff 97%, transparent),
    radial-gradient(ellipse 74px 28px at 86% 24%, #fff 97%, transparent),
    radial-gradient(ellipse 44px 26px at 83% 20.5%, #fff 97%, transparent),
    radial-gradient(ellipse 50px 20px at 55% 7%, rgba(255,255,255,.8) 97%, transparent),
    linear-gradient(180deg, var(--sky1), var(--sky2) 75%);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }

/* rolling hills along the bottom of every page */
.hills { position: fixed; left: 0; right: 0; bottom: 0; height: 120px; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 45% 75% at 18% 100%, var(--grass) 98%, transparent),
    radial-gradient(ellipse 55% 95% at 82% 100%, var(--grass2) 98%, transparent),
    radial-gradient(ellipse 70% 45% at 50% 100%, var(--grass) 98%, transparent); }
.hills::after { content: "🌼        🌷              🌻          🌼"; position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; font-size: 22px; white-space: pre; overflow: hidden; }

/* ---------- jelly buttons and cards ---------- */
.btn {
  --b: var(--c);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 60px; padding: 10px 26px; border: 0; border-radius: 20px;
  background: var(--b); color: var(--ink); font: 600 22px/1.1 var(--f-ui); text-decoration: none;
  box-shadow: 0 6px 0 var(--shadow), inset 0 -4px 0 rgba(0,0,0,.08), inset 0 3px 0 rgba(255,255,255,.45);
  transition: transform .08s, box-shadow .08s; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--shadow), inset 0 -4px 0 rgba(0,0,0,.08), inset 0 3px 0 rgba(255,255,255,.45); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--shadow), inset 0 -4px 0 rgba(0,0,0,.08); }
.btn.white { --b: #fff; }
.btn.big { font-size: 34px; font-weight: 700; min-height: 80px; padding-inline: 44px; border-radius: 26px; }
.card { background: var(--card); border-radius: 28px; box-shadow: 0 8px 0 var(--shadow); padding: 20px; }

/* ---------- game shell ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: rgba(255,255,255,.88); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 3px 0 var(--shadow); }
.top .back, .snd { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border: 0; border-radius: 50%; background: #fff; color: var(--ink); text-decoration: none; font-size: 22px; font-weight: 700; box-shadow: 0 4px 0 var(--shadow); }
.top .ttl { font-weight: 700; font-size: 24px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.top .sp { flex: 1; }
.dots { position: relative; z-index: 1; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; padding: 12px 16px 0; }
.dots i { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 3px rgba(36,50,74,.18), 0 3px 0 var(--shadow); font-style: normal; font-size: 14px; font-weight: 700; color: #fff; transition: transform .2s; }
.dots.many { gap: 6px; } .dots.many i { width: 19px; height: 19px; font-size: 11px; }
.dots i.now { background: var(--c); transform: scale(1.25); box-shadow: 0 0 0 4px #fff; }
.dots i.star { background: var(--yellow); color: var(--ink); }
.dots i.ok { background: var(--green); }

/* Pip and the speech bubble */
.coach { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; max-width: 760px; margin: 12px auto 0; padding: 0 16px; }
.pip-wrap { flex: none; width: 88px; cursor: pointer; animation: idle 3.2s ease-in-out infinite; }
.bubble { position: relative; flex: 1; display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 12px 12px 12px 18px; background: #fff; border-radius: 24px; box-shadow: 0 5px 0 var(--shadow); font-size: clamp(19px, 4.6vw, 23px); font-weight: 600; text-align: left; }
.bubble::before { content: ""; position: absolute; left: -14px; top: 50%; margin-top: -12px; border: 12px solid transparent; border-right: 16px solid #fff; border-left: 0; }
.bubble span { flex: 1; }
.bubble.pop { animation: pop .3s ease-out; }
/* hidden words: the text stays in the page for screen readers, but out of sight */
.bubble .hush-dots, .bubble .show { display: none; }
.bubble.hid #k-say { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.bubble.hid .hush-dots { display: block; color: var(--soft); letter-spacing: .15em; font-size: 26px; }
.bubble.hid .show { display: block; flex: none; padding: 8px 14px; border: 0; border-radius: 999px; background: #eef3f9; font: 600 17px/1 var(--f-ui); color: var(--ink); box-shadow: 0 3px 0 var(--shadow); }
.hear { display: grid; place-items: center; flex: none; width: 56px; height: 56px; border: 0; border-radius: 50%; background: var(--c); font-size: 26px; box-shadow: 0 4px 0 var(--shadow); }
.hear.stop { background: var(--ink); color: #fff; }
.hear:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }

.pip { display: block; width: 100%; height: auto; overflow: visible; }
.pip .eye { transform-box: fill-box; transform-origin: center; animation: blink 4.6s infinite; }
.pip .mouth { transform-box: fill-box; transform-origin: center top; }
.pip.talk .mouth { animation: talk .2s infinite alternate; }
.pip.happy { animation: hop .6s ease; }
.pip.oops { animation: tilt .6s ease; }

#stage { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 20px 16px 150px; display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }

/* start + end screens */
.hero-emoji { font-size: clamp(96px, 28vw, 150px); line-height: 1; filter: drop-shadow(0 8px 0 var(--shadow)); animation: bob 2.4s ease-in-out infinite; }
.hero-title { font-weight: 700; font-size: clamp(46px, 13vw, 80px); line-height: .95; color: #fff; text-shadow: 0 4px 0 var(--c), 0 9px 0 var(--shadow); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.best { color: var(--soft); font-weight: 600; font-size: 20px; }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.teach { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 640px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px 8px 12px; border: 0; border-radius: 999px; background: #fff; box-shadow: 0 4px 0 var(--shadow); font: 700 26px/1 var(--f-read); }
.chip span { font-size: 28px; }
.chip:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }
.stars { display: flex; gap: 10px; font-size: clamp(60px, 17vw, 84px); line-height: 1; }
.stars span { opacity: 0; animation: starIn .5s cubic-bezier(.3,1.6,.6,1) forwards; animation-delay: var(--d); }
.stars span.off { filter: grayscale(1); }
@keyframes starIn { from { opacity: 0; transform: scale(.2) rotate(-40deg); } to { opacity: 1; transform: none; } }
.stars span.off { animation-name: starOff; }
@keyframes starOff { to { opacity: .22; } }
.sticker-get { display: flex; align-items: center; gap: 14px; padding: 12px 22px 12px 14px; background: #fff; border-radius: 999px; box-shadow: 0 6px 0 var(--shadow); font-weight: 700; font-size: 22px; animation: pop .5s 1.2s both; }
.sticker { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; background: #fff7d6; border: 4px dashed var(--yellow); font-size: 50px; animation: peel 1s 1.3s both; }
@keyframes peel { 0% { transform: scale(0) rotate(-120deg); } 70% { transform: scale(1.15) rotate(10deg); } 100% { transform: scale(1) rotate(-6deg); } }

/* ---------- pieces the games share ---------- */
.pic { display: grid; place-items: center; width: clamp(150px, 42vw, 200px); aspect-ratio: 1; padding: 0; border: 0; border-radius: 40px; background: #fff; box-shadow: 0 8px 0 var(--shadow); font-size: clamp(88px, 25vw, 124px); line-height: 1; }
.pic:active { transform: translateY(4px); box-shadow: 0 4px 0 var(--shadow); }
.read { font: 700 clamp(56px, 16vw, 96px)/1.1 var(--f-read); letter-spacing: .03em; color: var(--ink); }
.slot { display: inline-block; min-width: .7em; height: 1em; margin: 0 .05em; vertical-align: -.1em; border-bottom: 7px dashed var(--c); color: var(--c); line-height: .95; }
.slot.wide { min-width: 1.3em; } .slot.wider { min-width: 1.8em; }
.slot.full { border-bottom-style: solid; min-width: 0; animation: pop .35s ease-out; }
.opts { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; width: 100%; }
.opt {
  display: grid; place-items: center; min-width: 108px; min-height: 108px; padding: 10px 20px;
  border: 5px solid transparent; border-radius: 28px; background: #fff; box-shadow: 0 7px 0 var(--shadow);
  font: 700 clamp(46px, 12vw, 62px)/1 var(--f-read); color: var(--ink); transition: transform .12s, opacity .2s, border-color .2s;
  touch-action: manipulation;
}
.opt:hover { transform: translateY(-3px); }
.opt:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--shadow); }
.opt.emo { font-size: clamp(60px, 17vw, 84px); min-width: clamp(110px, 28vw, 150px); min-height: clamp(110px, 28vw, 150px); }
.opt.lit, .lit { border-color: var(--c); transform: translateY(-6px) scale(1.04); }
.opt.yes { background: #e3f9ec; border-color: var(--green); }
.opt.no { opacity: .3; transform: scale(.9); filter: grayscale(.7); pointer-events: none; }

/* video pop-up */
.watch { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(36,50,74,.82); }
.watch-box { display: flex; flex-direction: column; gap: 16px; width: min(100%, 900px); }
.watch-frame { position: relative; aspect-ratio: 16 / 9; border-radius: 22px; overflow: hidden; background: #000; box-shadow: 0 8px 0 rgba(0,0,0,.3); }
.watch-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.btn.vid { min-height: 52px; font-size: 19px; padding-inline: 18px; }

/* feedback */
.spark { position: fixed; z-index: 30; pointer-events: none; font-size: 28px; animation: spark .8s ease-out forwards; }
@keyframes spark { from { transform: translate(-50%, -50%) scale(.3); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1) rotate(90deg); opacity: 0; } }
.confetti { position: fixed; top: -20px; z-index: 30; width: 12px; height: 16px; pointer-events: none; animation: fall linear forwards; }
.shake { animation: shake .45s; }
.pop { animation: pop .35s ease-out; }

@keyframes idle { 50% { transform: translateY(-5px); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes talk { from { transform: scaleY(.45); } to { transform: scaleY(1.5); } }
@keyframes hop { 30% { transform: translateY(-20px) rotate(-8deg); } 60% { transform: translateY(0) scale(1.08, .9); } }
@keyframes tilt { 25%, 65% { transform: rotate(12deg); } 45% { transform: rotate(-6deg); } }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-3deg); } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px) rotate(-2deg); } 40%, 80% { transform: translateX(8px) rotate(2deg); } }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes float { 50% { transform: translateY(-12px); } }

/* ---------- /phonics/ hub ---------- */
.hub { position: relative; z-index: 1; max-width: 1000px; margin: 0 auto; padding: 24px 16px 170px; }
.hub .crumb { display: inline-block; margin-bottom: 18px; color: var(--ink); font-weight: 600; text-decoration: none; background: rgba(255,255,255,.7); padding: 6px 14px; border-radius: 999px; }
.hub-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.hub-head .pip-wrap { width: clamp(100px, 24vw, 140px); }
.hub-head > div:not(.pip-wrap) { flex: 1; min-width: 240px; }
.logo { display: flex; flex-wrap: wrap; gap: 2px; font: 700 clamp(56px, 14vw, 110px)/1 var(--f-ui); }
.logo span { display: inline-block; color: var(--l); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--shadow); animation: bob 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * -.3s); }
.hi { position: relative; display: inline-flex; align-items: center; gap: 12px; margin-top: 12px; padding: 10px 10px 10px 18px; background: #fff; border-radius: 22px; box-shadow: 0 5px 0 var(--shadow); font-size: 20px; font-weight: 600; }
.book { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 28px; padding: 14px 20px; }
.book h2 { font-size: 22px; font-weight: 700; }
.book .got-stickers { display: flex; flex-wrap: wrap; gap: 4px; font-size: 32px; line-height: 1; }
.book .none { color: var(--soft); font-size: 17px; }
.stage { position: relative; margin-top: 40px; }
.stage::before { content: ""; position: absolute; left: 25px; top: 64px; bottom: -40px; border-left: 7px dotted rgba(255,255,255,.95); }
.stage:last-of-type::before { display: none; }
.stage-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.stage-num { display: grid; place-items: center; flex: none; width: 58px; height: 58px; border-radius: 50%; background: var(--s); border: 5px solid #fff; color: #fff; font-size: 28px; font-weight: 700; box-shadow: 0 5px 0 var(--shadow); text-shadow: 0 2px 0 rgba(0,0,0,.15); }
.stage h2 { font-size: clamp(26px, 6vw, 34px); font-weight: 700; line-height: 1.05; }
.stage .what { color: var(--soft); font-weight: 500; font-size: 17px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; margin-left: 72px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 16px 16px 14px; background: #fff; border-radius: 26px; box-shadow: 0 7px 0 var(--shadow); color: var(--ink); text-decoration: none; transition: transform .14s; }
.tile:hover, .tile:focus-visible { transform: translateY(-5px) rotate(-1deg); outline: none; box-shadow: 0 7px 0 var(--shadow), 0 0 0 5px var(--c); }
.tile .em { display: grid; place-items: center; width: 74px; height: 74px; margin-bottom: 6px; border-radius: 24px; background: var(--c); font-size: 46px; box-shadow: inset 0 -5px 0 rgba(0,0,0,.08); }
.tile h3 { font-size: 24px; font-weight: 700; line-height: 1.05; }
.tile p { color: var(--soft); font: 700 17px/1.2 var(--f-read); }
.tile .got { position: absolute; top: 14px; right: 14px; font-size: 17px; letter-spacing: 1px; }
.tile .got .off { filter: grayscale(1); opacity: .25; }
.tile .step { position: absolute; top: -12px; left: -10px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: #fff; border: 3px solid #fff; font-size: 17px; font-weight: 700; }
.tile.done .step { background: var(--green); }
.tile.next { box-shadow: 0 7px 0 var(--shadow), 0 0 0 5px var(--yellow); animation: bob 2s ease-in-out infinite; }
.tile.next::after { content: "▶ Play next"; position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); padding: 3px 12px; border-radius: 999px; background: var(--yellow); font-size: 14px; font-weight: 700; white-space: nowrap; }
.go-next { margin-top: 24px; max-width: 100%; font-size: clamp(22px, 5.5vw, 32px); }
.grown { margin-top: 48px; }
.grown summary { cursor: pointer; font-weight: 700; font-size: 20px; }
.grown p { color: var(--soft); margin-top: 12px; }
.grown ol { margin: 12px 0 0; padding-left: 22px; color: var(--soft); }
.grown li { margin: 6px 0; } .grown li b { color: var(--ink); }

@media (max-width: 560px) {
  .tiles { margin-left: 0; grid-template-columns: 1fr 1fr; gap: 14px; }
  .stage::before { display: none; }
  .tile .em { width: 60px; height: 60px; font-size: 38px; }
  .tile h3 { font-size: 20px; }
  .tile p { font-size: 15px; }
  .top .ttl { font-size: 20px; }
  .pip-wrap { width: 70px; }
  .opt { min-width: 92px; min-height: 92px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition: none !important; } }
