/* Aromet Academy - core styles. World-specific styles live in styles/*.css */
@import url('styles/number.css');
@import url('styles/atlas.css');
@import url('styles/stars.css');
@import url('styles/arena.css');
@import url('styles/myth.css');
@import url('styles/myth-hq.css');
@import url('styles/memory.css');

/* ================================================================ */
/* tokens                                                           */
/* ================================================================ */

:root {
  --ink: #2b2238;
  --ink-soft: #6b5f78;
  --paper: #fbf7f2;
  --paper-2: #f4eee7;
  --card: #ffffff;
  --line: #e8dfd4;
  --plum: #6d3f9e;
  --plum-soft: #f0e8fb;
  --amber: #e0821f;
  --teal: #1f8a80;
  --rose: #c4487b;
  --good: #2e9e5b;
  --good-soft: #e3f6ea;
  --bad: #d6455d;
  --bad-soft: #fde8ec;
  --gold: #f2b83a;
  --accent: var(--plum);
  --accent-2: #9b6fe0;
  --accent-soft: var(--plum-soft);
  --accent-ink: #fff;
  --shadow: 0 1px 2px rgba(43, 34, 56, 0.06), 0 10px 28px rgba(43, 34, 56, 0.09);
  --shadow-lg: 0 2px 6px rgba(43, 34, 56, 0.08), 0 24px 60px rgba(43, 34, 56, 0.16);
  --radius: 22px;
  --radius-sm: 14px;
  --font: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --display: 'Fredoka', 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --sc-ink: #2b2238;
  --sc-soft: #6b5f78;
  --sc-paper: #ffffff;
  --sc-line: #e3d9ee;
  --hud-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ink: #f3edf8;
    --ink-soft: #b9adc6;
    --paper: #16121c;
    --paper-2: #1d1825;
    --card: #231d2c;
    --line: #372d43;
    --plum: #b995f0;
    --plum-soft: #2d2239;
    --amber: #f0a751;
    --teal: #4dc4b8;
    --rose: #ee8ab3;
    --good: #52c485;
    --good-soft: #17301f;
    --bad: #f07186;
    --bad-soft: #3a1b22;
    --accent-2: #7b5ce0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 60px rgba(0, 0, 0, 0.5);
    --sc-ink: #f3edf8;
    --sc-soft: #b9adc6;
    --sc-paper: #2b2436;
    --sc-line: #463a55;
    color-scheme: dark;
  }
}

