@font-face { font-family: 'Mali'; font-weight: 500; font-display: swap; src: url(../fonts/mali-500-thai.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Mali'; font-weight: 500; font-display: swap; src: url(../fonts/mali-500-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Mali'; font-weight: 700; font-display: swap; src: url(../fonts/mali-700-thai.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Mali'; font-weight: 700; font-display: swap; src: url(../fonts/mali-700-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Andika'; font-weight: 400; font-display: swap; src: url(../fonts/andika-400-latin.woff2) format('woff2'); }
@font-face { font-family: 'Andika'; font-weight: 700; font-display: swap; src: url(../fonts/andika-700-latin.woff2) format('woff2'); }

:root {
  color-scheme: light;
  --bg: #fff6e6; --bg2: #ffeccc; --card: #ffffff; --ink: #3b2a1e; --muted: #8c7461; --line: #f0dcc0;
  --thai: #2fae6e; --math: #ff8a2a; --eng: #3683f5; --iq: #9563ea; --gold: #ffbe2e;
  --ok: #2fbf5b; --bad: #ff5d5d; --c: #ff8a2a;
  --r: 22px; --shadow: 0 6px 0 rgba(59, 42, 30, .12), 0 10px 24px rgba(59, 42, 30, .08);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg) radial-gradient(circle at 20% 0%, #fff 0, transparent 40%) fixed;
  color: var(--ink); font-family: 'Mali', 'Thonburi', system-ui, sans-serif; font-weight: 500;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 4px solid color-mix(in srgb, var(--c) 60%, white); outline-offset: 3px; }
img { -webkit-user-drag: none; }
#app { min-height: 100dvh; }
.screen { min-height: 100dvh; padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 20px) calc(var(--safe-l) + 16px); max-width: 1100px; margin: 0 auto; }
.muted { color: var(--muted); }
.en-letter, .en-word { font-family: 'Andika', 'Mali', sans-serif; font-weight: 700; }
.th-letter { font-family: 'Mali', 'Thonburi', sans-serif; font-weight: 700; line-height: 1.25; }
.num { font-family: 'Andika', 'Mali', sans-serif; font-weight: 700; line-height: 1; }

/* ---------- top bar ---------- */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 6px 0 10px; background: linear-gradient(var(--bg) 70%, transparent); }
.bar-title { flex: 1; min-width: 0; text-align: center; font-weight: 700; font-size: clamp(15px, 4.6vw, 22px); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bar-title .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.mock-sub { font-size: 13px; background: var(--c); color: #fff; border-radius: 99px; padding: 2px 10px; }
.round { width: 52px; height: 52px; flex: none; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 30px; line-height: 1; display: grid; place-items: center; font-weight: 700; }
.round:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(59, 42, 30, .12); }
.round.back { font-size: 40px; padding-bottom: 4px; color: var(--c); }
.round.speak { font-size: 24px; }
.round.ghost { visibility: hidden; }
.dots { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dots i.now { background: var(--c); transform: scale(1.35); }
.dots i.ok { background: var(--ok); } .dots i.late { background: var(--gold); } .dots i.bad { background: var(--bad); }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 8px 0 14px; }
.hero .owl { width: clamp(76px, 20vw, 120px); }
.hero-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.fs-btn { color: var(--ink, #3b2a1e); }
.tip-card { text-align: center; gap: 10px; padding: 22px 20px; max-width: 420px; }
.tip-card > b { font-size: 20px; } .tip-card p { line-height: 1.7; margin: 2px 0 6px; } .tip-card .btn { margin-top: 8px; }
.tip-card .share { display: inline-grid; vertical-align: middle; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--bg2, #ffe7b8); }
.bubble { position: relative; background: var(--card); border-radius: 20px; padding: 12px 16px; font-weight: 700; font-size: clamp(16px, 4.2vw, 22px); box-shadow: var(--shadow); line-height: 1.45; }
.bubble::before { content: ''; position: absolute; left: -10px; top: 50%; translate: 0 -50%; border: 10px solid transparent; border-right-color: var(--card); border-left: 0; }
.starpill { align-self: start; background: var(--card); border-radius: 99px; padding: 8px 14px; font-weight: 700; box-shadow: var(--shadow); white-space: nowrap; }
.subjects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 820px) { .subjects { grid-template-columns: repeat(4, 1fr); } }
.subject-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 10px 14px; border-radius: var(--r); background: var(--card); box-shadow: var(--shadow); border-top: 8px solid var(--c); text-align: center; overflow: hidden; }
.subject-card::after { content: ''; position: absolute; inset: auto -20% -60% -20%; height: 70%; background: color-mix(in srgb, var(--c) 14%, transparent); border-radius: 50%; z-index: 0; }
.subject-card > * { position: relative; z-index: 1; }
.subject-card:active, .game-card:active, .big-act:active, .mock-card:active, .tile:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(59, 42, 30, .12); }
.subject-card .mascot { width: clamp(84px, 26vw, 150px); aspect-ratio: 1; object-fit: contain; }
.sc-title { font-weight: 700; font-size: clamp(18px, 5vw, 24px); color: var(--c); }
.sc-sub { font-size: clamp(13px, 3.6vw, 16px); color: var(--muted); line-height: 1.4; }
.sc-stars { margin-top: 4px; min-height: 26px; }
.new { font-size: 13px; background: var(--c); color: #fff; padding: 2px 10px; border-radius: 99px; }
.stars span { color: #e6d6bd; font-size: 22px; } .stars span.on { color: var(--gold); text-shadow: 0 2px 0 #e09b00; }
.mock-card { margin-top: 16px; width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; padding: 12px 18px; border-radius: var(--r); background: linear-gradient(135deg, #fff3c9, #ffd977); box-shadow: var(--shadow); }
.mock-card .mascot { width: 72px; }
.mock-card b { display: block; font-size: clamp(19px, 5vw, 24px); }
.mock-card small { color: #7a5a1f; font-size: 14px; line-height: 1.4; }
.mock-card .arrow { margin-left: auto; font-size: 40px; color: #c98a00; }
.parent-link { display: block; margin: 18px auto 0; padding: 10px 16px; color: var(--muted); font-size: 15px; text-decoration: underline; text-underline-offset: 4px; }

/* ---------- hub ---------- */
.hub-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 14px; }
.hub-head .mascot { width: clamp(90px, 24vw, 140px); }
.hub-head h1 { margin: 0; font-size: clamp(26px, 7vw, 36px); color: var(--c); }
.hub-head p { margin: 2px 0 0; color: var(--muted); font-size: 17px; }
.hub-actions { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .hub-actions { grid-template-columns: 1fr 1fr; } }
.big-act { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--r); background: var(--card); box-shadow: var(--shadow); text-align: left; min-height: 88px; }
.big-act.learn { background: var(--c); color: #fff; }
.big-act .ico { font-size: 40px; }
.big-act b { display: block; font-size: 22px; }
.big-act small { font-size: 14px; opacity: .85; line-height: 1.4; }
.big-act.quiz .stars span { font-size: 16px; }
.sec { margin: 22px 4px 10px; font-size: 20px; }
.games { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .games { grid-template-columns: repeat(3, 1fr); } }
.game-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); text-align: left; border-left: 6px solid var(--c); min-height: 110px; }
.game-card .ico { font-size: 30px; }
.game-card b { font-size: 17px; line-height: 1.35; }
.game-card small { color: var(--muted); font-size: 13px; line-height: 1.35; }

/* ---------- learn ---------- */
.tabs { display: flex; gap: 8px; background: var(--bg2); border-radius: 99px; padding: 5px; margin: 0 auto 14px; width: fit-content; }
.tabs button { padding: 10px 22px; border-radius: 99px; font-weight: 700; font-size: 17px; color: var(--muted); }
.tabs button.on { background: var(--card); color: var(--c); box-shadow: 0 2px 0 rgba(0, 0, 0, .06); }
.hint { text-align: center; color: var(--muted); margin: 0 0 10px; }
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px; } }
.tile { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: 1; }
.tile .th-letter { font-size: clamp(36px, 10vw, 54px); color: var(--c); }
.tile .en-letter { font-size: clamp(30px, 8.6vw, 44px); color: var(--c); letter-spacing: .02em; }
.tile .num { font-size: clamp(36px, 10vw, 54px); color: var(--c); }
.tile small { font-size: 13px; color: var(--muted); line-height: 1.5; white-space: nowrap; }
.tiles.nums { grid-template-columns: repeat(5, minmax(0, 1fr)); }
/* portrait phones: two columns of wide 1–10 tiles that fill the screen */
@media (max-width: 600px) and (max-aspect-ratio: 23/20) {
  .tiles.nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles.nums .tile { aspect-ratio: auto; flex-direction: row; gap: 12px; height: clamp(72px, calc((100dvh - 170px) / 5 - 10px), 124px); }
  .tiles.nums .tile .num { font-size: clamp(40px, 12vw, 56px); min-width: 1.3em; text-align: center; }
  .tiles.nums .tile small { font-size: clamp(15px, 4.6vw, 20px); }
}
.tiles.shadows .tile img { width: 78%; aspect-ratio: 1; object-fit: contain; transition: filter .35s; }
.tiles.shadows .tile.shown { animation: pop .35s; box-shadow: 0 0 0 4px var(--c), var(--shadow); }
.tiles.shadows .tile.shown small { color: var(--c); font-weight: 700; font-size: 15px; }
.tiles.scenes { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .tiles.scenes { grid-template-columns: repeat(3, 1fr); } }
.scene-tile { aspect-ratio: auto; padding: 10px; gap: 4px; }
.scene-tile b { font-size: 22px; color: var(--c); }
.scene-tile.lit { outline: 5px solid var(--c); }

.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(59, 42, 30, .45); display: grid; place-items: center; padding: calc(var(--safe-t) + 12px) 12px calc(var(--safe-b) + 12px); animation: fade .2s; }
.flash { position: relative; width: min(560px, 100%); max-height: 100%; background: var(--card); border-radius: 28px; padding: 18px 16px 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); display: flex; flex-direction: column; animation: pop .25s; }
.flash .close { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; font-size: 20px; z-index: 2; }
.flash-body { flex: 1; min-height: 0; display: grid; place-items: center; cursor: pointer; }
.fc { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; }
.th-letter.huge { font-size: clamp(110px, min(34vw, 22vh), 200px); color: var(--c); }
.en-letter.huge { font-size: clamp(100px, min(30vw, 22vh), 190px); color: var(--c); display: flex; gap: .25em; align-items: baseline; line-height: 1.1; }
.en-letter .lo { color: color-mix(in srgb, var(--c) 70%, #3b2a1e); }
.num.huge { font-size: clamp(110px, min(32vw, 20vh), 190px); color: var(--c); }
.fc-art .art.big { width: clamp(120px, min(38vw, 24vh), 220px); height: clamp(120px, min(38vw, 24vh), 220px); }
.fc-cap { font-size: clamp(24px, 6.4vw, 34px); font-weight: 700; line-height: 1.5; }
.fc-words { font-size: clamp(22px, 6vw, 30px); font-weight: 700; display: flex; gap: .5em; align-items: baseline; flex-wrap: wrap; justify-content: center; }
.fc-words .thd { color: var(--c); }
.fc-hint { color: var(--muted); font-size: 14px; }
.flash-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.flash-nav .round { font-size: 36px; color: var(--c); }
.flash-nav .round:disabled { opacity: .3; }
.pill { flex: 1; max-width: 260px; height: 52px; border-radius: 99px; background: var(--c); color: #fff; font-weight: 700; font-size: 18px; box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 70%, black); }
.pill.on { background: var(--ink); box-shadow: 0 5px 0 #000; }
.flash-count { text-align: center; color: var(--muted); font-size: 14px; margin-top: 6px; }

/* ---------- art ---------- */
.art { display: inline-block; object-fit: contain; }
img.art { width: 100%; height: 100%; }
.shadow { filter: brightness(0) opacity(.82); }
.flip { transform: scaleX(-1); } .upside { transform: rotate(180deg); } .flip.upside { transform: scaleX(-1) rotate(180deg); }

/* ---------- play ---------- */
.screen.run { display: flex; flex-direction: column; height: 100dvh; min-height: 0; padding-bottom: calc(var(--safe-b) + 12px); position: relative; }
.owl-mini { position: absolute; width: clamp(54px, 13vmin, 92px); left: calc(var(--safe-l) + 8px); top: calc(var(--safe-t) + 74px); z-index: 1; pointer-events: none; transform-origin: 50% 100%; }
body.speaking .owl-mini, body.speaking .talk { animation: talk .45s ease-in-out infinite alternate; }
.play { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 14px; }
.stage { position: relative; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(10px, 2.4vmin, 18px); }
.opts.n2 { grid-template-columns: repeat(2, 1fr); }
.opts.n4 { grid-template-columns: repeat(2, 1fr); }
.opt { position: relative; background: var(--card); border-radius: var(--r); box-shadow: 0 7px 0 color-mix(in srgb, var(--c) 35%, #d9c4a6), 0 12px 24px rgba(59, 42, 30, .08); min-height: clamp(96px, 20vmin, 200px); padding: 8px; display: grid; place-items: center; transition: transform .08s; overflow: hidden; }
/* while the question is being read the answers rest, then wake up together */
.opts.wait .opt, .match.wait .m-item { opacity: .45; filter: saturate(.4); transform: scale(.96); pointer-events: none; }
.opts .opt, .match .m-item { transition: opacity .3s, filter .3s, transform .08s; }
.opt:active { transform: translateY(5px); box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 35%, #d9c4a6); }
.opt .th-letter { font-size: clamp(60px, min(15vw, 13vh), 130px); }
.opt .en-letter { font-size: clamp(56px, min(14vw, 12vh), 120px); line-height: 1.1; }
.opt .num { font-size: clamp(58px, min(15vw, 12vh), 120px); }
.opt .en-word { font-size: clamp(20px, min(6.4vw, 6vh), 52px); }
.opt img.art { width: min(100%, 22vmin); height: min(100%, 22vmin); max-width: 200px; max-height: 200px; }
.opt.ok { background: #e9fbe9; box-shadow: 0 0 0 5px var(--ok), 0 7px 0 #1f9a46; animation: pop .3s; }
.opt.bad { background: #ffecec; box-shadow: 0 0 0 4px var(--bad); opacity: .75; }
.opt.dim { opacity: .45; }
.opt.hint { animation: pulse 1s ease-in-out infinite; box-shadow: 0 0 0 6px var(--gold), 0 7px 0 #e0a100; }
.shake { animation: shake .4s; }
.big-ear { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: clamp(64px, 18vmin, 130px); background: var(--card); border-radius: 50%; width: clamp(150px, 38vmin, 260px); aspect-ratio: 1; justify-content: center; box-shadow: 0 8px 0 color-mix(in srgb, var(--c) 40%, #d9c4a6); }
.big-ear small { font-size: 16px; font-weight: 700; color: var(--c); }
body.speaking .big-ear { animation: pulse .9s ease-in-out infinite; }
.pic-card { background: var(--card); border-radius: 28px; padding: 14px; box-shadow: var(--shadow); display: grid; place-items: center; }
.pic-card .art.big { width: clamp(150px, min(50vw, 32vh), 320px); height: clamp(150px, min(50vw, 32vh), 320px); }
.target { background: var(--card); border-radius: 28px; padding: 6px 28px; box-shadow: var(--shadow); }
.target .th-letter, .target .en-letter, .target .num { font-size: clamp(110px, min(32vw, 26vh), 230px); color: var(--c); display: block; line-height: 1.2; }
.reveal { min-height: 1.6em; font-size: clamp(22px, 6vw, 32px); font-weight: 700; color: var(--c); }
.reveal:empty { display: none; }
.ask { background: var(--card); border-radius: 99px; padding: 8px 20px; font-size: clamp(18px, 5vw, 26px); font-weight: 700; box-shadow: var(--shadow); line-height: 1.5; text-align: center; }
.ask b { color: var(--c); }
.assist { background: #fff3c9; color: #7a5a1f; padding: 10px 18px; border-radius: 99px; font-weight: 700; font-size: 17px; box-shadow: 0 4px 0 #e5c56a; }

/* Mali draws Thai consonants low in its font box: the tails of ฎ ฏ ฐ ญ ฤ reach 0.32em below the
   baseline (past the font descent) and ป ฝ ฟ reach 0.88em above it. A 1.2em line lifted by 0.12em
   holds that whole range, so no tail is ever cut off by a card edge. */
.th-letter { display: inline-block; line-height: 1.2; transform: translateY(-.12em); }

/* counting objects */
.objs { display: grid; gap: 6px; grid-template-columns: repeat(var(--cols, 5), 1fr); width: min(88vw, 560px, 62vh); }
.objs.n1 { --cols: 1; width: min(40vw, 30vh); } .objs.n2 { --cols: 2; width: min(60vw, 40vh); } .objs.n3 { --cols: 3; width: min(80vw, 48vh); }
.objs.n4 { --cols: 2; width: min(56vw, 40vh); } .objs.n5, .objs.n6 { --cols: 3; width: min(80vw, 52vh); } .objs.n7, .objs.n8 { --cols: 4; width: min(88vw, 60vh); }
.objs.n9 { --cols: 3; width: min(78vw, 52vh); } .objs.n10 { --cols: 5; }
.objs .obj { width: 100%; aspect-ratio: 1; object-fit: contain; position: relative; transition: transform .15s; }
.objs .obj.counted { transform: scale(1.12); filter: drop-shadow(0 0 6px var(--gold)); }
.fc .objs.count { width: min(80vw, 420px); }
.fc .objs .obj { cursor: pointer; }
/* a group inside an answer card always shows every item: items are sized from the card
   (container units) for the biggest group on screen (asN), never cropped. --mc x --mr is
   the grid that gives the biggest items for that count in a square card, or in a wide one.
   The % width is the fallback for older browsers. */
.lay-groups .opt, .m-item:has(> .objs) { container-type: size; }
.objs.mini { --mc: 1; --mr: 1; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 2px; width: 100%; height: 100%; }
.objs.mini.as2 { --mc: 2; } .objs.mini.as3, .objs.mini.as4 { --mc: 2; --mr: 2; } .objs.mini.as5, .objs.mini.as6 { --mc: 3; --mr: 2; }
.objs.mini.as7, .objs.mini.as8, .objs.mini.as9 { --mc: 3; --mr: 3; } .objs.mini.as10 { --mc: 4; --mr: 3; }
@container (min-aspect-ratio: 3/2) {
  .objs.mini.as3 { --mc: 3; --mr: 1; } .objs.mini.as7, .objs.mini.as8 { --mc: 4; --mr: 2; } .objs.mini.as9, .objs.mini.as10 { --mc: 5; --mr: 2; }
}
.objs.mini .obj { flex: none; width: calc(100% / var(--mc) - 4px); height: auto; }
.stage { container-type: inline-size; }
@supports (width: 1cqw) {
  .pattern .cell, .play .pattern .cell { width: clamp(30px, calc((100cqw - 36px) / 7), 92px); height: clamp(30px, calc((100cqw - 36px) / 7), 92px); }
  .train .car, .play .train .car { min-width: clamp(40px, calc((100cqw - 40px) / 5), 110px); height: clamp(52px, calc((100cqw - 40px) / 5 * 1.15), 120px); font-size: clamp(28px, calc((100cqw - 40px) / 5 * .66), 76px); }
}
/* browsers without container units (iOS 15): let a group spill rather than hide items */
@supports not (width: 1cqw) { .lay-groups .opt, .m-item { overflow: visible; } }
@supports (width: 1cqw) {
  .objs.mini .obj { width: calc(min(100cqw / var(--mc), 100cqh / var(--mr)) - 4px); }
  /* at most five in a row, like a ten-frame: easier to count */
  .objs.mini { max-width: calc(5 * (min(100cqw / var(--mc), 100cqh / var(--mr)) - 4px) + 11px); }
}
.lay-groups .opt { padding: 10px; }
.lay-groups.lay-two .opts { grid-template-columns: repeat(2, 1fr); }
.lay-groups.lay-two .opt { min-height: clamp(150px, 34vmin, 320px); }
.train { display: flex; gap: clamp(4px, 1.6vw, 8px); justify-content: center; }
.train .car { min-width: clamp(48px, 15vw, 110px); height: clamp(64px, 17vw, 120px); display: grid; place-items: center; background: var(--card); border-radius: 18px 18px 10px 10px; box-shadow: var(--shadow); font: 700 clamp(34px, 11vw, 76px)/1 'Andika', sans-serif; color: var(--c); border-bottom: 10px solid var(--c); }
.train .car.hole { background: repeating-linear-gradient(45deg, #fff, #fff 10px, var(--bg2) 10px, var(--bg2) 20px); color: var(--muted); }

/* patterns */
/* up to 7 cells, always one line so it reads as a sequence */
.pattern { display: flex; justify-content: center; gap: 6px; max-width: 94vw; }
.pattern .cell { width: clamp(36px, min(12vw, (100vw - 80px) / 7), 92px); height: clamp(36px, min(12vw, (100vw - 80px) / 7), 92px); display: grid; place-items: center; background: var(--card); border-radius: 14px; box-shadow: 0 3px 0 rgba(59, 42, 30, .1); padding: 6px; }
.pattern .cell.hole { border: 3px dashed var(--c); background: #fff8; font-size: 34px; font-weight: 700; color: var(--c); }
.pattern .cell img, .pattern .cell svg { width: 100%; height: 100%; }
.opt .cell { width: 72%; height: 72%; display: grid; place-items: center; }
.opt .cell img, .opt .cell svg { width: 100%; height: 100%; }
.shape { width: 100%; height: 100%; }

/* scenes */
.scene { position: relative; width: 100%; aspect-ratio: 1; background: linear-gradient(#f3fbff 72%, #e6f3d8 72%); border-radius: 16px; overflow: hidden; }
.scene .prop, .scene .cat { position: absolute; }
.scene .prop svg { width: 100%; height: 100%; display: block; }
.scene .cat { object-fit: contain; aspect-ratio: 1; }
.scene .table { left: 8%; width: 84%; bottom: 6%; height: 48%; }
.s-on .cat { width: 40%; left: 30%; bottom: 47%; }
.s-under .cat { width: 32%; left: 34%; bottom: 5%; }
.scene .box-back { left: 20%; width: 60%; bottom: 8%; height: 40%; }
.scene .box-front { left: 20%; width: 60%; bottom: 8%; height: 40%; }
.s-in .cat { width: 40%; left: 30%; bottom: 22%; }
.s-out .box-back, .s-out .box-front { left: 4%; width: 50%; height: 34%; }
.s-out .cat { width: 38%; left: 58%; bottom: 6%; }
.scene .tree { left: 14%; width: 72%; bottom: 4%; height: 88%; }
.s-front .cat { width: 42%; left: 29%; bottom: 3%; }
.s-behind .cat { width: 30%; left: 52%; bottom: 14%; }
.opt .scene { width: 100%; }
.lay-scenes .opt { padding: 6px; }

/* halves */
.halves { display: flex; background: var(--card); border-radius: 22px; padding: 12px; box-shadow: var(--shadow); }
.half { display: block; width: clamp(80px, min(26vw, 17vh), 170px); aspect-ratio: 1 / 2; background-size: 200% 100%; background-repeat: no-repeat; }
.half.left { background-position: left center; } .half.right { background-position: right center; }
.half.missing { display: grid; place-items: center; border: 4px dashed var(--c); border-radius: 12px; font-size: 44px; font-weight: 700; color: var(--c); background: #fffaf2; }
.piece .half { width: clamp(52px, min(14vw, 11vh), 110px); }
.sizebox { width: 100%; aspect-ratio: 1; display: grid; place-items: end center; }
.sizebox img.art.s1 { width: 36%; height: 36%; } .sizebox img.art.s2 { width: 64%; height: 64%; } .sizebox img.art.s3 { width: 96%; height: 96%; }

/* match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(14px, 6vw, 60px); align-content: center; height: 100%; }
.match .col { display: grid; gap: 10px; grid-auto-rows: 1fr; }
/* number ↔ quantity: numbers need little room, the groups to count get the rest */
.match:has(.objs) { grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); }
.m-item { background: var(--card); border-radius: 18px; box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 35%, #d9c4a6); display: grid; place-items: center; padding: 6px; min-height: clamp(70px, 14vh, 150px); }
.m-item .th-letter { font-size: clamp(44px, min(12vw, 9vh), 90px); }
.m-item .en-letter { font-size: clamp(40px, min(11vw, 8vh), 84px); line-height: 1.1; }
.m-item .num { font-size: clamp(42px, min(11vw, 8vh), 84px); }
.m-item img.art { width: min(100%, 13vh); height: min(100%, 13vh); }
.m-item:has(> .objs) { min-height: clamp(80px, 15vh, 160px); }
.m-item.sel { box-shadow: 0 0 0 5px var(--c), 0 6px 0 color-mix(in srgb, var(--c) 60%, black); transform: translateY(-2px); }
.m-item.done { background: #e9fbe9; box-shadow: 0 0 0 4px var(--ok); opacity: .8; }

/* result */
.result-card { text-align: center; background: var(--card); border-radius: 30px; box-shadow: var(--shadow); padding: 22px 18px; margin: 10px auto 0; max-width: 560px; }
.result-card .mascot { width: 120px; }
.big-stars .stars span { font-size: 58px; }
.result-card h1 { margin: 6px 0; font-size: clamp(28px, 8vw, 40px); color: var(--c); }
.score { font-size: 19px; } .score b { font-size: 28px; color: var(--c); }
.breakdown { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.breakdown div { display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 14px; padding: 8px 10px; border-left: 6px solid var(--c); text-align: left; }
.breakdown img { width: 40px; } .breakdown b { flex: 1; min-width: 0; font-size: 16px; } .breakdown span { font: 700 20px 'Andika', sans-serif; }
.result-actions { display: flex; gap: 12px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.btn { min-height: 56px; padding: 0 24px; border-radius: 99px; background: var(--bg2); font-weight: 700; font-size: 18px; box-shadow: 0 5px 0 #e2c9a3; }
.btn.primary { background: var(--c); color: #fff; box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 70%, black); }
.btn:active { transform: translateY(4px); box-shadow: none; }

/* parent */
.panel { background: var(--card); border-radius: 20px; padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel h2 { margin: 0 0 10px; font-size: 18px; }
.panel table { width: 100%; border-collapse: collapse; font-size: 16px; }
.panel th, .panel td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.panel th { color: var(--muted); font-size: 13px; font-weight: 500; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid var(--c); border-radius: 99px; padding: 4px 12px; font-size: 18px; }
.chip b { color: var(--c); font-size: 14px; }
.plain { margin: 0; padding-left: 20px; line-height: 1.8; }
.panel.danger { background: none; box-shadow: none; text-align: center; }

/* splash, tap to hear */
.splash { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(255, 246, 230, .94); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); padding: 20px; transition: opacity .3s; }
.splash.out { opacity: 0; }
.splash-card { text-align: center; }
.splash-owl { width: clamp(140px, 40vmin, 230px); animation: talk .7s ease-in-out infinite alternate; }
.splash h1 { margin: 6px 0 0; font-size: clamp(34px, 9vw, 52px); color: var(--math); }
.splash p { margin: 4px 0 18px; color: var(--muted); font-size: 18px; }
.btn-start { background: var(--thai); color: #fff; font-size: clamp(22px, 6vw, 28px); font-weight: 700; padding: 18px 34px; border-radius: 99px; box-shadow: 0 7px 0 #1d8a52; animation: pulse 1.4s ease-in-out infinite; }
.splash small { display: block; margin-top: 16px; color: var(--muted); font-size: 15px; }
.tap-hear { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 18px); translate: -50% 0; z-index: 40; background: var(--ink); color: #fff; font-weight: 700; font-size: 20px; padding: 14px 26px; border-radius: 99px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: pulse 1.2s infinite; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: fall linear forwards; }

/* ---------- landscape: picture left, answers right ---------- */
@media (min-aspect-ratio: 23/20) {
  .play { grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; }
  .opts { align-content: center; }
  .lay-letters .opts, .lay-numbers .opts, .lay-words .opts { grid-template-columns: 1fr; max-width: 360px; width: 100%; justify-self: center; }
  .lay-letters .opt, .lay-numbers .opt, .lay-words .opt { min-height: 0; height: clamp(70px, 22vh, 170px); }
  .opts.n4 { grid-template-columns: repeat(2, 1fr); }
  .lay-pics .opt, .lay-scenes .opt { min-height: 0; }
  .play.lay-groups:not(.lay-two) .opts { grid-template-columns: 1fr; align-self: stretch; grid-auto-rows: minmax(0, 1fr); }
  .play.lay-groups:not(.lay-two) .opt { min-height: 0; }
  .lay-groups.lay-two .opts { grid-template-columns: repeat(2, 1fr); }
  .lay-groups.lay-two .opt { aspect-ratio: 1; min-height: 0; }
  .play.lay-groups.lay-two { grid-template-columns: minmax(0, .5fr) minmax(0, 1.5fr); }
  .play.lay-scenes, .play.lay-pics.lay-four { grid-template-columns: minmax(0, .6fr) minmax(0, 1.4fr); }
  .play.lay-pics:not(.lay-four):not(:has(.pattern)) { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
  .pattern { gap: 4px; }
  .train .car { min-width: clamp(40px, 8vw, 100px); height: clamp(52px, 11vw, 116px); font-size: clamp(28px, 6vw, 70px); }
  .pattern .cell { width: clamp(36px, 6vw, 92px); height: clamp(36px, 6vw, 92px); }
  .play.lay-scenes .opts { grid-template-columns: repeat(3, 1fr); }
  .owl-mini { top: auto; bottom: calc(var(--safe-b) + 10px); }
  /* landscape matching: one row on top, its partners in a row below */
  .match-play { grid-template-columns: 1fr; }
  .match { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(12px, 4vh, 36px); }
  .match .col { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); grid-auto-rows: auto; }
  .m-item, .m-item:has(> .objs) { min-height: 0; }
  .m-item .th-letter { font-size: clamp(40px, 19vh, 120px); }
  .m-item .en-letter, .m-item .num { font-size: clamp(38px, 17vh, 110px); }
  .m-item img.art { width: min(100%, 28vh); height: min(100%, 28vh); }
  .match:has(.objs) { grid-template-columns: 1fr; grid-template-rows: minmax(0, .8fr) minmax(0, 1.2fr); }
}
/* landscape flash card: big letter or number on the left, picture on the right,
   sized from the screen height so the arrows always stay on screen */
@media (min-aspect-ratio: 23/20) {
  .flash { width: min(860px, 100%); }
  .fc.th, .fc.num { display: grid; align-items: center; justify-items: center; column-gap: clamp(16px, 5vw, 56px); row-gap: 2px; }
  .fc.th { grid-template-areas: "l a" "c a"; }
  .fc.num { grid-template-areas: "l o" "w o" "h o"; }
  .fc.th .th-letter, .fc.num .num { grid-area: l; }
  .fc.th .fc-art { grid-area: a; } .fc.th .fc-cap { grid-area: c; }
  .fc.num .fc-words { grid-area: w; } .fc.num .objs { grid-area: o; } .fc.num .fc-hint { grid-area: h; }
  .th-letter.huge { font-size: clamp(70px, 30vh, 200px); line-height: 1.2; }
  .num.huge { font-size: clamp(64px, 26vh, 190px); line-height: 1.15; }
  .en-letter.huge { font-size: clamp(70px, 34vh, 190px); }
  .fc-art .art.big { width: clamp(90px, 46vh, 260px); height: clamp(90px, 46vh, 260px); }
  .fc .objs.count { width: min(40vw, 54vh, 420px); }
  .fc-cap { font-size: clamp(20px, 9vh, 34px); }
  .fc-words { font-size: clamp(18px, 8vh, 30px); }
}
/* short phones in landscape: tighten everything */
@media (min-aspect-ratio: 23/20) and (max-height: 500px) {
  .screen { padding-top: calc(var(--safe-t) + 4px); }
  .bar { padding: 2px 0 4px; }
  .round { width: 44px; height: 44px; font-size: 26px; }
  .owl-mini { display: none; }
  .dots i { width: 8px; height: 8px; }
  .pic-card { padding: 8px; }
  .target { padding: 0 20px; }
  .m-item, .m-item:has(> .objs) { min-height: 0; }
  .opt .th-letter { font-size: clamp(40px, 15vh, 120px); }
}
/* portrait: the question chip sits on top, the answer pictures get the room */
@media (max-aspect-ratio: 23/20) {
  .play.lay-scenes, .play.lay-groups.lay-two, .play.lay-pics.lay-four { grid-template-rows: auto minmax(0, 1fr); }
  .play.lay-scenes .opts, .play.lay-groups.lay-two .opts, .play.lay-pics.lay-four .opts { align-content: center; }
  .play.lay-scenes .opts { grid-template-columns: repeat(3, 1fr); }
  .play.lay-groups.lay-two .opts { grid-template-columns: repeat(2, 1fr); }
  /* which group has N: the number on top, three wide rows of things to count below */
  .play.lay-groups:not(.lay-two) { grid-template-rows: auto minmax(0, 1fr); }
  .play.lay-groups:not(.lay-two) .opts { grid-template-columns: 1fr; grid-auto-rows: minmax(0, 1fr); }
  .play.lay-groups:not(.lay-two) .opt { min-height: 0; }
  .play.lay-groups .target .num { font-size: clamp(80px, min(24vw, 17vh), 190px); }
}
@media (max-aspect-ratio: 23/20) and (max-width: 600px) {
  .play.lay-scenes .opts { grid-template-columns: repeat(2, 1fr); }
  .play.lay-scenes .opt:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc(50% - 8px); }
}

@keyframes talk { from { transform: rotate(-3deg) scale(1); } to { transform: rotate(3deg) scale(1.04); } }
@keyframes pop { 0% { transform: scale(.92); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
.bounce { animation: pulse 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
