/* Cloud Quest — game UI. Design notes: study/game/DESIGN.md */
:root {
  color-scheme: light;
  --bg: #f3f4fb;
  --bg-glow: rgb(99 102 241 / 0.10);
  --surface: #ffffff;
  --surface-2: #f2f3fa;
  --surface-3: #e5e8f4;
  --border: #dde1ef;
  --border-strong: #c3c9e2;
  --text: #141a33;
  --text-2: #444c6b;
  --text-3: #5b6383;
  --primary: #4f46e5;
  --primary-ledge: #3730a3;
  --primary-hover: #4338ca;
  --on-primary: #ffffff;
  --primary-soft: #eceafe;
  --primary-ink: #4338ca;
  --accent: #ea580c;
  --accent-ink: #c2410c;
  --accent-soft: #fff0e6;
  --gold: #f59e0b;
  --gold-ink: #92400e;
  --gold-soft: #fef6dd;
  --good: #16a34a;
  --good-ledge: #15803d;
  --good-ink: #166534;
  --good-soft: #e3f7ea;
  --bad: #dc2626;
  --bad-ledge: #991b1b;
  --bad-ink: #b91c1c;
  --bad-soft: #fdeceb;
  --heart: #be123c;
  --on-good: #ffffff;
  --on-bad: #ffffff;
  --good-fill: #15803d;
  --ring: #4f46e5;
  --scrim: rgb(10 14 32 / 0.55);
  --shadow-1: 0 1px 2px rgb(20 26 51 / 0.06);
  --shadow-2: 0 2px 4px rgb(20 26 51 / 0.04), 0 12px 32px rgb(49 46 129 / 0.10);

  --font-display: "Chakra Petch", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Be Vietnam Pro", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-full: 999px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 120ms;
  --t-med: 200ms;
  --t-slow: 260ms;
  --hud-h: 60px;
  --hud-total: calc(var(--hud-h) + env(safe-area-inset-top));
  --tab-h: 68px;
  --hue: 245;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1020; --bg-glow: rgb(99 102 241 / 0.16);
    --surface: #141a30; --surface-2: #1a2140; --surface-3: #242c4f;
    --border: #262f55; --border-strong: #3b4677;
    --text: #eef0ff; --text-2: #c5cae8; --text-3: #9ca3c9;
    --primary: #a5b4fc; --primary-ledge: #6366f1; --primary-hover: #c7d2fe; --on-primary: #10143a;
    --primary-soft: #232a57; --primary-ink: #c7d2fe;
    --accent: #fb923c; --accent-ink: #fdba74; --accent-soft: #3a2316;
    --gold: #fbbf24; --gold-ink: #fcd34d; --gold-soft: #3a2f12;
    --good: #22c55e; --good-ledge: #15803d; --good-ink: #4ade80; --good-soft: #10291c;
    --bad: #f87171; --bad-ledge: #b91c1c; --bad-ink: #fca5a5; --bad-soft: #36171b;
    --heart: #fb7185; --ring: #a5b4fc; --scrim: rgb(3 5 14 / 0.7); --on-good: #0b1020; --on-bad: #0b1020; --good-fill: #22c55e;
    --shadow-1: none; --shadow-2: 0 0 0 1px rgb(255 255 255 / 0.03), 0 16px 40px rgb(0 0 0 / 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020; --bg-glow: rgb(99 102 241 / 0.16);
  --surface: #141a30; --surface-2: #1a2140; --surface-3: #242c4f;
  --border: #262f55; --border-strong: #3b4677;
  --text: #eef0ff; --text-2: #c5cae8; --text-3: #9ca3c9;
  --primary: #a5b4fc; --primary-ledge: #6366f1; --primary-hover: #c7d2fe; --on-primary: #10143a;
  --primary-soft: #232a57; --primary-ink: #c7d2fe;
  --accent: #fb923c; --accent-ink: #fdba74; --accent-soft: #3a2316;
  --gold: #fbbf24; --gold-ink: #fcd34d; --gold-soft: #3a2f12;
  --good: #22c55e; --good-ledge: #15803d; --good-ink: #4ade80; --good-soft: #10291c;
  --bad: #f87171; --bad-ledge: #b91c1c; --bad-ink: #fca5a5; --bad-soft: #36171b;
  --heart: #fb7185; --ring: #a5b4fc; --scrim: rgb(3 5 14 / 0.7); --on-good: #0b1020; --on-bad: #0b1020; --good-fill: #22c55e;
  --shadow-1: none; --shadow-2: 0 0 0 1px rgb(255 255 255 / 0.03), 0 16px 40px rgb(0 0 0 / 0.35);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding: 190px 0 calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); }
html:has(body.playing) { scroll-padding: 120px 0 140px; }
@media (min-width: 1200px) { html { scroll-padding-bottom: 24px; } }
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible, main:focus-visible { outline: none; }
/* long AWS identifiers (ApproximateNumberOfMessagesVisible, aws:PrincipalTag/…) must never widen the page */
.q-title, .tf-statement, .opt .txt, .tile, .order-item .txt, .bucket-head > span:first-child, .dnode span, .fb-answer, .fb-yours, .fb-explain, .fb-detail, .fb-whys, .review-item, .svc b, .svc small, .takeaways li span, .hero p, .ach b, .ach small { overflow-wrap: break-word; min-width: 0; }
.tile, .chip { max-width: 100%; }
main { overflow-x: clip; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 50% -200px, var(--bg-glow), transparent 70%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; margin: 0 0 var(--s3); letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0 0 var(--s3); }
a { color: var(--primary-ink); }
button { font: inherit; color: inherit; }
img, svg { display: block; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--s3); top: -60px; z-index: 100; background: var(--primary); color: var(--on-primary); padding: var(--s2) var(--s4); border-radius: var(--r-sm); font-weight: 600; text-decoration: none; }
.skip:focus { top: var(--s3); }
.noscript { padding: var(--s6); text-align: center; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 24px; height: 24px; }
.icon.xl { width: 32px; height: 32px; }
.icon.fill { fill: currentColor; stroke: none; }

.muted { color: var(--text-2); }
.subtle { color: var(--text-3); font-size: 14px; }
.display { font-family: var(--font-display); }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: 700; }
.row { display: flex; align-items: center; gap: var(--s2); }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: var(--s4); }
.stack.tight { gap: var(--s2); }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

/* ---------- layout ---------- */
main { width: 100%; max-width: 760px; margin: 0 auto; padding: var(--s4) var(--s4) calc(var(--tab-h) + var(--s7) + env(safe-area-inset-bottom)); outline: none; }
.screen { animation: screen-in var(--t-slow) var(--ease) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin: var(--s6) 0 var(--s3); }
.section-title h2 { margin: 0; }