/* world themes: set the accent family used by buttons, bars and banners */
.theme-stars { --accent: #8f6fd8; --accent-2: #f08cc0; --accent-soft: #f3ecff; --accent-ink: #fff; }
.theme-number { --accent: #e0741f; --accent-2: #f5b240; --accent-soft: #fff1dc; --accent-ink: #fff; }
.theme-atlas { --accent: #1f8a80; --accent-2: #3fb6c9; --accent-soft: #e0f6f2; --accent-ink: #fff; }
.theme-arena { --accent: #6a4be0; --accent-2: #b06af0; --accent-soft: #ece6ff; --accent-ink: #fff; }
.theme-myth { --accent: #b8572a; --accent-2: #e0a23a; --accent-soft: #fbecdc; --accent-ink: #fff; }
.theme-memory { --accent: #6c4fd6; --accent-2: #f0a63a; --accent-soft: #efe9ff; --accent-ink: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-stars { --accent-soft: #2c2340; }
  :root:not([data-theme='light']) .theme-number { --accent: #f09a45; --accent-soft: #33240f; }
  :root:not([data-theme='light']) .theme-atlas { --accent: #3cc2b3; --accent-soft: #10302c; }
  :root:not([data-theme='light']) .theme-arena { --accent: #9b82f5; --accent-soft: #231c40; }
  :root:not([data-theme='light']) .theme-myth { --accent: #ee9a5c; --accent-soft: #35231a; }
  :root:not([data-theme='light']) .theme-memory { --accent: #a48cf7; --accent-soft: #261f40; }
}

/* ================================================================ */
/* base                                                             */
/* ================================================================ */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(155, 111, 224, 0.12), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(242, 184, 58, 0.12), transparent 60%),
    var(--paper);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
.muted { color: var(--ink-soft); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.78rem; font-weight: 900; color: var(--ink-soft); margin: 0; }
.lede { color: var(--ink-soft); font-size: 1.08rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 10px; }

.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; color: var(--ink-soft); font-weight: 700; }
.boot-logo { font-size: 64px; animation: float 2.4s ease-in-out infinite; }

#app { min-height: 100vh; }
.ac-view { max-width: 1080px; margin: 0 auto; padding: 18px 16px 90px; }

/* ================================================================ */
/* buttons, pills, chips                                            */
/* ================================================================ */

.ac-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 11px 22px; min-height: 46px;
  font-family: var(--display); font-weight: 600; font-size: 1.02rem; text-decoration: none;
  background: var(--card); color: var(--ink); cursor: pointer;
  box-shadow: 0 4px 0 var(--line), 0 6px 16px rgba(0, 0, 0, 0.06);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s, opacity 0.15s;
  user-select: none;
}
.ac-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.ac-btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 65%, #000), 0 8px 20px color-mix(in srgb, var(--accent) 30%, transparent); }
.ac-btn.primary:active { box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 65%, #000); }
.ac-btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.ac-btn.ghost:active { transform: translateY(1px); }
.ac-btn.small { min-height: 36px; padding: 6px 16px; font-size: 0.92rem; }
.ac-btn.big { min-height: 56px; padding: 14px 32px; font-size: 1.18rem; }
.ac-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.ac-icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); cursor: pointer; font-size: 1.15rem; display: grid; place-items: center; }

.ac-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.ac-row.end { justify-content: flex-end; }
.ac-row.center { justify-content: center; }
.ac-row.between { justify-content: space-between; }

.ac-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-weight: 900; text-decoration: none; font-size: 0.95rem; white-space: nowrap; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--paper-2); color: var(--ink-soft); font-size: 0.75rem; font-weight: 800; margin-left: 8px; vertical-align: middle; font-family: var(--font); letter-spacing: 0; }
.chip.rec { background: var(--accent); color: var(--accent-ink); }
.chip.good { background: var(--good-soft); color: var(--good); }

.ac-coin { display: inline-block; width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff4b8, #f7c948 45%, #d99a12); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15), 0 0 0 2px #e8a91c; position: relative; flex: none; }
.ac-coin::after { content: ''; position: absolute; inset: 5px; border-radius: 50%; border: 2px solid rgba(160, 100, 0, 0.35); }
.ac-coin.big { width: 34px; height: 34px; }
.ac-coin.big::after { inset: 8px; }

.ac-rarity { display: inline-block; padding: 3px 12px; border-radius: 999px; color: #fff; font-weight: 900; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }

/* segmented control */
.ac-seg { display: flex; flex-wrap: wrap; gap: 6px; background: var(--paper-2); padding: 5px; border-radius: 16px; }
.ac-seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 12px; font-weight: 800; cursor: pointer; color: var(--ink-soft); }
.ac-seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ================================================================ */
/* HUD                                                              */
/* ================================================================ */

.ac-hud {
  position: sticky; top: 0; z-index: 50; height: var(--hud-h);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px max(12px, env(safe-area-inset-left)) 8px max(12px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
body.in-run .ac-hud { display: none; }
.ac-hud-left, .ac-hud-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ac-hud-back { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow); text-decoration: none; font-size: 1.3rem; font-weight: 900; }
.ac-hud-me { display: flex; align-items: center; gap: 8px; text-decoration: none; min-width: 0; }
.ac-hud-buddy { width: 46px; height: 46px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; overflow: hidden; flex: none; }
.ac-hud-buddy svg { width: 44px; height: 44px; }
.ac-hud-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.ac-hud-who b { font-family: var(--display); font-weight: 600; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.ac-hud-level { display: flex; align-items: center; gap: 6px; }
.ac-lvl { font-size: 0.74rem; font-weight: 900; color: var(--plum); }
.ac-xpbar { width: 64px; height: 7px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.ac-xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--plum), #c38bf5); border-radius: 99px; }
.ac-pill.coins b { min-width: 2ch; }
.ac-pill.flame { background: #fff1e0; color: #b3540d; }
.ac-pill.eggs { gap: 5px; }
.ac-shards { display: inline-flex; gap: 2px; }
.ac-shards i { width: 6px; height: 12px; border-radius: 3px; background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--line); }
.ac-shards i.on { background: linear-gradient(#fff2c2, #f2b83a); box-shadow: none; }
@media (max-width: 520px) {
  .ac-hud-who .ac-hud-level { display: none; }
  .ac-pill.flame { display: none; }
  .ac-pill { padding: 5px 9px; font-size: 0.88rem; }
}

/* ================================================================ */
/* home                                                             */
/* ================================================================ */

.home-hero { display: flex; align-items: center; gap: 22px; padding: 18px 8px 8px; }
.home-buddy { border: 0; background: radial-gradient(circle at 50% 60%, var(--plum-soft), transparent 70%); border-radius: 50%; padding: 0; cursor: pointer; flex: none; width: 150px; height: 150px; display: grid; place-items: center; }
.home-buddy svg { animation: breathe 3.2s ease-in-out infinite; transform-origin: 50% 90%; }
.home-buddy.bounce svg { animation: bounce 0.6s ease; }
.home-egg { font-size: 80px; }
.home-hello h1 { font-size: clamp(2rem, 6vw, 2.8rem); }
.home-title { margin: 2px 0 8px; font-weight: 800; color: var(--plum); }
.home-xp { width: min(320px, 60vw); height: 12px; border-radius: 99px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line); overflow: hidden; }
.home-xp i { display: block; height: 100%; background: linear-gradient(90deg, var(--plum), #d08bf5); border-radius: 99px; transition: width 0.6s; }
.home-xp-note, .home-buddy-note { margin: 4px 0 0; font-size: 0.85rem; color: var(--ink-soft); font-weight: 700; }
.home-h { font-size: 1.5rem; margin: 26px 4px 12px; }

.home-egg-cta, .home-continue {
  display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 14px; padding: 14px 18px;
  border: 0; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); text-decoration: none; cursor: pointer; text-align: left;
}
.home-egg-cta { background: linear-gradient(120deg, #fff4d6, #ffe0ef); }
.home-egg-cta b, .home-continue b { display: block; font-family: var(--display); font-weight: 600; font-size: 1.12rem; }
.home-egg-cta small, .home-continue small, .home-continue em { display: block; color: var(--ink-soft); font-style: normal; font-size: 0.85rem; font-weight: 700; }
.home-egg-cta .chev { margin-left: auto; font-size: 2rem; color: var(--ink-soft); }
.home-egg-wobble { font-size: 44px; animation: wobble 1.8s ease-in-out infinite; display: inline-block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .home-egg-cta { background: linear-gradient(120deg, #3a2d18, #3a1d2c); } }
.home-continue { border-left: 6px solid var(--accent); }
.home-continue-icon { font-size: 34px; }
.home-continue .ac-btn { margin-left: auto; }

.portal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.portal {
  display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden; background: var(--card);
  box-shadow: var(--shadow); text-decoration: none; transition: transform 0.15s, box-shadow 0.15s;
}
.portal:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.portal:active { transform: translateY(0) scale(0.99); }
.portal-art { height: 130px; overflow: hidden; }
.portal-art svg { width: 100%; height: 100%; display: block; }
.portal-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.portal-ages { font-size: 0.72rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); }
.portal h3 { font-size: 1.3rem; }
.portal p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }
.portal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 10px; font-weight: 900; }
.portal-go { color: var(--accent); }

.home-card { margin-top: 22px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.home-card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; gap: 10px; }
.home-card-head h2 { font-size: 1.3rem; }
.quests { display: flex; flex-direction: column; gap: 10px; }
.quest { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: var(--paper-2); }
.quest.done { background: var(--good-soft); }
.quest.claimed { opacity: 0.6; }
.quest-icon { font-size: 28px; width: 40px; text-align: center; flex: none; }
.quest-main { flex: 1; min-width: 0; }
.quest-main b { display: block; font-size: 0.98rem; }
.quest-main small { color: var(--ink-soft); font-weight: 700; font-size: 0.8rem; }
.quest-bar { height: 8px; border-radius: 99px; background: var(--card); overflow: hidden; margin: 5px 0 3px; }
.quest-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--good), #7fd9a0); border-radius: 99px; }
.quest-tick { color: var(--good); font-weight: 900; font-size: 1.3rem; }
.claim { animation: pulse 1.6s ease-in-out infinite; }
.home-links { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 22px; }
.home-link { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 8px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; transition: transform 0.12s; }
.home-link:hover { transform: translateY(-2px); }
.home-link span { font-size: 30px; }
.home-link b { font-family: var(--display); font-weight: 600; }
.home-foot { text-align: center; margin-top: 30px; color: var(--ink-soft); font-size: 0.9rem; font-weight: 700; }
@media (max-width: 560px) {
  .home-hero { gap: 12px; }
  .home-buddy { width: 110px; height: 110px; }
  .home-buddy svg { width: 110px; height: 110px; }
  .home-links { grid-template-columns: repeat(2, 1fr); }
}

/* ================================================================ */
/* welcome                                                          */
/* ================================================================ */

.welcome { min-height: calc(100vh - 120px); display: grid; place-items: center; }
.welcome-card { width: min(760px, 100%); text-align: center; background: var(--card); border-radius: 30px; box-shadow: var(--shadow-lg); padding: 34px 24px; }
.welcome-card h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); margin-bottom: 8px; }
.welcome-badge { font-size: 64px; margin-bottom: 6px; }
.welcome-badge.spin { animation: spin 1.6s linear infinite; display: inline-block; }
.age-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 20px; }
.age-btn { border: 0; background: var(--paper-2); border-radius: 22px; padding: 18px 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 4px 0 var(--line); transition: transform 0.1s; }
.age-btn:hover { transform: translateY(-2px); }
.age-btn b { font-family: var(--display); font-size: 1.4rem; font-weight: 600; }
.age-emoji { font-size: 42px; }
.starter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-top: 20px; }
.starter { border: 0; border-radius: 24px; padding: 14px; cursor: pointer; background: linear-gradient(180deg, color-mix(in srgb, var(--el-light) 60%, var(--card)), var(--card)); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--el) 40%, transparent), var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 2px; transition: transform 0.15s; }
.starter:hover { transform: translateY(-4px) rotate(-1deg); }
.starter b { font-family: var(--display); font-size: 1.3rem; font-weight: 600; }
.starter small { font-weight: 800; color: var(--ink-soft); }
.starter-blurb { font-size: 0.86rem; color: var(--ink-soft); margin-top: 4px; }
.gift-row { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 18px 0 22px; }
.gift { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 18px; background: var(--paper-2); font-size: 1.3rem; }

/* ================================================================ */
/* world map                                                        */
/* ================================================================ */

.map-head { position: relative; border-radius: 28px; overflow: hidden; box-shadow: var(--shadow-lg); margin-bottom: 18px; min-height: 210px; display: flex; align-items: flex-end; }
.map-banner { position: absolute; inset: 0; }
.map-banner svg { width: 100%; height: 100%; display: block; }
.map-title { position: relative; width: 100%; padding: 60px 20px 18px; color: #fff; background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.5)); }
.map-title h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); }
.map-title p { margin: 4px 0 8px; font-weight: 700; max-width: 640px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4); }
.map-back { display: inline-block; margin-bottom: 6px; text-decoration: none; font-weight: 900; color: inherit; opacity: 0.92; }
.page .map-back { color: var(--ink-soft); }
.map-head .map-back { position: absolute; top: 14px; left: 16px; background: rgba(0, 0, 0, 0.3); padding: 4px 12px; border-radius: 99px; color: #fff; }
.map-meter { display: flex; align-items: center; gap: 10px; font-weight: 900; }
.map-bar { flex: 1; max-width: 280px; height: 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.3); overflow: hidden; }
.map-bar i { display: block; height: 100%; background: #ffe27a; border-radius: 99px; }
.map-extras { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.map-extra { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); text-decoration: none; flex: 1 1 220px; }
.map-extra span { font-size: 28px; }
.map-extra b { font-family: var(--display); font-weight: 600; }
.map-extra small { display: block; color: var(--ink-soft); font-weight: 700; }

.region { --region: var(--accent); background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; border-top: 6px solid var(--region); scroll-margin-top: 80px; }
.region.recommended { box-shadow: 0 0 0 3px color-mix(in srgb, var(--region) 45%, transparent), var(--shadow-lg); }
.region.locked { opacity: 0.75; }
.region-head { display: flex; gap: 14px; align-items: flex-start; }
.region-head > div { flex: 1; min-width: 0; }
.region-icon { font-size: 40px; width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: color-mix(in srgb, var(--region) 16%, var(--card)); flex: none; }
.region h2 { font-size: 1.35rem; }
.region-head p { margin: 2px 0 6px; color: var(--ink-soft); font-size: 0.94rem; }
.region-meta .chip { margin-left: 0; margin-right: 6px; }
.story-btn { flex: none; }
.region-lock { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 14px; border-radius: 16px; background: var(--paper-2); font-weight: 800; color: var(--ink-soft); }
.region-lock span { font-size: 26px; }
.region-lock p { margin: 0; }

.node-path { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 14px 10px; margin-top: 16px; }
.node { display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; text-align: center; padding: 6px 2px; border-radius: 16px; transition: transform 0.12s; }
a.node:hover { transform: translateY(-3px); }
a.node:active { transform: scale(0.96); }
.node-ring {
  --p: 0; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--region) calc(var(--p) * 1%), var(--paper-2) 0);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--region) 35%, var(--line));
}
.node-icon { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; background: var(--card); font-size: 30px; font-family: var(--display); font-weight: 700; color: var(--region); }
.node.locked { opacity: 0.5; filter: grayscale(0.8); }
.node.kind-boss .node-ring { width: 88px; height: 88px; border-radius: 26px; }
.node.kind-boss .node-icon { border-radius: 20px; width: 72px; height: 72px; }
.node.perfect .node-icon { background: linear-gradient(135deg, #fff6cf, #ffe08a); }
.node-name { font-weight: 800; font-size: 0.88rem; line-height: 1.2; max-width: 120px; }
.stars { display: inline-flex; gap: 1px; font-size: 1rem; letter-spacing: -1px; }
.stars i { font-style: normal; color: var(--line); }
.stars i.on { color: var(--gold); text-shadow: 0 1px 0 #c98a0e; }

/* story reader */
.story-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.story-head span { font-size: 32px; }
.story-page { min-height: 160px; }
.story-page p { font-size: 1.1rem; line-height: 1.6; }
.story-scene { border-radius: 16px; background: var(--paper-2); padding: 10px; margin-bottom: 10px; }

/* ================================================================ */
/* run                                                              */
/* ================================================================ */

body.in-run { background: linear-gradient(180deg, var(--accent-soft), var(--paper) 340px); }
.run { max-width: 860px; padding-top: 10px; }
.run-top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px; padding: 10px 0; background: linear-gradient(180deg, var(--paper) 70%, transparent); }
body.in-run .run-top { background: linear-gradient(180deg, var(--accent-soft) 70%, transparent); }
.run-close { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); cursor: pointer; font-size: 1.1rem; font-weight: 900; color: var(--ink-soft); }
.run-title { display: none; align-items: center; gap: 6px; font-weight: 900; white-space: nowrap; }
.run-progress { flex: 1; display: flex; gap: 5px; }
.run-progress i { flex: 1; height: 12px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 14%, var(--card)); transition: background 0.3s; }
.run-progress i.right { background: var(--good); }
.run-progress i.wrong { background: #f0b3bd; }
.run-streak { display: flex; align-items: center; gap: 3px; font-weight: 900; min-width: 30px; }
.run-streak .flame { font-size: 1.2rem; }
.run-streak .flame.warm { animation: pulse 1.2s infinite; }
.run-streak .flame.hot { animation: pulse 0.6s infinite; filter: drop-shadow(0 0 6px #ff8a2a); }
.run-coins { display: flex; align-items: center; gap: 5px; font-weight: 900; }
.run-top.done .run-progress { opacity: 0.5; }
@media (min-width: 720px) { .run-title { display: flex; } }

.run-stage { min-height: 60vh; }
.run-card { background: var(--card); border-radius: 28px; box-shadow: var(--shadow-lg); padding: 22px 20px 20px; margin-top: 8px; position: relative; }
.run-card.enter { animation: cardIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.run-card.stretch { box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 60%, transparent), var(--shadow-lg); }
.run-tag { display: inline-block; margin-bottom: 10px; padding: 3px 12px; border-radius: 99px; background: var(--paper-2); font-size: 0.8rem; font-weight: 900; color: var(--ink-soft); }
.run-tag.gold { background: #fff2cc; color: #9a6400; }
.run-intro { text-align: center; background: var(--card); border-radius: 28px; box-shadow: var(--shadow-lg); padding: 30px 22px; margin-top: 20px; }
.run-intro-icon { font-size: 64px; }
.run-intro h2 { font-size: 1.8rem; margin: 6px 0; }
.run-intro p { font-size: 1.1rem; color: var(--ink-soft); max-width: 560px; margin: 0 auto 18px; }

/* ================================================================ */
/* quiz                                                             */
/* ================================================================ */

.qz { display: flex; flex-direction: column; gap: 14px; }
.qz.shake { animation: shake 0.4s; }
.qz-story { background: var(--accent-soft); border-radius: 18px; padding: 12px 16px; }
.qz-story p { margin: 4px 0; font-size: 1.04rem; }
.qz-prompt-row { display: flex; gap: 10px; align-items: flex-start; }
.qz-prompt { font-size: clamp(1.25rem, 3.4vw, 1.6rem); line-height: 1.3; flex: 1; }
.qz-prompt .blank, .qz-story .blank { display: inline-block; width: 2.4em; border-bottom: 3px solid var(--accent); margin: 0 3px; vertical-align: -3px; }
.qz-speak { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent-soft); cursor: pointer; font-size: 1.2rem; }
.gentle .qz-speak { width: 56px; height: 56px; font-size: 1.6rem; animation: pulse 2.4s infinite; }
.qz-scene { display: flex; justify-content: center; background: var(--paper-2); border-radius: 20px; padding: 12px; }
.qz-scene svg { width: 100%; max-height: 300px; height: auto; }
.qz-answer { display: flex; flex-direction: column; gap: 12px; }

.qz-choices { display: grid; gap: 12px; }
.qz-choices.short { grid-template-columns: repeat(2, 1fr); }
.qz-choices.long { grid-template-columns: 1fr; }
.qz-choices.pictures { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
@media (min-width: 640px) { .qz-choices.short { grid-template-columns: repeat(4, 1fr); } .qz-choices.long { grid-template-columns: repeat(2, 1fr); } }
.qz-choice {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; text-align: center;
  min-height: 64px; padding: 12px 16px; border: 0; border-radius: 18px; cursor: pointer;
  background: var(--card); box-shadow: inset 0 0 0 2px var(--line), 0 4px 0 var(--line);
  font-weight: 800; font-size: 1.08rem; transition: transform 0.08s, box-shadow 0.12s, background 0.15s;
}
.qz-choices.short .qz-choice { font-family: var(--display); font-size: 1.6rem; font-weight: 600; min-height: 76px; }
.qz-choices.long .qz-choice { justify-content: flex-start; text-align: left; padding-left: 48px; }
.qz-choices.pictures .qz-choice { flex-direction: column; min-height: 130px; }
.qz-choice:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--accent), 0 4px 0 color-mix(in srgb, var(--accent) 40%, var(--line)); }
.qz-choice:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--accent), 0 1px 0 var(--line); }
.qz-choice:disabled { cursor: default; }
.qz-choice.wrong { background: var(--bad-soft); box-shadow: inset 0 0 0 2px var(--bad); opacity: 0.7; text-decoration: line-through; text-decoration-thickness: 2px; }
.qz-choices.pictures .qz-choice.wrong, .gentle .qz-choice.wrong { text-decoration: none; opacity: 0.35; }
.qz-choice.right { background: var(--good-soft); box-shadow: inset 0 0 0 3px var(--good), 0 4px 0 var(--good); animation: pop 0.35s; opacity: 1; }
.qz-choice.glow { animation: glow 1.2s ease-in-out infinite; }
.qz-key { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border-radius: 8px; background: var(--paper-2); font-size: 0.75rem; font-weight: 900; color: var(--ink-soft); display: grid; place-items: center; font-family: var(--font); }
.qz-choices.short .qz-key { top: 8px; left: 8px; transform: none; }
.qz-choice-scene { width: 100%; display: flex; justify-content: center; }
.qz-choice-scene svg { max-height: 120px; width: 100%; }
.qz-choice-emoji { font-size: 48px; line-height: 1; }
.gentle .qz-choice { min-height: 96px; font-size: 1.5rem; border-radius: 24px; }

