/* Story Quest M2 — styles */
:root {
  --ink: #2b2840;
  --paper: #fffaf0;
  --tb: 58px;
  --accent: #7048e8;
  --accent2: #f3f0ff;
  --good: #2f9e44;
  --bad: #e03131;
  --font: 'Baloo 2', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  --thai: 'Mali', 'Leelawadee UI', 'Thonburi', 'Tahoma', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #ffe9a8;
  background-image: radial-gradient(rgba(255, 255, 255, .55) 2.5px, transparent 3px), radial-gradient(rgba(255, 255, 255, .35) 2.5px, transparent 3px);
  background-size: 34px 34px, 34px 34px;
  background-position: 0 0, 17px 17px;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
.th { font-family: var(--thai); font-weight: 600; color: #6a5f86; font-size: .8em; display: block; line-height: 1.35; }

/* ---------------------------------------------------------------- top bar */
#topbar {
  position: sticky; top: 0; z-index: 50; height: var(--tb);
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: #fff; border-bottom: 4px solid var(--ink);
}
.tb-btn {
  border: 3px solid var(--ink); background: #fff3bf; border-radius: 14px; height: 42px; padding: 0 12px;
  font-size: 1.1rem; font-weight: 800; box-shadow: 0 3px 0 var(--ink);
}
.tb-btn:active { transform: translateY(3px); box-shadow: none; }
.tb-title { font-weight: 800; font-size: 1.45rem; letter-spacing: .5px; flex: 1; }
.tb-title span { color: #f76707; }
.tb-stars { font-weight: 800; font-size: 1.15rem; background: #fff3bf; border: 3px solid var(--ink); border-radius: 14px; padding: 2px 12px; }
body[data-screen="title"] #homeBtn { visibility: hidden; }

#screen { width: 100%; max-width: 1820px; margin: 0 auto; padding: 14px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  font-weight: 800; font-size: 1.12rem; line-height: 1.15; padding: .55em 1.05em;
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, filter .2s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; filter: grayscale(.7); box-shadow: 0 3px 0 var(--ink); }
.btn .th { display: block; color: inherit; opacity: .8; }
.btn.big { font-size: 1.5rem; padding: .5em 1.4em; }
.btn.small { font-size: 1rem; padding: .35em .8em; }
.btn-go { background: #69db7c; }
.btn-listen { background: #74c0fc; }
.btn-listen.on { background: #ffd43b; }
.btn-ghost { background: #f1f3f5; }
.btn-bad { background: #ffa8a8; }
.btn.locked { opacity: .5; filter: grayscale(.7); }
.check.nudge { animation: okPop .5s 2; box-shadow: 0 0 0 5px #ffd43b; }
.btn.pulse:not(:disabled) { animation: btnPulse 1.1s ease-in-out infinite; }
@keyframes btnPulse { 50% { transform: scale(1.07); } }
.link-btn { background: none; border: none; text-decoration: underline; color: #6a5f86; font-weight: 700; margin-top: 10px; }
.say-btn {
  flex: none; width: 2.3em; height: 2.3em; border-radius: 50%; border: 3px solid var(--ink); background: #d0ebff;
  font-size: .8em; line-height: 1; padding: 0; box-shadow: 0 3px 0 var(--ink); display: inline-grid; place-items: center;
}
.say-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.srow { color: #fab005; letter-spacing: 1px; -webkit-text-stroke: 1px #b8860b; }
.soff { color: #dee2e6; -webkit-text-stroke: 1px #adb5bd; }

/* world colours */
.wt-w1 { --accent: #2f9e44; --accent2: #ebfbee; }
.wt-w2 { --accent: #e8590c; --accent2: #fff4e6; }
.wt-w3 { --accent: #1971c2; --accent2: #e7f5ff; }
.wt-final { --accent: #9c36b5; --accent2: #f8f0fc; }

/* ---------------------------------------------------------------- stage + characters */
.stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden;
  border: 4px solid var(--ink); border-radius: 22px; background: #bde0fe;
  container-type: inline-size; box-shadow: 0 7px 0 rgba(43, 40, 64, .25);
}
.stage .layer { position: absolute; inset: 0; }
.stage .layer svg, .bg-svg { width: 100%; height: 100%; display: block; }
.stage .over { z-index: 40; pointer-events: none; }
.actor { position: absolute; transform: translateX(-50%); }
.actor-in { position: relative; height: 100%; transform: rotate(var(--rot, 0deg)); }
.ch { height: 100%; width: auto; display: block; overflow: visible; }
.flip .ch { transform: scaleX(-1); }
.ch.crop { overflow: hidden; }

.ch .ch-all { animation: bob 2.4s ease-in-out infinite; animation-delay: var(--d, 0s); transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes bob { 0%, 100% { transform: translateY(0) scaleY(1); } 50% { transform: translateY(-1.6%) scaleY(1.012); } }
.ch .e-open { animation: blink 4.4s infinite; animation-delay: var(--d, 0s); transform-box: fill-box; transform-origin: center; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.ch .neck { animation: nod 3.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes nod { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(3deg); } }
.ch .tail { animation: swish 1.8s ease-in-out infinite; }
@keyframes swish { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(14deg); } }

/* expressions */
.ch .e-closed, .ch .e-happy, .ch .m-open, .ch .m-sad, .ch .b-worry { display: none; }
.ex-sleep .e-open, .ex-happy .e-open, .cheer .e-open { display: none; }
.ex-sleep .e-closed { display: inline; }
.ex-happy .e-happy, .cheer .e-happy { display: inline; }
.ex-sad .m-smile { display: none; }
.ex-sad .m-sad, .ex-sad .b-worry { display: inline; }
.ex-sad .b-norm { display: none; }
.ex-wow .m-smile, .cheer .m-smile { display: none; }
.ex-wow .m-open, .cheer .m-open { display: inline; }
.ex-wow .brows { transform: translateY(-6px); }
.talking .m-smile, .talking .m-sad { display: none !important; }
.talking .m-open { display: inline !important; animation: talk .22s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 0; }
@keyframes talk { from { transform: scaleY(.35); } to { transform: scaleY(1.1); } }
.talking .actor-in { filter: drop-shadow(0 0 .8cqw #fff59d); }

/* body animations */
.a-wave .arm-r { animation: wave 1.1s ease-in-out infinite; transform-origin: 136px 162px; }
@keyframes wave { 0%, 100% { transform: rotate(-128deg); } 50% { transform: rotate(-98deg); } }
.a-wave .ch-pyramid .arm-r { animation-name: pwave; transform-origin: 196px 160px; }
@keyframes pwave { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(18deg); } }
.a-stretch .neck { animation: stretch 2.8s ease-in-out infinite; }
@keyframes stretch { 0%, 100% { transform: rotate(-2deg); } 55% { transform: rotate(20deg); } }
.a-jump > .actor-in, .actor-in.a-jump, .pa.a-jump { animation: jump .9s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes jump { 0%, 100% { transform: translateY(0) rotate(var(--rot, 0deg)); } 40% { transform: translateY(-12%) rotate(var(--rot, 0deg)); } }
.cheer > .actor-in { animation: jump .7s ease-in-out 2; }
.a-shake > .actor-in, .actor-in.a-shake { animation: shake 1.6s ease-in-out infinite; }
@keyframes shake { 0%, 50%, 100% { transform: translateX(0); } 10%, 30% { transform: translateX(-4%) rotate(-3deg); } 20%, 40% { transform: translateX(4%) rotate(3deg); } }
.a-charge > .actor-in { animation: charge 2.6s ease-in-out infinite; }
@keyframes charge { 0%, 100% { transform: translateX(28%); } 50% { transform: translateX(-30%) rotate(-3deg); } }
.a-slide > .actor-in { animation: slide 3.2s ease-in-out infinite; }
.a-slide2 > .actor-in { animation: slide 3.2s ease-in-out infinite; animation-delay: -1.6s; }
@keyframes slide { 0%, 100% { transform: translateX(-24%) rotate(-5deg); } 50% { transform: translateX(26%) rotate(5deg); } }
.a-breathe > .actor-in { animation: breathe 3.4s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes breathe { 0%, 100% { transform: rotate(var(--rot, 0deg)) scale(1); } 50% { transform: rotate(var(--rot, 0deg)) scale(1.035); } }

/* speech bubble on stage */
.sbub {
  position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -6%);
  background: #fff; border: .3cqw solid var(--ink); border-radius: 2cqw; padding: .2cqw 1.3cqw;
  font-weight: 800; font-size: 2.6cqw; white-space: nowrap; box-shadow: 0 .4cqw 0 rgba(0, 0, 0, .2);
  animation: popIn .5s backwards .3s;
}
.sbub.side { bottom: auto; top: 3%; left: 86%; transform: none; animation-name: popIn; }
.sbub.side::after { left: auto; right: 100%; top: 50%; transform: translateY(-50%); border-top-color: transparent; border-right-color: var(--ink); }
.sbub::after { content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 1cqw solid transparent; border-top-color: var(--ink); }

/* props */
.prop { position: absolute; z-index: 30; }
.prop.emo { line-height: 1; filter: drop-shadow(0 .3cqw 0 rgba(0, 0, 0, .18)); }
.p-float { animation: float 2.6s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14%); } }
.p-pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.18); } }
.p-drive { animation: drive 3.4s ease-in-out infinite; }
@keyframes drive { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-60%); } }
.tag {
  background: #fff; border: .3cqw solid var(--ink); border-radius: 1.4cqw; padding: .3cqw 1.4cqw;
  font-weight: 800; font-size: 2.5cqw; box-shadow: 0 .45cqw 0 rgba(0, 0, 0, .2); animation: popIn .5s backwards; white-space: nowrap;
}
.tag:nth-of-type(2) { animation-delay: .3s; } .tag:nth-of-type(3) { animation-delay: .6s; } .tag:nth-of-type(4) { animation-delay: .9s; }
@keyframes popIn { from { opacity: 0; transform: scale(.4); } }
.sbub { animation-name: popInB; }
@keyframes popInB { from { opacity: 0; transform: translate(-50%, 10%) scale(.4); } }
.dream-cloud {
  background: #fff; border: .35cqw solid var(--ink); border-radius: 50% / 46%; padding: 2.6cqw 2cqw;
  font-size: 4.6cqw; text-align: center; white-space: nowrap; animation: float 3.4s ease-in-out infinite; box-shadow: 0 .5cqw 0 rgba(0, 0, 0, .2);
}
.dream i { position: absolute; background: #fff; border: .3cqw solid var(--ink); border-radius: 50%; }
.dream .d1 { width: 3cqw; height: 3cqw; left: 2cqw; bottom: -3.4cqw; }
.dream .d2 { width: 1.8cqw; height: 1.8cqw; left: -.6cqw; bottom: -6.4cqw; }
.swing-wrap svg { height: 100%; width: auto; display: block; }
.swing-seat { animation: swingHi 7s ease-in-out infinite; }
@keyframes swingHi {
  0%, 100% { transform: rotate(0); } 8% { transform: rotate(8deg); } 16% { transform: rotate(-10deg); } 24% { transform: rotate(15deg); }
  32% { transform: rotate(-19deg); } 40% { transform: rotate(25deg); } 48% { transform: rotate(-30deg); } 56% { transform: rotate(36deg); }
  64% { transform: rotate(-41deg); } 72% { transform: rotate(45deg); } 80% { transform: rotate(-30deg); } 90% { transform: rotate(12deg); }
}

/* background details */
.cloud { animation: drift 18s ease-in-out infinite; }
@keyframes drift { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(90px); } }
.sun { animation: sunPulse 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes sunPulse { 50% { transform: scale(1.06); } }
.twinkle { animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .2; } }
.jig4 { animation: jig4 .22s linear infinite; } .jig3 { animation: jig3 .22s linear infinite; } .jig1 { animation: jig1 .22s linear infinite; }
@keyframes jig4 { 50% { transform: translateY(-9px); } }
@keyframes jig3 { 50% { transform: translateY(-5px); } }
@keyframes jig1 { 50% { transform: translateY(-2px); } }

/* scene effects */
.fx-layer { position: absolute; inset: 0; z-index: 45; pointer-events: none; overflow: hidden; }
.flake { position: absolute; top: -6%; color: #fff; text-shadow: 0 0 2px #74c0fc; animation: fall linear infinite; font-style: normal; }
@keyframes fall { from { top: -6%; transform: translateX(0); } to { top: 104%; transform: translateX(3cqw); } }
.heart { position: absolute; top: 104%; font-size: 3.2cqw; font-style: normal; animation: rise ease-in infinite; }
@keyframes rise { from { top: 104%; opacity: 1; transform: translateX(0); } to { top: -10%; opacity: .2; transform: translateX(4cqw); } }
.fx-quake .layer.bg, .fx-quake .actor-in, .fx-quake .tag { animation: quake 4.5s infinite; }
@keyframes quake {
  0%, 55%, 100% { transform: translate(0, 0) scale(1.02); }
  58% { transform: translate(-1.2%, .6%) scale(1.02); } 61% { transform: translate(1.2%, -.6%) scale(1.02); }
  64% { transform: translate(-1%, .4%) scale(1.02); } 67% { transform: translate(1%, -.4%) scale(1.02); }
  70% { transform: translate(-.6%, .2%) scale(1.02); } 73% { transform: translate(0, 0) scale(1.02); }
}

/* waves diagram */
.waves {
  background: rgba(255, 255, 255, .94); border: .35cqw solid var(--ink); border-radius: 2cqw; padding: 1.6cqw 2.2cqw;
  display: grid; gap: 1.4cqw; font-size: 2.3cqw; box-shadow: 0 .6cqw 0 rgba(0, 0, 0, .2);
}
.wv { display: grid; grid-template-columns: 15cqw 1fr 24cqw; align-items: center; gap: 1.4cqw; }
.wv-name { font-weight: 800; font-size: 2.8cqw; }
.wv svg { width: 100%; height: 8cqw; display: block; overflow: hidden; background: #f8f9fa; border-radius: 1cqw; }
.wv-note { line-height: 1.2; }
.wv-fast { animation: wvFast .43s linear infinite; }
.wv-slow { animation: wvSlow 1.9s linear infinite; }
@keyframes wvFast { to { transform: translateX(-44px); } }
@keyframes wvSlow { to { transform: translateX(-220px); } }
.wv-end { text-align: center; font-weight: 800; font-size: 2.8cqw; color: #2f9e44; }

/* ---------------------------------------------------------------- title screen */
.title-screen { text-align: center; padding: 10px 0 30px; }
.logo { display: inline-flex; gap: .25em; font-size: clamp(56px, 10vw, 120px); font-weight: 800; line-height: 1; margin-top: 6px; }
.logo span { -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); display: inline-block; animation: logoBob 2.4s ease-in-out infinite; }
.logo .l1 { color: #ff922b; } .logo .l2 { color: #51cf66; animation-delay: -1.2s; }
@keyframes logoBob { 50% { transform: translateY(-8px) rotate(-2deg); } }
.tagline { font-size: clamp(18px, 2vw, 26px); font-weight: 700; margin: 12px 0 0; }
.parade {
  display: flex; justify-content: center; align-items: flex-end; gap: clamp(4px, 1.5vw, 22px);
  height: clamp(170px, 30vh, 300px); margin: 18px auto 10px; max-width: 1100px;
  background: linear-gradient(transparent 82%, #8ce99a 82%, #69db7c); border-radius: 0 0 30px 30px; padding: 0 10px 8px; overflow: hidden;
}
.pa { height: 64%; }
.pa .ch { height: 100%; width: auto; }
.parade .pa-giraffe { height: 100%; } .parade .pa-paco { height: 72%; } .parade .pa-marcos, .parade .pa-ben { height: 58%; }
.parade .pa-ostrich { height: 66%; } .parade .pa-pyramid { height: 58%; }
.name-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 18px; }
.name-row label { font-weight: 800; font-size: 1.3rem; text-align: right; }
.name-row input {
  font: 700 1.4rem var(--font); padding: .35em .7em; border: 3px solid var(--ink); border-radius: 14px; width: min(320px, 80vw);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, .08);
}

/* ---------------------------------------------------------------- map */
.h1 { font-size: clamp(24px, 3vw, 38px); margin: 6px 0 16px; text-align: center; }
.h1 .th { display: block; font-size: .55em; }
.worlds { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.world-card {
  text-align: left; padding: 0; overflow: hidden; background: #fff; border: 4px solid var(--ink); border-radius: 24px;
  box-shadow: 0 7px 0 var(--ink); transition: transform .12s; display: flex; flex-direction: column;
}
.world-card:hover { transform: translateY(-4px) rotate(-.6deg); }
.world-card:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.wc-art .stage { border: none; border-radius: 0; box-shadow: none; border-bottom: 4px solid var(--ink); }
.final-art { aspect-ratio: 16 / 9; background: linear-gradient(#e5dbff, #fcc2d7); border-bottom: 4px solid var(--ink); position: relative; display: grid; place-items: center; overflow: hidden; }
.trophy { font-size: clamp(60px, 7vw, 96px); animation: logoBob 2s ease-in-out infinite; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .2)); z-index: 2; }
.final-chars { position: absolute; inset: auto 0 6% 0; display: flex; justify-content: space-between; align-items: flex-end; height: 48%; padding: 0 6%; }
.final-chars .grp { display: flex; align-items: flex-end; gap: 4px; height: 100%; }
.final-chars .pa { height: 100%; }
.final-chars .pa-giraffe { height: 150%; }
.wc-body { padding: 10px 16px 14px; background: var(--accent2); flex: 1; }
.wc-num { font-weight: 700; color: var(--accent); }
.wc-title { font-size: 1.55rem; font-weight: 800; line-height: 1.15; }
.wc-stars { font-size: 1.05rem; margin-top: 4px; }

/* ---------------------------------------------------------------- world menu */
.world-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: center; }
.world-info { background: #fff; border: 4px solid var(--ink); border-radius: 22px; padding: 16px 20px; box-shadow: 0 7px 0 rgba(43, 40, 64, .2); }
.wi-num { font-weight: 800; color: var(--accent); font-size: 1.1rem; }
.world-info h1 { margin: 0; font-size: clamp(30px, 4vw, 52px); line-height: 1.05; }
.wi-author { font-weight: 600; color: #6a5f86; margin-top: 4px; }
.guide-say { display: flex; gap: 10px; align-items: center; margin-top: 12px; background: var(--accent2); border-radius: 16px; padding: 10px 12px; font-size: 1.2rem; font-weight: 700; }
.acts { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 20px 0 16px; }
.act {
  display: grid; grid-template-columns: auto auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 10px;
  background: #fff; border: 4px solid var(--ink); border-radius: 20px; padding: 12px 14px; text-align: left; box-shadow: 0 6px 0 var(--accent);
  transition: transform .1s;
}
.act:hover { transform: translateY(-3px); }
.act:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent); }
.act-n { grid-row: span 2; width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; font-size: 1.3rem; display: grid; place-items: center; border: 3px solid var(--ink); }
.act-ic { grid-row: span 2; font-size: 2.3rem; }
.act-t { font-weight: 800; font-size: 1.3rem; line-height: 1.1; }
.act-s { font-size: 1.2rem; }

/* ---------------------------------------------------------------- story */
.story { display: grid; gap: 14px; }
.story-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dots { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); }
.dot.done { background: var(--accent); }
.dot.now { background: #ffd43b; transform: scale(1.3); }
.panel { background: #fff; border: 4px solid var(--ink); border-radius: 22px; display: flex; flex-direction: column; min-height: 0; box-shadow: 0 7px 0 rgba(43, 40, 64, .2); }
.panel-scroll { padding: 14px 16px; overflow: auto; flex: 1; }
.nav { display: flex; gap: 8px; justify-content: space-between; padding: 10px 12px 14px; border-top: 3px dashed #e5dbff; }
.scene-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.scene-head h2 { margin: 0; font-size: clamp(22px, 2vw, 30px); line-height: 1.1; }
.pill { background: var(--accent); color: #fff; font-weight: 800; border-radius: 99px; padding: 2px 12px; border: 3px solid var(--ink); white-space: nowrap; }
.heading-tag { background: #fff3bf; border: 3px dashed #f08c00; border-radius: 12px; padding: 6px 10px; margin: 4px 0 8px; font-weight: 600; }
.lines { display: flex; flex-direction: column; gap: 4px; }
.line { display: flex; gap: 10px; align-items: flex-start; padding: 6px 8px; border-radius: 14px; font-size: clamp(18px, 1.5vw, 24px); line-height: 1.4; transition: background .2s, box-shadow .2s; }
.line p { margin: 0; }
.line.narr .say-btn { margin-top: 2px; }
.line.reading { background: #fff9db; box-shadow: inset 0 0 0 3px #ffd43b; }
.line.talk .tb { background: var(--accent2); border: 2px solid color-mix(in srgb, var(--accent) 35%, white); border-radius: 4px 16px 16px 16px; padding: 4px 12px 6px; flex: 1; }
.line.talk .who { display: block; font-size: .78em; color: var(--accent); }
.say-btn.av { width: 3.1em; height: 3.1em; font-size: .78em; background: #fff; overflow: hidden; padding: 0; }
.say-btn.av svg { width: 100%; height: 100%; }
.kw {
  font: inherit; font-weight: 800; background: #ffe066; border: none; border-bottom: 3px solid #f59f00; border-radius: 6px;
  padding: 0 4px; margin: 0 1px; line-height: 1.25; color: inherit;
}
.kw:hover { background: #ffd43b; }
.kw.demo { display: inline; }
.tip { margin-top: 10px; background: #e7f5ff; border-radius: 14px; padding: 8px 12px; font-weight: 600; }
.check { margin-top: 12px; background: #f3f0ff; border: 3px solid #845ef7; border-radius: 18px; padding: 10px 12px 12px; }
.check-h { font-weight: 800; color: #5f3dc4; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.check-h .th { display: inline; }
.check-q { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: clamp(18px, 1.5vw, 23px); margin-top: 4px; }
.opts { display: grid; gap: 8px; margin-top: 10px; }
.opt, .qopt, .bopt {
  font-weight: 700; font-size: clamp(17px, 1.45vw, 22px); text-align: left; background: #fff; border: 3px solid var(--ink);
  border-radius: 14px; padding: .45em .8em; box-shadow: 0 4px 0 var(--ink); transition: transform .08s;
}
.opt:active:not(:disabled), .qopt:active:not(:disabled), .bopt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.ok { background: #b2f2bb !important; border-color: #2b8a3e !important; animation: okPop .45s; }
.bad { background: #ffc9c9 !important; animation: shakeX .45s; }
.opt.bad:disabled, .qopt.bad:disabled, .bopt.bad:disabled { opacity: .6; }
@keyframes okPop { 40% { transform: scale(1.06); } }
@keyframes shakeX { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.ck-fb { margin-top: 8px; font-weight: 800; min-height: 1.3em; }
.ck-fb .th { display: inline; }

@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .story { grid-template-columns: minmax(0, 1.75fr) minmax(380px, 1fr); height: calc(100dvh - var(--tb) - 28px); }
  .story-main { justify-content: center; }
  .stage-wrap .stage { width: min(100%, calc((100dvh - var(--tb) - 80px) * 16 / 9)); margin: 0 auto; }
}

/* ---------------------------------------------------------------- modal */
#modal { position: fixed; inset: 0; z-index: 100; background: rgba(43, 40, 64, .55); display: grid; place-items: center; padding: 16px; }
#modal[hidden] { display: none; }
.modal-box { background: #fff; border: 4px solid var(--ink); border-radius: 26px; padding: 22px 26px; max-width: 480px; width: 100%; box-shadow: 0 10px 0 var(--ink); animation: popIn .3s; }
.word-card { text-align: center; display: grid; gap: 10px; justify-items: center; }
.wcard-emoji { font-size: 76px; line-height: 1; animation: logoBob 2s ease-in-out infinite; }
.wcard-word { font-size: 2.3rem; font-weight: 800; display: flex; gap: 10px; align-items: center; }
.wcard-mean { font-size: 1.35rem; font-weight: 700; }
.wcard-th { font-family: var(--thai); font-size: 1.35rem; font-weight: 700; background: #fff3bf; border-radius: 14px; padding: 6px 14px; }
.th-flag { font-size: .7em; background: var(--ink); color: #fff; border-radius: 6px; padding: 1px 6px; margin-right: 4px; vertical-align: middle; }
.wcard-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.btn-th { font-family: var(--thai); font-size: 1.05rem; }

/* ---------------------------------------------------------------- shared game header */
.game-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.gh-text { flex: 1; min-width: 240px; }
.gh-text h1 { margin: 0; font-size: clamp(26px, 3vw, 40px); line-height: 1.05; }
.gh-ins { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 1.15rem; }
.gh-story { font-weight: 800; background: var(--accent2); border: 3px solid var(--accent); border-radius: 14px; padding: 4px 12px; }
.game-foot { text-align: center; font-weight: 800; font-size: 1.15rem; margin-top: 14px; }

/* word match */
.match-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 16px; }
.mcol { display: grid; gap: 10px; }
.mcard {
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 var(--ink); padding: 10px 14px;
  font-weight: 700; font-size: clamp(17px, 1.5vw, 22px); text-align: left; display: flex; align-items: center; gap: 10px; min-height: 62px;
  transition: transform .1s, background .2s;
}
.mw { justify-content: center; flex-direction: column; gap: 0; text-align: center; background: var(--accent2); }
.mw-w { font-size: 1.3em; font-weight: 800; }
.mw-th { font-family: var(--thai); font-size: .85em; color: #2b8a3e; }
.mm-e { font-size: 1.8em; flex: none; }
.mcard.sel { background: #ffe066; transform: translateY(-3px) scale(1.02); box-shadow: 0 8px 0 var(--ink); }
.mcard.ok { box-shadow: 0 2px 0 #2b8a3e; }

/* story order */
.trail { position: relative; background: linear-gradient(#a5d8ff, #d0ebff 60%, #8ce99a 60%); border: 4px solid var(--ink); border-radius: 22px; padding: 120px 110px 14px 14px; overflow: hidden; }
.trail-walker { position: absolute; top: 8px; left: 0; height: 120px; transition: left .7s cubic-bezier(.5, 1.6, .6, 1); margin-left: 14px; }
.trail-walker.hop { animation: jump .6s ease-in-out; }
.trail-goal { position: absolute; right: 10px; top: 10px; height: 120px; }
.trail-track { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.slot { background: rgba(255, 255, 255, .7); border: 3px dashed var(--ink); border-radius: 14px; min-height: 92px; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.slot.filled { background: #fff; border-style: solid; animation: okPop .5s; }
.slot-n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--ink); }
.slot-e { font-size: 1.6rem; line-height: 1; }
.slot-t { font-size: .85rem; font-weight: 700; line-height: 1.15; }
.order-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin-top: 16px; }
.ocard { display: flex; align-items: center; gap: 8px; background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 var(--ink); padding: 6px 10px 6px 6px; transition: opacity .35s, transform .35s; }
.ocard.gone { opacity: 0; transform: scale(.6); pointer-events: none; }
.oc-main { flex: 1; display: flex; align-items: center; gap: 10px; background: none; border: none; text-align: left; font-weight: 700; font-size: clamp(17px, 1.4vw, 21px); padding: 6px; }
.oc-e { font-size: 2rem; }

/* who am I */
.clue-card { background: #fff; border: 4px solid var(--ink); border-radius: 22px; padding: 14px 18px; text-align: center; box-shadow: 0 7px 0 var(--accent); }
.clue-n { font-weight: 800; color: var(--accent); }
.clue-t { display: flex; gap: 12px; align-items: center; justify-content: center; font-size: clamp(22px, 2.4vw, 34px); font-weight: 800; line-height: 1.25; margin: 4px 0; }
.clue-q { font-size: 1.4rem; font-weight: 800; color: #5f3dc4; }
.who-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-top: 18px; }
.who-btn { background: #fff; border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 6px 0 var(--ink); padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; transition: transform .1s; }
.who-btn:hover:not(:disabled) { transform: translateY(-3px); }
.who-av { width: min(130px, 100%); aspect-ratio: 1; border-radius: 50%; background: var(--accent2); border: 3px solid var(--ink); overflow: hidden; display: block; }
.who-av .ch { width: 100%; height: 100%; }
.who-name { font-weight: 800; font-size: 1.15rem; }
.who-btn.bad:disabled { opacity: .55; }
.who-foot { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; text-align: center; }
.who-foot .ck-fb { font-size: 1.3rem; }

/* build the pyramid */
.build-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.build-stage { position: relative; }
.pyr { position: absolute; left: 50%; bottom: 8%; width: 56%; height: 70%; transform: translateX(-50%); }
.pl {
  position: absolute; left: 50%; height: calc(100% / var(--n)); bottom: calc(var(--i) * 100% / var(--n));
  width: calc(100% - var(--i) * (100% / var(--n))); transform: translateX(-50%);
  border: 3px dashed rgba(43, 40, 64, .35); border-bottom: none; border-radius: 4px;
}
.pl.in {
  border: 3px solid var(--ink); background-color: #f2c66d;
  background-image: repeating-linear-gradient(90deg, transparent 0 34px, rgba(120, 80, 20, .35) 34px 37px);
  animation: drop .55s cubic-bezier(.4, 0, .7, 1.4) backwards;
}
.pl.cap { clip-path: polygon(50% 0, 100% 100%, 0 100%); border: none; background: rgba(43, 40, 64, .12); }
.pl.cap.in { background: #ffd43b; }
@keyframes drop { from { transform: translate(-50%, -500%); opacity: .2; } }
.pyr-face { position: absolute; inset: 0; opacity: 0; transition: opacity .6s; pointer-events: none; display: flex; justify-content: center; }
.pyr-face .ch { height: 108%; margin-top: -4%; }
.pyr.done .pl { opacity: 0; transition: opacity .6s .2s; }
.pyr.done .pyr-face { opacity: 1; }
.pyr.happy .pyr-face { --x: 1; }
.pyr.happy .pyr-face .ch { animation: jump .8s ease-in-out infinite; }
.pyr.happy .e-open { display: none; } .pyr.happy .e-happy { display: inline; }
.shaking { animation: quakeHard .16s linear infinite; }
@keyframes quakeHard { 25% { transform: translate(-7px, 3px) rotate(-.6deg); } 50% { transform: translate(6px, -3px); } 75% { transform: translate(-5px, -2px) rotate(.6deg); } }
.quake-banner {
  position: absolute; left: 50%; top: 6%; transform: translateX(-50%); background: #fff; border: 4px solid var(--ink); border-radius: 18px;
  padding: 4px 18px; font-weight: 800; font-size: clamp(20px, 2.4vw, 32px); white-space: nowrap; animation: popIn .4s; z-index: 5;
}
.bq-card { background: #fff; border: 4px solid var(--ink); border-radius: 22px; padding: 16px 18px; box-shadow: 0 7px 0 var(--accent); }
.bq-n { font-weight: 800; color: var(--accent); }
.bq-t { display: flex; gap: 10px; align-items: center; font-size: clamp(21px, 2.1vw, 30px); font-weight: 800; line-height: 1.3; margin: 6px 0 12px; }
.blank { display: inline-block; min-width: 2.4em; text-align: center; border-bottom: 4px solid var(--ink); color: #adb5bd; margin: 0 .2em; }
.blank.filled { color: #2b8a3e; animation: okPop .5s; }
.bq-opts { display: grid; gap: 10px; }
.bopt { font-size: clamp(22px, 2vw, 30px); text-align: center; font-weight: 800; }
.bq-big { font-size: clamp(24px, 2.4vw, 34px); font-weight: 800; }

/* ---------------------------------------------------------------- quiz */
.quiz-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.qtitle { font-weight: 800; font-size: clamp(20px, 2vw, 28px); }
.qprog { flex: 1; min-width: 140px; height: 22px; background: #fff; border: 3px solid var(--ink); border-radius: 99px; overflow: hidden; }
.qbar { height: 100%; background: linear-gradient(90deg, #ffd43b, #69db7c); transition: width .4s; }
.qcount, .qscore { font-weight: 800; font-size: 1.2rem; background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 0 10px; }
.quiz-body { display: grid; grid-template-columns: minmax(150px, .32fr) minmax(0, 1fr); gap: 18px; align-items: center; min-height: calc(100dvh - var(--tb) - 110px); }
.quiz-guide { height: clamp(220px, 44vh, 480px); display: flex; justify-content: center; align-items: flex-end; }
.quiz-guide .actor-in { height: 100%; }
.quiz-card { background: #fff; border: 4px solid var(--ink); border-radius: 24px; padding: 18px 20px 20px; box-shadow: 0 7px 0 var(--accent); max-width: 1200px; }
.q-from { display: inline-block; font-weight: 800; color: #fff; background: var(--accent); border-radius: 99px; padding: 0 12px; border: 3px solid var(--ink); margin-bottom: 6px; }
.q-text { display: flex; gap: 12px; align-items: center; font-size: clamp(22px, 2.3vw, 40px); font-weight: 800; line-height: 1.25; }
.q-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.qopt { font-size: clamp(18px, 1.8vw, 32px); min-height: 64px; }
.qopt { display: flex; align-items: center; gap: 12px; }
.qk { flex: none; width: 1.5em; height: 1.5em; line-height: 1; padding-top: .1em; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; border: 3px solid var(--ink); }
.qopt:nth-child(1) .qk { background: #f03e3e; } .qopt:nth-child(2) .qk { background: #1c7ed6; }
.qopt:nth-child(3) .qk { background: #f59f00; } .qopt:nth-child(4) .qk { background: #2f9e44; }
.q-fb { margin-top: 14px; border-radius: 18px; padding: 12px 14px; border: 3px solid var(--ink); display: grid; gap: 8px; animation: popIn .3s; }
.q-fb.good { background: #ebfbee; } .q-fb.miss { background: #fff5f5; }
.fb-title { font-weight: 800; font-size: 1.3rem; }
.fb-clue { display: flex; gap: 10px; align-items: center; font-size: 1.12rem; font-weight: 600; background: #fff; border-radius: 12px; padding: 8px 10px; }
.q-fb .btn { justify-self: end; }
.is-final .quiz-card { box-shadow: 0 7px 0 #9c36b5; }

/* ---------------------------------------------------------------- results + certificate */
.result { display: grid; place-items: center; padding: 10px 0 30px; }
.res-card { background: #fff; border: 4px solid var(--ink); border-radius: 28px; padding: 18px 26px 24px; text-align: center; max-width: 720px; width: 100%; box-shadow: 0 9px 0 var(--ink); }
.res-guide { height: clamp(150px, 26vh, 240px); display: flex; justify-content: center; }
.res-card h1 { margin: 4px 0 0; font-size: clamp(34px, 5vw, 56px); }
.res-stars { font-size: clamp(54px, 7vw, 84px); line-height: 1; }
.rs { display: inline-block; color: #dee2e6; -webkit-text-stroke: 3px #adb5bd; }
.rs.on { color: #fcc419; -webkit-text-stroke: 3px #b8860b; animation: starIn .6s cubic-bezier(.3, 1.8, .5, 1) backwards; }
@keyframes starIn { from { transform: scale(0) rotate(-120deg); opacity: 0; } }
.res-line { font-size: 1.3rem; font-weight: 700; }
.res-tip { font-weight: 700; color: #6a5f86; }
.res-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.cert-wrap { display: grid; justify-items: center; gap: 16px; padding-bottom: 30px; }
.cert {
  background: #fffdf3; border: 10px double #b8860b; outline: 4px solid var(--ink); border-radius: 18px; padding: 22px 28px; text-align: center;
  max-width: 900px; width: 100%; box-shadow: 0 10px 0 rgba(43, 40, 64, .35);
}
.cert-top { font-size: clamp(30px, 4vw, 52px); font-weight: 800; color: #b8860b; }
.cert-small { font-size: 1.2rem; font-weight: 600; }
.cert-name { font-size: clamp(36px, 6vw, 70px); font-weight: 800; color: #7048e8; line-height: 1.1; border-bottom: 4px dotted #b8860b; display: inline-block; padding: 0 20px; }
.cert-line { font-size: 1.3rem; font-weight: 600; margin-top: 8px; }
.cert-score { font-size: 1.6rem; font-weight: 800; margin-top: 8px; }
.cert-chars { display: flex; justify-content: center; align-items: flex-end; gap: 14px; height: clamp(110px, 18vh, 170px); margin-top: 10px; }
.cert-chars .pa { height: 80%; } .cert-chars .pa:nth-child(5) { height: 100%; }
.cert-date { font-weight: 700; color: #6a5f86; margin-top: 6px; }

/* ---------------------------------------------------------------- floating fx */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.conf { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: confFall linear forwards; }
@keyframes confFall { to { transform: translate(var(--x), 110vh) rotate(var(--r)); } }
.burst { position: absolute; font-size: 26px; animation: burst .85s ease-out forwards; }
@keyframes burst { from { transform: translate(-50%, -50%) scale(.4); opacity: 1; } to { transform: translate(calc(-50% + var(--bx)), calc(-50% + var(--by))) scale(1.1); opacity: 0; } }
.toast {
  position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 800; font-size: 1.3rem;
  padding: 10px 22px; border-radius: 99px; animation: popIn .3s;
}

/* ---------------------------------------------------------------- small screens */
@media (max-width: 760px) {
  :root { --tb: 52px; }
  #screen { padding: 10px; }
  .tb-title { font-size: 1.15rem; }
  .tb-btn span { display: none; }
  .parade { height: 122px; gap: 2px; padding: 0 4px 6px; }
  .cert { padding: 14px 10px; min-width: 0; }
  .cert-chars { height: 84px; gap: 4px; overflow: hidden; }
  .parade .pa-ben, .parade .pa-ostrich { display: none; }
  .world-hero, .build-grid { grid-template-columns: 1fr; }
  .match-grid { grid-template-columns: 1fr 1.3fr; gap: 8px; }
  .mcard { padding: 8px; font-size: 15px; }
  .trail { padding: 90px 70px 10px 10px; }
  .trail-walker, .trail-goal { height: 86px; }
  .trail-track { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .slot { min-height: 54px; padding: 3px; }
  .slot-t { display: none; }
  .quiz-body { grid-template-columns: 1fr; min-height: 0; }
  .game-head .gh-text { order: 3; min-width: 100%; }
  .nav { position: sticky; bottom: 0; background: #fff; border-radius: 0 0 18px 18px; z-index: 5; }
  .q-opts { grid-template-columns: 1fr; }
  .quiz-guide { height: 150px; }
  .nav .btn { font-size: 1rem; padding: .5em .7em; }
}
