:root {
  --bg: #0e0c1d; --bg2: #17142c; --card: rgba(22, 20, 44, .86); --line: rgba(255, 255, 255, .12);
  --tx: #f4f2ff; --mut: #a9a4c9; --acc: #8b6cff; --acc2: #ff7ac6; --good: #2ed69a; --bad: #ff5d73; --gold: #ffcb47;
  --mc: #8b6cff; --r: 18px;
  --fh: 'Fredoka', 'Nunito', system-ui, sans-serif; --fb: 'Nunito', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx); font-family: var(--fb); font-size: 16px; overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
h1, h2, h3, h4 { font-family: var(--fh); margin: 0 0 .4em; font-weight: 600; }
p { line-height: 1.5; }
.hidden { display: none !important; }
.dim { opacity: .25; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.row.end { justify-content: flex-end; } .row.center { justify-content: center; } .row.between { justify-content: space-between; }

/* ---------- Buttons ---------- */
.btn { padding: 11px 18px; border-radius: 14px; font-weight: 800; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); transition: transform .12s, background .2s, box-shadow .2s; }
.btn:hover:not(:disabled) { transform: translateY(-2px); background: rgba(255, 255, 255, .14); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--acc), var(--acc2)); border: 0; box-shadow: 0 6px 20px -6px var(--acc); color: #fff; }
.btn.primary:disabled { filter: grayscale(.8) brightness(.7); box-shadow: none; }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(255, 93, 115, .15); color: #ffb3bf; border-color: rgba(255, 93, 115, .4); }
.btn.big { padding: 15px 26px; font-size: 1.1rem; border-radius: 18px; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); font-size: 1.15rem; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: rgba(255, 255, 255, .16); }
.pill { padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); font-weight: 800; font-size: .9rem; white-space: nowrap; }
.pill.coins { color: var(--gold); }

/* ---------- Art layers ---------- */
.art-layer, .art, .intro-art, .mc-art { position: absolute; inset: 0; overflow: hidden; container-type: size; --u: 1cqh; }
.bg-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.deco { position: absolute; transform: translate(-50%, -50%); line-height: 1; pointer-events: none; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); user-select: none; }
.dimmed::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14, 12, 29, .55), rgba(14, 12, 29, .25) 40%, rgba(14, 12, 29, .75)); }
.twinkle { animation: twinkle 3s ease-in-out infinite; }
.pulse { animation: pulse 3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.drift { animation: drift 60s linear infinite alternate; }
.drift-loop { animation: driftLoop 320s linear infinite; }
.rain { animation: rain .6s linear infinite; }
.wave { animation: wave 6s ease-in-out infinite alternate; }
.wave.slow { animation-duration: 9s; animation-direction: alternate-reverse; }
.beam { animation: beam 6s ease-in-out infinite alternate; transform-origin: top center; transform-box: fill-box; }
.flicker { animation: flicker 2.2s infinite; }
.sway-svg { animation: swaysvg 6s ease-in-out infinite alternate; transform-origin: top; }
.an-swing { animation: swing 3s ease-in-out infinite alternate; transform-origin: top center; }
.an-float { animation: float 4s ease-in-out infinite; }
.an-bob { animation: bob 3.5s ease-in-out infinite; }
.an-sway { animation: sway 5s ease-in-out infinite alternate; transform-origin: bottom center; }
.an-flicker { animation: flickerE 1.4s infinite; }
.an-pulse { animation: pulseE 2.4s ease-in-out infinite; }
.an-twinkle { animation: twinkleE 2s ease-in-out infinite; }
.an-blink { animation: blink 5s infinite; }
.deco .flip { display: inline-block; transform: scaleX(-1); }
.an-fly { animation: fly 14s linear infinite; }
.an-drive { animation: drive 12s linear infinite; }
.an-drive2 { animation: drive2 16s linear infinite; }
.an-steam { animation: float 3s ease-in-out infinite; }
.an-idle { animation: bob 5s ease-in-out infinite; }
.an-flash { animation: flash 3.5s infinite; }
@keyframes twinkle { 50% { opacity: .15; } }
@keyframes pulse { 50% { transform: scale(1.04); } }
@keyframes drift { to { transform: translateX(-160px); } }
@keyframes driftLoop { to { transform: translateX(-1600px); } }
@keyframes rain { to { transform: translate(-8px, 26px); } }
@keyframes wave { to { transform: translateX(-90px); } }
@keyframes beam { from { transform: skewX(-6deg); } to { transform: skewX(6deg); } }
@keyframes flicker { 0%, 100% { opacity: .9; } 45% { opacity: .65; } 50% { opacity: 1; } 70% { opacity: .75; } }
@keyframes swaysvg { to { transform: skewX(2deg); } }
@keyframes swing { from { transform: translate(-50%, -50%) rotate(-6deg); } to { transform: translate(-50%, -50%) rotate(6deg); } }
@keyframes float { 50% { transform: translate(-50%, -62%); } }
@keyframes bob { 0%, 100% { transform: translate(-50%, -50%) rotate(-2deg); } 50% { transform: translate(-50%, calc(-50% - var(--u) * .7)) rotate(2deg); } }
@keyframes sway { from { transform: translate(-50%, -50%) rotate(-4deg); } to { transform: translate(-50%, -50%) rotate(4deg); } }
@keyframes flickerE { 0%, 100% { transform: translate(-50%, -50%) scale(1); filter: drop-shadow(0 0 18px #ff9b2f); } 50% { transform: translate(-50%, -50%) scale(1.08, .94); filter: drop-shadow(0 0 30px #ffb347); } }
@keyframes pulseE { 50% { transform: translate(-50%, -50%) scale(1.1); filter: drop-shadow(0 0 22px rgba(255, 255, 255, .7)); } }
@keyframes twinkleE { 50% { opacity: .2; transform: translate(-50%, -50%) scale(.7); } }
@keyframes blink { 0%, 92%, 100% { transform: translate(-50%, -50%) scaleY(1); } 95% { transform: translate(-50%, -50%) scaleY(.85); } }
@keyframes fly { 0% { left: var(--from, -10%); opacity: var(--fade, 1); } 8%, 92% { opacity: 1; } 100% { left: var(--to, 110%); opacity: var(--fade, 1); } }
@keyframes drive { from { left: -10%; } to { left: 110%; } }
@keyframes drive2 { from { left: 110%; } to { left: -10%; } }
@keyframes flash { 0%, 88%, 100% { filter: none; } 90% { filter: brightness(3) drop-shadow(0 0 30px #fff); } }

/* ---------- Title ---------- */
.screen { min-height: 100vh; position: relative; }
.title-screen { display: grid; place-items: center; overflow: hidden; height: 100vh; padding: 16px; }
.title-card { position: relative; z-index: 2; background: var(--card); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 28px; padding: 34px 32px; max-width: 520px; width: 100%; text-align: center; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7); animation: rise .7s cubic-bezier(.2, 1.3, .4, 1); }
.logo { margin: 0; line-height: 0; }
.logo img { display: block; width: min(420px, 78vw); height: auto; margin: 0 auto; }
.tagline { color: var(--mut); margin: 14px 0; }
.tagline b { color: var(--tx); }
.genre-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 22px; }
.genre-row span { padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .07); font-weight: 700; font-size: .85rem; }
.title-card .btn { width: 100%; margin-top: 10px; }
.name-in, .search { width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, .3); color: var(--tx); font: inherit; font-size: 1.05rem; outline: none; }
.name-in:focus, .search:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(139, 108, 255, .3); }
.foot { font-size: .8rem; color: var(--mut); margin: 16px 0 0; }
@keyframes rise { from { opacity: 0; transform: translateY(30px) scale(.96); } }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: rgba(14, 12, 29, .8); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.logo-sm { display: block; height: 28px; width: auto; }
.player { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 0; }
.rank-badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; background: linear-gradient(135deg, var(--acc), var(--acc2)); flex: none; }
.pname { font-weight: 800; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rname { color: var(--gold); }
.xpbar { width: 150px; max-width: 30vw; height: 6px; border-radius: 9px; background: rgba(255, 255, 255, .1); margin: 4px 0 2px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--acc2)); border-radius: 9px; }
.xptxt { font-size: .72rem; color: var(--mut); }
.stats { display: flex; gap: 8px; align-items: center; }