/* ---------- HUD ---------- */
.hud { position: sticky; top: 0; z-index: 30; height: var(--hud-total); padding-top: env(safe-area-inset-top); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--border); }
.hud-inner { max-width: 760px; height: 100%; margin: 0 auto; padding: 0 var(--s4); display: flex; align-items: center; gap: var(--s2); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; color: var(--text); text-decoration: none; margin-right: auto; min-height: 44px; white-space: nowrap; min-width: 0; }
.hud-inner > .pill, .hud-inner > .icon-btn { flex: none; }
@media (max-width: 430px) {
  .brand > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .hud-inner { gap: 6px; }
  .pill { padding: 0 10px; gap: 4px; }
}
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(140deg, #6366f1, #4338ca); color: #fff; display: grid; place-items: center; box-shadow: 0 3px 0 #312e81; }
.brand-mark .icon { width: 20px; height: 20px; fill: #fff; stroke: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: var(--r-full); background: var(--surface); border: 1px solid var(--border); font-family: var(--font-display); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill .icon { width: 18px; height: 18px; }
.pill.streak { color: var(--accent-ink); }
.pill.streak .icon { color: var(--accent); fill: currentColor; stroke-width: 1.5; }
.pill.streak.cold { color: var(--text-3); }
.pill.streak.cold .icon { color: var(--text-3); fill: none; }
.pill.xp { color: var(--primary-ink); }
.pill.xp .icon { color: var(--gold); fill: currentColor; stroke: none; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn[aria-pressed="false"] { color: var(--text-3); }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding: 6px max(var(--s2), calc(50% - 380px)) env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border-radius: 14px; color: var(--text-3); text-decoration: none; font-size: 12.5px; font-weight: 600; transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.tab .icon { width: 24px; height: 24px; }
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--primary-ink); background: var(--primary-soft); }
.tab .badge-dot { position: relative; }
.tab .count { position: absolute; top: -6px; right: -12px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: var(--on-bad); font: 700 11px/18px var(--font-display); text-align: center; }
@media (min-width: 1200px) {
  .tabbar { top: calc(var(--hud-total) + var(--s5)); bottom: auto; left: calc(50% - 380px - 176px - var(--s5)); right: auto; width: 176px; height: auto; padding: var(--s2); display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; font-size: 15px; min-height: 48px; }
  main { padding-bottom: var(--s7); }
}
body.playing .hud, body.playing .tabbar { display: none; }
body.playing main { padding-bottom: 240px; max-width: 720px; }

/* ---------- buttons ---------- */
.btn {
  --b-bg: var(--surface); --b-fg: var(--text); --b-ledge: var(--border-strong); --b-border: var(--border-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 50px; padding: 0 22px; border-radius: var(--r-md); border: 2px solid var(--b-border);
  background: var(--b-bg); color: var(--b-fg); box-shadow: 0 4px 0 var(--b-ledge);
  font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: 0.01em; text-decoration: none;
  cursor: pointer; user-select: none; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), filter var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  margin-bottom: 4px;
}
.btn:hover { filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--b-ledge); }
.btn.primary { --b-bg: var(--primary); --b-fg: var(--on-primary); --b-ledge: var(--primary-ledge); --b-border: var(--primary); }
.btn.good { --b-bg: var(--good-fill); --b-fg: var(--on-good); --b-ledge: #14532d; --b-border: var(--good-fill); }
.btn.bad { --b-bg: var(--bad); --b-fg: #fff; --b-ledge: var(--bad-ledge); --b-border: var(--bad); }
:root[data-theme="dark"] .btn.good, :root[data-theme="dark"] .btn.bad { --b-fg: #0b1020; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.good, :root:not([data-theme="light"]) .btn.bad { --b-fg: #0b1020; } }
.btn.accent { --b-bg: #c2410c; --b-fg: #fff; --b-ledge: #9a3412; --b-border: var(--accent); }
.btn.ghost { --b-bg: transparent; --b-ledge: transparent; --b-border: transparent; color: var(--primary-ink); box-shadow: none; }
.btn.ghost:hover { --b-bg: var(--primary-soft); filter: none; }
.btn.btn:disabled { --b-bg: var(--surface-3); --b-fg: var(--text-3); --b-ledge: var(--border); --b-border: var(--border); cursor: not-allowed; filter: none; }
.btn.block { width: 100%; }
.btn { text-wrap: balance; }
.btn:has(> input:focus-visible) { outline: 3px solid var(--ring); outline-offset: 2px; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: var(--r-sm); }
.btn.lg { min-height: 56px; font-size: 18px; }
.kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; font: 600 12px/1 var(--font-display); color: var(--text-3); background: var(--surface); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-1); }
.card.flat { box-shadow: none; }
.card.tight { padding: var(--s4); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 10px; border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip .icon { width: 14px; height: 14px; }
.chip.primary { background: var(--primary-soft); border-color: transparent; color: var(--primary-ink); }
.chip.good { background: var(--good-soft); border-color: transparent; color: var(--good-ink); }
.chip.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad-ink); }
.chip.gold { background: var(--gold-soft); border-color: transparent; color: var(--gold-ink); }
.chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.bar { height: 10px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width 400ms var(--ease); }
.bar.gold > i { background: var(--gold); }
.bar.good > i { background: var(--good); }

/* ---------- home: hero & quick cards ---------- */
.hero { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: var(--s5); color: #fff; background: linear-gradient(135deg, oklch(0.45 0.14 var(--hue)), oklch(0.3 0.11 calc(var(--hue) - 18))); box-shadow: var(--shadow-2); }
.hero .btn:focus-visible { outline-color: #fff; }
.hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(420px 200px at 100% 0%, rgb(255 255 255 / 0.18), transparent 70%), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='2' cy='2' r='1.2' fill='white' fill-opacity='.10'/%3E%3C/svg%3E"); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero .eyebrow { font-family: var(--font-display); font-weight: 600; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.9; margin-bottom: 6px; }
.hero h1, .hero h2 { color: #fff; margin-bottom: var(--s2); }
.hero p { color: rgb(255 255 255 / 0.9); }
.hero .btn.on-dark { --b-bg: #fff; --b-fg: oklch(0.35 0.12 var(--hue)); --b-ledge: rgb(0 0 0 / 0.28); --b-border: #fff; }
.hero .meters { display: grid; gap: var(--s2); margin: var(--s4) 0; }
.hero .meter { display: flex; align-items: center; gap: var(--s3); font-size: 14px; color: rgb(255 255 255 / 0.95); }
.hero .meter .m-label { display: inline-flex; align-items: center; gap: 6px; min-width: 84px; font-weight: 600; }
.hero .meter .num { min-width: 72px; text-align: right; font-size: 13.5px; }
.hero .meter .bar { flex: 1; background: rgb(255 255 255 / 0.22); }
.hero .meter .bar > i { background: #fff; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-top: var(--s4); }
.quick-card { display: flex; align-items: center; gap: var(--s3); padding: var(--s4); min-height: 76px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: 0 3px 0 var(--border); text-align: left; cursor: pointer; text-decoration: none; color: var(--text); transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.quick-card:hover { border-color: var(--border-strong); }
.quick-card:active { transform: translateY(3px); box-shadow: 0 0 0 var(--border); }
.quick-card .qc-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
@media (max-width: 420px) { .quick-card { padding: var(--s3); gap: 10px; } .quick-card .qc-icon { width: 38px; height: 38px; } .quick-card b { font-size: 14.5px; } }
.quick-card b { display: block; font-family: var(--font-display); font-size: 15.5px; line-height: 1.25; }
.quick-card small { display: block; color: var(--text-3); font-size: 13px; line-height: 1.35; margin-top: 2px; }
.qc-icon.accent { background: var(--accent-soft); color: var(--accent); }
.qc-icon.primary { background: var(--primary-soft); color: var(--primary-ink); }
.qc-icon.bad { background: var(--bad-soft); color: var(--bad-ink); }
.qc-icon.gold { background: var(--gold-soft); color: var(--gold-ink); }
.qc-icon.good { background: var(--good-soft); color: var(--good-ink); }
.done-mark { margin-left: auto; color: var(--good-ink); }

/* ---------- map ---------- */
.world { margin-top: var(--s6); }
.world-banner { position: sticky; top: calc(var(--hud-total) + 8px); z-index: 5; display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-lg); color: #fff; background: linear-gradient(120deg, oklch(0.44 0.14 var(--hue)), oklch(0.33 0.11 calc(var(--hue) - 10))); box-shadow: 0 4px 0 oklch(0.24 0.08 var(--hue)), var(--shadow-2); }
/* a strip of page colour above the stuck banner so scrolling nodes never show through the gap */
.world-banner::before { content: ""; position: absolute; left: -8px; right: -8px; bottom: 100%; height: 10px; background: var(--bg); }
.world-banner .wb-num { font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.88; }
.world-banner h2 { color: #fff; margin: 0; font-size: 19px; }
.world-banner p { margin: 0; font-size: 13.5px; color: rgb(255 255 255 / 0.92); line-height: 1.35; }
.world-banner .wb-stars { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-display); font-weight: 700; font-size: 15px; padding: 6px 10px; border-radius: var(--r-full); background: rgb(0 0 0 / 0.2); white-space: nowrap; }
.world-banner .wb-stars .icon { width: 16px; height: 16px; color: #fcd34d; fill: currentColor; stroke: none; }
.world-banner .icon-btn { color: #fff; background: rgb(255 255 255 / 0.14); }
.world-banner .icon-btn:hover { background: rgb(255 255 255 / 0.26); }
.world.locked .world-banner { background: linear-gradient(120deg, oklch(0.47 0.03 var(--hue)), oklch(0.36 0.025 var(--hue))); box-shadow: 0 4px 0 oklch(0.28 0.02 var(--hue)), var(--shadow-1); }
.path { position: relative; display: flex; flex-direction: column; align-items: center; gap: 30px; padding: var(--s7) 0 var(--s4); }
.path .trail { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: visible; }
.trail path { fill: none; stroke: oklch(0.8 0.06 var(--hue)); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 1 14; }
.trail path.done { stroke: oklch(0.6 0.13 var(--hue)); stroke-dasharray: none; stroke-width: 5; }
:root[data-theme="dark"] .trail path { stroke: oklch(0.42 0.06 var(--hue)); }
:root[data-theme="dark"] .trail path.done { stroke: oklch(0.55 0.12 var(--hue)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .trail path { stroke: oklch(0.42 0.06 var(--hue)); } :root:not([data-theme="light"]) .trail path.done { stroke: oklch(0.55 0.12 var(--hue)); } }
.node-wrap { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 132px; transform: translateX(var(--x, 0)); }
.node-wrap.has-bubble { margin-top: 26px; }
.node {
  --n-bg: oklch(0.47 0.15 var(--hue)); --n-ledge: oklch(0.34 0.12 var(--hue));
  position: relative; width: 76px; height: 70px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--n-bg); color: #fff; box-shadow: 0 7px 0 var(--n-ledge), inset 0 -4px 0 rgb(0 0 0 / 0.12), inset 0 3px 0 rgb(255 255 255 / 0.18);
  display: grid; place-items: center; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  margin-bottom: 7px;
}
.node:hover { filter: brightness(1.07); }
.node:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--n-ledge); }
.node .num { font-size: 22px; line-height: 1; }
.node .icon { width: 30px; height: 30px; }
/* 3 stars keep the world colour and get a gold ring + crown, so they never look like an unplayed gold-world node */
.node.perfect::after { content: ""; position: absolute; inset: -7px; border-radius: inherit; border: 3px solid #fbbf24; pointer-events: none; }
.perfect-badge { position: absolute; top: -10px; right: -10px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #f59e0b; color: #451a03; box-shadow: 0 2px 0 #a16207; }
.node .perfect-badge .icon, .node.boss .perfect-badge .icon { width: 16px; height: 16px; }
.node.locked { --n-bg: var(--surface-3); --n-ledge: var(--border-strong); color: var(--text-3); box-shadow: 0 7px 0 var(--n-ledge); cursor: pointer; }
.node.current::before { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 4px solid oklch(0.65 0.15 var(--hue) / 0.5); }
.node.boss { width: 94px; height: 86px; border-radius: 28px; }
.node.boss .icon { width: 38px; height: 38px; }
.node.boss .perfect-badge .icon { width: 16px; height: 16px; }
.node-label { max-width: 132px; text-align: center; font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--text-2); background: var(--bg); padding: 1px 6px; border-radius: 6px; }
.node-stars { background: var(--bg); padding: 0 4px; border-radius: 6px; }
.node-stars { display: flex; gap: 2px; height: 16px; }
.node-stars .icon { width: 16px; height: 16px; fill: none; stroke: var(--text-3); stroke-width: 1.6; }
.node-stars .icon.on { color: var(--gold); fill: currentColor; stroke: #b45309; stroke-width: 1.5; }
.start-bubble { position: absolute; top: -40px; left: 50%; transform: translateX(-50%); padding: 6px 12px; border-radius: 10px; background: var(--surface); border: 2px solid var(--border-strong); font: 700 13px/1.2 var(--font-display); color: oklch(0.42 0.13 var(--hue)); white-space: nowrap; box-shadow: var(--shadow-1); pointer-events: none; }
:root[data-theme="dark"] .start-bubble { color: oklch(0.85 0.09 var(--hue)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .start-bubble { color: oklch(0.85 0.09 var(--hue)); } }
.start-bubble::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 12px; height: 12px; background: var(--surface); border: solid var(--border-strong); border-width: 0 2px 2px 0; transform: translateX(-50%) rotate(45deg); }

/* ---------- sheets / dialogs ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; animation: fade-in var(--t-med) var(--ease) both; }
@keyframes fade-in { from { opacity: 0; } }
.sheet { position: relative; width: 100%; max-width: 560px; max-height: min(88dvh, 820px); overflow: auto; overscroll-behavior: contain; background: var(--surface); border-radius: 24px 24px 0 0; padding: var(--s5) var(--s5) calc(var(--s5) + env(safe-area-inset-bottom)); box-shadow: var(--shadow-2); animation: sheet-up var(--t-slow) var(--ease) both; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 640px) { .scrim { align-items: center; padding: var(--s5); } .sheet { border-radius: 24px; } }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: -8px auto var(--s4); }
@media (min-width: 640px) { .sheet .grab { display: none; } }
.sheet .close { position: absolute; top: 12px; right: 12px; }
.sheet-head { display: flex; gap: var(--s4); align-items: center; margin-bottom: var(--s4); padding-right: 40px; }
.badge-hex { width: 56px; height: 56px; flex: none; display: grid; place-items: center; border-radius: 16px; color: #fff; background: linear-gradient(140deg, oklch(0.47 0.15 var(--hue)), oklch(0.33 0.11 calc(var(--hue) - 16))); box-shadow: 0 4px 0 oklch(0.25 0.08 var(--hue)); }
.badge-hex .icon { width: 28px; height: 28px; }
.sheet h2 { margin: 0 0 2px; }
.takeaways { display: grid; gap: var(--s2); margin: var(--s3) 0 var(--s5); }
.takeaways li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); font-size: 15px; line-height: 1.45; }
.takeaways li .icon { color: var(--gold); margin-top: 2px; }
.takeaways.compact { margin: 0 0 var(--s3); }
.takeaways.compact li { padding: 6px 10px; font-size: 14px; }
.steps-list { list-style: decimal; padding-left: 22px; margin: 0 0 var(--s3); display: grid; gap: 4px; }
.rules { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--text-2); background: var(--surface-2); border-radius: var(--r-md); padding: 10px 12px; margin: 0 0 var(--s4); }
.rules .icon { color: var(--heart); margin-top: 3px; }
.sheet-actions { display: grid; gap: var(--s3); }
.sheet > div > .sheet-actions:last-child { position: sticky; z-index: 2; bottom: calc(-1 * (var(--s5) + env(safe-area-inset-bottom))); margin: 0 calc(-1 * var(--s5)) calc(-1 * (var(--s5) + env(safe-area-inset-bottom))); padding: var(--s4) var(--s5) calc(var(--s5) + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--surface) 14px); }
.sheet-actions.two { grid-template-columns: 1fr 1fr; }
details.disclose { border: 1px solid var(--border); border-radius: var(--r-md); padding: 0 var(--s4); margin-bottom: var(--s4); }
details.disclose summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 48px; cursor: pointer; font-weight: 600; list-style: none; }
details.disclose summary::-webkit-details-marker { display: none; }
details.disclose summary .icon { transition: transform var(--t-med) var(--ease); }
details.disclose[open] summary .icon { transform: rotate(180deg); }
details.disclose .takeaways { margin-top: 0; }

/* ---------- welcome ---------- */
.welcome { text-align: center; }
.welcome .brand-mark.big { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto var(--s4); box-shadow: 0 5px 0 #312e81; display: grid; }
.welcome .brand-mark.big .icon { width: 36px; height: 36px; }
.welcome h2 { font-size: 24px; }
.welcome-rules { display: grid; gap: var(--s2); margin: var(--s4) 0; text-align: left; }
.welcome-rule { display: flex; gap: var(--s3); align-items: center; padding: var(--s3); border-radius: var(--r-md); background: var(--surface-2); }
.welcome-rule .qc-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.welcome-rule b { display: block; font-family: var(--font-display); font-size: 15.5px; line-height: 1.3; }
.welcome-rule span:not(.qc-icon) { display: block; font-size: 14px; color: var(--text-2); line-height: 1.4; }
.welcome-q { font-weight: 600; margin: 0; text-align: center; }
.welcome .sheet-actions { margin-top: var(--s4); }
.qc-icon.primary, .qc-icon.accent, .qc-icon.good, .qc-icon.bad, .qc-icon.gold { flex: none; }

/* ---------- player ---------- */
.play-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s3); margin-inline: calc(-1 * var(--s4)); padding: calc(var(--s3) + env(safe-area-inset-top)) var(--s4) var(--s3); background: var(--bg); }
.counter { font-size: 14px; color: var(--text-2); min-width: 40px; text-align: center; }
body.playing { background: var(--bg); }
.play-progress { flex: 1; height: 16px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; position: relative; }
.play-progress > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(180deg, color-mix(in srgb, var(--good) 80%, #fff), var(--good)); transition: width 380ms var(--ease); }
.play-progress > i::after { content: ""; position: absolute; left: 8px; right: 8px; top: 4px; height: 4px; border-radius: 2px; background: rgb(255 255 255 / 0.35); }
.hearts { display: inline-flex; align-items: center; gap: 4px; font: 700 19px/1 var(--font-display); color: var(--heart); min-width: 48px; }
.hearts.out { color: var(--text-3); }
.hearts .icon { width: 24px; height: 24px; fill: currentColor; stroke: none; }
.hearts.hit { animation: heart-hit 420ms var(--ease); }
@keyframes heart-hit { 30% { transform: scale(1.35); } 60% { transform: scale(0.9); } }
.timer { display: inline-flex; align-items: center; gap: 6px; font: 700 18px/1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--text); min-width: 64px; justify-content: flex-end; }
.timer.low { color: var(--bad-ink); }
.combo-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 64px; flex: none; gap: 4px; height: 32px; padding: 0 12px; border-radius: var(--r-full); background: var(--accent-soft); color: var(--accent-ink); font: 700 14px/1 var(--font-display); white-space: nowrap; }
.combo-chip small { font-size: 12px; font-weight: 600; }
@media (max-width: 480px) { .combo-chip small { display: none; } }
@media (min-width: 481px) { .combo-chip { min-width: 116px; } }
/* single-key shortcuts switched off: hide their hints */
.no-shortcuts .hint-keys, .no-shortcuts .opt .key, .no-shortcuts .tf .opt .kbd, .no-shortcuts .bucket-head .kbd { display: none !important; }
.combo-chip .icon { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.combo-chip.bump { animation: pop 320ms var(--ease-pop); }
@keyframes pop { from { transform: scale(0.6); } }

.boss-bar { position: sticky; top: calc(68px + env(safe-area-inset-top)); z-index: 19; display: flex; align-items: center; gap: var(--s3); margin: var(--s2) 0 var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r-lg); color: #fff; background: linear-gradient(120deg, oklch(0.4 0.13 var(--hue)), oklch(0.26 0.09 calc(var(--hue) - 24))); box-shadow: 0 4px 0 oklch(0.2 0.07 var(--hue)), var(--shadow-2); }
.boss-bar .boss-hp-text { color: rgb(255 255 255 / 0.9); font-size: 14px; }
.boss-face { position: relative; width: 60px; height: 60px; flex: none; border-radius: 16px; display: grid; place-items: center; color: #fff; background: linear-gradient(140deg, oklch(0.52 0.17 var(--hue)), oklch(0.32 0.12 calc(var(--hue) - 30))); box-shadow: 0 4px 0 oklch(0.22 0.08 var(--hue)), inset 0 0 0 2px rgb(255 255 255 / 0.18); }
@media (max-width: 520px) { .boss-bar { padding: 8px 12px; gap: 10px; } .boss-face { width: 44px; height: 44px; border-radius: 12px; } .boss-face .icon { width: 24px; height: 24px; } .boss-line { display: none; } }
.boss-face .icon { width: 30px; height: 30px; }
.boss-face.hit { animation: boss-hit 380ms var(--ease); }
@keyframes boss-hit { 20% { transform: translateX(-6px) rotate(-6deg); filter: brightness(1.6); } 50% { transform: translateX(5px) rotate(4deg); } }
.boss-hp { position: relative; height: 14px; border-radius: var(--r-full); background: rgb(0 0 0 / 0.32); overflow: hidden; margin-top: 6px; }
/* one segment per hit */
.boss-hp::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(100% / var(--hp, 10) - 2px), rgb(0 0 0 / 0.35) 0 calc(100% / var(--hp, 10))); pointer-events: none; }
.boss-hp > i { display: block; height: 100%; background: linear-gradient(90deg, #ef4444, #f97316); transition: width 420ms var(--ease); }
.boss-name { font: 700 16px/1.2 var(--font-display); color: #fff; }
.boss-line { font-size: 13px; color: var(--text-3); font-style: italic; }
.dmg { position: absolute; right: -6px; top: -8px; font: 700 22px/1 var(--font-display); color: #fecaca; text-shadow: 0 2px 0 rgb(0 0 0 / 0.4); pointer-events: none; animation: dmg-up 700ms var(--ease) forwards; }
@keyframes dmg-up { to { transform: translateY(-36px); opacity: 0; } }

.q { padding-top: var(--s3); animation: q-in var(--t-slow) var(--ease) both; }
@keyframes q-in { from { opacity: 0; transform: translateX(16px); } }
.q-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.q-kind { display: inline-flex; align-items: center; gap: 6px; font: 700 13px/1 var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary-ink); }
.q-kind .icon { width: 16px; height: 16px; }
.pips { display: inline-flex; gap: 3px; align-items: center; }
.pips i { width: 8px; height: 8px; border-radius: 2px; background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-3); }
.pips i.on { background: var(--accent); box-shadow: none; }
.q-title { font-family: var(--font-body); font-weight: 600; font-size: 19px; line-height: 1.5; margin: 0 0 var(--s5); text-wrap: pretty; letter-spacing: 0; }
.q-title.long { font-weight: 500; font-size: 18px; }
@media (min-width: 640px) { .q-title { font-size: 21px; } }
.q-hint { font-size: 14px; color: var(--text-3); margin: calc(var(--s3) * -1) 0 var(--s4); }

.opts { display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); }
.opts.multi .opt .key { border-radius: 6px; }
.opt {
  --o-border: var(--border-strong); --o-ledge: var(--border-strong); --o-bg: var(--surface);
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 58px; padding: 12px 16px; text-align: left;
  border-radius: var(--r-md); border: 2px solid var(--o-border); background: var(--o-bg); box-shadow: 0 3px 0 var(--o-ledge);
  cursor: pointer; font-size: 16px; line-height: 1.45; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  margin-bottom: 3px;
}
.opt:hover:not(:disabled) { --o-bg: var(--surface-2); }
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--o-ledge); }
.opt .key { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; border: 2px solid var(--border-strong); font: 700 14px/1 var(--font-display); color: var(--text-3); }
.opt .txt { flex: 1; min-width: 0; }
.opt .why { display: block; font-size: 14px; color: var(--text-2); margin-top: 4px; font-weight: 400; }
.opt.is-dim .why { font-size: 13px; }
.opt[aria-pressed="true"], .opt[aria-checked="true"] { --o-border: var(--primary); --o-ledge: var(--primary-ledge); --o-bg: var(--primary-soft); }
.opt[aria-pressed="true"] .key, .opt[aria-checked="true"] .key { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.opt.is-right { --o-border: var(--good); --o-ledge: var(--good-ledge); --o-bg: var(--good-soft); }
.opt.is-right .key { border-color: var(--good-fill); background: var(--good-fill); color: var(--on-good); }
.opt.is-wrong { --o-border: var(--bad); --o-ledge: var(--bad-ledge); --o-bg: var(--bad-soft); }
.opt.is-wrong .key { border-color: var(--bad); background: var(--bad); color: var(--on-bad); }
.opt.is-dim { opacity: 0.72; }
.opt:disabled { cursor: default; }
.opt .state-icon { flex: none; }
.opt.is-right .state-icon { color: var(--good-ink); }
.opt.is-wrong .state-icon { color: var(--bad-ink); }

.tf-statement { font-family: var(--font-body); font-size: 19px; font-weight: 600; letter-spacing: 0; line-height: 1.5; padding: var(--s5); border-radius: var(--r-lg); background: var(--surface); border: 2px solid var(--border); margin-bottom: var(--s5); text-wrap: pretty; }
@media (min-width: 640px) { .tf-statement { font-size: 21px; } }
.tf { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.tf .opt { flex-direction: column; justify-content: center; min-height: 96px; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 18px; gap: 6px; }
.tf .opt .icon { width: 28px; height: 28px; }
.tf .opt .kbd { margin-top: 2px; }

.match { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s3); align-items: stretch; }
.match .col { display: grid; gap: var(--s3); grid-auto-rows: 1fr; min-width: 0; }
.match .col.right .tile { justify-content: flex-start; text-align: left; font-size: 14.5px; }
.tile .pair-no { flex: none; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--good-fill); color: var(--on-good); font: 700 12px/1 var(--font-display); margin-right: 8px; }
.tile {
  --t-border: var(--border-strong); --t-ledge: var(--border-strong); --t-bg: var(--surface);
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 64px; padding: 10px 12px; text-align: center;
  border-radius: var(--r-md); border: 2px solid var(--t-border); background: var(--t-bg); box-shadow: 0 3px 0 var(--t-ledge);
  font-size: 15px; line-height: 1.35; cursor: pointer; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), opacity var(--t-med) var(--ease);
  margin-bottom: 3px;
}
.tile.term { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; }
.tile:hover:not(:disabled) { --t-bg: var(--surface-2); }
.tile:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--t-ledge); }
.tile[aria-pressed="true"] { --t-border: var(--primary); --t-ledge: var(--primary-ledge); --t-bg: var(--primary-soft); }
.tile.matched { --t-border: var(--good); --t-ledge: var(--good-ledge); --t-bg: var(--good-soft); color: var(--good-ink); cursor: default; }
.tile.miss { --t-border: var(--bad); --t-ledge: var(--bad-ledge); --t-bg: var(--bad-soft); animation: shake 360ms var(--ease); }
.tile:disabled { cursor: default; }
.tile.placed { min-height: 44px; flex-wrap: wrap; justify-content: flex-start; text-align: left; gap: 2px 8px; min-width: 0; }
.tile.placed .fix { flex-basis: 100%; }
.tile.is-right { --t-border: var(--good); --t-ledge: var(--good-ledge); --t-bg: var(--good-soft); }
.tile.is-wrong { --t-border: var(--bad); --t-ledge: var(--bad-ledge); --t-bg: var(--bad-soft); }
.tile .fix { display: block; font-size: 12.5px; color: var(--bad-ink); font-weight: 600; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.tray { display: flex; flex-wrap: wrap; gap: var(--s2); min-height: 64px; padding: var(--s3); border-radius: var(--r-lg); border: 2px dashed var(--border-strong); margin-bottom: var(--s4); }
.tray .tile { width: auto; min-height: 44px; padding: 6px 12px; font-size: 14.5px; justify-content: flex-start; text-align: left; }
.tray-empty { color: var(--text-3); font-size: 14px; align-self: center; padding: 0 var(--s2); }
.buckets { display: grid; gap: var(--s3); grid-template-columns: repeat(var(--nb, 2), minmax(0, 1fr)); }
.bucket { min-width: 0; }
.bucket-head > span:first-child { min-width: 0; }
.sort-dock { display: none; }
@media (max-width: 560px), (max-height: 500px) and (orientation: landscape) {
  .sort-dock:not([hidden]) { display: block; position: sticky; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 4; margin: 0 0 var(--s3); padding: 6px 8px 8px; border-radius: var(--r-md); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 2px solid var(--primary); box-shadow: var(--shadow-2); }
  .dock-label { font-size: 13px; font-weight: 600; color: var(--primary-ink); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dock-btns { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .dock-btns::-webkit-scrollbar { display: none; }
  .dock-btns .btn { flex: 1 0 auto; margin-bottom: 3px; }
  .tray .tile { scroll-margin-bottom: 220px; }
}
@media (max-width: 560px) {
  .buckets { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .bucket { padding: 8px; min-height: 0; }
  .bucket .stack { display: flex; flex-wrap: wrap; gap: 6px; }
  .bucket .tile { width: auto; }
  .bucket-head { font-size: 14px; padding: 6px 10px; min-height: 44px; }
}
@media (hover: none) { .bucket-head .kbd, .tf .opt .kbd, .hint-keys { display: none !important; } }
.bucket { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); border-radius: var(--r-lg); border: 2px solid var(--border); background: var(--surface-2); min-height: 140px; }
.bucket-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); width: 100%; min-height: 48px; padding: 8px 12px; border-radius: var(--r-md); border: 2px solid var(--border-strong); background: var(--surface); font: 700 15px/1.25 var(--font-display); text-align: left; cursor: pointer; box-shadow: 0 3px 0 var(--border-strong); margin-bottom: 3px; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast); }
.bucket-head:disabled { cursor: default; }
.bucket.armed .bucket-head { border-color: var(--primary); box-shadow: 0 3px 0 var(--primary-ledge); color: var(--primary-ink); }
.bucket-head:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.bucket .tile { min-height: 44px; font-size: 14.5px; }

.order-list { display: grid; gap: var(--s2); grid-template-columns: minmax(0, 1fr); }
.order-item { display: flex; align-items: center; gap: var(--s2); padding: 8px 8px 8px 12px; border-radius: var(--r-md); border: 2px solid var(--border-strong); background: var(--surface); box-shadow: 0 3px 0 var(--border-strong); margin-bottom: 3px; transition: transform var(--t-med) var(--ease); }
.order-item .n { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); font: 700 14px/1 var(--font-display); }
.order-item .txt { flex: 1; min-width: 0; font-size: 15.5px; line-height: 1.4; }
.order-item .moves { display: flex; gap: 2px; }
.order-item .icon-btn { width: 44px; height: 44px; border: 1px solid var(--border); }
.order-item .icon-btn:disabled { opacity: 0.35; cursor: default; }
.order-item.is-right { border-color: var(--good); box-shadow: 0 3px 0 var(--good-ledge); background: var(--good-soft); }
.order-item.is-wrong { border-color: var(--bad); box-shadow: 0 3px 0 var(--bad-ledge); background: var(--bad-soft); }
.order-item.is-right .n { background: var(--good-fill); color: var(--on-good); }
.order-item.is-wrong .n { background: var(--bad); color: var(--on-bad); }
.order-item .fix { display: block; font-size: 13px; font-weight: 600; color: var(--bad-ink); }
.order-item.moved { animation: nudge 260ms var(--ease); }
@keyframes nudge { 40% { transform: scale(1.02); } }

.diagram { display: flex; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 0; padding: var(--s4); border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: var(--s4); background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 16px 16px; }
.dnode { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; flex: 1 1 0; min-width: 0; max-width: 150px; min-height: 76px; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface); border: 2px solid var(--border-strong); text-align: center; font: 700 14px/1.25 var(--font-display); }
.dnode .icon { color: var(--text-3); }
.dnode.slot { border-style: dashed; color: var(--text-3); cursor: pointer; background: var(--surface); transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast); }
.dnode.slot:hover:not(:disabled) { border-color: var(--primary); }
.dnode.slot.armed { border-color: var(--primary); border-style: solid; background: var(--primary-soft); color: var(--primary-ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.dnode.slot.filled { border-style: solid; border-color: oklch(0.55 0.13 var(--hue)); color: var(--text); }
.dnode.slot.is-right { border-color: var(--good); background: var(--good-soft); color: var(--good-ink); }
.dnode.slot.is-wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad-ink); }
.dnode .fix { flex-basis: 100%; font: 600 12px/1.25 var(--font-body); color: var(--good-ink); }
.dnode.slot:disabled { cursor: default; }
.arrow { display: grid; place-items: center; width: 28px; color: var(--text-3); }
@media (max-width: 560px) {
  .diagram { flex-direction: column; padding: var(--s3); }
  .dnode { width: 100%; max-width: 280px; min-height: 44px; padding: 6px 12px; flex: none; flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .arrow { width: auto; height: 14px; transform: rotate(90deg); }
  .arrow .icon { width: 16px; height: 16px; }
  /* the service pool is one swipeable row so it never hides the slots */
  .pool:not(.revealed) { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scroll-snap-type: x proximity; padding: 4px 0 8px; scrollbar-width: none; }
  .pool:not(.revealed)::-webkit-scrollbar { display: none; }
  .pool .tile { flex: none; min-width: 0; scroll-snap-align: start; }
  .dnode.slot { scroll-margin: 90px 0 200px; }
}
@media (max-width: 560px) and (min-height: 700px) {
  /* tall phones: keep that row next to the thumb while filling slots */
  .pool:not(.revealed) { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 4; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
}
@media (min-width: 561px) { .build.long .diagram { flex-direction: column; } .build.long .dnode { width: 100%; max-width: 320px; min-height: 52px; flex: none; flex-direction: row; } .build.long .arrow { transform: rotate(90deg); height: 18px; } }
.pool { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: center; }
.pool .tile { width: auto; min-width: 104px; min-height: 48px; font-family: var(--font-display); font-weight: 700; }
.pool .tile.used { opacity: 0.35; }
.pool.revealed .tile:not(.used) { opacity: 0.45; box-shadow: none; }
.arrow { flex: none; }

/* answer bar + feedback */
.answer-bar { position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; padding: var(--s4) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
.answer-bar-inner { max-width: 688px; margin: 0 auto; display: flex; align-items: center; gap: var(--s3); }
.answer-bar .hint-keys { color: var(--text-3); font-size: 13px; display: none; align-items: center; gap: 6px; }
@media (min-width: 720px) and (hover: hover) { .answer-bar .hint-keys { display: inline-flex; } }
.answer-bar .btn.primary { margin-left: auto; min-width: 180px; }
.answer-bar .btn.ghost { flex: none; min-width: 0; margin-left: -12px; }
@media (max-width: 520px) { .answer-bar .btn.primary { flex: 1; min-width: 0; } }
.feedback { position: fixed; z-index: 26; left: 0; right: 0; bottom: 0; padding: var(--s5) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom)); animation: sheet-up var(--t-slow) var(--ease) both; max-height: 72dvh; overflow: auto; border-radius: 22px 22px 0 0; box-shadow: 0 -14px 36px rgb(20 26 51 / 0.16); }
.feedback.good { background: var(--good-soft); box-shadow: inset 0 3px 0 var(--good), 0 -14px 36px rgb(20 26 51 / 0.16); }
.feedback.bad { background: var(--bad-soft); box-shadow: inset 0 3px 0 var(--bad), 0 -14px 36px rgb(20 26 51 / 0.16); }
.feedback-inner { max-width: 688px; margin: 0 auto; }
.fb-yours { margin-bottom: var(--s2); font-size: 15px; }
.fb-yours .why { color: var(--text-2); }
.fb-note { display: flex; gap: 8px; align-items: center; font-weight: 600; color: var(--bad-ink); margin-bottom: var(--s2); }
.fb-detail { margin-bottom: var(--s2); }
.fb-detail .takeaways li { background: rgb(255 255 255 / 0.55); }
:root[data-theme="dark"] .fb-detail .takeaways li { background: rgb(0 0 0 / 0.2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fb-detail .takeaways li { background: rgb(0 0 0 / 0.2); } }
.fb-meta { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-2); margin: calc(var(--s2) * -1) 0 var(--s3); }
.fb-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s2); }
.fb-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface); }
.feedback.good .fb-icon { color: var(--good-ink); }
.feedback.bad .fb-icon { color: var(--bad-ink); }
.fb-title { font: 700 22px/1.2 var(--font-display); margin: 0; }
.feedback.good .fb-title { color: var(--good-ink); }
.feedback.bad .fb-title { color: var(--bad-ink); }
.fb-answer { font-weight: 600; margin-bottom: var(--s2); }
.fb-explain { color: var(--text); font-size: 15.5px; line-height: 1.55; margin-bottom: var(--s4); }
.fb-actions { display: flex; align-items: center; gap: var(--s3); position: sticky; z-index: 1; bottom: calc(-1 * (var(--s4) + env(safe-area-inset-bottom))); margin: 0 calc(-1 * var(--s4)) calc(-1 * (var(--s4) + env(safe-area-inset-bottom))); padding: var(--s3) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom)); }
.feedback.good .fb-actions { background: var(--good-soft); }
.feedback.bad .fb-actions { background: var(--bad-soft); }
.fb-whys { margin: 0 0 var(--s3); font-size: 14.5px; }
.fb-whys summary { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; cursor: pointer; font-weight: 600; color: var(--text-2); list-style: none; }
.fb-whys summary::-webkit-details-marker { display: none; }
.fb-whys[open] summary .icon { transform: rotate(180deg); }
.fb-whys ul { display: grid; gap: 6px; padding-left: 0; }
.fb-whys li { padding: 8px 10px; border-radius: var(--r-sm); background: rgb(255 255 255 / 0.55); color: var(--text-2); }
:root[data-theme="dark"] .fb-whys li { background: rgb(0 0 0 / 0.2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fb-whys li { background: rgb(0 0 0 / 0.2); } }
.fb-whys li b { color: var(--text); font-weight: 600; }
.fb-actions .btn.primary-action { margin-left: auto; min-width: 180px; }
@media (max-width: 520px) { .fb-actions .btn.primary-action { flex: 1; min-width: 0; } }
.fb-actions .flag { color: var(--text-2); }
.fb-actions .flag[aria-pressed="true"] { color: var(--bad-ink); }
.xp-float { font: 700 15px/1 var(--font-display); color: var(--good-ink); margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }

.shake { animation: shake 360ms var(--ease); }
.pop-in { animation: pop 320ms var(--ease-pop) both; }

/* ---------- results ---------- */
.result { text-align: center; padding-top: var(--s6); }
.result h1 { font-size: 32px; margin-bottom: var(--s2); }
.stars-big { display: flex; justify-content: center; align-items: flex-end; gap: var(--s3); margin: var(--s5) 0; }
.stars-big > .icon { width: 64px; height: 64px; fill: none; stroke: var(--text-3); stroke-width: 1.4; }
.stars-big > .icon:nth-child(2) { width: 84px; height: 84px; }
.stars-big > .icon.on { color: var(--gold); fill: currentColor; stroke: #b45309; stroke-width: 1; filter: drop-shadow(0 4px 0 #b45309); animation: star-in 420ms var(--ease-pop) both; }
.stars-big > .icon.on:nth-child(2) { animation-delay: 160ms; }
.stars-big > .icon.on:nth-child(3) { animation-delay: 320ms; }
.result-badge { display: flex; justify-content: center; margin: var(--s5) 0; }
.result-badge .badge-hex { width: 84px; height: 84px; border-radius: 24px; }
.result-badge .icon { width: 40px; height: 40px; }
.result-xp { display: inline-flex; align-items: center; gap: 8px; margin: var(--s2) 0 var(--s4); font: 700 40px/1 var(--font-display); color: var(--gold-ink); font-variant-numeric: tabular-nums; }
.result-xp .icon { width: 32px; height: 32px; color: var(--gold); }
@keyframes star-in { from { transform: scale(0.2) rotate(-30deg); opacity: 0; } }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); margin: var(--s5) 0; }
.stat-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 0; }
@media (max-width: 420px) { .stat-grid.three .stat { padding: var(--s2) var(--s3); } .stat-grid.three .label { font-size: 11px; letter-spacing: 0.04em; } .stat-grid.three .label .icon { display: none; } .stat-grid.three .value { font-size: 22px; } }
@media (min-width: 560px) { .stat-grid.four { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: var(--s3) var(--s4); border-radius: var(--r-lg); border: 2px solid var(--border); background: var(--surface); text-align: left; }
.stat .label { display: flex; align-items: center; gap: 6px; font: 700 12px/1.2 var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; }
.stat .value { font: 700 26px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.stat.xp .value { color: var(--gold-ink); }
.stat.acc .value { color: var(--good-ink); }
.stat.acc.bad .value { color: var(--bad-ink); }
body.playing main:has(.result) { padding-bottom: var(--s6); }
.stat.cmb .value { color: var(--accent-ink); }
.review-list { display: grid; gap: var(--s3); text-align: left; grid-template-columns: minmax(0, 1fr); }
.topics { text-align: left; }
.topic-list { display: grid; gap: var(--s3); }
.topic { display: grid; grid-template-columns: minmax(0, 1fr) 56px; align-items: center; gap: var(--s3); }
.topic-act { display: flex; justify-content: flex-end; }
.topic .row.between .num { white-space: nowrap; flex: none; }
.topic .row.between b { min-width: 0; }
section.card .topic { grid-template-columns: minmax(0, 1fr); }
.topic .bar { margin-top: 6px; }
.bar.warn > i { background: var(--accent); }
.bar.topic-bar > i { background: oklch(0.55 0.14 var(--hue)); }
.review-item { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); padding: var(--s3) var(--s4); }
.review-item summary { cursor: pointer; display: flex; gap: var(--s2); align-items: flex-start; min-height: 32px; font-weight: 600; line-height: 1.45; list-style: none; }
.review-item summary::-webkit-details-marker { display: none; }
.review-item summary .icon { color: var(--bad-ink); margin-top: 3px; }
.review-item .ri-body { margin-top: var(--s2); font-size: 15px; color: var(--text-2); }
.review-item .ri-body b { color: var(--text); }
.unlock-row { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: center; margin: var(--s3) 0; }
.unlock-row .chip { text-decoration: none; min-height: 36px; padding: 6px 12px; white-space: normal; text-align: left; line-height: 1.3; }
.result section { margin-top: var(--s5); }
.ach.fresh { border-color: color-mix(in srgb, var(--gold) 55%, var(--border)); text-align: left; animation: pop 360ms var(--ease-pop) both; }
.result-actions { display: grid; gap: var(--s3); margin-top: var(--s5); }
@media (min-width: 560px) { .result-actions { grid-template-columns: 1fr 1fr; } .result-actions .btn.primary { grid-column: 1 / -1; } }
canvas.confetti { position: fixed; inset: 0; z-index: 60; pointer-events: none; }

/* ---------- modes ---------- */
.mode-grid { display: grid; gap: var(--s3); }
@media (min-width: 560px) { .mode-grid { grid-template-columns: 1fr 1fr; } }
.mode-card { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s5); border-radius: var(--r-lg); background: var(--surface); border: 2px solid var(--border); box-shadow: 0 4px 0 var(--border); text-align: left; cursor: pointer; color: var(--text); transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast); }
.mode-card:hover { border-color: var(--border-strong); }
.mode-card:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.mode-card:disabled { opacity: 0.6; cursor: not-allowed; }
.mode-card .qc-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; margin-bottom: var(--s2); }
.mode-card .qc-icon .icon { width: 28px; height: 28px; }
.mode-card h3 { margin: 0; font-size: 19px; }
.mode-card p { margin: 0; color: var(--text-2); font-size: 15px; }
.mode-card .foot { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-top: auto; padding-top: var(--s2); }
@media (max-width: 559px) {
  .mode-card { display: grid; grid-template-columns: 52px minmax(0, 1fr); column-gap: var(--s4); row-gap: 4px; padding: var(--s4); }
  .mode-card .qc-icon { grid-row: 1 / span 3; margin: 0; }
  .mode-card .foot { grid-column: 2; padding-top: 4px; }
}
.scope { display: flex; gap: var(--s2); flex-wrap: wrap; margin: var(--s3) 0 var(--s4); }
.seg { display: inline-flex; padding: 4px; border-radius: var(--r-md); background: var(--surface-3); gap: 4px; }
.seg button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font-weight: 600; cursor: pointer; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ---------- codex ---------- */
.codex-head { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s4); }
.codex-head .bar { flex: 1; }
.search { position: relative; margin-bottom: var(--s3); }
.search input { width: 100%; min-height: 48px; padding: 0 16px 0 44px; border-radius: var(--r-md); border: 2px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.search input:focus { outline: none; border-color: var(--primary); }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.filters { display: flex; gap: var(--s2); overflow-x: auto; padding: 2px 2px var(--s3); margin: 0 -2px var(--s2); scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: var(--r-full); border: 2px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 14px; cursor: pointer; }
.filter .icon { width: 16px; height: 16px; }
.filter[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); }
.codex-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.locked-grid { align-items: start; }
.locked-group { grid-column: 1 / -1; margin-top: var(--s3); }
.locked-group > summary { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 var(--s4); border-radius: var(--r-md); border: 2px dashed var(--border-strong); color: var(--text-2); font-weight: 600; cursor: pointer; list-style: none; }
.locked-group > summary::-webkit-details-marker { display: none; }
.locked-group > summary .icon:last-child { margin-left: auto; transition: transform var(--t-med) var(--ease); }
.locked-group[open] > summary .icon:last-child { transform: rotate(180deg); }
.locked-grid { margin-top: var(--s3); }
@media (min-width: 640px) { .codex-grid { grid-template-columns: repeat(3, 1fr); } }
.svc { position: relative; display: flex; flex-direction: column; gap: 6px; padding: var(--s3) var(--s4) var(--s4); min-height: 148px; border-radius: var(--r-lg); background: var(--surface); border: 2px solid var(--border); box-shadow: 0 3px 0 var(--border); text-align: left; cursor: pointer; color: var(--text); transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast); }
.svc:hover { border-color: var(--border-strong); }
.svc:active { transform: translateY(3px); box-shadow: none; }
.svc .cat-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: oklch(0.5 0.13 var(--c-hue)); box-shadow: 0 3px 0 oklch(0.36 0.1 var(--c-hue)); margin-bottom: 4px; }
.svc b { font-family: var(--font-display); font-size: 15.5px; line-height: 1.25; }
.svc small { color: var(--text-3); font-size: 13px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.svc.locked { min-height: 0; flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; background: transparent; border-style: dashed; box-shadow: none; }
.svc.locked .cat-ic { width: 32px; height: 32px; margin: 0; background: var(--surface-3); color: var(--text-3); box-shadow: none; }
.svc.locked .cat-ic .icon { width: 16px; height: 16px; }
.svc.locked b { color: var(--text-2); font-size: 14px; font-weight: 600; }
.svc .new { position: absolute; top: 10px; right: 10px; }
.codex-detail .cat-ic { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; color: #fff; background: oklch(0.5 0.13 var(--c-hue)); box-shadow: 0 4px 0 oklch(0.36 0.1 var(--c-hue)); flex: none; }
.codex-detail .cat-ic .icon { width: 28px; height: 28px; }
.empty { text-align: center; padding: var(--s7) var(--s4); color: var(--text-3); }
.empty .icon { width: 40px; height: 40px; margin: 0 auto var(--s3); }

/* ---------- profile ---------- */
.rank-card { display: flex; align-items: center; gap: var(--s4); }
.rank-emblem { width: 72px; height: 72px; flex: none; border-radius: 20px; display: grid; place-items: center; color: #fff; background: linear-gradient(140deg, #6366f1, #4338ca); box-shadow: 0 5px 0 #312e81; }
.rank-emblem .icon { width: 36px; height: 36px; }
.ach-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
@media (max-width: 400px) { .ach-grid { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 640px) { .ach-grid { grid-template-columns: repeat(3, 1fr); } }
.ach { display: flex; gap: var(--s3); align-items: center; padding: var(--s3); border-radius: var(--r-lg); border: 2px solid var(--border); background: var(--surface); }
.ach .a-ic { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold-ink); }
.ach b { display: block; font-family: var(--font-display); font-size: 14.5px; line-height: 1.25; }
.ach small { display: block; font-size: 12.5px; color: var(--text-3); line-height: 1.35; }
.ach:not(.locked) { border-color: color-mix(in srgb, var(--gold) 50%, var(--border)); }
.ach:not(.locked) .a-ic { background: linear-gradient(140deg, #fcd34d, #f59e0b); color: #78350f; box-shadow: 0 3px 0 #b45309; }
.ach.locked { background: transparent; border-style: dashed; }
.ach.locked .a-ic { background: var(--surface-3); color: var(--text-3); }
.ach.locked b { color: var(--text-2); }
.heat { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--surface-3); }
.heat i.l1 { background: color-mix(in srgb, var(--good) 35%, var(--surface-3)); }
.heat i.l2 { background: color-mix(in srgb, var(--good) 65%, var(--surface-3)); }
.heat i.l3 { background: var(--good); }
.heat i.today { outline: 2px solid var(--text-2); outline-offset: 1px; }
.settings { display: grid; gap: 0; }
.setting { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); min-height: 60px; padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting .s-text { flex: 1 1 180px; min-width: 0; }
.setting b { display: block; font-weight: 600; }
.setting small { display: block; color: var(--text-3); font-size: 13.5px; line-height: 1.4; }
.switch { position: relative; flex: none; width: 54px; height: 32px; border-radius: 16px; border: 0; background: transparent; box-shadow: inset 0 0 0 2px var(--text-3); cursor: pointer; transition: background var(--t-med) var(--ease); }
.switch::before { content: ""; position: absolute; inset: -6px -2px; }
.switch:not([aria-checked="true"])::after { background: var(--text-3); box-shadow: none; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); transition: transform var(--t-med) var(--ease); }
.switch[aria-checked="true"] { background: var(--primary); box-shadow: none; }
.switch[aria-checked="true"]::after { transform: translateX(22px); }
:root[data-theme="dark"] .switch[aria-checked="true"]::after { background: var(--on-primary); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .switch[aria-checked="true"]::after { background: var(--on-primary); } }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 70; left: 50%; top: calc(var(--hud-total) + 12px); transform: translateX(-50%); display: grid; gap: var(--s2); width: min(420px, calc(100% - 32px)); pointer-events: none; }
body.playing .toasts { top: auto; bottom: calc(var(--s4) + env(safe-area-inset-bottom)); }
.toast { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-lg); background: var(--surface); border: 2px solid var(--gold); box-shadow: var(--shadow-2); animation: toast-in var(--t-slow) var(--ease-pop) both; pointer-events: auto; }
.toast.out { animation: toast-out var(--t-med) var(--ease) forwards; }
.toast .a-ic { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold-ink); }
.toast b { display: block; font-family: var(--font-display); }
.toast.info { border-color: var(--border-strong); }
.toast.info .a-ic { background: var(--primary-soft); color: var(--primary-ink); }
.toast small { display: block; color: var(--text-3); font-size: 13px; }
@keyframes toast-in { from { transform: translateY(-16px) scale(0.96); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(-12px); opacity: 0; } }

