:root {
  color-scheme: dark;
  --background: #101526;
  --surface: #181f34;
  --surface-raised: #202942;
  --line: #39435d;
  --ink: #f3f1e3;
  --muted: #b1b9ce;
  --lime: #d1ec87;
  --mint: #8bd4b7;
  --gold: #f7c480;
  --rose: #efaeac;
  --radius: 13px;
  --mono: ui-monospace, Consolas, "Courier New", monospace;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% -10%, #293352 0%, transparent 57%), var(--background);
  color: var(--ink);
  line-height: 1.55;
}
button, textarea { font: inherit; }
button { min-height: 46px; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .44; }
button:focus-visible, summary:focus-visible, textarea:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.28; }
h1:focus, h2:focus { outline: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.shell {
  width: min(100%, 1168px);
  margin: 0 auto;
  padding: 0 max(24px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(24px, env(safe-area-inset-left));
}
.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand, .nav-button { border: 0; background: none; color: var(--ink); }
.brand { padding: 0; display: inline-flex; align-items: center; gap: 10px; font: 900 clamp(1.1rem, 2.5vw, 1.45rem)/1 var(--mono); }
.brand svg { width: 26px; height: 26px; color: var(--lime); }
.brand-accent { margin-left: 2px; color: var(--lime); }
.topbar nav { display: flex; gap: 5px; }
.nav-button { padding: 0 13px; border-radius: 7px; font-size: .88rem; font-weight: 750; color: var(--muted); }
.nav-button:hover:not(:disabled), .nav-button[aria-current] { background: #28334d; color: var(--ink); }
.frame { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 0 #090d1b80; }
.hero, .arena { position: relative; isolation: isolate; overflow: hidden; }
.hero {
  min-height: 506px;
  display: flex;
  align-items: center;
  padding: 43px clamp(24px, 5.6vw, 70px) 66px;
  background: #222e49 url("../assets/images/sky-city.svg") center 56% / cover no-repeat;
}
.hero::before, .arena::before { position: absolute; content: ""; inset: 0; z-index: -1; pointer-events: none; }
.hero::before { background: linear-gradient(90deg, #101528 0%, #101528f5 21%, #131930c0 43%, #151a3310 73%), linear-gradient(0deg, #101526bd, transparent 25%); }
.hero-copy { z-index: 1; position: relative; width: min(56%, 550px); }
.eyebrow { color: var(--mint); font-family: var(--mono); font-size: .85rem; font-weight: 750; letter-spacing: .075em; }
.diamond { display: inline-block; width: 9px; height: 9px; margin: 0 7px 1px 1px; transform: rotate(45deg); background: var(--lime); }
.hero-title {
  margin: .22em 0 .24em;
  font-weight: 900;
  font-size: clamp(2.7rem, 6.8vw, 5.05rem);
  line-height: 1.05;
  letter-spacing: .015em;
  text-shadow: 3px 4px #101426, 0 1px 24px #101426;
}
.hero-title span { color: var(--lime); white-space: nowrap; }
.hero-tagline { font-size: clamp(1.05rem, 2.4vw, 1.38rem); font-weight: 800; }
.hero-text { margin: 12px 0 22px; font-size: 1rem; color: #d6dbef; }
.hero-art { position: absolute; z-index: 0; inset: 0 0 0 45%; pointer-events: none; }
.hero-halo { position: absolute; top: 15%; right: 14%; width: 76%; aspect-ratio: 1; background: radial-gradient(ellipse at center, #fbc6913a, transparent 63%); }
.sprite, .traveler { display: block; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 9px 0 #0d142558); }
.hero-dragon { width: min(91%, 480px); position: absolute; right: 7%; bottom: 18%; animation: hover-sprite 5s steps(6) infinite; }
.hero-traveler { position: absolute; bottom: 10%; right: 12%; width: clamp(38px, 7vw, 88px); }
.hero-counter { position: absolute; z-index: 1; bottom: 18px; right: 22px; display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: #11182be8; border: 1px solid #64708a; border-radius: 6px; color: #d6dbec; font-size: .87rem; }
.hero-counter strong { color: var(--lime); font: 800 1.08rem var(--mono); }
.hero-counter > span { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.primary, .secondary, .toggle {
  border: 1px solid var(--line); border-radius: 7px; padding: 10px 18px; font-weight: 800;
  color: var(--ink); background: var(--surface-raised);
}
.primary { color: #202816; background: var(--lime); border-color: #eaf9ba; box-shadow: 0 3px 0 #769452; }
.primary:hover { background: #e0f6a4; }
.secondary:hover, .toggle:hover { background: #313e5a; }
.primary:active, .secondary:active, .choice:active { transform: translateY(1px); }
.hero-actions .primary, .hero-actions .secondary { min-height: 52px; padding-inline: 22px; }
.route { margin-top: 27px; }
.route h2 { font-size: 1.13rem; margin-bottom: 12px; }
.route-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; list-style: none; margin: 0; padding: 0; }
.route-card { display: flex; align-items: center; min-width: 0; gap: 11px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.route-pic { display: grid; place-content: center; width: 70px; height: 60px; border-radius: 6px; background: radial-gradient(ellipse, var(--glow), #111827 76%); flex: none; }
.route-pic img { width: 62px; height: 53px; }
.route-card .eyebrow { font-size: .79rem; color: var(--theme-ink); }
.route-card h3 { font-size: 1rem; margin: 2px 0; }
.route-card p { font-size: .83rem; color: var(--muted); }
.theme-slime { --glow: #388b855f; --theme-ink: #a1e4cf; }
.theme-golem { --glow: #a86b5970; --theme-ink: #f9cda3; }
.theme-dragon { --glow: #a2629e70; --theme-ink: #f2bae7; }
footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 23px 0; color: var(--muted); font-size: .81rem; }
footer span:first-child { font-family: var(--mono); font-weight: 700; }
.notice, .loading { border: 1px solid #756078; border-radius: 7px; background: #33283e; padding: 10px 14px; color: #ffe1db; margin-bottom: 12px; }
.loading { background: var(--surface); color: var(--ink); border-color: var(--line); }
.topbar { padding-top: env(safe-area-inset-top, 0px); }
.mode-hero { min-height: 308px; padding-block: 27px; }
.mode-hero .hero-title { font-size: clamp(2.3rem, 6vw, 4.4rem); }
.mode-hero .hero-dragon { width: min(67%, 370px); bottom: 1%; right: 12%; }
.mode-hero .hero-traveler { width: 54px; }
.mode-hero .hero-actions:not(:empty) { margin-top: 15px; }
.mode-select { margin-top: 18px; }
.mode-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.mode-heading h2 { font-size: 1.15rem; }
.scope-entry { padding-inline: 11px; font-size: .9rem; }
.mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.mode-card {
  border-color: #516979; color: var(--ink); text-align: left; min-width: 0; min-height: 76px; padding: 10px 11px;
  background: linear-gradient(135deg,#254942,#1a293d); display: flex; align-items: center; gap: 9px;
}
.mode-card.mode-science { background: linear-gradient(135deg,#29465a,#202b45); }
.mode-card.mode-mixed { background: linear-gradient(135deg,#55415c,#27243f); }
.mode-card:hover:not(:disabled) { outline: 1px solid var(--mint); }
.mode-icon { flex: none; font-size: 1.28rem; color: var(--mint); }
.mode-science .mode-icon { color: #a7d9fc; }
.mode-mixed .mode-icon { color: #ffc88e; }
.mode-name { flex: 1; min-width: 0; }
.mode-name strong, .mode-name small { display: block; }
.mode-name strong { font-size: 1.05rem; }
.mode-name small { font-size: .86rem; color: #d3d8e9; margin-top: 2px; }
.mode-count { flex: none; font: 750 .9rem var(--mono); color: var(--lime); }
.mode-extra { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.mode-extra summary, .scope summary { cursor: pointer; min-height: 46px; padding: 10px 7px; }
.mode-extra summary { color: var(--muted); font-size: .9rem; }
.scope fieldset { border: 1px solid var(--line); margin: 15px 0; padding: 11px; border-radius: 8px; min-width: 0; }
.scope legend { padding: 0 6px; font-weight: 800; color: var(--lime); }
.scope-select { display: grid; gap: 5px; }
.scope-select select {
  width: 100%; min-width: 0; font: inherit; min-height: 46px; padding: 7px;
  color: var(--ink); background: var(--surface-raised); border: 1px solid var(--line); border-radius: 6px;
}
.scope-checks { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,235px),1fr)); gap: 4px; }
.scope-checks label { display: flex; align-items: center; min-height: 44px; gap: 6px; }
.scope-checks input { min-width: 20px; min-height: 20px; accent-color: var(--lime); }

.arena {
  min-height: 352px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #28334e url("../assets/images/sky-city.svg") center 58% / cover no-repeat;
}
.arena::before { background: linear-gradient(#0f1529ed, #14183022 49%, #10152683), radial-gradient(ellipse at 68% 61%, var(--glow), transparent 54%); }
.arena.theme-slime { background-position: center 77%; }
.arena.theme-golem { background-position: center 88%; }
.arena.theme-dragon { border-color: #927faf; }
.arena-hud, .arena-foot { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 22px; }
.arena-heading h1 { font-size: clamp(1.38rem, 3.7vw, 2.05rem); text-shadow: 2px 2px #181b32; }
.arena-heading .eyebrow { color: var(--theme-ink); }
.hp-box { display: grid; gap: 3px; width: clamp(112px, 30vw, 270px); font: 800 .86rem/1.5 var(--mono); flex: none; }
.hp-box > div:first-child { display: flex; justify-content: space-between; gap: 2px; color: var(--ink); }
.hp-box > div:first-child > span { color: var(--mint); }
.meter { height: 14px; padding: 2px; border: 1px solid #b0b4c3; background: #111527; border-radius: 3px; overflow: hidden; }
.meter > span { display: block; width: var(--meter); height: 100%; background: repeating-linear-gradient(90deg, #afd970 0 10px, #9cc65e 10px 12px); }
.has-hit .meter > span { animation: drain var(--drain) var(--impact) cubic-bezier(.15,.65,.25,1) both; }
.arena-visuals { position: relative; min-height: 183px; }
.hero-unit, .enemy-unit { position: absolute; bottom: 6%; display: grid; justify-items: center; }
.hero-unit { left: 17%; width: clamp(52px, 11vw, 104px); }
.enemy-unit { right: 15%; width: clamp(132px, 25vw, 250px); }
.hero-unit img, .enemy-unit img { width: 100%; }
.hero-shadow, .enemy-shadow { position: absolute; bottom: 4%; z-index: -1; width: 83%; height: 13%; border-radius: 50%; background: #131a2caa; }
.enemy-unit img { animation: hover-sprite var(--idle-duration, 2.15s) steps(7) infinite; max-height: 226px; }
.theme-slime { --idle-duration: 1.55s; }
.theme-golem { --idle-duration: 3.4s; }
.theme-dragon { --idle-duration: 2.4s; }
.arena.entering .enemy-unit { animation: arrive var(--entry) steps(9) both; }
.arena.defeated .enemy-unit img { opacity: .14; }
.arena.has-hit .enemy-unit img { animation: recoil 260ms var(--impact) steps(7) both; }
.arena.has-hit.defeated .enemy-unit img { animation: recoil 245ms var(--impact) steps(7) backwards, defeated 405ms var(--defeat) steps(9) forwards; }
.arena.boss-fight.has-hit.defeated .enemy-unit img { animation-name: recoil, boss-break; }
.arena.effect-slash .hero-unit img { animation: lunge 410ms steps(8) both; }
.arena.effect-magic .hero-unit img { animation: cast 370ms steps(8) both; }
.damage {
  position: absolute; top: 5%; left: 38%; z-index: 3; pointer-events: none;
  font: 900 clamp(1.65rem, 5vw, 3rem) var(--mono); color: var(--gold); text-shadow: 2px 3px #191529, 0 0 12px #241834;
  animation: damage var(--damage) var(--impact) ease-out both;
}
.impact, .impact-ring, .sparks { position: absolute; z-index: 2; pointer-events: none; }
.impact {
  inset: 14% 5%; background: linear-gradient(169deg,#fff9d5 32%,#f4c187 61%,#eda06c);
  clip-path: polygon(0 87%, 33% 65%, 77% 22%, 100% 0, 87% 34%, 48% 77%, 17% 95%, 0 100%, 29% 80%, 67% 45%, 86% 22%);
  animation: strike 245ms var(--impact) steps(7) both;
}
.impact-ring { inset: 22% 18%; border: 4px solid var(--gold); border-radius: 50%; animation: wave 375ms var(--impact) ease-out both; }
.sparks {
  inset: 0; background:
    linear-gradient(#fff3b4,#fff3b4) 14% 48% / 8px 4px,
    linear-gradient(#fff3b4,#fff3b4) 70% 17% / 5px 9px,
    linear-gradient(#fac38b,#fac38b) 84% 63% / 9px 5px,
    linear-gradient(#fac38b,#fac38b) 28% 84% / 6px 6px,
    linear-gradient(#fff3b4,#fff3b4) 50% 29% / 6px 6px;
  background-repeat: no-repeat; animation: sparks 325ms var(--impact) steps(8) both;
}
.effect-magic .impact { background: linear-gradient(145deg,#effcff,#acdfff 49%,#926eeb); clip-path: polygon(50% 0,61% 35%,100% 50%,62% 64%,50% 100%,38% 64%,0 50%,38% 36%); }
.effect-magic .impact-ring { border-color: #c0c6ff; box-shadow: 0 0 16px #a7a2ed9c; }
.arena-callout, .victory-banner, .level-callout {
  position: absolute; z-index: 4; text-align: center; width: max-content; max-width: 95%; padding: 7px 17px;
  background: #151e34f0; border-block: 2px solid var(--gold); color: var(--gold); font-weight: 900;
  font-size: clamp(1rem, 2.8vw, 1.55rem); pointer-events: none;
}
.arena-callout, .victory-banner { left: 50%; top: 60%; translate: -50% -50%; }
.arena-callout { top: 27%; color: var(--lime); border-color: var(--mint); animation: entry-callout 750ms ease both; }
.boss-fight .arena-callout { color: #ffe0aa; border-color: #e699a9; box-shadow: 0 0 27px #a6639063; }
.has-hit .victory-banner { animation: banner-in 315ms var(--defeat) both; }
.boss-fight .victory-banner { background: #2c203bf5; border-color: #ffbd90; color: #ffdfad; box-shadow: 0 0 32px #f09a8a50; }
.boss-fight .victory-banner small { display: block; color: #f9b1d9; font-size: .78rem; letter-spacing: .2em; }
.level-callout {
  left: 10%; top: 10%; color: var(--lime); border-color: var(--lime); font: 900 clamp(.9rem, 2vw, 1.22rem) var(--mono);
  animation: banner-in 260ms var(--level) both;
}
.level-callout strong { color: var(--ink); }
.arena-foot { padding-block: 9px; background: #101626e8; font-family: var(--mono); font-size: .86rem; font-weight: 700; }
.arena-foot > span:first-child, .level-up { color: var(--lime); }
.arena-foot > span:last-child { margin-left: auto; color: var(--muted); white-space: nowrap; }
.level-up { margin-left: 5px; color: var(--gold); }
.battle-panels { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 15px; align-items: start; }
.panel { padding: clamp(16px, 3vw, 28px); background: var(--surface); min-width: 0; }
.panel > h1 { font-size: clamp(1.55rem, 4vw, 2.35rem); margin: .16em 0 .55em; }
.panel h2 { font-size: clamp(1.15rem, 2.7vw, 1.5rem); margin-bottom: 10px; }
.quest h2 { margin-top: .25em; }
.prompt { margin: 0 0 14px; font-weight: 650; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.choice {
  display: flex; align-items: center; text-align: left; gap: 9px; min-height: 52px; min-width: 0; padding: 7px 9px;
  border: 1px solid #495678; border-radius: 6px; background: #242f4b; color: var(--ink); font-weight: 750; overflow-wrap: anywhere;
}
.choice:hover { background: #324265; border-color: var(--mint); }
.letter { display: grid; place-content: center; background: #131b32; color: var(--mint); border-radius: 4px; width: 26px; height: 26px; flex: none; font: 800 .85rem var(--mono); }
.hint-panel h2, .field-notes h2 { display: flex; align-items: center; gap: 8px; }
.icon { width: 19px; height: 19px; flex: none; color: var(--mint); vertical-align: -.25em; }
.hint-steps { list-style: none; padding: 0; margin: 0 0 15px; display: grid; gap: 7px; }
.hint-steps li { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); padding: 7px 9px; border: 1px solid #3a4663; border-radius: 6px; }
.hint-steps li > span { font: 800 .9rem/1.6 var(--mono); color: var(--mint); }
.hint-steps li > div { flex: 1; }
.hint-steps li.revealed { background: #243b42; color: var(--ink); border-color: #547762; }
.hint-steps p { margin-top: 4px; }
.hint-panel .secondary { width: 100%; }
.field-notes p { color: var(--muted); margin: 6px 0; }
.feedback, .explanation, .reward { padding: 11px 13px; border-radius: 7px; margin: 12px 0; }
.feedback { background: #352b43; border: 1px solid #755576; color: #f9d9e2; font-weight: 750; }
.feedback.success { background: #203b36; border-color: #64876c; color: #e1f4bc; }
.explanation { border: 1px solid #567c79; background: #172e38; }
.answer-label { font-weight: 700; margin: 6px 0; }
.answer-label strong { color: var(--lime); margin-left: .4em; }
.solve-steps { padding-left: 1.35rem; margin-block: 8px; }
.solve-steps li + li { margin-top: 5px; }
.learning-point, .trivia { margin-top: 8px; color: #d2e2e0; }
.learning-point strong, .trivia strong { color: var(--mint); margin-right: .35em; }
.explanation .primary { margin-top: 10px; }
.reward { display: flex; align-items: center; gap: 12px; color: #ffdf9d; background: #393040; border: 1px solid #988269; }
.treasure { width: 52px; height: 52px; flex: none; }
.treasure-lid { transform: translateY(-8px) rotate(-9deg); transform-origin: 10px 21px; }
.reward.opening .treasure-lid { animation: open-chest 215ms var(--chest) steps(6) both; }
.reward.opening .treasure-rays { animation: chest-light 215ms var(--chest) ease-out both; }
.reward strong { display: block; font-size: 1.06rem; }
.reward p { color: #efe3d7; font-size: .9rem; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 4px 0 13px; font-size: .9rem; }
caption { color: var(--muted); text-align: left; margin-bottom: 5px; font-weight: 700; }
thead { background: #29344d; }
th, td { padding: 6px 5px; text-align: center; overflow-wrap: anywhere; border-bottom: 1px solid #4a5670; }
tr.highlight { background: #314b48; color: #e6f4bb; font-weight: 800; }
.settings, .review, .results { max-width: 820px; margin-inline: auto; }
.settings .setting-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 0; border-top: 1px solid var(--line); }
.settings h2 { margin: 0 0 3px; }
.settings p, .muted { color: var(--muted); }
.toggle { min-width: 75px; }
.toggle[aria-pressed="true"] { background: var(--lime); color: #243118; }
.danger { color: #f8c3be; }
.settings .actions, .review .actions, .results .actions { margin-top: 16px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metrics > div { border: 1px solid var(--line); background: #202b43; border-radius: 8px; padding: 10px; }
.metrics dt { color: #d7ddeb; font-size: .9rem; }
.metrics dd { margin: 4px 0 0; font: 800 clamp(1.25rem, 3vw, 2rem) var(--mono); color: var(--lime); white-space: nowrap; }
.results > p { margin-bottom: 8px; }
.progress-line { display: flex; align-items: center; gap: 12px; color: var(--mint); font-family: var(--mono); }
.progress-line strong { font-size: 1.25rem; }
.inventory { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.inventory li { padding: 7px 9px; display: flex; align-items: center; gap: 7px; background: #242e47; border: 1px solid var(--line); border-radius: 7px; }
.inventory small { display: block; color: var(--muted); }
.record-details { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 10px; }
.record-details summary { cursor: pointer; min-height: 40px; font-weight: 750; }
.record-details li { margin: 4px 0; }
.record-details li > span { display: block; color: var(--muted); }
.copy-box { display: block; margin-top: 12px; }
.copy-box textarea { display: block; margin-top: 6px; width: 100%; background: #101526; color: var(--ink); border: 1px solid var(--line); padding: 10px; }

@keyframes hover-sprite { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes arrive { 0% { transform: translate(80px,-29px) scale(.83); opacity: 0; } 74% { transform: translate(-5px,3px); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes entry-callout { 0%, 100% { opacity: 0; transform: scale(.9); } 18%, 82% { opacity: 1; transform: none; } }
@keyframes recoil { 0%, 100% { transform: none; filter: none; } 25% { transform: translate(17px,-10px) skewX(-8deg); filter: brightness(1.25); } 57% { transform: translate(6px,3px) scale(1.04,.94); } }
@keyframes defeated { from { transform: none; opacity: 1; } to { transform: translateY(14px) scale(.91,.72); opacity: .14; } }
@keyframes boss-break { from { transform: none; opacity: 1; } to { transform: translateY(-13px) scale(1.12); filter: sepia(.45); opacity: .14; } }
@keyframes lunge { 0%, 100% { transform: none; } 16% { transform: translateX(-12px) rotate(-9deg); } 44% { transform: translate(clamp(90px,34vw,435px),-13px) rotate(8deg); } }
@keyframes cast { 0%, 100% { transform: none; filter: none; } 43% { transform: translate(11px,-15px) scale(1.1); filter: drop-shadow(0 0 12px #adb5fb); } }
@keyframes damage { 0% { transform: translateY(8px) scale(.7); opacity: .4; } 30% { transform: translateY(-8px) scale(1.16); opacity: 1; } 100% { transform: translateY(-31px); opacity: 0; } }
@keyframes strike { 0% { transform: translate(-25%,16%) scale(.5); opacity: 0; } 29% { transform: none; opacity: 1; } 100% { transform: translate(14%,-17%) scale(1.12); opacity: 0; } }
@keyframes wave { from { opacity: .85; transform: scale(.38); } to { opacity: 0; transform: scale(1.43); } }
@keyframes sparks { from { opacity: 1; transform: scale(.5); } to { opacity: 0; transform: scale(1.6); } }
@keyframes drain { from { width: var(--old-meter); } to { width: var(--meter); } }
@keyframes banner-in { from { opacity: 0; transform: translateY(9px) scale(.88); } to { opacity: 1; transform: none; } }
@keyframes open-chest { from { transform: none; } to { transform: translateY(-8px) rotate(-9deg); } }
@keyframes chest-light { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (max-width: 780px) {
  .hero { min-height: 420px; }
  .route-list { gap: 8px; }
  .route-card { padding: 7px; gap: 7px; }
  .route-pic { width: 46px; height: 45px; }
  .route-pic img { width: 41px; height: 41px; }
  .desktop-break { display: none; }
}
@media (max-width: 600px) {
  .shell { padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right)); }
  .topbar { min-height: 57px; }
  .brand { gap: 6px; }
  .brand svg { width: 19px; height: 19px; }
  .nav-button { padding-inline: 7px; }
  .hero { min-height: 475px; align-items: end; padding: 14px 17px 57px; background-position: 65% center; }
  .hero::before { background: linear-gradient(0deg, #101528 1%, #101528e8 39%, #151b3580 73%, #151b3510 100%); }
  .hero-copy { width: 100%; }
  .hero-art { inset: 0 0 auto 0; height: 49%; }
  .hero-dragon { width: min(59%, 245px); top: 4%; right: 18%; bottom: auto; }
  .hero-traveler { bottom: 3%; right: 12%; }
  .hero-title { font-size: clamp(1.82rem, 8.9vw, 3.45rem); margin: 4px 0 7px; }
  .hero-tagline { font-size: 1.05rem; }
  .hero-text { margin: 6px 0 12px; }
  .hero-counter { bottom: 11px; right: 12px; }
  .route { margin-top: 18px; }
  .route-list { grid-template-columns: minmax(0, 1fr); }
  .route-card { padding: 6px 10px; }
  .route-card h3 { display: inline; margin-left: 5px; }
  .arena { min-height: 227px; }
  .arena-hud, .arena-foot { padding: 8px 10px; }
  .arena-heading h1 { font-size: clamp(1.03rem, 5.4vw, 1.55rem); }
  .arena-heading .eyebrow { font-size: .74rem; }
  .arena-visuals { min-height: 130px; }
  .arena-foot { font-size: .78rem; flex-wrap: wrap; }
  .enemy-unit { right: 12%; width: min(43vw, 150px); }
  .hero-unit { left: 14%; width: min(17vw, 72px); }
  .battle-panels { grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 11px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setting-row .secondary { padding-inline: 10px; }
  .mode-hero { min-height: 148px; padding: 15px; align-items: center; }
  .mode-hero .hero-art { inset: 0 0 0 45%; height: 100%; }
  .mode-hero .hero-copy { width: min(74%,250px); }
  .mode-hero .hero-dragon { width: 102%; max-width: 190px; right: 3%; top: 9%; }
  .mode-hero .hero-traveler { display: none; }
  .mode-hero .hero-title { font-size: clamp(1.5rem, 7vw, 2.45rem); line-height: 1.04; }
  .mode-hero .hero-title span { display: block; }
  .mode-hero .hero-tagline { font-size: .9rem; }
  .mode-hero .hero-actions .primary { min-height: 46px; padding-inline: 10px; }
  .mode-select { margin-top: 11px; }
  .mode-grid { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .mode-card { min-height: 59px; padding: 6px 10px; }
  .mode-extra { margin-top: 10px; }
  .knowledge-arena { min-height: 174px; }
  .knowledge-arena .arena-hud { padding-block: 6px; }
  .knowledge-arena .arena-visuals { min-height: 88px; }
  .knowledge-arena .enemy-unit { right: 11%; width: min(36vw,120px); }
  .knowledge-arena .hero-unit { width: min(14vw,55px); }
  .knowledge-panels .quest { padding: 12px; }
  .knowledge-panels .quest h2 { font-size: clamp(1.08rem,4.6vw,1.3rem); line-height: 1.37; }
  .knowledge-panels .quest .eyebrow { font-size: .84rem; }
  .knowledge-panels .choices { grid-template-columns: minmax(0,1fr); gap: 6px; }
  .knowledge-panels .choice { min-height: 49px; font-size: 1rem; }
  .quick-hints { padding: 10px 12px; }
  .quick-hints h2, .quick-hints .hint-steps:not(:has(.revealed)), .quick-hints li:not(.revealed) { display: none; }
}
@media (max-width: 360px) {
  .hero { min-height: 468px; }
  .panel { padding: 12px; }
  .choices { gap: 6px; }
  .choice { padding-inline: 6px; gap: 5px; font-size: .93rem; }
  th, td { padding-inline: 3px; }
  .mode-hero { min-height: 134px; }
  .knowledge-arena .hp-box { width: 99px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .arena-callout, .impact, .impact-ring, .sparks { display: none; }
}