.qz-count-field { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 14px; background: var(--paper-2); border-radius: 20px; }
.qz-count-obj { position: relative; width: 70px; height: 70px; border-radius: 20px; border: 0; background: var(--card); box-shadow: 0 3px 0 var(--line); cursor: pointer; font-size: 40px; display: grid; place-items: center; }
.qz-count-obj[data-n] { box-shadow: inset 0 0 0 3px var(--accent); }
.qz-count-num { position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 0.95rem; font-weight: 900; display: grid; place-items: center; font-family: var(--display); animation: pop 0.3s; }

.qz-entry { align-self: center; display: flex; align-items: center; gap: 8px; min-width: 200px; min-height: 68px; padding: 8px 20px; border-radius: 18px; background: var(--paper-2); box-shadow: inset 0 0 0 3px var(--line); font-family: var(--display); font-size: 2rem; font-weight: 600; justify-content: center; }
.qz-entry.empty .qz-entry-value::before { content: '?'; color: var(--ink-soft); opacity: 0.4; }
.qz-entry.bad { box-shadow: inset 0 0 0 3px var(--bad); animation: shake 0.35s; }
.qz-entry.revealed { box-shadow: inset 0 0 0 3px var(--good); background: var(--good-soft); }
.qz-caret { width: 3px; height: 1.1em; background: var(--accent); animation: blink 1s steps(1) infinite; border-radius: 2px; }
.qz-entry.revealed .qz-caret { display: none; }
.qz-affix { color: var(--ink-soft); font-size: 1.3rem; }
.qz-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(360px, 100%); align-self: center; }
.qz-key-btn { min-height: 58px; border: 0; border-radius: 16px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line), 0 4px 0 var(--line); font-family: var(--display); font-size: 1.5rem; font-weight: 600; cursor: pointer; }
.qz-key-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--line), 0 1px 0 var(--line); }
.qz-key-btn.back { color: var(--ink-soft); }
.qz-key-btn.alt { font-size: 1.05rem; }
.qz-key-btn.ok { grid-column: 1 / -1; background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 65%, #000); font-size: 1.25rem; }
.qz-keypad-note { text-align: center; color: var(--ink-soft); font-size: 0.85rem; font-weight: 700; margin: 0; }

.qz-order-ends { display: flex; justify-content: space-between; font-weight: 900; color: var(--ink-soft); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
.qz-order-slots { display: flex; flex-direction: column; gap: 8px; }
.qz-slot { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px; border-radius: 14px; border: 2px dashed var(--line); background: transparent; text-align: left; font-weight: 800; cursor: pointer; }
.qz-slot:not(.empty) { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.qz-order-slots.revealed .qz-slot { border-color: var(--good); background: var(--good-soft); }
.qz-slot-n { width: 28px; height: 28px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 900; font-size: 0.85rem; flex: none; }
.qz-order-pool { display: flex; flex-wrap: wrap; gap: 8px; }
.qz-order-item { padding: 10px 16px; border-radius: 14px; border: 0; background: var(--card); box-shadow: inset 0 0 0 2px var(--line), 0 3px 0 var(--line); font-weight: 800; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.qz-order-item:disabled { opacity: 0.25; }
.qz-row { display: flex; justify-content: center; }

.qz-tile-slots, .qz-tile-pool { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.qz-tile { width: 52px; height: 58px; border-radius: 14px; border: 0; background: var(--card); box-shadow: inset 0 0 0 2px var(--line), 0 4px 0 var(--line); font-family: var(--display); font-size: 1.7rem; font-weight: 600; cursor: pointer; display: grid; place-items: center; }
.qz-tile:disabled { opacity: 0.2; }
.qz-tile.slot { background: var(--paper-2); box-shadow: inset 0 -3px 0 var(--accent); }
.qz-tile.slot.empty { box-shadow: inset 0 -3px 0 var(--line); }
.qz-tile-slots.bad .qz-tile { box-shadow: inset 0 -3px 0 var(--bad); animation: shake 0.35s; }
.qz-tile.revealed { background: var(--good-soft); box-shadow: inset 0 -3px 0 var(--good); }

.qz-tools { display: flex; justify-content: center; }
.qz-tools:empty { display: none; }
.qz-hint { background: #fff8e1; border-radius: 16px; padding: 8px 14px; color: #6b4d00; font-weight: 700; }
.qz-hint p { margin: 4px 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .qz-hint { background: #3a2f12; color: #ffe39a; } }

.qz-feedback { border-radius: 20px; padding: 14px 16px; animation: slideUp 0.28s ease; }
.qz-feedback-title { font-family: var(--display); font-weight: 600; font-size: 1.3rem; margin-bottom: 4px; }
.qz-feedback p { margin: 6px 0; }
.qz-feedback.kind-right { background: var(--good-soft); color: var(--good); }
.qz-feedback.kind-right p { color: var(--ink); }
.qz-feedback.kind-wrong { background: var(--bad-soft); }
.qz-feedback.kind-wrong .qz-feedback-title { color: var(--bad); }
.qz-feedback.kind-soft { background: var(--accent-soft); text-align: center; }
.qz-feedback.kind-reveal { background: var(--paper-2); }
.qz-feedback .qz-continue { margin-top: 12px; width: 100%; }
.qz-nudge { font-weight: 700; }
.qz-solution { margin-top: 8px; }
.qz-answer-reveal { display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--good-soft); color: var(--good); }
.qz-answer-reveal span { font-weight: 900; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; }
.qz-answer-reveal b { font-family: var(--display); font-size: 1.4rem; font-weight: 600; color: var(--ink); }
.qz-steps { list-style: none; padding: 0; margin: 12px 0 0; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.qz-step { counter-increment: step; position: relative; padding: 10px 12px 10px 48px; border-radius: 14px; background: var(--card); animation: fadeUp 0.4s both; }
.qz-step::before { content: counter(step); position: absolute; left: 12px; top: 10px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 900; font-size: 0.85rem; display: grid; place-items: center; }
.qz-step-head { font-weight: 900; }
.qz-formula { font-family: ui-monospace, 'Cascadia Code', Menlo, monospace; background: var(--paper-2); padding: 6px 10px; border-radius: 10px; margin-top: 6px; display: inline-block; font-weight: 700; }
.qz-step-scene svg { max-height: 200px; }
.qz-explain { font-weight: 700; }
.qz.is-right .qz-entry { box-shadow: inset 0 0 0 3px var(--good); background: var(--good-soft); }

/* ================================================================ */
/* results                                                          */
/* ================================================================ */

.results { text-align: center; background: var(--card); border-radius: 30px; box-shadow: var(--shadow-lg); padding: 26px 20px; margin-top: 16px; animation: cardIn 0.4s; }
.result-stars { display: flex; justify-content: center; gap: 8px; margin-bottom: 4px; }
.rstar { font-size: 64px; color: var(--line); line-height: 1; transition: transform 0.3s; }
.rstar:nth-child(2) { transform: translateY(-14px); font-size: 78px; }
.rstar.on { color: var(--gold); text-shadow: 0 3px 0 #c98a0e, 0 0 24px rgba(242, 184, 58, 0.6); animation: starPop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
.rstar:nth-child(2).on { animation-name: starPopMid; }
.results h1 { font-size: 2.2rem; }
.result-score { font-weight: 800; color: var(--ink-soft); margin: 4px 0; }
.result-improve { color: var(--good); font-weight: 900; margin: 0; }
.result-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 18px 0; }
.rtile { background: var(--paper-2); border-radius: 18px; padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.rtile > span { font-size: 30px; line-height: 34px; height: 34px; }
.rtile b { font-family: var(--display); font-size: 1.5rem; font-weight: 600; }
.rtile small { color: var(--ink-soft); font-weight: 800; }
.result-skills { color: var(--ink-soft); font-size: 0.88rem; font-weight: 700; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.reward-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 10px 0; }
.reward-card { text-align: left; padding: 14px; border-radius: 20px; background: linear-gradient(160deg, var(--accent-soft), var(--card)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); animation: flipIn 0.6s 0.4s both; }
.reward-kind { display: block; font-size: 0.75rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); margin-bottom: 6px; }
.reward-card b { font-family: var(--display); font-size: 1.15rem; font-weight: 600; }
.reward-card p { margin: 4px 0 0; font-size: 0.92rem; }
.reward-icon { font-size: 44px; }
.reward-icon.big { font-size: 72px; text-align: center; }
.reward-scene svg { max-height: 140px; width: 100%; }

/* ================================================================ */
/* modal, toast, celebrate, hatch                                   */
/* ================================================================ */

.ac-modal { position: fixed; inset: 0; z-index: 1000; background: rgba(28, 20, 38, 0.55); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; opacity: 0; transition: opacity 0.2s; overflow: auto; }
.ac-modal.in { opacity: 1; }
.ac-modal.out { opacity: 0; }
.ac-modal-card { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--card); border-radius: 28px; padding: 24px; box-shadow: var(--shadow-lg); transform: translateY(16px) scale(0.97); transition: transform 0.25s cubic-bezier(0.2, 1.2, 0.4, 1); }
.ac-modal.in .ac-modal-card { transform: none; }
.ac-confirm h3 { font-size: 1.4rem; }
.ac-confirm p { color: var(--ink-soft); }

.ac-toasts { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); z-index: 1100; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 24px)); pointer-events: none; }
.ac-toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow-lg); font-weight: 700; animation: toastIn 0.35s cubic-bezier(0.2, 1.3, 0.4, 1); transition: opacity 0.3s, transform 0.3s; }
.ac-toast.out { opacity: 0; transform: translateY(-10px); }
.ac-toast-icon { font-size: 1.5rem; }
.ac-toast.tone-gold { box-shadow: inset 0 0 0 2px var(--gold), var(--shadow-lg); }
.ac-toast.tone-good { box-shadow: inset 0 0 0 2px var(--good), var(--shadow-lg); }

.ac-confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 2000; }
.ac-float { position: fixed; z-index: 1500; transform: translate(-50%, 0); font-family: var(--display); font-weight: 700; font-size: 1.3rem; pointer-events: none; animation: floatUp 1.1s ease-out forwards; color: var(--accent); }
.ac-float.coin { color: #d99a12; text-shadow: 0 1px 0 #fff; }

.ac-celebrate { text-align: center; padding: 10px 0; }
.ac-celebrate-icon { font-size: 80px; animation: starPop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1); }
.ac-celebrate-art { display: flex; justify-content: center; animation: starPop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1); }
.ac-celebrate h2 { font-size: 2rem; margin: 8px 0; }
.ac-celebrate p { color: var(--ink-soft); font-weight: 700; }

