/* Akshar — big, round and bright, for small hands. */
:root {
  --ink: #1d2b4f; --soft: #5b6b8f; --sky: #eaf5ff; --paper: #ffffff; --line: #d9e6f5;
  --c: #3d5af1; /* the colour of whatever is on screen: a language, a letter */
  --lf: "Baloo 2"; /* the font of the language being learnt */
  --ui: "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font-family: var(--ui); color: var(--ink); background: var(--sky) linear-gradient(#eaf5ff, #f7fbff 60%, #fff8ec) fixed; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
.script { font-family: var(--lf), "Baloo 2", system-ui, sans-serif; }

/* top bar */
.bar { display: flex; align-items: center; gap: 10px; padding: 10px max(16px, env(safe-area-inset-left)) 6px; max-width: 1100px; width: 100%; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo { width: 44px; height: 44px; border-radius: 13px; background: #ff9f1c; color: #fff; font-weight: 800; font-size: 27px; display: grid; place-items: center; box-shadow: 0 4px 0 #d97f00; line-height: 1; padding-top: 3px; }
.name { font-weight: 800; font-size: 26px; letter-spacing: -.01em; }
.grow { flex: 1; }
.chip { text-decoration: none; font-weight: 700; font-size: 18px; padding: 5px 14px 3px; border-radius: 999px; background: #fff; border: 2px solid var(--line); font-family: var(--lf), "Baloo 2", sans-serif; line-height: 1.35; }
.stars { font-weight: 800; font-size: 20px; background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 4px 14px 2px; white-space: nowrap; }

.view { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 6px 16px 28px; }

/* a chunky button that looks pressable */
.push { background: var(--c); color: #fff; border-radius: 22px; box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 72%, #000); transition: transform .08s, box-shadow .08s; text-decoration: none; display: grid; place-items: center; user-select: none; -webkit-user-select: none; }
.push:active { transform: translateY(5px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c) 72%, #000); }
@media (hover: hover) { .push:hover { filter: brightness(1.06); } }
.push:focus-visible, .round:focus-visible, .nav:focus-visible, .hear:focus-visible { outline: 4px solid #1d2b4f; outline-offset: 3px; }

/* home */
.hero { position: relative; border-radius: 28px; background: linear-gradient(160deg, #cfe9ff, #e3f3ff 55%, #fff2d6); overflow: hidden; }
.hero canvas { display: block; width: 100%; height: clamp(230px, 36vh, 340px); touch-action: pan-y; cursor: pointer; }
.hero-text { text-align: center; padding: 0 16px 18px; }
.hero h1 { margin: 0; font-size: clamp(30px, 6vw, 48px); font-weight: 800; line-height: 1.1; letter-spacing: -.015em; }
.hero p { margin: 4px 0 0; font-size: clamp(16px, 2.4vw, 20px); color: var(--soft); font-weight: 500; }
.langs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 14px; margin-top: 20px; }
.lang { padding: 14px 8px 10px; gap: 0; text-align: center; }
.lang .g { font-size: 58px; font-weight: 700; line-height: 1.15; height: 70px; display: grid; place-items: center; }
.lang .n { font-size: 22px; font-weight: 700; line-height: 1.3; }
.lang .e { font-size: 14px; font-weight: 500; opacity: .9; letter-spacing: .02em; }
.foot { margin-top: 34px; color: var(--soft); font-size: 14.5px; line-height: 1.5; max-width: 760px; }
.foot b { color: var(--ink); }
.foot .fine { font-size: 13px; }
.ad { display: none; margin: 16px 0; }
.ad:has([data-yld]:not(:empty)) { display: block; }
.ad small { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .7; margin-bottom: 4px; }
.ad [data-yld] { max-width: 100%; overflow: hidden; }

/* the letters of a language */
.head { display: flex; align-items: center; gap: 14px; margin: 4px 0 4px; }
.head h2 { margin: 0; font-size: clamp(28px, 5vw, 40px); font-weight: 800; flex: 1; line-height: 1.3; font-family: var(--lf), "Baloo 2", sans-serif; }
.head h2 small { font-family: var(--ui); font-size: .5em; font-weight: 500; color: var(--soft); margin-left: 8px; }
.play-btn { --c: #2bb673; font-size: 22px; font-weight: 800; padding: 10px 22px 7px; display: flex; gap: 8px; align-items: center; }
.play-btn span { font-size: 26px; line-height: 1; }
.group-title { margin: 20px 0 10px; font-size: 20px; font-weight: 700; color: var(--soft); font-family: var(--lf), "Baloo 2", sans-serif; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 16px 12px; }
.tile { position: relative; aspect-ratio: 1 / 1.05; padding: 4px 2px 0; }
.tile .g { font-size: 46px; font-weight: 700; line-height: 1.2; font-family: var(--lf), "Baloo 2", sans-serif; }
.tile .l { font-size: 13px; font-weight: 500; opacity: .92; line-height: 1; margin-top: -2px; font-family: var(--ui); }
.tile.seen::after { content: "✓"; position: absolute; top: -7px; right: -5px; width: 24px; height: 24px; border-radius: 50%; background: #fff; color: #2bb673; font: 800 15px/24px var(--ui); box-shadow: 0 2px 5px rgba(29, 43, 79, .25); }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 18px 14px; } .tile .g { font-size: 58px; } .tile .l { font-size: 14px; } }

/* one letter */
#v-letter { display: flex; flex-direction: column; gap: 14px; padding-bottom: 18px; }
.stage-wrap { position: relative; flex: 1; min-height: 300px; border-radius: 28px; overflow: hidden; background: radial-gradient(120% 95% at 50% 0%, color-mix(in srgb, var(--c) 20%, #fff), #f2f9ff 70%); }
.stage-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.stage-wrap canvas:active { cursor: grabbing; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); width: 60px; height: 60px; border-radius: 50%; background: #fff; color: var(--ink); font-size: 40px; font-weight: 800; line-height: 1; padding-bottom: 6px; box-shadow: 0 4px 0 var(--line), 0 6px 18px rgba(29, 43, 79, .14); }
.nav:active { transform: translateY(calc(-50% + 3px)); box-shadow: 0 1px 0 var(--line); }
.nav.prev { left: 10px; } .nav.next { right: 10px; }
.round { width: 50px; height: 50px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 800; text-decoration: none; cursor: pointer; box-shadow: 0 3px 0 var(--line), 0 5px 14px rgba(29, 43, 79, .12); flex: none; }
.round.back { position: absolute; top: 10px; left: 10px; }
.count { position: absolute; top: 16px; right: 16px; font-weight: 700; font-size: 16px; color: var(--soft); background: rgba(255, 255, 255, .8); border-radius: 999px; padding: 4px 12px 2px; }
.card { display: flex; align-items: center; gap: 16px; background: #fff; border-radius: 26px; padding: 12px 16px; box-shadow: 0 4px 0 var(--line); min-height: 104px; }
.hear { flex: none; width: 76px; height: 76px; border-radius: 50%; background: var(--c); display: grid; place-items: center; box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 72%, #000); transition: transform .08s, box-shadow .08s; }
.hear:active { transform: translateY(5px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c) 72%, #000); }
.word { flex: 1; min-width: 0; }
.word-text { font-family: var(--lf), "Baloo 2", sans-serif; font-weight: 700; font-size: clamp(38px, 8.5vw, 68px); line-height: 1.25; overflow-wrap: anywhere; }
.word-text b, .word-sub b, .q-answer b { color: var(--c); font-weight: inherit; }
.word-text.only { color: var(--soft); font-size: clamp(22px, 4vw, 30px); font-family: var(--ui); font-weight: 500; }
.word-sub { font-size: clamp(16px, 2.6vw, 21px); font-weight: 500; color: var(--soft); line-height: 1.3; }
.picks { display: flex; gap: 10px; flex: none; }
.pick { width: 64px; height: 64px; border-radius: 18px; background: #f2f7fd; font-size: 36px; border: 3px solid transparent; display: grid; place-items: center; line-height: 1; }
.pick.on { border-color: var(--c); background: #fff; }
@media (max-width: 560px) {
  .card { flex-wrap: wrap; gap: 10px 14px; padding: 12px; }
  .hear { width: 64px; height: 64px; font-size: 28px; }
  .picks { width: 100%; justify-content: center; }
  .pick { width: 58px; height: 58px; font-size: 32px; }
  .nav { width: 50px; height: 50px; font-size: 34px; }
}
/* the letter page fills the screen so nothing scrolls while a child plays */
body.fill { height: 100vh; height: 100dvh; overflow: hidden; }

/* games */
.quiz { max-width: 720px; margin: 0 auto; text-align: center; }
.q-top { display: flex; align-items: center; gap: 14px; }
.q-dots { flex: 1; display: flex; gap: 6px; justify-content: center; }
.q-dots i { width: 22px; height: 22px; border-radius: 50%; background: #d5e3f3; display: grid; place-items: center; font-style: normal; font-size: 15px; line-height: 1; }
.q-dots i.now { background: #fff; box-shadow: 0 0 0 3px var(--c); }
.q-dots i.won { background: none; } .q-dots i.won::before { content: "⭐"; }
.q-dots i.lost { background: #b9c7dc; }
.q-ask { margin: 16px 0 8px; font-size: clamp(18px, 3.4vw, 24px); font-weight: 700; color: var(--soft); }
.q-show { min-height: 150px; display: grid; place-items: center; }
.q-pic { font-size: clamp(96px, 24vw, 150px); line-height: 1.1; cursor: pointer; filter: drop-shadow(0 8px 0 rgba(29, 43, 79, .1)); animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
.q-letter { --c: #3d5af1; width: 150px; height: 150px; font-size: 92px; font-weight: 700; border-radius: 34px; font-family: var(--lf), "Baloo 2", sans-serif; line-height: 1.2; animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
.q-ear { --c: #f78c1f; width: 140px; height: 140px; border-radius: 50%; animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
.q-answer { min-height: 62px; font-family: var(--lf), "Baloo 2", sans-serif; font-weight: 700; font-size: clamp(30px, 7vw, 46px); line-height: 1.3; display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
.q-answer small { font-family: var(--ui); font-size: .45em; color: var(--soft); font-weight: 500; }
.slot { min-width: 54px; height: 62px; padding: 0 8px; border-radius: 14px; border: 3px dashed #b9c7dc; display: grid; place-items: center; font-size: 34px; line-height: 1.2; }
.slot.full { border: 3px solid var(--c); background: #fff; color: var(--c); animation: pop .25s cubic-bezier(.2, 1.6, .4, 1); }
.q-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 14px; margin: 18px auto 0; max-width: 460px; }
.q-options.pieces { display: flex; flex-wrap: wrap; justify-content: center; max-width: 620px; }
.opt { min-height: 104px; font-size: 62px; font-weight: 700; font-family: var(--lf), "Baloo 2", sans-serif; line-height: 1.25; padding: 4px 6px 0; }
.opt.pic { background: #fff; box-shadow: 0 6px 0 var(--line); font-size: 64px; }
.opt.pic:active { box-shadow: 0 1px 0 var(--line); }
.opt.piece { min-height: 76px; min-width: 76px; font-size: 40px; padding: 2px 14px 0; }
.opt.no { animation: shake .4s; opacity: .35; pointer-events: none; }
.opt.yes { animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); outline: 5px solid #2bb673; outline-offset: 3px; }
.opt.used { visibility: hidden; }
.done { padding: 30px 0; }
.done .big { font-size: clamp(44px, 11vw, 76px); font-weight: 800; line-height: 1.15; }
.done p { font-size: 22px; font-weight: 700; color: var(--soft); margin: 6px 0 26px; }
.done .row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.done .push { font-size: 22px; font-weight: 800; padding: 14px 28px 10px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* pinyin carries tone marks the round fonts do not have */
.pinyin .word-sub, .pinyin .q-answer small, .pinyin .opt.piece, .pinyin .slot { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
