/* Charles' Math Quest — styles. Deep navy and royal purple, jewel highlights, big and readable. */
:root {
  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --ink: #16133f; --ink2: #4b4f86; --muted: #c6ccff; --line: rgba(255, 255, 255, .14);
  --gold: #ffd24a; --gold2: #ffae00; --blue: #3b9cff; --green: #19c58c; --turq: #22d3ee; --pink: #f472b6; --red: #ff5f6d; --purple: #a855f7;
  --wc: #3b9cff; --wc2: #1d4ed8; --toph: 70px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Stop a downward swipe near the top from pull-to-refreshing the page
   mid-question, which would reload the game. */
html { overscroll-behavior-y: contain; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; overscroll-behavior-y: contain; font-family: var(--font); font-size: 18px; color: #fff; background: #0a0b26; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; text-wrap: balance; line-height: 1.1; }
p { margin: 0; text-wrap: pretty; line-height: 1.45; }
[hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 24px; height: 24px; flex: none; }
:focus { outline: none; }
:focus-visible { outline: 4px solid #fff; outline-offset: 4px; box-shadow: 0 0 0 9px rgba(255, 210, 74, .55) !important; border-radius: 14px; }
h1:focus, h2:focus, #screen:focus { outline: none; box-shadow: none !important; }
.booting, .noscript { display: grid; place-items: center; min-height: 80vh; font-weight: 800; font-size: 24px; }

/* ---------- background ---------- */
#bg { position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background:
    radial-gradient(1100px 700px at 8% -12%, rgba(98, 54, 220, .75), transparent 62%),
    radial-gradient(900px 620px at 104% 112%, rgba(20, 110, 200, .55), transparent 62%),
    radial-gradient(760px 520px at 78% 18%, color-mix(in srgb, var(--wc) 26%, transparent), transparent 70%),
    linear-gradient(180deg, #0d1140 0%, #0a0b26 70%); transition: background .6s; }
.stars { position: absolute; inset: -50%; opacity: .55;
  background-image: radial-gradient(1.6px 1.6px at 20px 30px, #fff, transparent 60%), radial-gradient(1.2px 1.2px at 140px 90px, #cfe3ff, transparent 60%), radial-gradient(2px 2px at 220px 170px, #fff, transparent 60%), radial-gradient(1px 1px at 60px 210px, #fff, transparent 60%), radial-gradient(1.4px 1.4px at 260px 40px, #ffe9a8, transparent 60%);
  background-size: 300px 260px; animation: drift 180s linear infinite; }
.stars.s2 { opacity: .3; background-size: 420px 380px; animation-duration: 260s; animation-direction: reverse; }
.float-gems i { position: absolute; width: 22px; height: 22px; transform: rotate(45deg); border-radius: 5px; opacity: .22; background: linear-gradient(135deg, #fff, var(--c, #7dd3fc)); box-shadow: 0 0 22px var(--c, #7dd3fc); animation: floaty 14s ease-in-out infinite; }
.float-gems i:nth-child(1) { left: 6%; top: 22%; --c: #3b9cff; }
.float-gems i:nth-child(2) { left: 88%; top: 30%; --c: #f472b6; animation-delay: -3s; width: 16px; height: 16px; }
.float-gems i:nth-child(3) { left: 14%; top: 78%; --c: #22c55e; animation-delay: -6s; }
.float-gems i:nth-child(4) { left: 70%; top: 84%; --c: #ffd24a; animation-delay: -9s; width: 14px; height: 14px; }
.float-gems i:nth-child(5) { left: 46%; top: 12%; --c: #a855f7; animation-delay: -4s; width: 12px; height: 12px; }
.float-gems i:nth-child(6) { left: 94%; top: 70%; --c: #22d3ee; animation-delay: -11s; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 60px; padding: 0 24px; border: 0; border-radius: 18px; cursor: pointer; color: #fff;
  font: 900 20px/1 var(--font); letter-spacing: .02em; text-transform: uppercase; text-decoration: none; position: relative; user-select: none;
  touch-action: manipulation; transition: transform .12s ease, box-shadow .18s ease, filter .18s ease; -webkit-tap-highlight-color: transparent; }
.btn .ic { width: 26px; height: 26px; }
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.07); }
.btn:active:not(:disabled) { transform: translateY(4px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold { color: #1a1147; background: linear-gradient(180deg, #ffe48a 0%, #ffc81f 52%, #ffab00 100%); box-shadow: 0 6px 0 #c98300, 0 14px 28px rgba(255, 186, 0, .32), inset 0 2px 0 rgba(255, 255, 255, .75); }
.btn-gold:active:not(:disabled) { box-shadow: 0 2px 0 #c98300, inset 0 2px 0 rgba(255, 255, 255, .75); }
.btn-glass { background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .22), 0 5px 0 rgba(3, 4, 30, .35); }
.btn-glass:hover:not(:disabled) { background: rgba(255, 255, 255, .16); }
.btn-blue { background: linear-gradient(180deg, #6cb8ff, #2f86f5); box-shadow: 0 6px 0 #1b56b8, 0 14px 26px rgba(59, 156, 255, .3), inset 0 2px 0 rgba(255, 255, 255, .45); }
.btn-green { background: linear-gradient(180deg, #4ee6b0, #16b37f); box-shadow: 0 6px 0 #0c7a56, 0 14px 26px rgba(25, 197, 140, .28), inset 0 2px 0 rgba(255, 255, 255, .45); }
.btn-red { background: linear-gradient(180deg, #ff8a95, #ff3f55); box-shadow: 0 6px 0 #b11a2e, 0 14px 26px rgba(255, 63, 85, .32), inset 0 2px 0 rgba(255, 255, 255, .45); }
.btn-pink { background: linear-gradient(180deg, #ff9fd0, #ec4d9c); box-shadow: 0 6px 0 #a3226a, 0 14px 26px rgba(244, 114, 182, .28), inset 0 2px 0 rgba(255, 255, 255, .45); }
.btn-danger { background: linear-gradient(180deg, #ff7a86, #e82b44); box-shadow: 0 6px 0 #9c1426; }
/* Locked used to desaturate the red button, which lands on brown. A cool
   slate reads as "not yet" without looking like mud. */
.btn.is-locked { filter: none; background: linear-gradient(180deg, #5b6784, #3c4660); box-shadow: 0 6px 0 #232a3d, inset 0 2px 0 rgba(255, 255, 255, .18); color: #c9d1e3; }
.btn-sm { min-height: 48px; padding: 0 16px; font-size: 16px; border-radius: 14px; }
.btn-sm .ic { width: 20px; height: 20px; }
.btn-md { min-height: 62px; font-size: 18px; }
.btn-lg { min-height: 70px; font-size: 22px; padding: 0 28px; }
.btn-xl { min-height: 80px; font-size: 26px; padding: 0 34px; border-radius: 22px; }
.btn-xl .ic { width: 32px; height: 32px; }
.btn-xxl { min-height: 100px; font-size: 30px; padding: 0 34px; border-radius: 26px; }
.btn-xxl .ic { width: 38px; height: 38px; }
.iconbtn { width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; color: #fff; background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .18); transition: background .2s, transform .12s; }
.iconbtn:hover { background: rgba(255, 255, 255, .2); }
.iconbtn[aria-pressed="false"] { color: #9aa1d6; }

/* ---------- cards ---------- */
.card { background: linear-gradient(160deg, rgba(64, 50, 168, .78), rgba(24, 20, 80, .9)); border: 1.5px solid rgba(255, 255, 255, .14); border-radius: 28px; box-shadow: 0 22px 50px rgba(3, 4, 30, .5), inset 0 1px 0 rgba(255, 255, 255, .14); }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.sec-head h2, .card > h2 { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 900; }
.sec-sub { color: var(--muted); font-weight: 700; font-size: 16px; }

/* ---------- sprites and speech ---------- */
.spr { display: block; width: auto; user-select: none; -webkit-user-drag: none; filter: drop-shadow(0 14px 14px rgba(0, 0, 0, .38)); }
.spr-missing { display: grid; place-items: center; align-content: center; gap: 4px; min-width: 110px; min-height: 130px; border-radius: 22px; background: rgba(255, 255, 255, .08); border: 2px dashed rgba(255, 255, 255, .35); color: #fff; text-align: center; padding: 8px; }
.spr-missing b { font-size: 44px; font-weight: 900; }
.spr-missing span { font-size: 13px; font-weight: 700; color: var(--muted); }
.bubble { position: relative; background: #fff; color: var(--ink); border-radius: 24px; padding: 18px 20px 15px; font-weight: 700; font-size: 19px; line-height: 1.38; max-width: 470px; box-shadow: 0 0 0 4px var(--cc, #a78bfa), 0 14px 28px rgba(0, 0, 0, .35); }
.bubble .btext { text-wrap: pretty; }
.bubble i { font-style: italic; color: #6b3fd6; }
.bname { position: absolute; top: -14px; left: 16px; background: var(--cc, #a78bfa); color: #fff; font: 900 13px/1 var(--font); letter-spacing: .1em; text-transform: uppercase; padding: 6px 11px; border-radius: 999px; box-shadow: 0 3px 0 rgba(0, 0, 0, .2); }
.bubble::after { content: ""; position: absolute; left: -12px; bottom: 18px; width: 22px; height: 22px; background: #fff; transform: rotate(45deg); box-shadow: -4px 4px 0 0 var(--cc, #a78bfa); border-radius: 0 0 0 5px; }
.pop { animation: pop .42s cubic-bezier(.2, .9, .3, 1.35) both; }
.bob { animation: bob 3.4s ease-in-out infinite; }
.bob2 { animation: bob 3.8s ease-in-out -1.2s infinite; }

/* ---------- top bar ---------- */
#top[hidden] { display: none; }
#top { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 14px; padding: 10px 20px; min-height: 70px;
  background: rgba(10, 11, 40, .78); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: #fff; cursor: pointer; font: 700 18px var(--font); padding: 6px 8px; border-radius: 12px; }
.brand b { font-weight: 900; color: var(--gold); }
.brand-gem { display: grid; filter: drop-shadow(0 0 8px rgba(255, 210, 74, .6)); }
.stats { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 14px; border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .15); font-weight: 800; font-size: 17px; white-space: nowrap; }
.pill .ic { width: 20px; height: 20px; color: var(--gold); }
.pill .of { color: var(--muted); font-size: 14px; }
.world-pill { border-color: color-mix(in srgb, var(--wc) 70%, transparent); background: color-mix(in srgb, var(--wc) 22%, transparent); }
.xp-lbl { font-size: 13px; color: var(--gold); letter-spacing: .06em; }
.xp-bar { width: 62px; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.xp-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ff9f1a); border-radius: 99px; }
.rank { color: var(--muted); font-size: 14px; font-weight: 700; }
.bump { animation: bump .5s ease; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.save-ind { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; font-size: 14px; font-weight: 800; color: var(--muted); background: rgba(255, 255, 255, .06); white-space: nowrap; }
.save-ind .ic { width: 18px; height: 18px; }
.save-ind.ok { color: #7ff0c3; background: rgba(25, 197, 140, .14); }
.save-ind.bad { color: #fff; background: #e82b44; animation: pulse 1.2s infinite; }
.save-ind.pulse { animation: savedPulse .7s ease; }

/* ---------- title ---------- */
.title-wrap { position: relative; min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; justify-items: center; align-items: center; gap: 12px; padding: 22px 16px 26px; overflow: hidden; }
.title-bg { position: absolute; inset: -60px; background-size: cover; background-position: center; filter: blur(30px) brightness(.5) saturate(1.35); transform: scale(1.08); z-index: 0; }
.logo, .title-art, .title-go { position: relative; z-index: 1; }
.logo { text-align: center; line-height: 1; animation: logoIn .9s cubic-bezier(.2, .9, .3, 1.2) both; }
.logo-top { font-weight: 900; font-size: clamp(22px, 3vw, 36px); letter-spacing: .28em; text-shadow: 0 4px 0 #3b1f8f, 0 8px 24px rgba(0, 0, 0, .5); margin-bottom: 2px; padding-left: .28em; }
.logo-main { font-weight: 900; font-size: clamp(50px, min(8vw, 11vh), 108px); letter-spacing: -.01em; background: linear-gradient(180deg, #fffbe0 0%, #ffe070 38%, #ffb400 70%, #ff8a00 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 5px 0 #5b21b6) drop-shadow(0 10px 0 #2e1065) drop-shadow(0 18px 24px rgba(0, 0, 0, .55)); }
.logo-sub { display: inline-block; margin-top: 12px; font-weight: 900; font-size: clamp(20px, 3.2vw, 38px); letter-spacing: .06em; color: #0b1033; padding: 8px 24px 10px; border-radius: 14px; background: linear-gradient(90deg, #5eead4, #38bdf8 50%, #818cf8); transform: rotate(-3deg); box-shadow: 0 6px 0 #1e40af, 0 14px 30px rgba(34, 211, 238, .35); }
.title-art img { display: block; max-height: 50vh; max-height: 50dvh; max-width: min(92vw, 880px); width: auto; border-radius: 28px; border: 4px solid rgba(255, 255, 255, .75); box-shadow: 0 0 0 10px rgba(255, 210, 74, .22), 0 30px 80px rgba(0, 0, 0, .6); animation: floatArt 7s ease-in-out infinite; }
.title-go { display: grid; justify-items: center; gap: 12px; }
.title-go .btn { animation: breathe 2.2s ease-in-out infinite; }
.loadbar { width: 220px; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .15); overflow: hidden; transition: opacity .6s; }
.loadbar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s; }
.loadbar.done { opacity: 0; }

/* ---------- intro comic ---------- */
.comic { max-width: 1120px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; gap: 16px; padding: 18px 20px 24px; }
.comic-top { display: flex; justify-content: space-between; align-items: center; }
.dots { display: flex; gap: 8px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, .2); }
.dots i.on { background: var(--gold); transform: scale(1.25); box-shadow: 0 0 12px var(--gold); }
.dots i.done { background: rgba(255, 255, 255, .6); }
.panel { position: relative; border-radius: 34px; border: 5px solid #fff; overflow: hidden; min-height: 460px; box-shadow: 0 30px 70px rgba(0, 0, 0, .5), inset 0 0 120px rgba(0, 0, 0, .25); background: radial-gradient(circle at 30% 70%, #3a4fd8, #1b1466 70%); display: grid; }
.panel-1 { background: radial-gradient(circle at 30% 70%, #7c3aed, #1e1060 70%); }
.panel-2 { background: radial-gradient(circle at 35% 65%, #ff5f6d, #6d1238 72%); }
.panel-3 { background: radial-gradient(circle at 30% 70%, #f472b6, #4a1567 72%); }
.panel-4 { background: radial-gradient(circle at 30% 70%, #22d3ee, #13306b 72%); }
.caption { position: absolute; top: 18px; left: 18px; z-index: 3; background: var(--gold); color: #1a1147; font-weight: 900; font-size: 20px; padding: 9px 16px; border-radius: 10px; transform: rotate(-2deg); box-shadow: 0 5px 0 #c98300; }
.panel-stage { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: end; gap: 20px; padding: 70px 34px 0; }
.panel-spr { max-height: min(56vh, 470px); max-width: 100%; justify-self: center; position: relative; z-index: 2; }
.panel-spr.enter { animation: enter .6s cubic-bezier(.2, .9, .3, 1.2) both; }
.panel-bubble { align-self: center; font-size: 26px; max-width: 520px; margin-bottom: 40px; z-index: 2; }
.flying-gems { position: absolute; left: 6%; bottom: 12%; width: 42%; height: 75%; z-index: 1; }
.flying-gems span { position: absolute; left: 50%; top: 50%; animation: orbit 3.2s linear infinite; animation-delay: calc(var(--k) * -.53s); }
.burst { position: absolute; left: -20%; top: -40%; width: 90%; height: 180%; background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, .16) 0 8deg, transparent 8deg 20deg); animation: spin 18s linear infinite; }
.comic-go { display: flex; justify-content: center; }

/* ---------- home ---------- */
.home { max-width: 1280px; margin: 0 auto; padding: 22px 24px 60px; display: grid; gap: 22px; }
.hero { position: relative; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); overflow: hidden; min-height: 420px;
  background: radial-gradient(circle at 78% 70%, color-mix(in srgb, var(--wc) 45%, transparent), transparent 55%), linear-gradient(160deg, rgba(70, 52, 180, .85), rgba(24, 20, 80, .92)); }
.hero-left { position: relative; z-index: 2; padding: 34px 36px; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.kicker { display: inline-flex; align-self: flex-start; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; letter-spacing: .08em; text-transform: uppercase; padding: 7px 14px; border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1.5px solid color-mix(in srgb, var(--wc) 70%, transparent); }
.hero h1 { font-weight: 900; font-size: clamp(44px, 5.4vw, 70px); letter-spacing: -.015em; text-shadow: 0 5px 0 rgba(20, 10, 70, .6); }
.hero h1 span { display: block; margin-top: 8px; font-size: .44em; letter-spacing: .03em; text-transform: uppercase; color: var(--gold); text-shadow: none; }
.gem-row { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 4px; }
.gem-row .g { display: grid; transition: transform .2s; }
.gem-row .g.mastered { filter: drop-shadow(0 0 7px var(--wc)); animation: gemGlow 3s ease-in-out infinite; }
.gem.dim { opacity: .3; filter: grayscale(.5); }
.gem-lbl { color: var(--muted); font-weight: 600; font-size: 17px; }
.gem-lbl b { color: #fff; font-weight: 900; }
.btn-xxl .cta { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; text-align: left; }
.btn-xxl .cta small { font-size: 15px; font-weight: 800; text-transform: none; letter-spacing: 0; opacity: .78; }
#continueBtn { align-self: flex-start; margin-top: 8px; }
.hero-stage { position: relative; min-height: 400px; }
.stage-glow { position: absolute; left: 10%; right: 10%; bottom: -10%; height: 70%; border-radius: 50%; background: radial-gradient(ellipse, rgba(255, 255, 255, .22), transparent 65%); }
.hero-charles { position: absolute; bottom: 0; left: 6%; height: 94%; max-width: 50%; object-fit: contain; object-position: bottom; }
.hero-buddy { position: absolute; bottom: 0; right: 3%; height: 74%; max-width: 46%; object-fit: contain; object-position: bottom; }
.hero-buddy.zeus { height: 50%; max-width: 48%; }
.hero-buddy.angel { height: 78%; }
.hero-bubble { position: absolute; top: 22px; right: 16px; max-width: min(340px, 62%); font-size: 18px; z-index: 3; }
.hero-bubble::after { left: auto; right: 40px; bottom: -10px; transform: rotate(-45deg); box-shadow: -4px 4px 0 0 var(--cc); }
.acts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.act { position: relative; display: grid; grid-template-rows: auto auto 1fr auto; gap: 6px; text-align: left; color: #fff; padding: 22px 22px 20px; min-height: 200px; cursor: pointer; overflow: hidden; border-top: 6px solid var(--ac); transition: transform .15s, box-shadow .2s; }
.act::before { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--ac) 50%, transparent), transparent 70%); }
.act:hover:not(.locked) { transform: translateY(-4px); box-shadow: 0 0 0 3px var(--ac), 0 26px 50px rgba(3, 4, 30, .55); }
.act-ic { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--ac); color: #fff; box-shadow: 0 6px 0 rgba(0, 0, 0, .25); }
.act-ic .ic { width: 34px; height: 34px; }
.act-title { font-weight: 900; font-size: 30px; letter-spacing: .01em; margin-top: 8px; }
.act-desc { color: var(--muted); font-weight: 600; font-size: 17px; }
.act-meta { justify-self: start; font-size: 14px; font-weight: 800; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .1); }
.act.locked { filter: saturate(.55); }
.act.locked .act-ic { background: #4a4f8a; }
.map { padding: 22px 24px 18px; }
.islands { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px 14px; padding-top: 6px; }
.isle { position: relative; display: grid; justify-items: center; gap: 2px; background: none; border: 0; color: #fff; cursor: pointer; padding: 6px 4px 10px; border-radius: 20px; font-family: var(--font); animation: isleFloat 6s ease-in-out infinite; animation-delay: calc(var(--i) * -.6s); }
.isle:nth-child(even) { margin-top: 26px; }
.isle-art { width: 100%; max-width: 150px; display: block; transition: transform .2s, filter .2s; }
.isle-art svg { width: 100%; height: auto; display: block; }
.isle:hover .isle-art { transform: scale(1.06); filter: drop-shadow(0 0 16px var(--wc)); }
.isle-num { font-weight: 900; font-size: 22px; color: var(--wc); text-shadow: 0 2px 0 rgba(0, 0, 0, .4); margin-top: -6px; }
.isle-name { font-weight: 700; font-size: 14px; color: var(--muted); text-align: center; line-height: 1.2; max-width: 160px; text-wrap: balance; }
.isle-bar { width: 70%; height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .14); overflow: hidden; margin-top: 4px; }
.isle-bar i { display: block; height: 100%; background: var(--wc); border-radius: 99px; }
.isle.locked { cursor: not-allowed; }
.isle.locked .isle-num { color: #6b72b3; }
.isle.cur .isle-art { filter: drop-shadow(0 0 18px var(--wc)); }
.isle.cur::before { content: ""; position: absolute; left: 50%; top: 38%; width: 130px; height: 50px; transform: translate(-50%, 0); border-radius: 50%; border: 3px solid var(--wc); animation: ring 2s ease-out infinite; }
.you { font-size: 11px; font-weight: 900; letter-spacing: .1em; background: var(--gold); color: #1a1147; padding: 4px 8px; border-radius: 999px; margin-top: 4px; }
.isle.unlocking .isle-art { animation: unlockPop 1.4s cubic-bezier(.2, .9, .3, 1.3) .4s both; }
.home-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tile { display: flex; align-items: center; gap: 14px; padding: 18px; text-align: left; color: #fff; min-height: 100px; cursor: pointer; font-family: var(--font); transition: transform .15s; flex-wrap: wrap; }
div.tile { cursor: default; }
button.tile:hover:not([aria-disabled]) { transform: translateY(-3px); }
.tile b { display: block; font-size: 19px; font-weight: 900; }
.tile small { display: block; color: var(--muted); font-size: 15px; font-weight: 600; margin-top: 3px; }
.tile > span:nth-child(2) { flex: 1; min-width: 140px; }
.tile-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: rgba(255, 255, 255, .12); flex: none; }
.tile-ic.gold { background: linear-gradient(180deg, #ffe48a, #ffae00); color: #1a1147; }
.tile-btns { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.tile-btns .btn { flex: 1 1 110px; min-height: 48px; padding: 0 12px; font-size: 15px; }
.tile[aria-disabled] { opacity: .75; }

/* ---------- world title card ---------- */
.world-card { max-width: 1180px; margin: 0 auto; padding: 20px 24px 50px; display: grid; gap: 18px; }
.wc-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.wc-gems { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.wc-gems span:last-child { margin-left: 10px; font-weight: 800; color: var(--muted); font-size: 16px; }
.wc-title { text-align: center; display: grid; justify-items: center; gap: 8px; }
.wc-num { font-weight: 900; font-size: 18px; letter-spacing: .2em; padding: 8px 18px 8px 22px; border-radius: 999px; background: var(--wc); box-shadow: 0 5px 0 var(--wc2), 0 0 30px color-mix(in srgb, var(--wc) 60%, transparent); }
.wc-title h1 { font-weight: 900; font-size: clamp(36px, 5.2vw, 64px); text-shadow: 0 5px 0 rgba(20, 10, 70, .6); animation: logoIn .7s cubic-bezier(.2, .9, .3, 1.2) both; }
.wc-done { display: inline-flex; gap: 8px; align-items: center; font-weight: 800; color: #7ff0c3; }
.wc-scene { position: relative; border-radius: 30px; overflow: hidden; min-height: 330px; padding: 26px 26px 120px; border: 2px solid rgba(255, 255, 255, .16);
  background: radial-gradient(circle at 80% 0%, color-mix(in srgb, var(--wc) 55%, transparent), transparent 55%), linear-gradient(180deg, color-mix(in srgb, var(--wc) 28%, #1b1566), #110e40); }
.scenery { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 150px; }
.story { position: relative; z-index: 1; display: grid; gap: 16px; max-width: 860px; margin: 0 auto; }
.story-row { display: flex; align-items: flex-end; gap: 14px; animation: rise .55s cubic-bezier(.2, .9, .3, 1.2) both; animation-delay: var(--d); }
.story-row:nth-child(even) { flex-direction: row-reverse; }
.story-row:nth-child(even) .bubble::after { left: auto; right: -12px; box-shadow: 4px -4px 0 0 var(--cc); }
.story-spr { height: 160px; max-width: 190px; object-fit: contain; object-position: bottom; flex: none; }
.story-bubble { font-size: 18px; }
.wc-bottom { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.wc-boss { display: flex; align-items: center; gap: 16px; padding: 12px 20px 12px 12px; border-radius: 24px; background: rgba(255, 95, 109, .12); border: 2px solid rgba(255, 95, 109, .4); }
.wc-boss-art { width: 110px; height: 110px; flex: none; }
.wc-boss-art svg { width: 100%; height: 100%; }
/* A sealed boss used to be painted solid black, which on a dark card was an
   unreadable blob. Now it is dimmed and desaturated with a bright outline in
   the world's colour, so the shape reads and it still looks locked. */
.wc-boss.sealed .wc-boss-art { filter: saturate(.25) brightness(.62) contrast(1.08) drop-shadow(0 0 2px var(--wc)) drop-shadow(0 0 12px var(--wc)); opacity: .95; }
.wc-boss.sealed { position: relative; }
.wc-boss.sealed::after { content: "🔒"; position: absolute; left: 92px; top: 10px; font-size: 20px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
.wc-boss .lbl, .lbl { font-size: 12px; font-weight: 900; letter-spacing: .14em; color: #ff8a95; }
.wc-boss b { display: block; font-size: 22px; font-weight: 900; }
.wc-boss small { display: block; color: var(--muted); font-weight: 600; font-size: 15px; margin-top: 2px; }
.wc-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- mode screens (learn / practice / boss) ---------- */
.mode { max-width: 1280px; margin: 0 auto; padding: 16px 24px 40px; }
.mode-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.mode-title { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 28px; }
.mode-title .ic { width: 30px; height: 30px; color: var(--gold); }
.play-grid { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 26px; align-items: start; }
.guide-box { position: sticky; top: 92px; }
.guide { display: grid; justify-items: center; gap: 16px; }
.guide-bubble { font-size: 18px; }
.guide-bubble::after { left: 50%; bottom: -10px; margin-left: -11px; transform: rotate(-45deg); box-shadow: -4px 4px 0 0 var(--cc); }
.guide-spr { max-height: 330px; max-width: 100%; object-fit: contain; }
.guide-spr.zeus { max-height: 240px; }

/* chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.chip { min-width: 46px; height: 42px; padding: 0 8px; border-radius: 12px; border: 2px solid transparent; background: rgba(255, 255, 255, .08); color: #fff; font: 800 16px var(--font); cursor: pointer; position: relative; }
.chip.seen { background: rgba(255, 255, 255, .16); }
.chip.mastered { border-color: var(--wc); box-shadow: inset 0 -4px 0 var(--wc); }
.chip.on { background: #fff; color: var(--ink); transform: translateY(-2px); }
.chip.focus::after { content: ""; position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--pink); border: 2px solid #0a0b26; }

/* flashcards */
.flash-col { display: grid; gap: 18px; justify-items: center; }
.flash { position: relative; width: 100%; max-width: 820px; height: clamp(400px, 54vh, 540px); perspective: 1800px; cursor: pointer; border-radius: 34px; }
.flash .face { position: absolute; inset: 0; border-radius: 34px; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .65s cubic-bezier(.3, .7, .3, 1.1); }
.flash .front { display: grid; place-items: center; align-content: center; gap: 4px; background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--wc) 55%, #3b2aa8), #1a1466 75%); border: 4px solid rgba(255, 255, 255, .7); box-shadow: 0 10px 0 rgba(0, 0, 0, .22), 0 30px 60px rgba(0, 0, 0, .4), inset 0 0 90px rgba(255, 255, 255, .08); }
.flash .back { transform: rotateY(180deg); background: #fff; color: var(--ink); border: 4px solid var(--gold); box-shadow: 0 10px 0 rgba(0, 0, 0, .22), 0 30px 60px rgba(0, 0, 0, .4); padding: 22px 26px; overflow-y: auto; display: grid; align-content: start; gap: 12px; justify-items: center; }
.flash.flipped .front { transform: rotateY(-180deg); }
.flash.flipped .back { transform: rotateY(0deg); }
.card-tag { position: absolute; top: 18px; left: 20px; display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.eq { font-weight: 900; font-size: clamp(90px, 13vw, 160px); line-height: 1; letter-spacing: -.02em; text-shadow: 0 8px 0 rgba(0, 0, 0, .28); }
.eq span, .q span { color: var(--gold); }
.eq-q { font-weight: 900; font-size: clamp(54px, 7vw, 80px); color: var(--gold); line-height: 1; }
.flip-hint { position: absolute; bottom: 18px; display: flex; gap: 8px; align-items: center; color: var(--muted); font-weight: 700; font-size: 16px; }
.mast { position: absolute; top: 16px; right: 18px; display: flex; gap: 6px; align-items: center; font-weight: 800; font-size: 14px; color: #0b3b2a; background: #7ff0c3; padding: 6px 12px; border-radius: 999px; }
.eq-full { font-weight: 900; font-size: clamp(44px, 6vw, 64px); letter-spacing: -.01em; }
.eq-full b { background: var(--gold); padding: 0 14px; border-radius: 14px; box-shadow: 0 4px 0 #c98300; }
.zeus-guess { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: var(--ink2); background: #f2f3ff; border-radius: 14px; padding: 6px 14px 6px 6px; }
.zg-spr { height: 54px; width: 54px; object-fit: cover; object-position: 50% 10%; border-radius: 50%; background: #ffe7c7; filter: none; }
.zeus-guess s { color: #e11d48; font-weight: 800; }
.zeus-guess b { color: var(--ink); }
.learn-btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.read { justify-self: center; }
.learn-done, .summary, .bossfail { display: grid; place-items: center; min-height: calc(100vh - 110px); min-height: calc(100dvh - 110px); }
.done-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px; align-items: center; padding: 30px 36px; max-width: 900px; }
.done-card h1 { font-size: 44px; font-weight: 900; }
.done-card p { color: var(--muted); font-size: 20px; margin: 10px 0 18px; }
.done-spr { height: 280px; }
.done-btns { display: flex; gap: 12px; flex-wrap: wrap; }

/* explanations */
.explain { display: grid; gap: 12px; justify-items: center; text-align: center; width: 100%; }
.ex-words { font-weight: 700; font-size: 20px; color: var(--ink2); text-wrap: balance; }
.ex-words b { color: var(--ink); }
.groups { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 100%; }
.groups.none { font-weight: 800; color: var(--ink2); background: #f2f3ff; padding: 14px 20px; border-radius: 16px; }
.grp { display: grid; grid-template-columns: repeat(var(--cols), var(--dot)); gap: 3px; padding: 6px; border-radius: 12px; background: color-mix(in srgb, var(--gc) 12%, #fff); border: 2.5px solid var(--gc); animation: popIn .35s both; }
.grp i { width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--gc); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18); }
.ex-add { font-weight: 800; font-size: 20px; color: var(--ink); max-width: 100%; overflow-wrap: anywhere; }
.ex-add span { color: var(--ink2); font-weight: 700; }
.ex-add b { font-size: 1.25em; }
.skip { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.skip span { min-width: 44px; height: 38px; padding: 0 6px; border-radius: 10px; background: #eef0ff; color: var(--ink); font-weight: 800; font-size: 18px; display: grid; place-items: center; }
.skip span.hit { background: var(--gold); box-shadow: 0 3px 0 #c98300; }
.ex-flip { font-weight: 700; font-size: 15px; color: var(--ink2); }
.ex-tip { display: flex; gap: 10px; align-items: flex-start; text-align: left; background: #fff4c6; color: var(--ink); border-radius: 16px; padding: 10px 14px; font-weight: 700; font-size: 16px; max-width: 640px; }
.ex-tip .ic { color: #e89b00; width: 22px; height: 22px; margin-top: 1px; }
.explain.compact { gap: 8px; }
.explain.compact .grp { --dot: 9px; }
.explain.compact .ex-words, .explain.compact .ex-add { font-size: 17px; }
.explain.compact .skip span { min-width: 36px; height: 32px; font-size: 15px; }

/* practice */
.setup-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 26px; align-items: center; }
.setup-guide .guide-spr { max-height: 360px; }
.setup-main { display: grid; gap: 18px; }
.setup-sub { font-size: 20px; color: var(--muted); font-weight: 600; }
.sizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.size { display: grid; justify-items: center; gap: 6px; padding: 26px 16px; color: #fff; cursor: pointer; font-family: var(--font); border-top: 6px solid var(--ac); transition: transform .15s, box-shadow .2s; }
.size:hover { transform: translateY(-4px); box-shadow: 0 0 0 3px var(--ac), 0 26px 50px rgba(3, 4, 30, .55); }
.size-ic { width: 70px; height: 70px; border-radius: 22px; display: grid; place-items: center; background: var(--ac); color: #1a1147; }
.size-ic .ic { width: 36px; height: 36px; }
.size b { font-size: 26px; font-weight: 900; }
.size small { font-size: 16px; color: var(--muted); font-weight: 600; }
.setrow.inline { border: 0; justify-content: flex-start; flex-wrap: wrap; }
.progress { display: flex; gap: 6px; flex: 1; justify-content: center; flex-wrap: wrap; }
.progress i { width: 30px; height: 12px; border-radius: 99px; background: rgba(255, 255, 255, .15); transition: background .3s; }
.progress i.ok { background: var(--green); }
.progress i.no { background: #ff8a95; }
.progress i.cur { background: var(--gold); animation: pulse 1.4s ease-in-out infinite; }
.progress .count { font-weight: 800; color: var(--muted); }
.streak { display: flex; align-items: center; gap: 4px; min-width: 64px; color: #ffb020; font-weight: 900; font-size: 24px; }
.streak .ic { width: 28px; height: 28px; animation: flame .6s ease-in-out infinite alternate; }
.qa { display: grid; gap: 18px; width: 100%; max-width: 840px; min-width: 0; justify-self: center; }
.qcard { background: linear-gradient(170deg, #ffffff, #eef1ff); color: var(--ink); border-radius: 32px; padding: 20px 26px 30px; text-align: center; border: 5px solid var(--wc); box-shadow: 0 10px 0 rgba(0, 0, 0, .2), 0 30px 60px rgba(0, 0, 0, .35); }
.qcard.enter { animation: cardIn .45s cubic-bezier(.2, .9, .3, 1.2) both; }
.q-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.q-tag { font-weight: 900; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: var(--wc); padding: 7px 14px; border-radius: 999px; }
.pips { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; color: var(--ink2); }
.pips i { width: 16px; height: 16px; border-radius: 50%; background: #dfe3ff; box-shadow: inset 0 0 0 2px #c3c9f0; }
.pips i.on { background: var(--wc); box-shadow: 0 0 8px var(--wc); }
.pips.done { color: #0f8f64; font-weight: 800; }
.q { font-weight: 900; font-size: clamp(56px, 7.6vw, 108px); line-height: 1.05; letter-spacing: -.02em; margin-top: 10px; white-space: nowrap; }
.q span { color: #6c73c2; }
.q .eqs { color: #9aa1d6; }
.slot { display: inline-block; min-width: 1.4em; padding: 0 .12em; border-radius: 20px; background: #eef0ff; color: var(--ink) !important; border: 5px dashed #c3c9f0; line-height: 1.1; }
.slot.typing { border-color: var(--wc); border-style: solid; }
.slot.right { background: var(--green); color: #fff !important; border: 5px solid #0f9e6f; animation: popIn .4s both; }
.slot.shown { background: var(--gold); border: 5px solid #e0a800; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.answers.three { grid-template-columns: repeat(3, 1fr); }
.ans { position: relative; touch-action: manipulation; min-height: 112px; border: 0; border-radius: 26px; cursor: pointer; font: 900 clamp(46px, 6vw, 66px)/1 var(--font); color: var(--ink); background: linear-gradient(180deg, #fff, #e8ebff); box-shadow: 0 8px 0 #9aa3e0, 0 16px 30px rgba(0, 0, 0, .3); transition: transform .12s, box-shadow .15s, background .2s; -webkit-tap-highlight-color: transparent; }
.ans kbd { position: absolute; top: 10px; left: 12px; font: 800 14px var(--font); color: #6c73c2; background: #eef0ff; border-radius: 8px; padding: 3px 8px; }
.ans:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 11px 0 #9aa3e0, 0 0 0 5px var(--gold), 0 18px 34px rgba(0, 0, 0, .3); }
.ans:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 3px 0 #9aa3e0; }
.ans:disabled { cursor: default; }
.ans.right { background: linear-gradient(180deg, #45e8ad, #16b37f); color: #fff; box-shadow: 0 8px 0 #0c7a56, 0 0 0 6px rgba(25, 197, 140, .35); animation: popIn .4s both; }
.ans.right kbd { background: rgba(255, 255, 255, .25); color: #fff; }
.ans.wrong { background: linear-gradient(180deg, #ffd6da, #ffb7be); color: #8a1426; box-shadow: 0 8px 0 #e08b96; }
.ans.stolen { animation: stolen 1.4s ease-in-out; }
.shake { animation: shake .45s ease; }
.feedback { background: #fff; color: var(--ink); border-radius: 28px; padding: 20px 22px; display: grid; gap: 14px; justify-items: center; border: 5px solid var(--gold); box-shadow: 0 20px 40px rgba(0, 0, 0, .35); animation: rise .4s cubic-bezier(.2, .9, .3, 1.2) both; }
.fb-head { display: flex; gap: 14px; align-items: baseline; justify-content: center; flex-wrap: wrap; text-align: center; }
.fb-ans { font-weight: 900; font-size: 38px; }
.fb-ans b { background: var(--gold); padding: 0 12px; border-radius: 12px; }
.fb-you { font-weight: 700; font-size: 17px; color: var(--ink2); max-width: 520px; }
.typepad { display: grid; justify-items: center; }
.pad { display: grid; grid-template-columns: repeat(3, 100px); gap: 12px; }
.padk { touch-action: manipulation; height: 80px; border: 0; border-radius: 22px; background: linear-gradient(180deg, #fff, #e8ebff); color: var(--ink); font: 900 36px var(--font); cursor: pointer; box-shadow: 0 6px 0 #9aa3e0; display: grid; place-items: center; transition: transform .1s; }
.padk:active { transform: translateY(4px); box-shadow: 0 2px 0 #9aa3e0; }
.padk .ic { width: 32px; height: 32px; }
.padk.ok { background: linear-gradient(180deg, #45e8ad, #16b37f); color: #fff; box-shadow: 0 6px 0 #0c7a56; }
.padk.del { background: linear-gradient(180deg, #ffe6e9, #ffd0d6); color: #8a1426; box-shadow: 0 6px 0 #e3a0a9; }
.bonus { padding: 22px; display: grid; gap: 18px; border: 3px solid var(--gold); animation: cardIn .45s both; }
.bonus-head { display: flex; gap: 16px; align-items: center; }
.bonus-spr { height: 120px; flex: none; }
.bonus-tag { font-weight: 900; font-size: 14px; letter-spacing: .12em; color: var(--gold); margin-bottom: 6px; }
.bonus h2 { font-size: 26px; font-weight: 800; line-height: 1.3; }
.bonus-foot { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
.bonus-res { font-weight: 800; font-size: 20px; }

/* summary */
.sum-card { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 26px; align-items: center; padding: 30px; max-width: 1060px; width: 100%; }
.sum-stage { display: grid; justify-items: center; gap: 16px; }
.sum-bubble::after { left: 50%; bottom: -10px; margin-left: -11px; transform: rotate(-45deg); box-shadow: -4px 4px 0 0 var(--cc); }
.sum-bubble { order: -1; }
.sum-spr { max-height: 320px; max-width: 100%; object-fit: contain; }
.sum-main { display: grid; gap: 16px; }
.sum-main h1 { font-size: clamp(40px, 5vw, 58px); font-weight: 900; background: linear-gradient(180deg, #fffbe0, #ffd24a 50%, #ff9f1a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 0 #5b21b6); }
.sum-main > p { color: var(--muted); font-size: 19px; }
.stars { display: flex; gap: 10px; }
.star .ic { width: 60px; height: 60px; color: rgba(255, 255, 255, .2); fill: rgba(255, 255, 255, .08); }
.star.on .ic { color: #ffae00; fill: var(--gold); filter: drop-shadow(0 0 12px rgba(255, 210, 74, .8)); animation: starIn .5s cubic-bezier(.2, .9, .3, 1.5) both; animation-delay: calc(var(--i) * .25s + .2s); }
.sum-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.sum-stats div { background: rgba(255, 255, 255, .08); border-radius: 18px; padding: 12px 8px; text-align: center; }
.sum-stats b { display: block; font-size: 30px; font-weight: 900; color: var(--gold); }
.sum-stats span { font-size: 14px; font-weight: 700; color: var(--muted); }
.sum-gems { display: flex; gap: 12px; flex-wrap: wrap; }
.sg { display: grid; justify-items: center; font-weight: 800; font-size: 13px; animation: popIn .4s both; }
.sum-prog { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.sum-prog span { margin-left: 10px; color: var(--muted); font-weight: 700; }
.sum-prog b { color: #fff; }
.sum-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.missed { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.miss { background: #fff; color: var(--ink); border-radius: 18px; padding: 12px 14px; border-left: 6px solid var(--gold); }
.miss b { display: block; font-size: 24px; font-weight: 900; }
.miss small { display: block; color: var(--ink2); font-weight: 600; font-size: 14px; margin-top: 2px; }

/* boss */
.boss-intro { position: relative; min-height: calc(100vh - 90px); min-height: calc(100dvh - 90px); display: grid; align-content: center; justify-items: center; gap: 16px; text-align: center; }
.bi-flash { position: fixed; inset: 0; z-index: -1; background: radial-gradient(circle at 50% 40%, rgba(255, 63, 85, .45), transparent 60%); animation: throb 2.4s ease-in-out infinite; }
.bi-kicker { display: inline-block; font-weight: 900; font-size: 16px; letter-spacing: .2em; padding: 8px 16px; border-radius: 999px; background: #ff3f55; box-shadow: 0 5px 0 #9c1426; }
.bi-title h1 { font-weight: 900; font-size: clamp(38px, 6vw, 72px); margin-top: 12px; text-shadow: 0 6px 0 #6d1238, 0 0 40px rgba(255, 63, 85, .6); }
.bi-sub { color: var(--muted); font-weight: 700; font-size: 19px; margin-top: 6px; }
.bi-stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: 26px; width: 100%; max-width: 1040px; }
.bi-boss { width: min(360px, 80vw); aspect-ratio: 1; justify-self: center; }
.bi-boss svg { width: 100%; height: 100%; }
.bi-boss.drop { animation: bossDrop .9s cubic-bezier(.3, 1.4, .5, 1) both; }
.bi-line { display: flex; gap: 12px; align-items: flex-end; text-align: left; }
.bi-spr { height: 160px; max-width: 150px; object-fit: contain; flex: none; }
.bi-face { width: 96px; height: 96px; flex: none; }
.bi-face svg { width: 100%; height: 100%; }
.bi-rules { display: inline-flex; gap: 10px; align-items: center; font-weight: 700; font-size: 18px; padding: 12px 20px; border-radius: 999px; background: rgba(255, 255, 255, .08); }
.bi-rules b { color: var(--gold); }
.bi-btns { display: flex; gap: 12px; }
.bscore { display: flex; gap: 12px; margin-left: auto; font-weight: 700; color: var(--muted); flex-wrap: wrap; }
.bscore b { color: #fff; }
.arena { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: end; gap: 20px; min-height: 230px; padding: 10px 26px 0; border-radius: 30px; margin-bottom: 14px;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 255, 255, .14), transparent 60%), linear-gradient(180deg, rgba(255, 63, 85, .12), rgba(40, 30, 120, .3)); border: 2px solid rgba(255, 255, 255, .12); }
.hero-spr { height: 220px; max-width: 100%; object-fit: contain; object-position: bottom; }
.hero-spr.attack { animation: lunge .5s ease; }
.boss-side { position: relative; display: grid; justify-items: center; gap: 8px; }
.hp { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.hp i { width: 22px; height: 18px; border-radius: 5px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22); transition: background .3s, transform .3s; }
.hp i.on { background: linear-gradient(180deg, #ff95a0, #ff3b4f); box-shadow: 0 0 10px rgba(255, 59, 79, .6); }
.boss-art { width: 200px; height: 200px; animation: bossIdle 3s ease-in-out infinite; }
.boss-art svg { width: 100%; height: 100%; }
.boss-art.ouch { animation: ouch .55s ease; }
.boss-art.gloat { animation: gloat .6s ease; }
.taunt { position: absolute; right: 78%; top: 20px; width: 250px; z-index: 3; }
.taunt .bubble { font-size: 16px; }
.taunt .bubble::after { left: auto; right: -12px; box-shadow: 4px -4px 0 0 var(--cc, #a78bfa); }
.boss-qa { max-width: 840px; margin: 0 auto; }
.boss-fight .qcard { border-color: #ff5f6d; padding-top: 8px; padding-bottom: 16px; }
.boss-fight .ans { min-height: 96px; }
.boss-fight .mode-head { margin-bottom: 10px; }
.shot { position: fixed; z-index: 85; pointer-events: none; transition: transform .4s cubic-bezier(.3, .6, .4, 1); filter: drop-shadow(0 0 14px #fff); }
.burst-hit { position: fixed; width: 170px; height: 170px; margin: -85px 0 0 -85px; border-radius: 50%; pointer-events: none; z-index: 84; background: radial-gradient(circle, #fff 0%, #ffd24a 28%, rgba(255, 95, 109, .5) 50%, transparent 70%); animation: burst .6s ease-out forwards; }

/* victory + finale */
.victory, .finale { position: relative; min-height: calc(100vh - 70px); min-height: calc(100dvh - 70px); overflow: hidden; }
.finale { min-height: 100vh; min-height: 100dvh; }
.vic-bg { position: absolute; inset: -60px; background-size: cover; background-position: center; filter: blur(26px) brightness(.42) saturate(1.35); }
.vic-inner { position: relative; max-width: 1220px; margin: 0 auto; padding: 22px 24px 40px; display: grid; gap: 18px; }
.vic-title { text-align: center; }
.vic-kicker { display: inline-block; font-weight: 900; font-size: 15px; letter-spacing: .14em; text-transform: uppercase; padding: 8px 16px; border-radius: 999px; background: rgba(255, 255, 255, .12); }
.vic-title h1, .fin-title { font-weight: 900; font-size: clamp(44px, 6vw, 84px); margin-top: 8px; background: linear-gradient(180deg, #fffbe0, #ffe070 40%, #ffb400 72%, #ff8a00); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 5px 0 #5b21b6) drop-shadow(0 10px 0 #2e1065) drop-shadow(0 16px 24px rgba(0, 0, 0, .5)); animation: logoIn .8s cubic-bezier(.2, .9, .3, 1.3) both; }
.vic-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.vic-photo { position: relative; }
.vic-photo img { display: block; width: 100%; border-radius: 26px; border: 4px solid #fff; box-shadow: 0 0 0 10px rgba(255, 210, 74, .25), 0 30px 70px rgba(0, 0, 0, .5); }
.ko { position: absolute; right: -14px; bottom: -18px; width: 130px; height: 130px; transform: rotate(14deg); }
.ko svg { width: 100%; height: 100%; filter: grayscale(.4) brightness(.9); }
.ko span { position: absolute; left: 0; right: 0; top: 36%; text-align: center; font-weight: 900; font-size: 40px; color: #ff3b4f; -webkit-text-stroke: 2px #fff; transform: rotate(-14deg); text-shadow: 0 4px 0 #6d1238; }
.vic-side { display: grid; gap: 16px; }
.vic-line { display: flex; gap: 10px; align-items: flex-end; animation: rise .5s cubic-bezier(.2, .9, .3, 1.2) both; animation-delay: var(--d); }
.vic-spr { height: 120px; max-width: 130px; object-fit: contain; flex: none; }
.vic-line .bubble { font-size: 17px; }
.reward { display: flex; gap: 16px; align-items: center; padding: 16px 18px; border-radius: 22px; background: linear-gradient(135deg, rgba(255, 210, 74, .26), rgba(255, 255, 255, .06)); border: 2px solid rgba(255, 210, 74, .6); animation: rise .5s both 1.8s; }
.reward-trophy { width: 90px; flex: none; animation: shine 2.4s ease-in-out infinite; }
.reward b { display: block; font-size: 22px; font-weight: 900; }
.reward.again { display: block; }
.reward.again small { display: block; color: var(--muted); font-weight: 600; margin-top: 4px; }
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.rchip { display: inline-flex; gap: 6px; align-items: center; font-weight: 800; font-size: 15px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .14); }
.next-world { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-radius: 22px; border: 2px solid var(--nc); background: color-mix(in srgb, var(--nc) 18%, transparent); animation: rise .5s both 2.3s; }
.next-world .lbl { color: var(--nc); }
.next-world b { font-size: 20px; font-weight: 900; }
.vic-btns, .fin-btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.vic-note { text-align: center; color: var(--muted); font-weight: 600; }
.fin-inner { position: relative; max-width: 1100px; margin: 0 auto; padding: 16px 24px; display: grid; gap: 12px; justify-items: center; text-align: center; min-height: 100vh; align-content: center; }
.fin-stage { position: relative; display: grid; justify-items: center; gap: 12px; width: 100%; }
.fin-family { max-height: 34vh; width: auto; filter: drop-shadow(0 24px 30px rgba(0, 0, 0, .5)); animation: floatArt 6s ease-in-out infinite; }
.fin-trophy { display: grid; justify-items: center; gap: 4px; padding: 14px 22px; border-radius: 24px; background: rgba(255, 210, 74, .18); border: 2px solid var(--gold); animation: popIn .6s both; }
.fin-trophy svg { width: 110px; }
.fin-trophy b { font-size: 26px; font-weight: 900; color: var(--gold); }
.fin-trophy small { color: #fff; font-weight: 600; }
.fin-line { display: flex; gap: 12px; align-items: flex-end; text-align: left; }
.fin-spr { height: 150px; max-width: 150px; object-fit: contain; }

/* trophy room */
.trophy-room, .settings { max-width: 1180px; margin: 0 auto; padding: 20px 24px 60px; display: grid; gap: 20px; }
.settings { max-width: 980px; }
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 12px; font-size: 42px; font-weight: 900; }
.page-head h1 .ic { width: 40px; height: 40px; color: var(--gold); }
.trophy-room .card, .settings .card { padding: 22px 24px; }
.trophy-room .card > h2, .settings .card > h2 { margin-bottom: 14px; }
.family-frame { display: grid; justify-items: center; gap: 12px; }
.frame { max-width: 560px; width: 100%; border-radius: 22px; overflow: hidden; border: 7px solid var(--gold); box-shadow: 0 0 0 4px #c98300, 0 24px 50px rgba(0, 0, 0, .45); background: #fff; }
.frame img { display: block; width: 100%; }
.frame-cap { text-align: center; }
.frame-cap b { display: block; font-size: 24px; font-weight: 900; }
.frame-cap span { color: var(--muted); font-weight: 700; }
.shelf { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.trophy { display: grid; justify-items: center; text-align: center; gap: 4px; padding: 14px 8px; border-radius: 20px; background: rgba(255, 255, 255, .05); border: 1.5px solid rgba(255, 255, 255, .08); }
.trophy-art { width: 92px; }
.trophy-art svg { width: 100%; height: auto; display: block; }
.trophy.won { background: radial-gradient(circle at 50% 30%, rgba(255, 210, 74, .22), rgba(255, 255, 255, .04) 70%); border-color: rgba(255, 210, 74, .5); }
.trophy.won .trophy-art { animation: shine 3s ease-in-out infinite; }
.trophy b { font-size: 15px; font-weight: 800; line-height: 1.25; }
.trophy small { color: var(--muted); font-size: 13px; font-weight: 600; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.badge { display: grid; grid-template-columns: 52px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 12px; border-radius: 18px; background: rgba(255, 255, 255, .05); opacity: .62; }
.badge.got { opacity: 1; background: linear-gradient(135deg, rgba(168, 85, 247, .28), rgba(255, 255, 255, .06)); border: 1.5px solid rgba(168, 85, 247, .6); }
.badge-ic { grid-row: 1 / 3; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: rgba(255, 255, 255, .1); }
.badge.got .badge-ic { background: linear-gradient(180deg, #ffe48a, #ffae00); color: #1a1147; }
.badge b { font-size: 17px; font-weight: 900; }
.badge small { color: var(--muted); font-size: 14px; font-weight: 600; }
.vault { display: grid; gap: 4px; }
.vault-row { display: grid; grid-template-columns: 190px minmax(0, 1fr) 60px; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.vault-row.locked { opacity: .45; }
.vault-name { font-weight: 800; }
.vault-gems { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; }
.boss-gem { margin-left: 8px; display: grid; }
.vault-n { font-weight: 800; color: var(--muted); text-align: right; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat { background: rgba(255, 255, 255, .06); border-radius: 18px; padding: 16px 10px; text-align: center; }
.stat b { display: block; font-size: 38px; font-weight: 900; color: var(--gold); }
.stat span { color: var(--muted); font-weight: 700; font-size: 15px; }

/* settings */
.saveinfo-card { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 22px; align-items: center; }
.saveinfo-art .spr { height: 240px; margin: 0 auto; }
.saveinfo-main { display: grid; gap: 12px; }
.saveinfo-main h2 { font-size: 30px; font-weight: 900; }
.saveinfo-main p { color: var(--muted); font-weight: 600; }
.saveinfo-main p.small { font-size: 15px; }
.saveinfo-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.setrow { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setrow:last-child { border-bottom: 0; }
.setrow b { font-size: 19px; font-weight: 800; }
.setrow small { display: block; color: var(--muted); font-weight: 600; font-size: 15px; margin-top: 2px; }
.switch { position: relative; width: 78px; height: 44px; flex: none; border: 0; border-radius: 999px; cursor: pointer; background: rgba(255, 255, 255, .2); transition: background .2s; }
.switch i { position: absolute; top: 5px; left: 5px; width: 34px; height: 34px; border-radius: 50%; background: #fff; box-shadow: 0 3px 6px rgba(0, 0, 0, .3); transition: left .2s cubic-bezier(.2, .9, .3, 1.3); }
.switch.on { background: var(--green); }
.switch.on i { left: 39px; }
.seg { display: inline-flex; flex-wrap: wrap; background: rgba(255, 255, 255, .08); border-radius: 16px; padding: 5px; gap: 4px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding: 0 16px; border: 0; border-radius: 12px; background: transparent; color: #fff; font: 800 16px var(--font); cursor: pointer; }
.seg button .ic { width: 20px; height: 20px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 3px 0 rgba(0, 0, 0, .2); }
.grownups summary { cursor: pointer; font-weight: 800; font-size: 19px; display: flex; align-items: center; gap: 10px; list-style: none; }
.grownups summary::-webkit-details-marker { display: none; }
.grownups[open] summary { margin-bottom: 12px; }
.grownups p { color: var(--muted); font-weight: 600; font-size: 16px; }

/* modal */
#modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
#modal[hidden] { display: none; }
.modal-back { position: absolute; inset: 0; background: rgba(5, 6, 30, .72); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.modal-card { position: relative; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; padding: 26px 26px 24px; border-radius: 30px; background: linear-gradient(160deg, #2c2388, #15124a); border: 2px solid rgba(255, 255, 255, .22); box-shadow: 0 40px 90px rgba(0, 0, 0, .6); animation: popIn .35s cubic-bezier(.2, .9, .3, 1.3) both; }
.modal-card h2 { font-size: 28px; font-weight: 900; margin-bottom: 12px; }
.modal-body { display: grid; gap: 12px; color: #e5e8ff; font-size: 18px; }
.modal-body b { color: #fff; }
.modal-body .warn { color: #ffd1d6; font-weight: 700; }
.modal-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.modal-btns .btn { min-height: 56px; font-size: 18px; }
table.cmp { width: 100%; border-collapse: collapse; font-size: 16px; }
table.cmp th, table.cmp td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.cmp th { color: var(--muted); font-weight: 700; }
.tip-grid { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; align-items: start; }
.tip-spr { height: 210px; margin: 0 auto; }
.checks { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.checks li { position: relative; padding-left: 32px; line-height: 1.4; }
.checks li::before { content: ""; position: absolute; left: 0; top: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L19 7'/%3E%3C/svg%3E") center/14px no-repeat; }
.type-reset { width: 100%; height: 60px; border-radius: 16px; border: 3px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .08); color: #fff; font: 900 26px var(--font); letter-spacing: .2em; text-align: center; text-transform: uppercase; }
.type-reset:focus { border-color: var(--gold); outline: none; }
textarea.raw { width: 100%; height: 160px; font: 12px monospace; }

/* toasts, ticker, runner, bone, effects */
#toasts { position: fixed; right: 20px; top: calc(var(--toph) + 14px); z-index: 70; display: grid; gap: 10px; width: min(390px, calc(100vw - 40px)); pointer-events: none; }
body[data-screen="practice"] #toasts, body[data-screen="learn"] #toasts, body[data-screen="boss"] #toasts { right: auto; left: 20px; top: auto; bottom: 20px; }
.toast { position: relative; pointer-events: auto; display: flex; gap: 12px; align-items: center; padding: 12px 48px 12px 12px; border-radius: 22px; background: #fff; color: var(--ink); border: 3px solid var(--gold); box-shadow: 0 16px 40px rgba(0, 0, 0, .45); transform: translateX(120%); opacity: 0; transition: transform .38s cubic-bezier(.2, .9, .3, 1.2), opacity .3s; }
.toast.in { transform: none; opacity: 1; }
.toast.out { opacity: 0; transform: translateX(40px); }
body[data-screen="practice"] .toast:not(.in), body[data-screen="learn"] .toast:not(.in), body[data-screen="boss"] .toast:not(.in) { transform: translateX(-120%); }
.toast-face { width: 66px; height: 66px; border-radius: 50%; overflow: hidden; flex: none; background: radial-gradient(circle at 50% 30%, #fff, color-mix(in srgb, var(--cc, #a78bfa) 45%, #fff)); border: 3px solid var(--cc, #a78bfa); display: grid; place-items: center; }
.toast-face .spr { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; filter: none; transform: scale(1.35); transform-origin: 50% 10%; }
.toast-face.ach-face { background: linear-gradient(180deg, #ffe48a, #ffae00); color: #1a1147; border-color: #c98300; }
.toast-face.ach-face .ic { width: 34px; height: 34px; }
.toast-face.gemface { background: radial-gradient(circle, #fff, #dff6ff); border-color: var(--turq); }
.toast-face.sq { background: #eef1ff; border-color: #9aa4c7; }
.toast-face.sq svg { width: 58px; }
.toast-title { font-weight: 900; font-size: 13px; letter-spacing: .1em; color: #6b3fd6; text-transform: uppercase; margin-bottom: 2px; }
.toast-text { font-weight: 700; font-size: 16px; line-height: 1.35; text-wrap: pretty; }
.toast-text i { font-style: italic; color: #6b3fd6; }
.toast.ach { border-color: var(--purple); }
.toast.phone { border-color: var(--pink); }
.toast.gem { border-color: var(--turq); }
.toast-x { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: #eef0ff; color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.toast-x .ic { width: 18px; height: 18px; }
#ticker { position: fixed; left: 0; right: 0; top: var(--toph); z-index: 65; height: 50px; display: flex; align-items: center; background: #ff3f55; color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); transform: translateY(-220%); visibility: hidden; transition: transform .4s cubic-bezier(.2, .9, .3, 1.1), visibility 0s .4s; pointer-events: none; }
#ticker.show { transform: none; visibility: visible; transition: transform .4s cubic-bezier(.2, .9, .3, 1.1); pointer-events: auto; }
.tk-lbl { flex: none; align-self: stretch; display: flex; align-items: center; padding: 0 16px; background: #16133f; font-weight: 900; font-size: 15px; letter-spacing: .1em; }
.tk-txt { flex: 1; overflow: hidden; white-space: nowrap; font-weight: 800; font-size: 19px; }
.tk-txt span { display: inline-block; padding-left: 100%; animation: marquee 11s linear forwards; }
.tk-x { flex: none; width: 50px; height: 50px; border: 0; background: rgba(0, 0, 0, .15); color: #fff; display: grid; place-items: center; cursor: pointer; }
#bonebox { position: fixed; right: 22px; top: calc(var(--toph) + 70px); z-index: 66; }
.bone-btn { border: 0; background: none; cursor: pointer; display: grid; justify-items: center; gap: 4px; padding: 6px; border-radius: 20px; animation: boneBob 1.2s ease-in-out infinite; }
.bone-btn .gbone { width: 116px; filter: drop-shadow(0 0 14px rgba(255, 210, 74, .9)); }
.bone-btn span { font-weight: 900; font-size: 15px; background: var(--gold); color: #1a1147; padding: 5px 12px; border-radius: 999px; box-shadow: 0 3px 0 #c98300; }
#runner { position: fixed; left: 0; right: 0; bottom: 0; height: 0; z-index: 64; pointer-events: none; }
.dash { position: absolute; bottom: 0; left: 100%; animation: dash 2.8s linear forwards; }
.dash .spr { height: 150px; }
.swoop { position: absolute; bottom: 40px; right: 0; animation: swoop 3.1s cubic-bezier(.3, .8, .3, 1) forwards; }
.swoop .spr { height: 260px; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.cf { position: absolute; top: -24px; width: 11px; height: 17px; border-radius: 3px; animation: fall linear forwards; }
.cf.still { animation: fadeOut 3.5s forwards; }
.floaty { position: fixed; transform: translate(-50%, 0); font-weight: 900; font-size: 28px; color: var(--gold); text-shadow: 0 3px 0 #5b21b6, 0 0 22px rgba(255, 210, 74, .6); white-space: nowrap; animation: floatUp 1.35s ease-out forwards; z-index: 86; }
.floaty.tip { font-size: 18px; color: #fff; text-shadow: 0 2px 0 #5b21b6; }
.floaty.pow { font-size: 48px; -webkit-text-stroke: 2px #5b21b6; }
.flygem { position: fixed; z-index: 90; transition: transform .9s cubic-bezier(.45, -.3, .5, 1), opacity .9s; }

/* ---------- animations ---------- */
@keyframes drift { to { transform: translate(300px, 260px); } }
@keyframes floaty { 0%, 100% { transform: rotate(45deg) translateY(0); } 50% { transform: rotate(45deg) translateY(-26px); } }
@keyframes pop { from { opacity: 0; transform: scale(.7) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes savedPulse { 0% { box-shadow: 0 0 0 0 rgba(25, 197, 140, .7); } 100% { box-shadow: 0 0 0 12px rgba(25, 197, 140, 0); } }
@keyframes logoIn { from { opacity: 0; transform: scale(.6) translateY(-20px); } to { opacity: 1; transform: none; } }
@keyframes floatArt { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes enter { from { opacity: 0; transform: translateX(-60px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes orbit { from { transform: rotate(0deg) translateX(150px) rotate(0deg); } to { transform: rotate(360deg) translateX(150px) rotate(-360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes gemGlow { 0%, 100% { filter: drop-shadow(0 0 5px var(--wc)); } 50% { filter: drop-shadow(0 0 12px var(--wc)); } }
@keyframes isleFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes ring { from { opacity: .9; transform: translate(-50%, 0) scale(.6); } to { opacity: 0; transform: translate(-50%, 0) scale(1.4); } }
@keyframes unlockPop { 0% { transform: scale(.4); filter: brightness(3) drop-shadow(0 0 40px #fff); } 60% { transform: scale(1.18); } 100% { transform: scale(1); filter: drop-shadow(0 0 18px var(--wc)); } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(20px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-7px); } 80% { transform: translateX(6px); } }
@keyframes stolen { 0% { transform: none; } 30% { transform: translate(40vw, 30vh) rotate(40deg) scale(.4); opacity: .3; } 60% { transform: translate(40vw, 30vh) rotate(-30deg) scale(.4); opacity: .3; } 100% { transform: none; opacity: 1; } }
@keyframes flame { from { transform: scale(1) rotate(-4deg); } to { transform: scale(1.12) rotate(4deg); } }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } to { transform: none; } }
@keyframes throb { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }
@keyframes bossDrop { 0% { transform: translateY(-120%) scale(.8); opacity: 0; } 60% { transform: translateY(6%) scale(1.05); opacity: 1; } 75% { transform: translateY(-3%) rotate(-2deg); } 100% { transform: none; } }
@keyframes bossIdle { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-8px) rotate(1deg); } }
@keyframes ouch { 0% { transform: none; filter: none; } 20% { transform: translateX(14px) rotate(6deg) scale(.95); filter: brightness(2.4) saturate(0); } 45% { transform: translateX(-10px) rotate(-4deg); filter: brightness(1.4); } 70% { transform: translateX(5px); } 100% { transform: none; filter: none; } }
@keyframes gloat { 0%, 100% { transform: none; } 30% { transform: translateY(-16px) scale(1.06); } 60% { transform: translateY(0) scale(.98); } }
@keyframes lunge { 0% { transform: none; } 35% { transform: translateX(40px) rotate(4deg); } 100% { transform: none; } }
@keyframes burst { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
@keyframes shine { 0%, 100% { filter: drop-shadow(0 0 8px rgba(255, 210, 74, .45)); } 50% { filter: drop-shadow(0 0 20px rgba(255, 210, 74, .95)); } }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@keyframes boneBob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-10px) rotate(6deg); } }
@keyframes dash { from { transform: translateX(0); } to { transform: translateX(calc(-100vw - 260px)); } }
@keyframes swoop { 0% { transform: translateX(110%); } 22% { transform: translateX(-10%); } 78% { transform: translateX(-10%); } 100% { transform: translateX(110%); } }
@keyframes fall { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), 108vh) rotate(var(--rot)); opacity: .9; } }
@keyframes fadeOut { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.7); } 20% { opacity: 1; transform: translate(-50%, -10px) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -80px) scale(1); } }
.boss-svg .siren { animation: pulse .5s infinite; }
.boss-svg .shard { animation: floaty 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.boss-svg .blink, .boss-svg .lights circle:nth-child(odd) { animation: pulse .9s infinite; }
.boss-svg .float { animation: bob 2s ease-in-out infinite; }
.boss-svg .glow9 { filter: drop-shadow(0 0 8px #67e8f9); }

/* ---------- calm motion ---------- */
body.rm *, body.rm *::before, body.rm *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
body.rm .stars, body.rm .float-gems { display: none; }
body.rm .tk-txt span { padding-left: 0; animation: none !important; white-space: normal; }
body.rm .tk-txt { white-space: normal; font-size: 16px; line-height: 1.2; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .tk-txt span { padding-left: 0; animation: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .home-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rank { display: none; }
  .shelf { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .play-grid, .setup-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .guide-box { position: static; }
  .guide, .setup-guide .guide { grid-template-columns: auto minmax(0, 1fr); justify-items: start; align-items: center; gap: 14px; }
  .guide-spr, .setup-guide .guide-spr { max-height: 120px; max-width: 110px; order: -1; }
  .guide-spr.zeus { max-height: 90px; }
  .guide-bubble { order: 0; font-size: 16px; padding: 14px 16px 12px; }
  .guide-bubble::after { left: -12px; bottom: 18px; margin-left: 0; transform: rotate(45deg); box-shadow: -4px 4px 0 0 var(--cc); }
  .chips { justify-content: flex-start; }
  .islands { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .isle:nth-child(even) { margin-top: 0; }
  .isle:nth-child(3n+2) { margin-top: 22px; }
  .wc-bottom { grid-template-columns: minmax(0, 1fr); }
  .wc-actions { justify-content: stretch; }
  .wc-actions .btn { flex: 1; }
  .sum-card { grid-template-columns: minmax(0, 1fr); }
  .sum-spr { max-height: 200px; }
  .vic-grid { grid-template-columns: minmax(0, 1fr); }
  .bi-stage { grid-template-columns: minmax(0, 1fr); }
  .bi-boss { width: min(260px, 70vw); }
  .brand-txt { display: none; }
}
@media (max-width: 820px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-left { padding: 26px 22px 12px; }
  .hero-stage { min-height: 300px; }
  .acts { grid-template-columns: minmax(0, 1fr); }
  .act { min-height: 0; grid-template-columns: 64px minmax(0, 1fr); grid-template-rows: auto auto auto; column-gap: 16px; }
  .act-ic { grid-row: 1 / 4; align-self: center; }
  .act-title { margin-top: 0; font-size: 26px; }
  .arena { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); min-height: 220px; padding: 10px 12px 0; }
  .hero-spr { height: 190px; }
  .boss-art { width: 170px; height: 170px; }
  .taunt { position: static; width: auto; }
  .taunt .bubble::after { display: none; }
  .saveinfo-card { grid-template-columns: minmax(0, 1fr); }
  .saveinfo-art { display: none; }
  .done-card { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .done-spr { height: 180px; }
  .done-btns { justify-content: center; }
  .shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .vault-row { grid-template-columns: minmax(0, 1fr) 50px; }
  .vault-gems { grid-column: 1 / -1; grid-row: 2; }
  .panel-stage { grid-template-columns: minmax(0, 1fr); padding: 64px 18px 0; justify-items: center; }
  .panel-bubble { order: -1; font-size: 20px; margin-bottom: 0; }
  .panel-spr { max-height: 38vh; }
  .flying-gems { left: 10%; width: 80%; height: 50%; }
  .flying-gems span { animation-name: orbitS; }
  #toasts, body[data-screen] #toasts { left: 10px; right: 10px; bottom: auto; top: calc(var(--toph) + 6px); width: auto; }
  .toast, body[data-screen] .toast:not(.in) { transform: translateY(-140%); }
  .toast { padding: 8px 44px 8px 8px; gap: 10px; border-radius: 18px; }
  .toast-face { width: 50px; height: 50px; }
  .toast-text { font-size: 15px; }
}
@keyframes orbitS { from { transform: rotate(0deg) translateX(90px) rotate(0deg); } to { transform: rotate(360deg) translateX(90px) rotate(-360deg); } }
@media (max-width: 600px) {
  body { font-size: 17px; }
  #top { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .stats { order: 3; flex-basis: 100%; gap: 6px; }
  .pill { height: 36px; padding: 0 10px; font-size: 15px; gap: 5px; }
  .stats { flex-wrap: nowrap; }
  .world-pill span, .xp-bar, .pill .of { display: none; }
  .world-pill { padding: 0 9px; }
  .top-actions { margin-left: auto; }
  .save-ind span { display: none; }
  .save-ind { padding: 0 10px; }
  .iconbtn { width: 44px; height: 44px; }
  .home, .mode, .world-card, .trophy-room, .settings { padding-left: 14px; padding-right: 14px; }
  .hero h1 { font-size: 40px; }
  .btn-xxl { min-height: 84px; font-size: 22px; padding: 0 20px; width: 100%; justify-content: flex-start; }
  .btn-xxl .cta small { font-size: 14px; }
  #continueBtn { align-self: stretch; }
  .btn-xl { min-height: 70px; font-size: 21px; padding: 0 22px; }
  .btn-lg { min-height: 64px; font-size: 19px; padding: 0 20px; }
  /* The speech bubble was absolutely positioned over the top-right of the
     stage, which on a phone is exactly where Chris's head is. It's now in
     the flow at the top of the stage, and the characters are sized to the
     room left below it. */
  .hero-stage { min-height: 360px; display: flex; flex-direction: column; }
  .hero-bubble { position: static; align-self: flex-end; max-width: 78%; margin: 14px 14px 0 auto; font-size: 16px; }
  .hero-bubble::after { right: 34px; }
  .hero-charles { height: 58%; left: 4%; max-width: 50%; }
  .hero-buddy { height: 50%; right: 3%; max-width: 46%; }
  .hero-buddy.zeus { height: 38%; }
  .hero-buddy.angel { height: 54%; }
  .islands { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .isle:nth-child(3n+2) { margin-top: 0; }
  .isle:nth-child(even) { margin-top: 20px; }
  .home-row { grid-template-columns: minmax(0, 1fr); }
  .mode-title { font-size: 22px; }
  .mode-head .progress { order: 5; flex-basis: 100%; justify-content: flex-start; }
  .mode-head .progress i { width: 24px; }
  .qcard { padding: 14px 14px 22px; border-radius: 26px; }
  .q { font-size: clamp(50px, 15vw, 80px); }
  .answers { gap: 12px; }
  .ans { min-height: 92px; font-size: 44px; border-radius: 22px; }
  .answers.three { grid-template-columns: minmax(0, 1fr); }
  .pad { grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; max-width: 340px; }
  .padk { height: 70px; font-size: 32px; }
  .flash { height: clamp(400px, 64vh, 520px); }
  .flash .back { padding: 16px 14px; }
  .learn-btns { display: grid; grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr); width: 100%; }
  .learn-btns #lPrev { grid-row: 1; }
  .learn-btns #lFlip { grid-column: 2 / 4; }
  .learn-btns #lNext { grid-column: 1 / 4; }
  .learn-btns .btn { padding: 0 10px; font-size: 16px; }
  .sizes { grid-template-columns: minmax(0, 1fr); }
  .size { grid-template-columns: 64px minmax(0, 1fr); justify-items: start; text-align: left; padding: 16px; column-gap: 14px; }
  .size-ic { grid-row: 1 / 3; width: 60px; height: 60px; }
  .sum-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sum-card { padding: 20px 16px; }
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head h1 { font-size: 32px; }
  .setrow { flex-wrap: wrap; }
  .story-spr { height: 90px; max-width: 100px; }
  .story-bubble { font-size: 16px; }
  .wc-scene { padding: 20px 14px 76px; min-height: 0; }
  .bubble { font-size: 17px; }
  .tip-grid { grid-template-columns: minmax(0, 1fr); }
  .tip-spr { height: 140px; }
  .modal-card { padding: 22px 18px; }
  .bi-line { flex-direction: column; align-items: center; text-align: center; }
  .bi-btns { flex-direction: column-reverse; width: 100%; }
  .bi-btns .btn { width: 100%; }
  .bscore { margin-left: 0; font-size: 15px; }
  .arena { grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); }
  .hero-spr { height: 150px; }
  .boss-art { width: 140px; height: 140px; }
  .hp i { width: 12px; height: 14px; border-radius: 4px; }
  .hp { gap: 3px; flex-wrap: nowrap; }
  .vic-btns .btn, .sum-btns .btn, .fin-btns .btn { width: 100%; }
  .ko { width: 90px; height: 90px; right: -6px; bottom: -10px; }
  .ko span { font-size: 26px; }
  .fin-line { flex-direction: column; align-items: center; text-align: center; }
  #bonebox { right: 10px; }
  .bone-btn .gbone { width: 90px; }
  .tk-txt { font-size: 16px; }
}

/* ────────────────────────────────────────────────────────────────────────
   PHONE HELD SIDEWAYS
   A phone in landscape is wide but very short — roughly 740x390. It lands on
   the tablet layout, where a 112px answer button, a 80px question and a
   full-height card add up to more than the screen, so a kid ends up scrolling
   between every question. This trades vertical size for fitting on screen.
   Keyed on height, so it never fires on a real tablet.
   ──────────────────────────────────────────────────────────────────────── */
@media (max-height: 520px) and (orientation: landscape) {
  body { font-size: 16px; }

  /* nothing should demand a full screen's height when there isn't one */
  .learn-done, .summary, .bossfail,
  .boss-intro, .victory, .finale { min-height: 0; padding-top: 10px; padding-bottom: 14px; }
  .title-wrap, .comic { min-height: 0; padding-top: 12px; padding-bottom: 16px; }

  #top { padding: 4px 10px; }
  .pill { height: 32px; font-size: 14px; }
  .iconbtn { width: 40px; height: 40px; }

  /* the question and answers, sized to fit two rows plus the question */
  .qcard { padding: 8px 12px 12px; border-radius: 20px; }
  .q { font-size: clamp(34px, 7vh, 52px); }
  .answers { gap: 8px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .answers.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ans { min-height: 60px; font-size: clamp(26px, 5.5vh, 40px); border-radius: 16px; }
  .ans kbd { display: none; }

  /* typing mode */
  .pad { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 260px; gap: 6px; }
  .padk { height: 44px; font-size: 24px; }

  /* flashcards fit the short screen instead of running off it */
  .flash { height: clamp(210px, 72vh, 330px); }
  .flash .back { padding: 10px 12px; }

  /* the drawn characters and bosses are the first thing to give up space */
  .hero-stage { min-height: 180px; }
  .hero-spr { height: 130px; }
  .boss-art { width: 110px; height: 110px; }
  .arena { min-height: 150px; }
  .spr { max-height: 44vh; }

  .hero h1 { font-size: 30px; }
  .btn-xxl { min-height: 58px; font-size: 18px; }
  .btn-xl { min-height: 52px; font-size: 17px; }
  .btn-lg { min-height: 48px; font-size: 16px; }

  /* two columns of worlds reads better than one on a wide, short screen */
  .islands { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .isle:nth-child(even), .isle:nth-child(3n+2) { margin-top: 0; }
}

/* Very narrow phones (an iPhone SE is 375px, some Androids report 360px).
   The four-choice grid needs to stay two-by-two rather than squeezing. */
@media (max-width: 380px) {
  /* narrower phones wrap the bubble onto more lines, so the stage gets
     taller and the characters a little shorter to keep clear of it */
  .hero-stage { min-height: 410px; }
  .hero-bubble { max-width: 88%; }
  .hero-charles { height: 52%; }
  .hero-buddy { height: 45%; }
  .hero-buddy.zeus { height: 34%; }
  .hero-buddy.angel { height: 49%; }
  .answers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ans { min-height: 84px; font-size: 38px; }
  .hero h1 { font-size: 34px; }
  .q { font-size: clamp(44px, 14vw, 64px); }
  .islands { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pad { max-width: 100%; }
}