/* ---------- touch targets ---------- */
@media (pointer: coarse) {
  .pill { height: 44px; }
  .btn.sm, .filter, .seg button { min-height: 44px; }
  .unlock-row .chip { min-height: 44px; padding: 0 14px; }
}

/* ---------- short landscape phones ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --hud-h: 48px; --tab-h: 52px; }
  .tab { flex-direction: row; gap: 8px; min-height: 44px; }
  .world-banner { position: static; }
  .play-top { padding-block: 6px; }
  .boss-bar { position: static; }
  .feedback { max-height: calc(100dvh - 140px); padding-top: 12px; }
  .feedback-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; }
  .feedback-inner > * { grid-column: 1; }
  .fb-actions { grid-column: 2; grid-row: 1 / span 8; flex-direction: column-reverse; align-self: start; position: sticky; top: 0; bottom: auto; margin: 0; padding: 0; background: none !important; }
  .sheet { max-height: 96dvh; }
  .sheet-actions:not(.two) { grid-auto-flow: column; grid-auto-columns: 1fr; }
  .sheet-actions .welcome-q { grid-column: 1 / -1; }
}

/* ---------- notches in landscape ---------- */
@supports (padding: max(0px)) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .answer-bar, .feedback { padding-left: max(var(--s4), env(safe-area-inset-left)); padding-right: max(var(--s4), env(safe-area-inset-right)); }
  .hud { margin-inline: calc(-1 * env(safe-area-inset-left)) calc(-1 * env(safe-area-inset-right)); padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition: none !important; scroll-behavior: auto !important; }
}
:root.reduce-motion *, :root.reduce-motion *::before, :root.reduce-motion *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition: none !important; }