/* ---------- Hub ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.wrap.narrow { max-width: 760px; }
.hello h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin-bottom: 4px; }
.hello p { color: var(--mut); margin-top: 0; }
.hand-wave { display: inline-block; animation: wavehand 2s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes wavehand { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20%, 40% { transform: rotate(-8deg); } }
.missions { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin: 20px 0 28px; }
.mcard { text-align: left; border-radius: 22px; overflow: hidden; background: var(--bg2); border: 1px solid var(--line); transition: transform .25s, box-shadow .25s; display: flex; flex-direction: column; animation: rise .6s backwards; }
.mcard:nth-child(2) { animation-delay: .08s; } .mcard:nth-child(3) { animation-delay: .16s; } .mcard:nth-child(4) { animation-delay: .24s; }
.mcard:hover { transform: translateY(-6px) rotate(-.4deg); box-shadow: 0 20px 40px -14px var(--mc); }
.mcard.locked { filter: grayscale(.7) brightness(.7); }
.mc-art { position: relative; height: 150px; inset: auto; }
.mc-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, var(--bg2)); }
.mc-icon { position: absolute; left: 16px; bottom: 6px; font-size: 3rem; z-index: 2; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .5)); transition: transform .3s; }
.mcard:hover .mc-icon { transform: scale(1.15) rotate(-6deg); }
.lvl { position: absolute; right: 12px; top: 12px; z-index: 2; background: rgba(0, 0, 0, .55); padding: 4px 10px; border-radius: 99px; font-weight: 800; font-size: .78rem; }
.mc-body { padding: 4px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.mc-genre { color: var(--mc); font-weight: 800; text-transform: uppercase; font-size: .75rem; letter-spacing: 1.5px; filter: brightness(1.4); }
.mc-body h3 { font-size: 1.3rem; margin: 2px 0 6px; }
.mc-body p { color: var(--mut); font-size: .9rem; margin: 0 0 10px; }
.mc-gram { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.mc-gram span { font-size: .72rem; padding: 3px 8px; border-radius: 8px; background: rgba(255, 255, 255, .06); color: #d7d2f5; }
.mc-foot { margin-top: auto; font-size: .82rem; color: var(--mut); }
.lockmsg { color: var(--gold); font-weight: 700; }
.pbar { height: 8px; border-radius: 9px; background: rgba(255, 255, 255, .1); overflow: hidden; margin-bottom: 6px; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mc, var(--acc)), var(--acc2)); border-radius: 9px; transition: width .4s; }
.tools-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.tcard { display: flex; gap: 14px; align-items: center; text-align: left; padding: 16px; border-radius: 18px; background: var(--bg2); border: 1px solid var(--line); transition: transform .2s; }
.tcard:hover { transform: translateY(-3px); border-color: var(--acc); }
.t-ic { font-size: 2.2rem; }
.tcard h4 { margin: 0; font-size: 1.1rem; } .tcard p { margin: 2px 0 0; color: var(--mut); font-size: .85rem; }

/* ---------- Mission map ---------- */
.mapscreen { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.map-area { position: relative; flex: 1; overflow: hidden; }
.map-title { position: absolute; left: 22px; top: 18px; z-index: 3; max-width: 520px; background: rgba(14, 12, 29, .6); backdrop-filter: blur(8px); padding: 14px 18px; border-radius: 18px; border: 1px solid var(--line); }
.map-title h2 { font-size: 1.6rem; margin: 2px 0 4px; } .map-title p { margin: 0; color: #d4cfee; font-size: .9rem; }
.mt-genre { font-weight: 800; color: var(--gold); font-size: .8rem; letter-spacing: 1px; text-transform: uppercase; }
.trail-svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.trail-svg path { fill: none; stroke: rgba(255, 255, 255, .5); stroke-width: .5; stroke-dasharray: 1.4 1.4; vector-effect: non-scaling-stroke; stroke-width: 4; }
.node { position: absolute; z-index: 2; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.n-num { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; background: radial-gradient(circle at 30% 30%, #fff3, transparent 60%), var(--mc); border: 4px solid #fff; box-shadow: 0 10px 24px rgba(0, 0, 0, .5), inset 0 -6px 0 rgba(0, 0, 0, .2); transition: transform .2s; }
.node:hover .n-num { transform: scale(1.1); }
.node.locked .n-num { background: #3a3650; border-color: #6a6585; font-size: 1.5rem; }
.node.done .n-num { border-color: var(--gold); }
.node.current .n-num { animation: nodePulse 1.6s infinite; }
@keyframes nodePulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .6), 0 10px 24px rgba(0, 0, 0, .5); } 50% { box-shadow: 0 0 0 16px rgba(255, 255, 255, 0), 0 10px 24px rgba(0, 0, 0, .5); } }
.n-stars { color: var(--gold); font-size: 1.05rem; letter-spacing: 1px; min-height: 1.1em; text-shadow: 0 2px 6px #000; }
.n-name { font-weight: 800; font-size: .85rem; background: rgba(0, 0, 0, .65); padding: 4px 10px; border-radius: 10px; white-space: nowrap; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(6, 5, 15, .7); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fade .25s; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 24px; padding: 24px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: rise .4s cubic-bezier(.2, 1.3, .4, 1); }
.modal.small { max-width: 460px; }
.modal.intro { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.intro-art { position: relative; height: 200px; inset: auto; flex: none; }
.intro-badge { position: absolute; left: 16px; top: 14px; background: rgba(0, 0, 0, .6); padding: 5px 12px; border-radius: 99px; font-weight: 800; font-size: .8rem; }
.intro-body { padding: 20px 24px 24px; overflow: auto; }
.intro-body p { color: #d7d2f0; }
.goal-box { background: rgba(255, 203, 71, .1); border: 1px solid rgba(255, 203, 71, .35); padding: 10px 14px; border-radius: 12px; font-size: .92rem; }
.kinds { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.kinds span { font-size: .78rem; padding: 4px 9px; border-radius: 8px; background: rgba(255, 255, 255, .07); text-transform: capitalize; }
.best { margin: 10px 0 0; } .best .stars { color: var(--gold); }
.big-emoji { font-size: 4rem; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
.col-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }

/* ---------- Play stage ---------- */
.screen.play { height: 100vh; overflow: hidden; background: #000; }
.stage { position: absolute; inset: 0; overflow: hidden; }
.stage .art { inset: auto; left: 50%; top: 50%; width: max(100vw, 177.78vh); height: max(100vh, 56.25vw); transform: translate(calc(-50% + var(--px, 0) * -14px), calc(-50% + var(--py, 0) * -10px)) scale(1.03); transition: transform .4s ease-out; }
.spots { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.spots.active { pointer-events: auto; }
.spot { position: absolute; transform: translate(-50%, -50%); line-height: 1; padding: 8px; border-radius: 50%; transition: transform .2s; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .5)); animation: spotIn .5s backwards; }
.spot::after { content: ''; position: absolute; inset: 10%; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, .0); transition: border-color .2s; }
.spot:hover { transform: translate(-50%, -50%) scale(1.18); }
.spot:hover::after { border-color: rgba(255, 255, 255, .7); }
.spot.seen { opacity: .85; }
.spot.found::before { content: '✓'; position: absolute; right: 0; top: 0; font-size: 14px; width: 22px; height: 22px; border-radius: 50%; background: var(--good); color: #fff; display: grid; place-items: center; font-weight: 900; }
.spot.reveal span { display: inline-block; animation: reveal 1s ease-in-out infinite; }
@keyframes reveal { 50% { filter: drop-shadow(0 0 16px #fff) drop-shadow(0 0 30px var(--gold)); transform: scale(1.15); } }
@keyframes spotIn { from { opacity: 0; transform: translate(-50%, -30%) scale(.5); } }
.spots.active .spot:not(.seen) span { display: inline-block; animation: shimmer 3s ease-in-out infinite; }
@keyframes shimmer { 0%, 85%, 100% { filter: none; } 90% { filter: brightness(1.6) drop-shadow(0 0 10px #fff8); } }

.hud { position: absolute; z-index: 10; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: linear-gradient(180deg, rgba(0, 0, 0, .6), transparent); }
.hud-title { display: flex; flex-direction: column; min-width: 0; text-shadow: 0 2px 6px #000; }
.hud-title small { color: #d9d4f7; font-size: .75rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-title b { font-family: var(--fh); font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-prog { flex: 1; height: 10px; border-radius: 9px; background: rgba(255, 255, 255, .18); overflow: hidden; min-width: 60px; }
.hud-prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--good), #a6ffcf); border-radius: 9px; transition: width .5s; }
.hearts { display: flex; gap: 2px; font-size: 1.3rem; filter: drop-shadow(0 2px 4px #000); }
.hearts .lost { filter: grayscale(1) brightness(.5); transform: scale(.8); display: inline-block; transition: .3s; }
.hearts.hit { animation: hit .5s; }
@keyframes hit { 25% { transform: scale(1.3) rotate(-8deg); } 75% { transform: scale(.9) rotate(5deg); } }
.toolbar { position: absolute; z-index: 10; right: 14px; top: 74px; display: flex; flex-direction: column; gap: 8px; }
.tool { position: relative; width: 50px; height: 50px; border-radius: 15px; font-size: 1.5rem; background: rgba(20, 18, 40, .78); border: 1px solid var(--line); backdrop-filter: blur(6px); transition: transform .15s; }
.tool:hover:not(:disabled) { transform: scale(1.1); border-color: var(--gold); }
.tool:disabled { opacity: .4; }
.tool .cnt { position: absolute; right: -4px; bottom: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--acc); font-size: .72rem; font-weight: 900; display: grid; place-items: center; padding: 0 5px; }
.tool.empty .cnt { background: #555; }

.actor { position: absolute; z-index: 6; left: max(16px, calc(50% - 560px)); bottom: calc(min(50vh, 440px) + 4px); pointer-events: none; opacity: 0; transform: translateY(40px); transition: opacity .35s, transform .45s cubic-bezier(.2, 1.4, .4, 1); }
.actor.show { opacity: 1; transform: none; }
.screen.play:has(.panel.t-directions) .actor { display: none; }
.avatar { font-size: clamp(4rem, 14vh, 8.5rem); line-height: 1; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .6)); transform-origin: bottom center; }
.actor.talk .avatar { animation: talk .3s ease-in-out infinite; }
.scene-actor span { display: inline-block; transform-origin: bottom center; animation: spotIn .5s backwards; }
.scene-actor.talk span { animation: talk .3s ease-in-out infinite; }
@keyframes talk { 50% { transform: scaleY(1.05) translateY(-4px); } }

.panel { position: absolute; z-index: 8; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(780px, calc(100vw - 28px)); max-height: min(50vh, 440px); overflow: auto; background: var(--card); backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 22px; padding: 18px 20px; box-shadow: 0 20px 60px -10px rgba(0, 0, 0, .7); }
.panel.enter { animation: panelIn .4s cubic-bezier(.2, 1.2, .4, 1); }
.panel.shake { animation: shake .4s; }
@keyframes panelIn { from { opacity: 0; transform: translate(-50%, 20px); } }
@keyframes shake { 20%, 60% { transform: translateX(calc(-50% - 8px)); } 40%, 80% { transform: translateX(calc(-50% + 8px)); } }
.panel.t-investigate { max-height: 34vh; }
.panel.t-directions { max-height: calc(100vh - 90px); width: min(880px, calc(100vw - 28px)); }
.nametag { display: inline-flex; align-items: center; gap: 6px; font-family: var(--fh); font-weight: 600; font-size: 1rem; padding: 4px 12px; border-radius: 10px; background: var(--mc); margin-bottom: 8px; box-shadow: 0 4px 12px -4px var(--mc); }
.nametag small { font-family: var(--fb); opacity: .8; font-size: .75rem; }
.line { font-size: 1.12rem; margin: 4px 0 8px; line-height: 1.55; }
.line.narration { font-style: italic; color: #e3defa; }
.q { font-weight: 800; margin: 8px 0 10px; font-size: 1.02rem; }
.q.small { font-size: .85rem; color: var(--mut); margin-bottom: 2px; }
.hint-line { color: var(--mut); font-size: .9rem; margin: -4px 0 8px; }
.gl { border-bottom: 2px dashed var(--gold); cursor: help; color: #ffe39a; font-weight: 700; }
.gl-pop { position: fixed; z-index: 200; max-width: 300px; background: #fff; color: #1b1733; padding: 10px 14px; border-radius: 12px; font-size: .92rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: rise .25s; }
.gl-pop small { display: block; color: #7a6ac9; margin-top: 4px; font-weight: 700; }

.opts { display: grid; gap: 8px; }
.opts.chips { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.opt { text-align: left; padding: 12px 16px; border-radius: 14px; background: rgba(255, 255, 255, .07); border: 2px solid rgba(255, 255, 255, .1); font-weight: 700; transition: transform .12s, background .2s, border-color .2s; }
.opts.chips .opt { text-align: center; }
.opt:hover:not(:disabled) { background: rgba(255, 255, 255, .14); border-color: var(--acc); transform: translateX(3px); }
.opt.right { background: rgba(46, 214, 154, .2); border-color: var(--good); animation: pop .3s; }
.opt.wrong { background: rgba(255, 93, 115, .15); border-color: var(--bad); text-decoration: line-through; opacity: .7; }
.opt.struck { opacity: .3; text-decoration: line-through; }
.gapline { font-size: 1.25rem; }
.blank { display: inline-block; min-width: 90px; text-align: center; border-bottom: 3px solid var(--acc); color: var(--mut); padding: 0 6px; }
.blank.filled { color: var(--good); border-color: var(--good); font-weight: 800; animation: pop .3s; }
.fb { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 14px; margin-top: 12px; font-size: .95rem; line-height: 1.45; animation: rise .3s; }
.fb > span { font-weight: 900; font-size: 1.1rem; }
.fb.good { background: rgba(46, 214, 154, .14); border: 1px solid rgba(46, 214, 154, .45); }
.fb.bad { background: rgba(255, 93, 115, .12); border: 1px solid rgba(255, 93, 115, .45); }
.board { background: #3b2b1c; border: 6px solid #6b4a2a; border-radius: 12px; padding: 10px; margin: 6px 0 4px; display: flex; flex-wrap: wrap; gap: 8px; }
.board-title { width: 100%; font-weight: 800; color: #ffe2b0; font-size: .85rem; }
.pin { background: #fff8d6; color: #3b2b1c; font-size: .82rem; font-weight: 700; padding: 6px 10px; border-radius: 4px; transform: rotate(-1deg); box-shadow: 2px 3px 0 rgba(0, 0, 0, .3); }
.pin:nth-child(odd) { transform: rotate(1.2deg); background: #ffe0ec; }

.listen-box { display: flex; align-items: center; gap: 14px; margin: 6px 0; }
.play-big { width: 70px; height: 70px; border-radius: 50%; font-size: 1.9rem; background: linear-gradient(135deg, var(--acc), var(--acc2)); box-shadow: 0 8px 24px -6px var(--acc); transition: transform .15s; }
.play-big:hover { transform: scale(1.08); }
.wave-anim { display: flex; gap: 4px; align-items: center; height: 36px; }
.wave-anim i { width: 6px; height: 8px; border-radius: 4px; background: var(--acc2); opacity: .5; }
.wave-anim.on i { animation: eq .5s ease-in-out infinite alternate; opacity: 1; }
.wave-anim i:nth-child(2) { animation-delay: .1s; } .wave-anim i:nth-child(3) { animation-delay: .2s; } .wave-anim i:nth-child(4) { animation-delay: .3s; } .wave-anim i:nth-child(5) { animation-delay: .15s; }
@keyframes eq { to { height: 34px; } }
.transcript { background: rgba(255, 255, 255, .06); border-left: 3px solid var(--acc2); padding: 8px 12px; border-radius: 8px; font-style: italic; animation: rise .3s; }

.built { min-height: 58px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px; border-radius: 14px; border: 2px dashed rgba(255, 255, 255, .2); margin-bottom: 10px; }
.built.ok { border-color: var(--good); background: rgba(46, 214, 154, .1); }
.built .ph { color: var(--mut); font-size: .9rem; }
.end-p { font-weight: 900; font-size: 1.2rem; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.tile { padding: 9px 14px; border-radius: 12px; background: #f4f1ff; color: #1d1840; font-weight: 800; box-shadow: 0 4px 0 #b9b0e6; transition: transform .1s; animation: pop .25s; }
.tile:hover:not(:disabled) { transform: translateY(-3px); }
.tile:active { transform: translateY(2px); box-shadow: 0 1px 0 #b9b0e6; }
.tile.in { background: var(--acc); color: #fff; box-shadow: 0 4px 0 #5a40c8; }
.lock-card { display: flex; gap: 14px; align-items: center; background: rgba(0, 0, 0, .25); padding: 12px 16px; border-radius: 14px; }
.lock-icon { font-size: 2.6rem; }
.lock-icon.emo-big { font-size: 4rem; line-height: 1.1; }
.slots { display: flex; gap: 6px; justify-content: center; margin: 14px 0; flex-wrap: wrap; }
.slots.shake { animation: shakeS .4s; }
@keyframes shakeS { 25%, 75% { transform: translateX(-8px); } 50% { transform: translateX(8px); } }
.slot { width: 42px; height: 50px; border-radius: 10px; background: rgba(0, 0, 0, .35); border: 2px solid rgba(255, 255, 255, .2); display: grid; place-items: center; font-family: var(--fh); font-size: 1.5rem; font-weight: 600; }
.slot.given { border-color: var(--gold); color: var(--gold); }
.slots.ok .slot { border-color: var(--good); background: rgba(46, 214, 154, .2); animation: pop .3s; }
.letters { justify-content: center; }
.tile.letter { width: 44px; height: 46px; padding: 0; font-family: var(--fh); font-size: 1.3rem; }

.match { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }
.match .col { display: flex; flex-direction: column; gap: 8px; }
.m-item { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .07); border: 2px solid rgba(255, 255, 255, .1); font-weight: 700; text-align: left; font-size: .92rem; transition: .15s; }
.L .m-item { font-family: var(--fh); font-size: 1.02rem; }
.m-item:hover:not(:disabled) { border-color: var(--acc); }
.m-item.sel { border-color: var(--gold); background: rgba(255, 203, 71, .15); transform: scale(1.02); }
.m-item.paired { border-color: var(--good); background: rgba(46, 214, 154, .15); opacity: .75; }
.m-item.wrong { border-color: var(--bad); animation: shakeS .4s; }
.m-item.nudge { animation: shakeS .3s; }
.match.has-pics { grid-template-columns: 1fr 1.4fr; align-items: start; }
.match .col.pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.m-item.pic { font-size: 3.6rem; line-height: 1; text-align: center; padding: 12px 6px; aspect-ratio: 1; display: grid; place-items: center; }
.m-item.pic.sel { transform: scale(1.06); }
/* Pictures inside tasks: emoji in answers, cards and buttons are shown big for young learners. */
.emo { font-size: 1.6em; line-height: 1; vertical-align: -0.2em; display: inline-block; margin: 0 .08em; }
.chip .emo { font-size: 1.5em; }
.opts.pics { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.opts.pics .opt { text-align: center; aspect-ratio: 1; display: grid; place-items: center; padding: 8px; }
.opts.pics .opt .emo { font-size: 3.4rem; margin: 0; vertical-align: 0; }
.opts.pics .opt:hover:not(:disabled) { transform: scale(1.04); }
.sort-card .emo { display: block; font-size: 3.6rem; margin: 0 auto 6px; }
.sort-card.pic { padding: 10px 24px; min-width: 160px; }
.sort-card.pic .emo { font-size: 5rem; }
.bucket .emo { font-size: 1.8em; }
.dc-t .emo { font-size: 1.5em; }

.sort-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 6px 0 14px; }
.sort-card { min-width: 240px; max-width: 100%; padding: 18px 24px; border-radius: 16px; background: #fff; color: #1d1840; font-weight: 800; font-size: 1.15rem; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.sort-card.pop { animation: pop .3s; }
.sort-card.fly-0 { transition: .4s; transform: translate(-120px, 60px) scale(.4) rotate(-12deg); opacity: 0; }
.sort-card.fly-1 { transition: .4s; transform: translate(120px, 60px) scale(.4) rotate(12deg); opacity: 0; }
.sort-count { color: var(--mut); font-size: .8rem; font-weight: 700; }
.buckets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bucket { padding: 16px 10px; border-radius: 16px; font-weight: 900; font-family: var(--fh); font-size: 1.05rem; border: 2px solid; display: flex; flex-direction: column; gap: 6px; align-items: center; transition: transform .15s; }
.bucket:hover { transform: translateY(-3px); }
.bucket.b0 { background: rgba(139, 108, 255, .18); border-color: var(--acc); }
.bucket.b1 { background: rgba(255, 122, 198, .15); border-color: var(--acc2); }
.bucket.glow { animation: reveal 0.7s 2; }
.pile { min-height: 10px; letter-spacing: 2px; color: var(--gold); font-size: .9rem; }

.inv-head { display: flex; align-items: center; gap: 10px; }
.inv-head .q { flex: 1; margin: 0; }
.inv-ic { font-size: 1.7rem; }
.counter { font-family: var(--fh); font-weight: 600; font-size: 1.2rem; padding: 4px 12px; border-radius: 10px; background: rgba(255, 203, 71, .15); color: var(--gold); }
.clue-card { display: flex; gap: 14px; align-items: flex-start; background: #fffaf0; color: #2a2240; border-radius: 14px; padding: 12px 14px; margin-top: 10px; box-shadow: 0 8px 20px rgba(0, 0, 0, .3); }
.clue-card.pop { animation: pop .3s; }
.cc-e { font-size: 3.6rem; line-height: 1; }
.cc-w { font-family: var(--fh); font-size: 1.25rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.cc-d { font-size: .86rem; color: #6d6490; font-style: italic; }
.cc-c { margin-top: 4px; font-weight: 700; }
.clue-card .gl { color: #8a5a00; }
.tag { font-family: var(--fb); font-size: .65rem; font-weight: 900; padding: 2px 7px; border-radius: 6px; background: var(--bad); color: #fff; letter-spacing: 1px; }
.mini-say { font-size: 1rem; padding: 2px 6px; border-radius: 8px; background: rgba(0, 0, 0, .06); }
.found-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { padding: 5px 10px; border-radius: 99px; background: rgba(46, 214, 154, .15); border: 1px solid rgba(46, 214, 154, .4); font-size: .82rem; font-weight: 700; }

.decision-tag { display: inline-block; font-weight: 900; font-size: .75rem; letter-spacing: 2px; color: var(--gold); padding: 3px 10px; border: 1px solid var(--gold); border-radius: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.dcard { text-align: left; padding: 14px; border-radius: 16px; background: linear-gradient(160deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .03)); border: 2px solid rgba(255, 255, 255, .14); transition: transform .15s, border-color .2s; display: flex; flex-direction: column; gap: 6px; }
.dcard:hover:not(:disabled) { transform: translateY(-4px); border-color: var(--gold); }
.dcard:disabled { opacity: .45; }
.dc-t { font-family: var(--fh); font-size: 1.15rem; font-weight: 600; }
.dc-d { color: var(--mut); font-size: .88rem; flex: 1; }
.dc-cost { font-weight: 900; color: var(--gold); font-size: .9rem; }

.dir-wrap { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(200px, 1fr); gap: 14px; align-items: center; }
.dmap { width: 100%; max-height: 52vh; }
.streets { fill: #3d4354; }
.blk { fill: #6a7a99; }
.blk.lm { fill: #8a6cff; }
.dir-wrap.cave .streets { fill: #2a2235; } .dir-wrap.cave .blk { fill: #4e4236; } .dir-wrap.cave .blk.lm { fill: #7a5e2a; }
.lm-e { font-size: 30px; text-anchor: middle; dominant-baseline: middle; }
.lm-t { font-size: 8px; fill: #fff; text-anchor: middle; font-weight: 800; font-family: var(--fb); }
.trail { fill: none; stroke: var(--gold); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 2 8; opacity: .8; }
.me { transition: transform .3s ease; }
.me-c { fill: var(--acc2); stroke: #fff; stroke-width: 3; }
.me-a { fill: #fff; }
.goal { fill: none; stroke: var(--good); stroke-width: 4; animation: pulse 1s infinite; transform-box: fill-box; transform-origin: center; }
.dpad { display: flex; flex-direction: column; gap: 8px; }
.dpad .btn { width: 100%; }
.dpad .row { margin-top: 0; flex-wrap: nowrap; }
.dir-status { font-size: .9rem; color: var(--mut); }
.dir-status b { color: var(--tx); }

/* ---------- Results ---------- */
.result h2 { margin-top: 6px; }
.res-stars { display: flex; justify-content: center; gap: 8px; font-size: 3rem; margin: 6px 0 14px; }
.res-stars span { color: #3a3650; }
.res-stars span.on { color: var(--gold); animation: starIn .6s cubic-bezier(.2, 1.8, .4, 1) backwards; text-shadow: 0 0 20px rgba(255, 203, 71, .6); }
@keyframes starIn { from { transform: scale(0) rotate(-120deg); } }
.res-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.res-grid div { background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 10px 4px; }
.res-grid b { display: block; font-family: var(--fh); font-size: 1.35rem; color: var(--gold); }
.res-grid small { color: var(--mut); font-size: .72rem; }
.new-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.new-words span { padding: 4px 10px; border-radius: 99px; background: rgba(139, 108, 255, .2); font-weight: 700; font-size: .85rem; }
.rankup, .mission-done { margin-top: 12px; padding: 10px; border-radius: 12px; background: linear-gradient(135deg, rgba(255, 203, 71, .25), rgba(255, 122, 198, .2)); font-weight: 800; animation: pop .5s; }
.mission-done { margin: 0 0 6px; font-family: var(--fh); font-size: 1.2rem; }
.tip-line { color: var(--mut); font-size: .88rem; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; z-index: 300; top: 70px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #fff; color: #1d1840; padding: 10px 16px; border-radius: 14px; font-weight: 800; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: rise .3s; transition: .4s; font-size: .92rem; text-align: center; }
.toast.gold { background: linear-gradient(135deg, #ffe08a, #ffc24a); }
.toast.out { opacity: 0; transform: translateY(-10px); }

/* ---------- Plain pages ---------- */
.plain { background: radial-gradient(1200px 600px at 20% -10%, rgba(139, 108, 255, .25), transparent), radial-gradient(900px 500px at 100% 0, rgba(255, 122, 198, .15), transparent), var(--bg); }
.sub { color: var(--mut); margin-top: 0; }
.lab-top { display: flex; justify-content: space-between; align-items: baseline; }
.lab-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 22px; padding: 22px; margin-top: 16px; text-align: center; animation: rise .35s; }
.lab-card .opts { text-align: left; }
.lab-q { font-size: 1.3rem; font-weight: 800; padding: 12px; }
.lab-q.word { font-family: var(--fh); font-size: 2.2rem; color: var(--gold); }
.lab-play { margin: 10px auto; display: block; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.shop-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 18px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.shop-card p { color: var(--mut); font-size: .88rem; flex: 1; margin: 4px 0; }
.s-ic { font-size: 3rem; }
.own { font-size: .85rem; margin-bottom: 8px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip-btn { padding: 7px 12px; border-radius: 99px; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); font-weight: 700; font-size: .85rem; }
.chip-btn.on { background: var(--acc); border-color: var(--acc); }
.words { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.wrow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line); }
.wrow .mini-say { background: rgba(255, 255, 255, .08); }
.ww { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ww b { font-family: var(--fh); font-size: 1.1rem; font-weight: 600; } .ww span { color: var(--mut); font-size: .88rem; }
.dots { display: flex; gap: 3px; } .dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .15); } .dots i.on { background: var(--good); }
.empty { color: var(--mut); text-align: center; padding: 30px; }
.tog { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 700; }
.tog.col { flex-direction: column; align-items: stretch; }
.tog input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--acc); }
.tog input[type=range] { accent-color: var(--acc); }
.stat-row { display: flex; justify-content: space-between; gap: 8px; margin: 14px 0; font-size: .85rem; color: var(--mut); }
.stat-row b { display: block; font-size: 1.2rem; color: var(--tx); }
.shake { animation: shakeS .4s; }

/* ---------- Narrow & portrait screens ---------- */
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .logo-sm, .xptxt { display: none; }
  .stats .pill:not(.coins) { display: none; }
  .map-title { left: 12px; right: 12px; top: 10px; padding: 10px 14px; }
  .map-title p { display: none; }
  .n-num { width: 58px; height: 58px; font-size: 1.6rem; }
  .n-name { font-size: .7rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .res-grid { grid-template-columns: repeat(2, 1fr); }
  .dir-wrap { grid-template-columns: 1fr; }
  .match, .match.has-pics { grid-template-columns: 1fr; }
  .match .col.pics { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .m-item.pic { font-size: 2.8rem; }
}
@media (max-aspect-ratio: 4/5) {
  /* Portrait: the scene sits on top as a 16:9 picture, the task panel fills the space below. */
  .screen.play { display: flex; flex-direction: column; overflow: auto; height: 100dvh; background: var(--bg); }
  .stage { position: relative; inset: auto; height: 56.25vw; flex: none; }
  .stage .art { width: 100vw; height: 56.25vw; transform: translate(-50%, -50%); }
  .hud { padding: 8px 10px; gap: 8px; }
  .hud-title small { display: none; }
  .hud-title b { font-size: .95rem; max-width: 30vw; }
  .hearts { font-size: 1rem; }
  .hud .pill { display: none; }
  .toolbar { position: static; flex-direction: row; justify-content: center; padding: 8px; gap: 10px; }
  .tool { width: 46px; height: 46px; }
  .actor { top: calc(56.25vw - 22vw); bottom: auto; left: 10px; }
  .avatar { font-size: 20vw; }
  .panel, .panel.t-investigate, .panel.t-directions { position: relative; left: auto; bottom: auto; transform: none; width: auto; max-height: none; margin: 0 10px 16px; overflow: visible; }
  .panel.enter { animation: fade .35s; }
  .panel.shake { animation: shakeS .4s; }
  .mapscreen .node .n-name { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* ---------- Heroes ---------- */
.modal.hero-modal { max-width: 720px; }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.hero-card { --hc: var(--acc); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 16px 12px; border-radius: 20px; background: linear-gradient(170deg, color-mix(in srgb, var(--hc) 28%, transparent), rgba(255, 255, 255, .03)); border: 2px solid color-mix(in srgb, var(--hc) 45%, transparent); transition: transform .2s, box-shadow .2s; }
.hero-card:hover, .hero-card.on { transform: translateY(-5px); box-shadow: 0 14px 30px -12px var(--hc); border-color: var(--hc); }
.h-av { font-size: 3.4rem; line-height: 1.1; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .4)); }
.hero-card b { font-family: var(--fh); font-size: 1.2rem; font-weight: 600; }
.hero-card small { color: var(--hc); font-weight: 800; filter: brightness(1.3); }
.hero-card p { color: var(--mut); font-size: .82rem; margin: 6px 0 0; line-height: 1.35; }
.hero-pill { position: relative; font-size: 1.1rem; padding: 3px 10px; }
.hero-pill .shield { position: absolute; right: -6px; bottom: -6px; font-style: normal; font-size: .8rem; }
.tog.between { justify-content: space-between; }
.test-badge { position: fixed; z-index: 400; left: 50%; bottom: 0; transform: translateX(-50%); background: #ffcb47; color: #1d1840; font-weight: 900; font-size: .75rem; padding: 4px 12px; border-radius: 10px 10px 0 0; pointer-events: none; }
@media (max-aspect-ratio: 4/5) { .hud .hero-pill { display: none; } }

/* ---------- Superhero art animations ---------- */
.bubble { animation: bubble 3.2s ease-in infinite; transform-box: fill-box; }
@keyframes bubble { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: .8; } 100% { transform: translateY(-180px); opacity: 0; } }
.bolt { opacity: 0; animation: bolt 7s infinite; }
.bolt-sky { opacity: 0; animation: boltSky 7s infinite; }
@keyframes bolt { 0%, 80%, 86%, 100% { opacity: 0; } 81%, 83% { opacity: 1; } 82% { opacity: .2; } }
@keyframes boltSky { 0%, 80%, 86%, 100% { opacity: 0; } 81%, 83% { opacity: .12; } }

/* ---------- Comic-book missions (mission `style: 'comic'`) ---------- */
:root { --fcomic: 'Bangers', 'Impact', system-ui, sans-serif; --fcap: 'Comic Neue', 'Comic Sans MS', var(--fb); --ink: #0b0a10; }
.st-comic .stage::after, .st-comic .intro-art::after, .mcard.st-comic .mc-art::after, .mapscreen.st-comic .art-layer::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(rgba(0, 0, 0, .5) 1px, transparent 1.7px) 0 0 / 6px 6px; mix-blend-mode: multiply; opacity: .45;
}
.mcard.st-comic .mc-art::after { background: radial-gradient(rgba(0, 0, 0, .25) 1px, transparent 1.7px) 0 0 / 6px 6px, linear-gradient(180deg, transparent 40%, var(--bg2)); mix-blend-mode: normal; opacity: 1; }
.st-comic .stage::after { box-shadow: inset 0 0 0 6px var(--ink); }
.st-comic .hud-title b, .mcard.st-comic h3, .mapscreen.st-comic .map-title h2, .modal.st-comic h2 { font-family: var(--fcomic); font-weight: 400; letter-spacing: 1px; }
.mcard.st-comic h3 { font-size: 1.45rem; }
.modal.st-comic .intro-badge { font-family: var(--fcomic); font-weight: 400; letter-spacing: 1px; background: #f5c518; color: var(--ink); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); transform: rotate(-3deg); }
.st-comic .panel { border: 3px solid var(--ink); border-radius: 6px; box-shadow: 8px 8px 0 var(--ink), 0 20px 60px -10px rgba(0, 0, 0, .7); }
.st-comic .nametag { font-family: var(--fcomic); font-weight: 400; letter-spacing: 1px; font-size: 1.15rem; color: var(--ink); border: 2px solid var(--ink); border-radius: 4px; box-shadow: 3px 3px 0 var(--ink); transform: rotate(-1.5deg); }
.st-comic .nametag small { font-family: var(--fcap); font-weight: 700; color: var(--ink); opacity: .75; }
/* Narration is a yellow caption box; character lines are speech bubbles pointing up at the speaker. */
.st-comic .line.narration { font-style: normal; font-family: var(--fcap); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; font-size: 1.02rem; color: #1a1408; background: #ffe680; border: 2px solid var(--ink); padding: 10px 14px; box-shadow: 4px 4px 0 var(--ink); }
.st-comic .t-say .line:not(.narration), .st-comic .t-choice > .line { position: relative; font-family: var(--fcap); font-weight: 700; color: #14121c; background: #fffdf6; border: 2px solid var(--ink); border-radius: 22px; padding: 10px 16px; margin-top: 14px; }
.st-comic .t-say .line:not(.narration)::before, .st-comic .t-choice > .line::before { content: ''; position: absolute; left: 26px; top: -9px; width: 16px; height: 16px; background: #fffdf6; border-left: 2px solid var(--ink); border-top: 2px solid var(--ink); transform: rotate(45deg) skew(12deg, 12deg); }
.st-comic .line .gl { color: #6a2bd8; border-bottom-color: #c58b00; }
.st-comic .line.narration .gl { color: #7a3d00; }
.burst { position: absolute; z-index: 3; width: calc(var(--u) * 30); aspect-ratio: 220 / 160; display: grid; place-items: center; pointer-events: none; transform: translate(-50%, -50%) rotate(var(--rot, -6deg)); animation: burstIn .45s cubic-bezier(.2, 1.6, .4, 1) both, burstOut .5s 2.4s ease-in forwards; }
.burst svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.burst polygon { fill: #ffd400; stroke: var(--ink); stroke-width: 6; stroke-linejoin: round; }
.burst b { position: relative; font-family: var(--fcomic); font-weight: 400; font-size: calc(var(--u) * 6.5); color: #e8202a; -webkit-text-stroke: 2px var(--ink); text-shadow: 3px 3px 0 var(--ink); letter-spacing: 1px; white-space: nowrap; }
@keyframes burstIn { from { transform: translate(-50%, -50%) rotate(var(--rot, -6deg)) scale(.2); opacity: 0; } }
@keyframes burstOut { to { transform: translate(-50%, -50%) rotate(var(--rot, -6deg)) scale(1.15); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .burst { animation: none; } }

/* ---------- Storybook Library (kids' series) ---------- */
.library { margin: 22px 0 8px; padding: 20px; border-radius: 28px; background: linear-gradient(160deg, rgba(255, 196, 120, .16), rgba(255, 120, 180, .1) 60%, rgba(120, 200, 255, .1)); border: 1px solid rgba(255, 210, 150, .3); }
.lib-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.lib-head h2 { font-family: var(--fh); font-size: 1.6rem; margin: 0; }
.lib-head p { margin: 4px 0 0; opacity: .8; }
.stickers { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-radius: 18px; background: rgba(0, 0, 0, .25); }
.stk { width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.6rem; border-radius: 50%; background: rgba(255, 255, 255, .08); border: 2px dashed rgba(255, 255, 255, .25); filter: grayscale(1); opacity: .45; }
.stk.on { filter: none; opacity: 1; border: 2px solid var(--gold, #ffd34d); background: rgba(255, 211, 77, .18); box-shadow: 0 0 14px rgba(255, 211, 77, .45); animation: pop .5s cubic-bezier(.2, 1.3, .4, 1); }
.shelf { margin: 16px 0 0; }
.mcard.book { border-radius: 26px; border: 2px solid color-mix(in srgb, var(--mc) 45%, transparent); }
.book-no { position: absolute; top: 10px; left: 10px; z-index: 2; background: var(--mc); color: #fff; font-weight: 900; font-size: .78rem; padding: 4px 10px; border-radius: 10px; box-shadow: 0 4px 10px rgba(0, 0, 0, .3); }
.sec-title { font-family: var(--fh); font-size: 1.4rem; margin: 26px 0 0; }

/* ---------- Keyboard shortcuts ---------- */
kbd { display: inline-block; min-width: 1.6em; padding: 2px 7px; border-radius: 7px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25); border-bottom-width: 3px; font: 800 .85em/1.3 ui-monospace, Menlo, monospace; text-align: center; }
.toast kbd { background: rgba(0, 0, 0, .08); border-color: rgba(0, 0, 0, .2); }
.keys-t { width: 100%; border-collapse: collapse; margin: 10px 0; }
.keys-t td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.keys-t td:first-child { width: 110px; white-space: nowrap; }

/* ---------- Full Pass ---------- */
.pass-badge { position: absolute; left: 10px; bottom: 12px; z-index: 2; background: linear-gradient(135deg, #ffcb47, #ff9f1c); color: #1d1840; font-weight: 900; font-size: .74rem; padding: 4px 10px; border-radius: 10px; box-shadow: 0 4px 10px rgba(0, 0, 0, .3); }
.pass-card { border-color: rgba(255, 203, 71, .45); background: linear-gradient(135deg, rgba(255, 203, 71, .14), var(--bg2) 60%); }
.pass-card:hover { border-color: var(--gold); }
.pass-card.on .t-ic { filter: drop-shadow(0 0 8px rgba(255, 203, 71, .6)); }
.node.pass .n-num { background: linear-gradient(135deg, #ffcb47, #ff9f1c); }
.pass { text-align: center; }
.pass-crown { font-size: 3rem; line-height: 1; filter: drop-shadow(0 6px 16px rgba(255, 203, 71, .5)); }
.pass h2 { margin: 6px 0 4px; }
.pass-perks { list-style: none; padding: 0; margin: 14px 0; text-align: left; display: grid; gap: 8px; }
.pass-perks li { background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 6px 0 4px; }
.plan { position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 14px; border-radius: 16px; background: var(--bg2); border: 1px solid var(--line); transition: transform .15s, border-color .2s; }
.plan:hover { transform: translateY(-3px); border-color: var(--acc); }
.plan.best { border-color: var(--gold); box-shadow: 0 10px 30px -14px var(--gold); }
.plan small { color: var(--mut); font-weight: 600; }
.plan-price { font-family: var(--fh); font-size: 1.5rem; font-weight: 600; }
.plan-price small { font-size: .8rem; }
.plan-month { color: var(--gold); font-weight: 800; font-size: .85rem; }
.plan-tag { position: absolute; top: -10px; right: 12px; background: var(--gold); color: #1d1840; font-size: .7rem; font-weight: 900; padding: 2px 8px; border-radius: 99px; }
.pass-note { color: var(--gold); font-weight: 700; }
.pass-fine { color: var(--mut); font-size: .78rem; margin: 12px 0 0; }
.pass-fine a, .foot.legal a { color: inherit; text-decoration: underline; }
.gate-q { font-family: var(--fh); font-size: 2rem; text-align: center; margin: 8px 0; }
.gate-in, .key-in { width: 100%; text-align: center; }
.key-in { font-family: ui-monospace, Menlo, monospace; font-size: .9rem; }
.key-err { color: var(--bad); font-weight: 700; min-height: 1.2em; margin: 8px 0 0; }
.foot.legal { margin-top: 4px; opacity: .8; }

/* ---------- Courses & Arabic script (js/lang.js) ---------- */
:root { --far: 'Noto Naskh Arabic', 'Geeza Pro', 'Arabic Typesetting', 'Traditional Arabic', serif; }
.ar { font-family: var(--far); font-size: 1.22em; line-height: 1.75; font-weight: 600; letter-spacing: 0; font-style: normal; }
.slot .ar, .tile.letter .ar { font-size: 1.15em; line-height: 1; }
.lab-q.word .ar, .spell-word .ar { line-height: 1.5; }
/* In the Arabic course every paragraph and button takes its direction from its first letter: Arabic lines run
   right to left and align right, English questions and explanations stay left to right. */
.course-ar :is(p, h1, h2, h3, h4, li, td, .opt, .tile, .m-item, .sort-card, .bucket, .dc-t, .dc-d, .fb > div, .pin, .cc-w, .cc-d, .cc-c, .ww b, .ww span, .lab-q, .chip, .new-words span) { unicode-bidi: plaintext; }
.course-ar :is(.panel p, .opt, .m-item:not(.pic), .fb > div, .ww b, .ww span, .cc-d, .cc-c) { text-align: start; }
.built[dir=rtl] .ph { direction: ltr; }
.tr-line { color: var(--mut); font-size: .9rem; margin: -2px 0 10px; line-height: 1.4; }
.transcript p { margin: 0; }
.transcript .tr-line { margin: 6px 0 0; font-style: normal; }
.spell-word { min-height: 1.6em; margin: -6px 0 10px; text-align: center; font-size: 1.9rem; color: var(--gold); }

.course-pill { cursor: pointer; }
.course-pill b { font-family: var(--fh); color: var(--gold); margin-right: 2px; }
.course-pill .ar { font-size: 1.05em; line-height: 1; }
.course-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 10px; }
.course-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 18px 14px; border-radius: 20px; background: linear-gradient(170deg, rgba(139, 108, 255, .22), rgba(255, 255, 255, .03)); border: 2px solid rgba(139, 108, 255, .35); transition: transform .2s, box-shadow .2s, border-color .2s; }
.course-card:hover, .course-card.on { transform: translateY(-4px); border-color: var(--acc); box-shadow: 0 14px 30px -12px var(--acc); }
.course-card .cc-badge { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: rgba(255, 255, 255, .1); font-family: var(--fh); font-size: 1.7rem; color: var(--gold); margin-bottom: 6px; }
.course-card b { font-family: var(--fh); font-size: 1.25rem; font-weight: 600; }
.course-card small { color: var(--mut); font-weight: 800; }
.course-card p { color: var(--mut); font-size: .84rem; margin: 6px 0; line-height: 1.35; }
.course-card .cc-meta { font-size: .8rem; font-weight: 800; color: var(--gold); }
.course-tip { display: flex; gap: 14px; align-items: center; padding: 12px 16px; margin: 4px 0 18px; border-radius: 16px; background: rgba(255, 203, 71, .08); border: 1px solid rgba(255, 203, 71, .25); }
.course-tip p { margin: 0; color: var(--mut); line-height: 1.45; }
.course-tip p b { color: var(--tx); }
.ct-badge { flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: rgba(255, 203, 71, .16); color: var(--gold); font-family: var(--fh); font-size: 1.3rem; }
@media (max-width: 640px) { .stats .pill.course-pill { display: inline-block; padding: 6px 9px; font-size: 0; } .course-pill b { font-size: .9rem; margin: 0; } }

/* ---------- First-run setup & level (js/onboarding.js) ---------- */
.modal.onb { max-width: 620px; }
.onb h2 { margin-top: 6px; }
.onb-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 8px; }
.onb-dots i { width: 28px; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .15); }
.onb-dots i.on { background: linear-gradient(90deg, var(--acc), var(--acc2)); }
.onb-intro { background: rgba(255, 203, 71, .1); border: 1px solid rgba(255, 203, 71, .3); border-radius: 12px; padding: 10px 14px; margin: 0 0 6px; }
.onb-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0 6px; }
.onb-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.onb-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 18px 10px; border-radius: 18px; background: rgba(255, 255, 255, .05); border: 2px solid var(--line); transition: transform .15s, border-color .15s, background .15s; }
.onb-card:hover, .onb-card.on { transform: translateY(-3px); border-color: var(--acc); background: rgba(139, 108, 255, .15); }
.onb-card b { font-family: var(--fh); font-size: 1.1rem; font-weight: 600; }
.onb-card small { color: var(--mut); font-weight: 700; }
.oc-e { font-size: 2.4rem; line-height: 1.2; }
.oc-e.badge { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; background: rgba(255, 255, 255, .08); font-family: var(--fh); font-size: 1.6rem; color: var(--gold); }
.onb-levels { display: grid; gap: 8px; margin: 12px 0 14px; }
.onb-level { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 14px; border-radius: 14px; background: rgba(255, 255, 255, .05); border: 2px solid var(--line); transition: border-color .15s, background .15s; }
.onb-level:hover, .onb-level.on { border-color: var(--acc); background: rgba(139, 108, 255, .15); }
.onb-level .ol-e { font-size: 1.6rem; }
.onb-level b { display: block; font-weight: 900; }
.onb-level small { color: var(--mut); }
.onb-level i { margin-left: auto; font-style: normal; font-family: var(--fh); font-weight: 600; color: var(--gold); }
.onb-test { width: 100%; }
.onb-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; min-height: 8px; }
.onb-skip { margin-left: auto; color: var(--mut); font-weight: 800; text-decoration: underline; padding: 6px; }
.onb-skip:hover { color: var(--tx); }
.onb-quiz .oq-top { display: flex; justify-content: space-between; font-weight: 900; color: var(--mut); margin-bottom: 8px; }
.onb-quiz .oq-q { font-size: 1.25rem; font-weight: 800; margin: 18px 0 12px; unicode-bidi: plaintext; }
.onb-quiz .opt { unicode-bidi: plaintext; text-align: start; }
.oq-note { color: var(--mut); font-size: .85rem; margin: 12px 0 0; }
.onb-result { text-align: center; }
@media (max-width: 560px) { .onb-grid { grid-template-columns: 1fr; } .onb-card { flex-direction: row; text-align: left; padding: 12px 14px; gap: 12px; } .onb-card .oc-e { font-size: 2rem; } .onb-card small { margin-left: auto; } }

/* “Start here” card and “Your level” badge on the hub */
.start-here { display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; padding: 14px 18px; margin: 0 0 18px; border-radius: 20px; background: linear-gradient(110deg, color-mix(in srgb, var(--mc) 35%, transparent), rgba(255, 255, 255, .04)); border: 2px solid color-mix(in srgb, var(--mc) 70%, transparent); box-shadow: 0 14px 34px -18px var(--mc); transition: transform .15s; }
.start-here:hover { transform: translateY(-2px); }
.sh-icon { font-size: 2.6rem; }
.sh-body { display: flex; flex-direction: column; min-width: 0; }
.sh-body small { color: var(--gold); font-weight: 900; text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; }
.sh-body b { font-family: var(--fh); font-size: 1.35rem; font-weight: 600; }
.sh-body span { color: var(--mut); font-weight: 700; font-size: .9rem; }
.start-here .btn { margin-left: auto; flex: none; }
.for-you { position: absolute; right: 10px; bottom: 12px; z-index: 2; background: var(--gold); color: #1b1733; font-weight: 900; font-size: .72rem; padding: 3px 9px; border-radius: 99px; box-shadow: 0 4px 10px rgba(0, 0, 0, .3); }
@media (max-width: 560px) { .start-here .btn { padding: 8px 12px; } .sh-icon { font-size: 2rem; } }