.hatch { text-align: center; }
.hatch-stage { display: flex; justify-content: center; cursor: pointer; min-height: 220px; align-items: center; }
.hatch-stage .egg { animation: wobble 2s ease-in-out infinite; }
.hatch-stage.wobble .egg { animation: shakeHard 0.45s; }
.hatch-stage.burst .egg { animation: burst 0.45s forwards; }
.hatch-stage.reveal { cursor: default; animation: starPop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1); }
.hatch-caption { font-weight: 900; font-size: 1.2rem; color: var(--ink-soft); }
.hatch-info h2 { font-size: 1.8rem; margin: 8px 0 4px; }
.hatch-info p { color: var(--ink-soft); margin: 4px 0; }
.hatch-el { font-weight: 900; }

/* settings */
.ac-settings h2 { margin-bottom: 12px; }
.ac-toggle { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.ac-toggle > span { flex: 1; }
.ac-toggle small { display: block; color: var(--ink-soft); font-weight: 600; }
.ac-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ac-switch { width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; transition: background 0.2s; flex: none; }
.ac-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s; }
.ac-toggle input:checked + .ac-switch { background: var(--good); }
.ac-toggle input:checked + .ac-switch::after { transform: translateX(20px); }
.ac-toggle input:focus-visible + .ac-switch { outline: 3px solid var(--accent); outline-offset: 2px; }
.ac-field { padding: 12px 0; }
.ac-field small { display: block; color: var(--ink-soft); margin-bottom: 8px; }

