:root {
  color-scheme: light;
  --bg: #eef7fb;
  --panel: #fffdf7;
  --panel-strong: #fff4cf;
  --ink: #1b2632;
  --muted: #566575;
  --line: #c9d7dd;
  --accent: #126c85;
  --accent-2: #d85a37;
  --success: #117a4b;
  --danger: #b2332e;
  --warning: #a86400;
  --focus: #ffc533;
  --shadow: 0 16px 40px rgba(25, 47, 62, 0.16);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.65), rgba(238,247,251,0.2) 38%, rgba(230,241,229,0.78)),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

button:focus-visible,
input:focus-visible,
[role="button"]:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

ruby rt {
  font-size: 0.62em;
  color: #435462;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(280px, 1.6fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px 18px;
  background: rgba(255, 253, 247, 0.94);
  border-bottom: 2px solid #d9c48c;
  box-shadow: 0 8px 22px rgba(40, 55, 72, 0.08);
  backdrop-filter: blur(10px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #126c85, #31a37b);
  font-weight: 900;
  border: 3px solid #f4cc64;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,0.14);
}

.brand-lockup h1 {
  margin: 0;
  font-size: clamp(1.15rem, 1.8vw, 1.7rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.status-bar {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.player-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}

.player-name {
  font-weight: 900;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 3px 10px;
  border: 1px solid #d5c18f;
  border-radius: 999px;
  background: #fff8df;
  font-size: 0.88rem;
  font-weight: 800;
}

.exp-wrap {
  display: grid;
  grid-template-columns: 64px 1fr 92px;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.bar {
  position: relative;
  overflow: hidden;
  height: 14px;
  border-radius: 999px;
  border: 1px solid #8db6c1;
  background: #dfecef;
}

.bar > span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  background: linear-gradient(90deg, #2da36e, #ffc94a);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.top-nav button,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  border: 2px solid #25465a;
  border-radius: var(--radius);
  padding: 8px 14px;
  color: var(--ink);
  background: #fffdf7;
  font-weight: 900;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.1);
}

.top-nav button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  color: #fff;
  background: linear-gradient(180deg, #197d91, #126276);
  border-color: #0d4656;
}

.secondary-button {
  background: #ffefbd;
  border-color: #8c6320;
}

.ghost-button {
  background: #f3f8f9;
}

.danger-button {
  color: #fff;
  background: #b2332e;
  border-color: #73201d;
}

.app-main {
  width: min(1180px, calc(100% - 28px));
  margin: 22px auto 48px;
}

.view-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.hero-panel,
.panel,
.unit-card,
.battle-panel {
  border: 2px solid #b89c58;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-panel {
  overflow: hidden;
}

.hero-scene {
  min-height: 320px;
  padding: 26px;
  background:
    linear-gradient(180deg, rgba(70,160,186,0.22), rgba(255,255,255,0.55)),
    linear-gradient(135deg, #d9f1f3, #f9e8b8 58%, #d9e9d0);
}

.hero-content {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 0.75fr);
  gap: 24px;
  align-items: center;
}

.hero-title {
  margin: 0 0 12px;
  font-size: clamp(2rem, 5vw, 4.3rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.lead {
  max-width: 56ch;
  margin: 0 0 18px;
  color: #31414d;
  font-size: 1.08rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.name-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.name-form input {
  min-height: 44px;
  min-width: min(280px, 100%);
  border: 2px solid #87a9b2;
  border-radius: var(--radius);
  padding: 8px 12px;
  background: #fff;
}

.home-dragon {
  min-height: 260px;
}

.panel {
  padding: 18px;
}

.panel h2,
.panel h3,
.unit-card h2,
.battle-panel h2 {
  margin-top: 0;
  line-height: 1.2;
  letter-spacing: 0;
}

.info-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.info-list li {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffffcc;
}

.grade-tabs,
.inventory-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-button {
  min-width: 120px;
  border: 2px solid #356274;
  border-radius: var(--radius);
  padding: 8px 14px;
  background: #ecf7f9;
  font-weight: 900;
}

.tab-button.is-active {
  color: #fff;
  background: #126c85;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.42fr);
  gap: 18px;
  align-items: start;
}

.map-shell {
  overflow: hidden;
  border: 2px solid #8fb2a2;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #bfe7f0, #e9f6ef 55%, #cae2b7);
  box-shadow: var(--shadow);
}

.world-map {
  display: block;
  width: 100%;
  height: auto;
  min-height: 560px;
}

.map-node {
  cursor: pointer;
}

.map-node .node-ring {
  stroke-width: 5;
  filter: drop-shadow(0 5px 4px rgba(0,0,0,0.18));
}

.map-node.locked {
  cursor: not-allowed;
  opacity: 0.46;
}

.map-node.unlocked .node-ring {
  stroke: #ffcf45;
}

.map-node.basicCleared .node-ring {
  stroke: #2f9b6a;
}

.map-node.bossCleared .node-ring {
  stroke: #875bd6;
}

.map-node.perfected .node-ring {
  stroke: #f1b500;
  stroke-width: 8;
}

.node-label {
  fill: #152735;
  font-size: 15px;
  font-weight: 900;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #fffdf7;
  stroke-width: 5px;
  stroke-linejoin: round;
}

.unit-card {
  padding: 18px;
  position: sticky;
  top: 112px;
}

.unit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #edf6f8;
  border: 1px solid #9ec7d0;
  color: #214a5b;
  font-size: 0.83rem;
  font-weight: 800;
}

.tag.warn {
  background: #fff4d7;
  border-color: #d7a944;
  color: #6b4300;
}

.tag.good {
  background: #e7f7ec;
  border-color: #83bd94;
  color: #155b35;
}

.tag.rare-tag,
.rare-tag {
  color: #573800;
  background: #fff1ad;
  border-color: #d4a923;
}

.sub-list {
  margin: 12px 0;
  padding-left: 1.2em;
}

.monster-row,
.equipment-row,
.reward-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.monster-mini {
  display: inline-grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 150px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffffcc;
  font-size: 0.88rem;
  font-weight: 800;
}

.monster-mini > span:first-child {
  display: block;
  width: 42px;
  height: 36px;
}

.monster-mini svg {
  display: block;
  width: 100%;
  height: 100%;
}

.battle-panel {
  padding: 18px;
}

.battle-grid {
  display: grid;
  grid-template-columns: minmax(250px, 0.55fr) minmax(0, 1fr);
  gap: 18px;
}

.enemy-stage {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #dff5f7, #f9f0d3);
  border: 2px solid #93b8bb;
}

.battle-panel.tier-bonus .enemy-stage {
  background: linear-gradient(180deg, #fff5bf, #e8f8ff);
  border-color: #d4a923;
  box-shadow: inset 0 0 0 2px rgba(255, 216, 90, 0.42);
}

.enemy-art {
  min-height: 230px;
  display: grid;
  place-items: center;
}

.battle-monster {
  display: block;
  width: min(100%, 280px);
  max-width: 280px;
  aspect-ratio: 11 / 9;
}

.battle-monster svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.monster-fallback {
  display: grid;
  place-items: center;
  width: 180px;
  height: 150px;
  border: 4px solid #274255;
  border-radius: 50%;
  background: #fff7d1;
  color: #274255;
  font-size: 4rem;
  font-weight: 900;
}

.battle-stats {
  display: grid;
  gap: 8px;
}

.question-card {
  display: grid;
  gap: 14px;
}

.question-count {
  color: var(--muted);
  font-weight: 800;
}

.question-stem {
  margin: 0;
  padding: 14px;
  border-left: 6px solid var(--accent);
  border-radius: var(--radius);
  background: #f4fbfc;
  font-size: 1.15rem;
  font-weight: 800;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice-grid.ox {
  grid-template-columns: repeat(2, minmax(120px, 220px));
}

.choice-button {
  min-height: 70px;
  border: 2px solid #496273;
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.08);
}

.choice-button.is-correct {
  border-color: var(--success);
  background: #e7f7ec;
}

.choice-button.is-wrong {
  border-color: var(--danger);
  background: #ffe9e7;
}

.feedback {
  display: none;
  padding: 14px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: #fffdf7;
}

.feedback.is-visible {
  display: grid;
  gap: 8px;
}

.feedback.good {
  border-color: var(--success);
}

.feedback.bad {
  border-color: var(--danger);
}

.feedback-mark {
  font-size: 1.3rem;
  font-weight: 900;
}

.battle-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inventory-grid,
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.inventory-card,
.collection-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 2px solid #d2bf88;
  border-radius: var(--radius);
  background: #fffdf7;
}

.rare-equipment-grid {
  margin-top: 10px;
}

.rare-card {
  border-color: #d4a923;
  background:
    linear-gradient(180deg, rgba(255, 240, 161, 0.9), rgba(255, 253, 247, 0.95));
  box-shadow: 0 0 0 2px rgba(255, 216, 90, 0.28);
}

.rare-card.is-locked {
  border-style: dashed;
  color: #6d6d6d;
  background: #f1eee2;
  box-shadow: none;
}

.rare-card-head {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.rare-card h4 {
  margin: 0 0 4px;
  font-size: 1rem;
  line-height: 1.25;
}

.rare-mark {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 4px;
  border-radius: 50%;
  color: #573800;
  background: #ffd85a;
  border: 1px solid #8b6500;
  font-weight: 900;
}

.rare-silhouette {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: #573800;
  background: #fff1ad;
  border: 2px solid #d4a923;
  font-size: 1.4rem;
  font-weight: 900;
}

.rare-card.is-locked .rare-silhouette {
  color: #777;
  background: #d8d5cc;
  border-color: #aaa;
}

.equipment-slot {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.toggle-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.toggle-line input {
  width: 24px;
  height: 24px;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(10, 20, 29, 0.45);
}

.modal-root.is-open {
  display: grid;
}

.modal-card {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 18px;
  border: 3px solid #8a6122;
  border-radius: var(--radius);
  background: #fffdf7;
  box-shadow: var(--shadow);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100% - 32px));
}

.toast {
  padding: 12px 14px;
  border: 2px solid #2b5668;
  border-radius: var(--radius);
  color: #fff;
  background: #183948;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.empty-state {
  padding: 16px;
  border: 2px dashed #a8bbc3;
  border-radius: var(--radius);
  background: #f7fbfc;
  color: var(--muted);
  font-weight: 800;
}

.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;
}

@media (max-width: 980px) {
  .app-header {
    grid-template-columns: 1fr;
  }

  .top-nav {
    justify-content: flex-start;
  }

  .view-grid,
  .map-layout,
  .battle-grid,
  .hero-content {
    grid-template-columns: 1fr;
  }

  .unit-card {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-main {
    width: min(100% - 18px, 1180px);
    margin-top: 12px;
  }

  .app-header {
    padding: 10px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .top-nav button {
    flex: 1 1 44%;
  }

  .exp-wrap {
    grid-template-columns: 1fr;
  }

  .hero-scene {
    min-height: auto;
    padding: 18px;
  }

  .choice-grid,
  .choice-grid.ox {
    grid-template-columns: 1fr;
  }

  .world-map {
    min-height: 500px;
  }
}

/* ------------------------------------------------------------------
   Rika Quest visual refresh: magic x science adventure theme
   ------------------------------------------------------------------ */
:root {
  --bg1: #241a63;
  --bg2: #3a1f8c;
  --bg3: #4c2bb0;
  --bgglow: #6d4fe0;
  --magic: #a855f7;
  --magicD: #7c3aed;
  --energy: #22d3ee;
  --energyD: #0e93b3;
  --gold: #ffd43b;
  --goldD: #f59e0b;
  --danger: #fb6f8e;
  --dangerD: #e11d48;
  --heal: #34d399;
  --healD: #059669;
  --card: #ffffff;
  --card2: #f2efff;
  --ink: #2a2350;
  --inkSoft: #6a6398;
  --round: "Hiragino Maru Gothic ProN", "Rounded Mplus 1c", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --sh-soft: 0 10px 24px rgba(20, 10, 60, .35);
  --r-btn: 16px;
  --r-panel: 20px;
  --r-card: 24px;
  --r-stage: 26px;
  --focus: #fff;
  --radius: var(--r-panel);
  --line: #ded6ff;
  --muted: var(--inkSoft);
  --accent: var(--energy);
  --success: var(--healD);
  --warning: var(--goldD);
  --shadow: var(--sh-soft);
  --panel: linear-gradient(180deg, #fff, #f4f1ff);
}

html {
  background: var(--bg1);
}

body {
  color: #fff;
  font-family: var(--round);
  background:
    radial-gradient(120% 90% at 15% -5%, #5b34c9 0%, transparent 55%),
    radial-gradient(120% 90% at 95% 8%, #2bb6d6 0%, transparent 50%),
    linear-gradient(160deg, #2a1a6e 0%, #241a63 45%, #1b1350 100%);
}

ruby rt {
  color: var(--inkSoft);
  font-weight: 800;
}

.app-header {
  grid-template-columns: minmax(210px, .9fr) minmax(300px, 1.35fr) auto;
  background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.22);
  border-width: 0 0 1px;
  box-shadow: var(--sh-soft);
  backdrop-filter: blur(6px);
}

.brand-mark {
  border-radius: 14px;
  color: #7a4a00;
  background: radial-gradient(circle at 50% 30%, #ffe98a, var(--gold) 60%, var(--goldD));
  border: 2px solid #fff;
  box-shadow: 0 4px 0 var(--goldD), inset 0 2px 3px rgba(255,255,255,.7);
}

.brand-lockup h1 {
  color: var(--gold);
  font-weight: 900;
  text-shadow: 0 3px 0 rgba(74,42,0,.75), 0 8px 14px rgba(0,0,0,.35);
}

.eyebrow {
  color: #d9d0ff;
  font-weight: 900;
}

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.06));
  box-shadow: var(--sh-soft);
  backdrop-filter: blur(4px);
}

.lv {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 2px solid #fff;
  border-radius: 14px;
  color: #7a4a00;
  background: radial-gradient(circle at 50% 30%, #ffe98a, var(--gold) 60%, var(--goldD));
  box-shadow: 0 4px 0 var(--goldD), inset 0 2px 3px rgba(255,255,255,.7);
}

.lv b {
  font-size: 18px;
  line-height: 1;
}

.lv small {
  font-size: 9px;
  font-weight: 900;
}

.who {
  flex: 1 1 auto;
  min-width: 0;
}

.who .name,
.player-name {
  color: #fff;
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0,0,0,.5);
}

.exp-text {
  margin-top: 2px;
  color: #d9d0ff;
  font-size: .72rem;
  font-weight: 900;
}

.gear {
  display: flex;
  gap: 6px;
}

.slot {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(180deg, #3c2b86, #2a1c63);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.4);
}

.slot.rare,
.inventory-card:has(.rare-mark),
.rare-card.is-owned,
.tag.rare-tag {
  animation: rareGlow 1.8s ease-in-out infinite;
}

.slot.rare {
  border: 2px solid #fff;
  color: #7a4a00;
  background: linear-gradient(180deg, #ffe98a, var(--gold));
  box-shadow: 0 0 12px rgba(255,212,59,.9), inset 0 2px 3px rgba(255,255,255,.8);
}

.xp,
.bar {
  position: relative;
  overflow: hidden;
  height: 14px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  background: rgba(0,0,0,.28);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.45);
}

.xp > i,
.bar > span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, #a7f3d0, var(--heal) 60%, var(--healD));
  box-shadow: 0 0 8px rgba(52,211,153,.8);
  transition: width .5s cubic-bezier(.2,.8,.2,1);
}

.xp > i::after,
.bar > span::after {
  content: "";
  display: block;
  height: 50%;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(180deg, rgba(255,255,255,.55), transparent);
}

.top-nav button,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.tab-button,
.choice-button {
  min-height: 44px;
  border: 0;
  border-radius: var(--r-btn);
  font-family: var(--round);
  font-weight: 900;
  transition: transform .08s, box-shadow .08s, filter .12s;
}

.top-nav button,
.primary-button,
.tab-button.is-active {
  color: #fff;
  background: linear-gradient(180deg, var(--magic), var(--magicD));
  box-shadow: 0 5px 0 #5b23b8, 0 8px 16px rgba(80,30,180,.35);
}

.secondary-button,
.tab-button,
.ghost-button {
  color: var(--ink);
  background: linear-gradient(180deg, #fff, #eae4ff);
  box-shadow: 0 5px 0 #c9bff0, 0 8px 14px rgba(60,40,120,.18);
}

.danger-button {
  color: #fff;
  background: linear-gradient(180deg, var(--danger), var(--dangerD));
  box-shadow: 0 5px 0 #a30f36, 0 8px 14px rgba(225,29,72,.22);
}

.top-nav button:active,
.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.danger-button:active,
.tab-button:active,
.choice-button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
}

.app-main {
  animation: viewIn .22s ease-out;
}

.panel,
.hero-panel,
.unit-card,
.battle-panel,
.inventory-card,
.collection-card,
.modal-card {
  border: 1px solid #e6e0ff;
  border-radius: var(--r-card);
  color: var(--ink);
  background: linear-gradient(180deg, #fff, #f4f1ff);
  box-shadow: var(--sh-soft), inset 0 2px 0 #fff;
}

.rpg-frame::before {
  inset: 8px;
  border-color: rgba(255,255,255,.52);
  border-radius: calc(var(--r-card) - 9px);
}

.hero-scene {
  background:
    radial-gradient(90% 70% at 70% 20%, rgba(34,211,238,.35), transparent 60%),
    radial-gradient(80% 60% at 20% 15%, rgba(168,85,247,.4), transparent 60%),
    linear-gradient(180deg, #3a2a9a 0%, #2a1c74 55%, #20164f 100%);
}

.hero-title {
  color: var(--gold);
  font-weight: 900;
  text-shadow: 0 4px 0 #4a2a00, 0 12px 18px rgba(0,0,0,.35);
}

.lead,
.hero-panel p {
  color: #efeaff;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0,0,0,.45);
}

.home-dragon,
.home-hero {
  display: grid;
  place-items: center;
  min-height: 270px;
}

.home-hero svg,
.home-dragon svg {
  width: min(100%, 270px);
  height: auto;
  filter: drop-shadow(0 0 18px rgba(34,211,238,.45)) drop-shadow(0 10px 12px rgba(0,0,0,.35));
  animation: floaty 3.2s ease-in-out infinite;
}

.info-list li,
.toggle-line,
.empty-state {
  border-color: #e0d8ff;
  border-radius: var(--r-panel);
  background: rgba(255,255,255,.82);
}

.grade-tabs,
.inventory-tabs {
  padding: 8px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: var(--r-panel);
  background: rgba(255,255,255,.08);
  box-shadow: var(--sh-soft);
}

.map-shell {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r-stage);
  background:
    radial-gradient(70% 90% at 80% 20%, rgba(34,211,238,.3), transparent 60%),
    linear-gradient(160deg, #3a2a9a, #241a63);
  box-shadow: var(--sh-soft);
}

.world-map {
  filter: drop-shadow(0 10px 18px rgba(0,0,0,.28));
}

.map-node .node-ring {
  stroke: #fff;
  stroke-width: 4;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,.3));
}

.map-node.unlocked .node-ring,
.map-node.perfected .node-ring {
  animation: rareGlow 1.8s ease-in-out infinite;
}

.node-label {
  fill: #fff;
  stroke: rgba(42,26,110,.85);
  text-shadow: 0 2px 4px rgba(0,0,0,.5);
}

.tag,
.bonus-label {
  border: 0;
  color: #fff;
  background: linear-gradient(180deg, var(--energy), var(--energyD));
  box-shadow: 0 3px 0 rgba(14,147,179,.5);
}

.tag.warn {
  color: #7a4a00;
  background: linear-gradient(180deg, #ffe98a, var(--gold));
  box-shadow: 0 3px 0 var(--goldD);
}

.tag.good {
  color: #06492f;
  background: linear-gradient(180deg, #a7f3d0, var(--heal));
  box-shadow: 0 3px 0 var(--healD);
}

.tag.rare-tag,
.rare-tag {
  color: #7a4a00;
  background: linear-gradient(180deg, #ffe98a, var(--gold));
  box-shadow: 0 3px 0 var(--goldD), 0 0 12px rgba(255,212,59,.55);
}

.monster-mini,
.inventory-card,
.collection-card {
  border: 1px solid #ded6ff;
  border-radius: var(--r-card);
  background: linear-gradient(180deg, #fff, #f4f1ff);
  box-shadow: 0 8px 18px rgba(20,10,60,.16), inset 0 2px 0 #fff;
}

.monster-mini svg,
.collection-card svg {
  filter: drop-shadow(0 0 10px rgba(34,211,238,.35));
}

.monster-figure {
  display: block;
}

.monster-figure svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.monster-figure.theme-sky { filter: drop-shadow(0 0 14px rgba(34,211,238,.55)); }
.monster-figure.theme-plant { filter: drop-shadow(0 0 14px rgba(52,211,153,.45)); }
.monster-figure.theme-life { filter: drop-shadow(0 0 14px rgba(251,111,142,.45)); }
.monster-figure.theme-water { filter: drop-shadow(0 0 14px rgba(34,211,238,.45)); }
.monster-figure.theme-solution { filter: drop-shadow(0 0 16px rgba(34,211,238,.6)); }
.monster-figure.theme-electric { filter: drop-shadow(0 0 16px rgba(255,212,59,.62)); }
.monster-figure.theme-physics { filter: drop-shadow(0 0 14px rgba(255,212,59,.38)); }
.monster-figure.theme-fire { filter: drop-shadow(0 0 16px rgba(251,111,142,.55)); }
.monster-figure.theme-body { filter: drop-shadow(0 0 16px rgba(251,111,142,.48)); }
.monster-figure.theme-space { filter: drop-shadow(0 0 16px rgba(168,85,247,.6)); }
.monster-figure.theme-earth { filter: drop-shadow(0 0 14px rgba(245,158,11,.48)); }
.monster-figure.theme-chem { filter: drop-shadow(0 0 16px rgba(168,85,247,.55)); }
.monster-figure.theme-eco { filter: drop-shadow(0 0 16px rgba(52,211,153,.48)); }

.rare-card {
  border: 2px solid var(--gold);
  background: linear-gradient(180deg, #fff7c7, #fff);
}

.rare-card.is-locked {
  background: linear-gradient(180deg, #eeeaf8, #fff);
  filter: grayscale(.35);
}

.battle-panel {
  overflow: hidden;
  background: transparent;
  box-shadow: none;
  border: 0;
  padding: 0;
}

.battle-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.battle-stage {
  position: relative;
  min-height: 330px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--r-stage);
  background:
    radial-gradient(90% 70% at 70% 20%, rgba(34,211,238,.35), transparent 60%),
    radial-gradient(80% 60% at 20% 15%, rgba(168,85,247,.4), transparent 60%),
    linear-gradient(180deg, #3a2a9a 0%, #2a1c74 55%, #20164f 100%);
  box-shadow: var(--sh-soft);
}

.stage-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(14px);
  opacity: .55;
  animation: drift 9s ease-in-out infinite;
}

.stage-orb.a {
  width: 130px;
  height: 130px;
  left: -20px;
  top: 22px;
  background: #4fd0ff;
}

.stage-orb.b {
  width: 96px;
  height: 96px;
  right: -10px;
  top: 132px;
  background: #b06bff;
  animation-delay: -3s;
}

.stage-orb.c {
  width: 64px;
  height: 64px;
  left: 62%;
  top: -10px;
  background: var(--gold);
  animation-delay: -6s;
}

.stage-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 84px;
  border-top: 2px solid rgba(255,255,255,.14);
  background: radial-gradient(60% 120% at 50% 0%, rgba(124,58,237,.55), rgba(20,15,60,.9));
}

.stage-ground::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 14px;
  width: 240px;
  height: 38px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(34,211,238,.5), transparent);
}

.enemy-bar {
  position: absolute;
  z-index: 4;
  top: 14px;
  left: 16px;
  right: 16px;
}

.enemy-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: #fff;
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0,0,0,.5);
}

.enemy-bar .bar > span {
  background: linear-gradient(90deg, #ffd0d9, var(--danger) 55%, var(--dangerD));
  box-shadow: 0 0 8px rgba(251,111,142,.8);
}

.enemy-stage {
  position: absolute;
  inset: 52px 0 0;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}

.enemy-art {
  position: absolute;
  z-index: 3;
  top: 36px;
  left: 50%;
  min-height: 0;
  transform: translateX(-50%);
}

.enemy-art.hit {
  animation: hitFlash .4s;
}

.battle-monster {
  width: min(48vw, 280px);
  min-width: 180px;
  filter: drop-shadow(0 0 18px rgba(34,211,238,.55));
  animation: floaty 3s ease-in-out infinite;
}

.battle-panel.tier-boss .battle-monster,
.battle-panel.tier-bonus .battle-monster {
  width: min(52vw, 330px);
  filter: drop-shadow(0 0 20px rgba(168,85,247,.75));
}

.battle-panel.tier-bonus .battle-monster {
  filter: drop-shadow(0 0 26px rgba(255,212,59,.9));
}

.battle-hero {
  position: absolute;
  z-index: 4;
  left: 12px;
  bottom: 10px;
  width: 126px;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.4));
  animation: floaty 3.4s ease-in-out infinite;
}

.battle-hero svg {
  display: block;
  width: 100%;
  height: auto;
}

.battle-stage .battle-stats {
  position: absolute;
  z-index: 5;
  right: 14px;
  bottom: 14px;
  max-width: min(360px, calc(100% - 150px));
}

.battle-stage .reward-row {
  justify-content: flex-end;
}

.battle-stage .quest-log {
  display: none;
}

.hp-hearts {
  justify-content: flex-end;
}

.heart {
  width: auto;
  height: auto;
  border: 0;
  color: #ff557c;
  background: transparent;
  font-size: 1.45rem;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.4));
}

.heart::before {
  content: "❤️";
}

.heart {
  font-size: 0;
}

.heart.is-empty {
  opacity: .28;
  filter: grayscale(1);
}

.battle-flash {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  display: grid;
  place-items: center;
}

.battle-word {
  opacity: 0;
  color: var(--gold);
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  font-weight: 900;
  text-shadow: 0 3px 0 rgba(0,0,0,.35), 0 0 18px currentColor;
}

.battle-word.good {
  color: var(--gold);
}

.battle-word.bad {
  color: #ff9db0;
}

.battle-word.show {
  animation: wordPop .7s;
}

.spark {
  position: absolute;
  z-index: 9;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  pointer-events: none;
  background: linear-gradient(180deg, #fff, var(--gold));
  box-shadow: 0 0 8px var(--gold);
  animation: sparkFly .7s ease-out forwards;
}

.battle-stage.shake {
  animation: stageShake .3s;
}

.question-card {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid #e6e0ff;
  border-radius: var(--r-card);
  color: var(--ink);
  background: linear-gradient(180deg, #fff, #f4f1ff);
  box-shadow: var(--sh-soft), inset 0 2px 0 #fff;
}

.question-count {
  display: inline-flex;
  width: fit-content;
  min-height: 30px;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(180deg, var(--energy), var(--energyD));
  box-shadow: 0 3px 0 rgba(14,147,179,.5);
}

.question-stem {
  border-left: 0;
  border-radius: var(--r-panel);
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 0 0 2px #efeaff;
}

.choice-button {
  min-height: 72px;
  border: 0;
  padding: 14px 12px;
  text-align: left;
  color: var(--ink);
  background: linear-gradient(180deg, #fff, #eae4ff);
  box-shadow: 0 5px 0 #c9bff0, 0 8px 14px rgba(60,40,120,.18);
}

.choice-prefix {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: 8px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(180deg, #b9a8ff, var(--magicD));
}

.choice-button.is-correct {
  background: linear-gradient(180deg, #c9ffe4, #7ef0b6);
  box-shadow: 0 5px 0 var(--healD);
  animation: goodShake .5s;
}

.choice-button.is-wrong {
  background: linear-gradient(180deg, #ffd7de, #ff9db0);
  box-shadow: 0 5px 0 var(--dangerD);
}

.choice-button.is-correct::after,
.choice-button.is-wrong::after {
  float: right;
  font-size: 1.2rem;
  font-weight: 900;
}

.choice-button.is-correct::after {
  content: "✓";
  color: var(--healD);
}

.choice-button.is-wrong::after {
  content: "✗";
  color: var(--dangerD);
}

.feedback {
  border: 2px solid #e0d8ff;
  border-radius: var(--r-panel);
  background: #fff;
}

.feedback.good {
  border-color: var(--heal);
}

.feedback.bad {
  border-color: var(--danger);
}

.modal-root {
  background: radial-gradient(circle at 50% 40%, rgba(80,40,160,.55), rgba(10,6,30,.85));
}

.modal-card {
  border: 2px solid rgba(255,255,255,.3);
  background: linear-gradient(180deg, #fff, #f4f1ff);
  animation: pop .25s ease-out;
}

.toast {
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--r-panel);
  background: linear-gradient(180deg, #3c2b86, #2a1c63);
  box-shadow: var(--sh-soft);
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

@keyframes drift {
  0%, 100% { transform: translate(0,0); }
  50% { transform: translate(12px,-14px); }
}

@keyframes hitFlash {
  0% { filter: drop-shadow(0 0 18px #fff) brightness(2); }
  30% { transform: translateX(-50%) translateY(-8px) rotate(-4deg); }
  60% { transform: translateX(-50%) rotate(3deg); }
  100% { transform: translateX(-50%); }
}

@keyframes pop {
  0% { transform: scale(.72); opacity: 0; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes viewIn {
  0% { transform: scale(.985); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes wordPop {
  0% { transform: scale(.4) translateY(20px); opacity: 0; }
  25% { transform: scale(1.15); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: scale(1) translateY(-18px); opacity: 0; }
}

@keyframes goodShake {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-3px) rotate(-1deg); }
  75% { transform: translateY(-1px) rotate(1deg); }
}

@keyframes rareGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(255,212,59,.7), inset 0 2px 3px rgba(255,255,255,.8); }
  50% { box-shadow: 0 0 22px rgba(255,212,59,1), inset 0 2px 3px rgba(255,255,255,.9); }
}

@keyframes sparkFly {
  0% { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; }
}

@keyframes stageShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

@media (max-width: 980px) {
  .battle-stage {
    min-height: 300px;
  }

  .battle-hero {
    width: 104px;
  }
}

@media (max-width: 640px) {
  .app-header {
    position: static;
  }

  .hud {
    flex-wrap: wrap;
  }

  .battle-stage .battle-stats {
    left: 118px;
    right: 10px;
    max-width: none;
  }

  .battle-monster {
    width: min(72vw, 250px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