/* ================================================================ */
/* pages: trophies, journal, parent                                 */
/* ================================================================ */

.page-head { margin: 8px 0 18px; }
.page-head h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); }
.page-head p { color: var(--ink-soft); margin: 4px 0 0; font-weight: 700; }
.trophy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.trophy { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 16px 12px; text-align: center; display: flex; flex-direction: column; gap: 3px; opacity: 0.55; }
.trophy.won { opacity: 1; background: linear-gradient(180deg, #fff8e0, var(--card)); box-shadow: inset 0 0 0 2px #f2d27a, var(--shadow); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .trophy.won { background: linear-gradient(180deg, #3a2f12, var(--card)); } }
.trophy-icon { font-size: 40px; }
.trophy small { color: var(--ink-soft); font-weight: 700; }
.trophy em { font-size: 0.75rem; color: var(--ink-soft); font-style: normal; }

.tabs { margin-bottom: 16px; }
.fact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.fact-card { border: 0; background: linear-gradient(160deg, #e0f6f2, var(--card)); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; text-align: center; }
.fact-card.unknown { background: var(--paper-2); box-shadow: none; opacity: 0.6; cursor: default; }
.fact-card small { color: var(--ink-soft); font-weight: 700; }
.fact-icon { font-size: 36px; }
.fact-full { text-align: center; }
.fact-full h2 { margin: 10px 0; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.sticker { aspect-ratio: 1; border-radius: 50%; background: var(--paper-2); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 40px; color: var(--ink-soft); }
.sticker.got { background: var(--card); box-shadow: 0 0 0 4px #fff, var(--shadow); animation: none; }
.sticker small { font-size: 0.7rem; font-weight: 800; }
.sticker svg { width: 64px; height: 64px; }
.story-list { display: grid; gap: 10px; }
.story-item { display: flex; align-items: center; gap: 12px; padding: 14px; border: 0; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); cursor: pointer; text-align: left; }
.story-item span { font-size: 30px; }
.story-item b { flex: 1; font-family: var(--display); font-weight: 600; font-size: 1.1rem; }
.story-item:disabled { opacity: 0.5; cursor: default; }

.hold-gate { text-align: center; padding: 60px 16px; }
.hold-btn { position: relative; overflow: hidden; margin: 20px auto; display: block; border: 0; border-radius: 999px; padding: 18px 36px; font-weight: 900; font-size: 1.1rem; background: var(--card); box-shadow: var(--shadow); cursor: pointer; user-select: none; touch-action: none; }
.hold-btn i { position: absolute; inset: 0; background: var(--plum-soft); transform: scaleX(0); transform-origin: left; }
.hold-btn.holding i { transform: scaleX(1); transition: transform 1.4s linear; }
.hold-btn span { position: relative; }
.parent-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.pstat { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 14px; }
.pstat b { display: block; font-family: var(--display); font-size: 1.7rem; font-weight: 600; }
.pstat small { color: var(--ink-soft); font-weight: 700; }
.parent-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; overflow-x: auto; }
.parent-card h2 { font-size: 1.25rem; margin-bottom: 10px; }
.parent-card.danger { box-shadow: inset 0 0 0 2px var(--bad-soft), var(--shadow); }
.mis-list { padding-left: 18px; margin: 0; }
.mis-list li { margin-bottom: 8px; }
.mis-list small { display: block; color: var(--ink-soft); }
.skill-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.skill-table th { text-align: left; color: var(--ink-soft); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 6px; }
.skill-table td { padding: 8px 6px; border-top: 1px solid var(--line); }
.skill-bar { width: 110px; height: 8px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.skill-bar i { display: block; height: 100%; background: var(--good); }

.ac-error { text-align: center; padding: 60px 16px; }
.ac-error h2 { margin-bottom: 14px; }

/* ================================================================ */
/* motion                                                           */
/* ================================================================ */

@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes breathe { 50% { transform: scale(1.03, 0.97); } }
@keyframes bounce { 30% { transform: translateY(-18px) scale(0.95, 1.08); } 60% { transform: translateY(0) scale(1.08, 0.92); } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-7deg); } 40% { transform: rotate(6deg); } 60% { transform: rotate(-3deg); } }
@keyframes shakeHard { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px) rotate(-6deg); } 40% { transform: translateX(10px) rotate(6deg); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes burst { to { transform: scale(1.4); opacity: 0; filter: brightness(2); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 50% { transform: translateX(7px); } 75% { transform: translateX(-4px); } }
@keyframes pop { 0% { transform: scale(0.85); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes glow { 50% { box-shadow: inset 0 0 0 3px var(--gold), 0 0 0 8px rgba(242, 184, 58, 0.35); transform: scale(1.03); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(0.98); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.95); } }
@keyframes floatUp { to { opacity: 0; transform: translate(-50%, -46px); } }
@keyframes starPop { 0% { transform: scale(0) rotate(-30deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes starPopMid { 0% { transform: translateY(-14px) scale(0) rotate(-30deg); } 100% { transform: translateY(-14px) scale(1); } }
@keyframes flipIn { from { opacity: 0; transform: perspective(600px) rotateY(80deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  /* a dialog only fades: it starts at its full size, so it does not slide or grow */
  .ac-modal-card { transform: none; }
}
html.calm *, html.calm *::before, html.calm *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
html.calm .ac-modal-card { transform: none; }

/* ================================================================ */
/* phones and tablets                                               */
/* ================================================================ */
/*
 * Three ranges, the same as the main site:
 *   - up to 1024px wide: touch sizes (44px targets)
 *   - up to 640px wide, or up to 500px high (a phone on its side): 16px body text
 *   - up to 500px high: the quiz puts the picture next to the answers
 * Above 1024px nothing here applies, except the notch padding (0 on a desktop).
 */

/* the left inset belongs on the left; the bar grows by the top inset under a notch */
.ac-hud {
  height: auto;
  min-height: var(--hud-h);
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
}
/* the name gives way first, so the coins and the settings button never leave the screen */
.ac-hud-left { flex: 1 1 0; }
.ac-hud-right { flex: none; }
.ac-view {
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}
.home-hello { flex: 1; min-width: 0; }
.home-xp { width: 100%; max-width: 320px; }

@media (max-width: 1024px) {
  .ac-btn.small { min-height: 44px; }
  .ac-icon-btn, .ac-hud-back, .run-close { width: 44px; height: 44px; flex: none; }
  .ac-hud .ac-pill { min-height: 44px; }
  .ac-seg button { min-height: 44px; }
  .map-back, .vault-back, .my-hero-back, .mp-hero-back { display: inline-flex; align-items: center; min-height: 44px; }
  .map-head .map-back { padding: 0 14px; top: 10px; left: 12px; }
  .home-foot a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; }
  .ac-toggle { min-height: 56px; }
  .ac-lvl, .portal-ages { font-size: 0.75rem; }
}

@media (max-width: 640px), (max-height: 500px) {
  .home-xp-note, .home-buddy-note { font-size: 1rem; }
  .portal p { font-size: 1rem; }
  .quest-main small { font-size: 0.875rem; }
  .home-egg-cta small, .home-continue small, .home-continue em { font-size: 0.9rem; }
  .home-foot { font-size: 1rem; }
  .starter-blurb { font-size: 0.9rem; }
  .ac-toggle small, .ac-field small { font-size: 0.9rem; }
  .qz-keypad-note, .result-skills { font-size: 1rem; }
  .welcome { min-height: calc(100vh - 120px); min-height: calc(100dvh - 120px); }
  .welcome-card { padding: 24px 16px; border-radius: 24px; }
  /* a dialog never grows past the part of the screen that shows */
  .ac-modal { padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  .ac-modal-card { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); padding: 20px 16px; border-radius: 24px; }
  .ac-toasts { top: calc(var(--hud-h) + env(safe-area-inset-top) + 6px); }
  .run-top { padding-top: max(10px, env(safe-area-inset-top)); }
}

@media (max-width: 640px) {
  .home-hero { padding: 12px 0 4px; }
  /* two buddies per row, so the three starters fit one screen */
  .starter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .starter { padding: 10px 8px; }
  .starter svg { width: 104px; height: 104px; }
  .age-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .age-btn { padding: 12px 8px; }
  .age-emoji { font-size: 34px; }
  .run-card { padding: 18px 14px 16px; border-radius: 22px; }
  .ac-settings .ac-seg button { flex: 1 1 28%; }
  .ac-settings .ac-row.end .ac-btn { flex: 1; }
}

/* the narrowest phones: the egg pill keeps its count and drops the shard pips */
@media (max-width: 380px) {
  .ac-hud { gap: 6px; }
  .ac-hud-left, .ac-hud-right { gap: 6px; }
  .ac-shards { display: none; }
  .ac-hud .ac-pill.eggs { min-width: 44px; justify-content: center; }
}

/*
 * A phone on its side. The screen is wide and short, so a question with a
 * picture shows the picture on the left and the answers on the right; without
 * this the picture fills the screen and the answers sit below the fold.
 */
@media (max-height: 500px) and (min-width: 640px) {
  .ac-hud { min-height: 52px; padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .ac-view { padding-top: 10px; }
  .run-top { padding-bottom: 6px; }
  .run-stage { min-height: 0; }
  .run-card { padding: 14px 16px; margin-top: 2px; }
  .run-intro { padding: 14px 16px; margin-top: 6px; }
  .run-intro-icon { font-size: 40px; }
  .qz { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 16px; align-items: start; }
  .qz > * { grid-column: 1 / -1; }
  .qz > .qz-scene { grid-column: 1; }
  .qz > .qz-scene + .qz-answer { grid-column: 2; }
  .qz-scene { padding: 8px; }
  .qz-scene svg { max-height: calc(100vh - 190px); max-height: calc(100dvh - 190px); }
  .qz-prompt { font-size: 1.25rem; }
  .qz-choices.short .qz-choice { min-height: 60px; }
  .qz-key-btn { min-height: 46px; }
  .qz-entry { min-height: 52px; font-size: 1.6rem; }
  /* number pad: the entry on the left, four keys per row on the right */
  .qz-keypad { grid-template-columns: repeat(4, 1fr); width: min(460px, 100%); }
  .welcome { min-height: 0; }
  .welcome-card { padding: 16px; }
  .welcome-badge { font-size: 40px; margin-bottom: 0; }
  .age-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 12px; }
  .age-btn { padding: 10px 6px; }
  .age-emoji { font-size: 30px; }
  .starter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
  .starter svg { width: 96px; height: 96px; }
}
