/* ═══════════════════════════════════════════════════════════════
   Mystic Forest Academia — Word Study Page
   Aesthetic: warm magical adventure + scholastic elegance
   Differentiation: enchanted golden fragment glow + parchment depth
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Color story */
  --color-abyss: #071816;
  --color-forest: #0d2622;
  --color-ember: #1a1208;
  --color-gold: #f0c94a;
  --color-gold-deep: #c8922a;
  --color-gold-pale: #fff3b0;
  --color-cream: #fff7e6;
  --color-parchment: #f5e6c8;
  --color-parchment-dark: #d4b896;
  --color-emerald: #4ade80;
  --color-emerald-deep: #166534;
  --color-ruby: #ef4444;
  --color-ruby-deep: #7f1d1d;
  --color-sapphire: #60a5fa;
  --color-sapphire-deep: #1e3a5f;
  --color-amber: #f59e0b;

  /* Typography */
  --font-display: 'Ma Shan Zheng', 'STKaiti', 'KaiTi', 'FZKai-Z03', serif;
  --font-body: 'HarmonyOS Sans SC', 'Microsoft YaHei', 'PingFang SC', system-ui, sans-serif;

  /* Spacing rhythm (based on vmin) */
  --space-unit: 1vmin;

  /* Depth layers */
  --shadow-card: 0 0.6vmin 1.2vmin rgba(0, 0, 0, 0.45);
  --shadow-glow-gold: 0 0 1.8vmin rgba(240, 201, 74, 0.35);
  --shadow-glow-emerald: 0 0 1.6vmin rgba(74, 222, 128, 0.4);
  --shadow-text: 0 0.15vmin 0.12vmin rgba(0, 0, 0, 0.7);
}

/* ── Reset & Base ──────────────────────────────────────────── */
* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--color-cream);
  background: var(--color-abyss);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

/* ── Viewport — cinematic background blur ──────────────────── */
.viewport {
  position: relative;
  display: grid;
  width: 100vw;
  height: 100vh;
  place-items: center;
  overflow: hidden;
  background: var(--color-abyss);
}

.viewport::before {
  position: absolute;
  inset: -2%;
  content: "";
  background-image: var(--scene-bg-url, url("../assets/word-study/questions/场景背景-生活大陆入口图.png"));
  background-position: center;
  background-size: cover;
  filter: blur(10px) brightness(0.42) saturate(1.06);
  transform: scale(1.04);
}

/* Subtle grain overlay for texture */
.viewport::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  content: "";
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* ── Stage — the game canvas ────────────────────────────────── */
.stage {
  position: relative;
  width: min(100vw, 150.41vh);
  aspect-ratio: 1280 / 851;
  overflow: hidden;
  isolation: isolate;
  background: var(--color-forest);
  border-radius: 0.3vmin;
  box-shadow:
    0 0 6vmin rgba(0, 0, 0, 0.6),
    0 0 2vmin rgba(240, 201, 74, 0.08),
    inset 0 0 0 0.15vmin rgba(255, 255, 255, 0.04);
}

.stage img {
  user-select: none;
  -webkit-user-drag: none;
}

/* ── Scene Background ───────────────────────────────────────── */
.scene-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 54%;
  filter: blur(0.6px) saturate(1.06) brightness(0.78);
}

/* Atmospheric vignette */
.scene-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 38% 62%, rgba(240, 201, 74, 0.06) 0%, transparent 48%),
    radial-gradient(ellipse at 65% 55%, rgba(96, 165, 250, 0.04) 0%, transparent 42%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.22), transparent 28%, transparent 64%, rgba(0, 0, 0, 0.24)),
    linear-gradient(180deg, rgba(13, 38, 34, 0.04), rgba(0, 0, 0, 0.2));
}

/* ── Pause Button ───────────────────────────────────────────── */
.pause-button {
  position: absolute;
  top: 2.8%;
  right: 1.4%;
  z-index: 15;
  width: 4.3%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.55) 100%);
  animation: pause-breathe 2.4s ease-in-out infinite;
  transition: transform 0.2s ease;
  filter:
    drop-shadow(0 0.6vmin 0.4vmin rgba(0, 0, 0, 0.55))
    drop-shadow(0 0 0.8vmin rgba(255, 232, 150, 0.35));
}

.pause-button:hover,
.pause-button:focus-visible {
  transform: scale(1.08);
  filter:
    drop-shadow(0 0.7vmin 0.5vmin rgba(0, 0, 0, 0.6))
    drop-shadow(0 0 1.2vmin rgba(255, 232, 150, 0.55));
}

.pause-button:focus-visible {
  outline: 0.25vmin solid rgba(255, 236, 161, 0.85);
  outline-offset: 0.4vmin;
}

.pause-button img,
.continue-button img,
.pause-actions img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Hero Character ─────────────────────────────────────────── */
.hero-image {
  position: absolute;
  left: 3.6%;
  bottom: 0;
  z-index: 4;
  width: auto;
  height: 58%;
  max-width: 27%;
  max-height: none;
  object-fit: contain;
  object-position: left bottom;
  filter:
    drop-shadow(0 1.2vmin 0.9vmin rgba(0, 0, 0, 0.5))
    drop-shadow(0 0 1.6vmin rgba(96, 165, 250, 0.1));
  transition:
    opacity 200ms ease,
    transform 240ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hero-image.is-wrong {
  transform: translateX(-1.4%) rotate(-1.2deg);
  filter:
    drop-shadow(0 1.2vmin 0.9vmin rgba(0, 0, 0, 0.5))
    drop-shadow(0 0 1.6vmin rgba(239, 68, 68, 0.18));
}

/* ── NPC Character ──────────────────────────────────────────── */
.npc-image {
  position: absolute;
  right: 7.8%;
  bottom: 31%;
  z-index: 5;
  width: auto;
  height: 36%;
  max-width: 21%;
  max-height: none;
  object-fit: contain;
  filter:
    drop-shadow(0 1vmin 0.7vmin rgba(0, 0, 0, 0.45))
    drop-shadow(0 0 1.2vmin rgba(240, 201, 74, 0.12));
  transform-origin: center bottom;
}

.npc-image.is-fairy {
  right: 9%;
  bottom: 32%;
  height: 37%;
  max-width: 20%;
  animation: fairy-hover 2.8s ease-in-out infinite;
  filter:
    drop-shadow(0 1vmin 0.7vmin rgba(0, 0, 0, 0.45))
    drop-shadow(0 0 1.6vmin rgba(240, 201, 74, 0.2));
}

/* ── Scene Label (top banner) ───────────────────────────────── */
.scene-label {
  position: absolute;
  top: 2.6%;
  left: 50%;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64%;
  min-height: 16%;
  padding: 0 3%;
  overflow: hidden;
  color: var(--color-gold-pale);
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(14px, 1.15vw, 18px);
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow:
    0 0.16vmin 0.12vmin rgba(28, 27, 7, 0.88),
    0 0 0.5vmin rgba(55, 92, 20, 0.95);
  transform: translateX(-50%);
}

/* ── NPC Bubble (question dialog) ───────────────────────────── */
.npc-bubble {
  position: absolute;
  top: 13%;
  left: 31.2%;
  width: 38.8%;
  height: 18.8%;
}

.npc-bubble img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  filter:
    drop-shadow(0 0.6vmin 0.5vmin rgba(0, 0, 0, 0.3))
    drop-shadow(0 0 0.4vmin rgba(240, 201, 74, 0.08));
}

.bubble-copy {
  position: absolute;
  inset: 27% 12.5% 15% 12%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8%;
  color: #2e2217;
  font-weight: 900;
  line-height: 1.12;
}

.bubble-copy p,
.bubble-copy strong {
  margin: 0;
}

.bubble-copy p {
  color: #3e2a18;
  font-size: clamp(13px, 1.22vw, 20px);
  text-shadow: 0 0.08vmin 0 rgba(255, 245, 220, 0.5);
}

.bubble-copy strong {
  color: #b23231;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.2vw, 36px);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-shadow:
    0 0.1vmin 0 rgba(255, 236, 201, 0.6),
    0 0.16vmin 0.1vmin rgba(112, 33, 22, 0.16);
}

/* ── Question Layer ─────────────────────────────────────────── */
.question-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
}

/* ── Answer Buttons ─────────────────────────────────────────── */
.answers-panel {
  position: absolute;
  left: 33.8%;
  bottom: 26%;
  width: 34.8%;
  height: 8.4%;
}

.answers {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3.8%;
  align-items: stretch;
}

.answer-button {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 7%;
  border: 0.14vmin solid rgba(103, 74, 39, 0.5);
  border-radius: 0.7vmin;
  color: #332518;
  background:
    linear-gradient(180deg,
      rgba(252, 244, 215, 0.98) 0%,
      rgba(240, 220, 170, 0.98) 40%,
      rgba(218, 194, 151, 0.98) 100%);
  box-shadow:
    inset 0 0.14vmin 0.2vmin rgba(255, 255, 255, 0.6),
    inset 0 -0.16vmin 0.18vmin rgba(112, 72, 30, 0.12),
    0 0.06vmin 0.1vmin rgba(255, 237, 190, 0.2),
    0 0.4vmin 0.6vmin rgba(0, 0, 0, 0.25);
  font-size: clamp(12px, 1.12vw, 18px);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 0.1vmin 0 rgba(255, 244, 210, 0.5);
  transition:
    color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 180ms ease;
  cursor: pointer;
}

/* Magical shimmer on top */
.answer-button::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255, 255, 255, 0.3) 45%,
    rgba(255, 255, 255, 0.5) 50%,
    rgba(255, 255, 255, 0.3) 55%,
    transparent 60%
  );
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.answer-button:hover::before,
.answer-button:focus-visible::before {
  opacity: 1;
}

.answer-button:hover,
.answer-button:focus-visible {
  transform: translateY(-3%) scale(1.03);
  box-shadow:
    inset 0 0.14vmin 0.2vmin rgba(255, 255, 255, 0.6),
    inset 0 -0.16vmin 0.18vmin rgba(112, 72, 30, 0.12),
    0 0.4vmin 0.8vmin rgba(240, 201, 74, 0.25),
    0 0.6vmin 1vmin rgba(0, 0, 0, 0.3);
  border-color: rgba(192, 146, 42, 0.6);
}

.answer-button:focus-visible {
  outline: 0.22vmin solid rgba(240, 201, 74, 0.8);
  outline-offset: 0.25vmin;
}

/* Correct answer state */
.answer-button.is-correct {
  border-color: rgba(134, 239, 120, 0.9);
  color: #fff9dc;
  background:
    linear-gradient(180deg, rgba(74, 222, 128, 0.95) 0%, rgba(34, 150, 70, 0.98) 60%, rgba(20, 100, 50, 0.98) 100%);
  box-shadow:
    inset 0 0.14vmin 0.2vmin rgba(255, 255, 255, 0.3),
    0 0 0.8vmin rgba(74, 222, 128, 0.35),
    0 0 1.6vmin rgba(74, 222, 128, 0.15);
  text-shadow:
    0 0.16vmin 0.14vmin rgba(0, 0, 0, 0.55),
    0 0 0.4vmin rgba(255, 247, 196, 0.45);
  animation: correct-pulse 0.6s ease-out;
}

/* Wrong answer state */
.answer-button.is-wrong {
  border-color: rgba(255, 150, 130, 0.85);
  color: #fff7ed;
  background:
    linear-gradient(180deg, rgba(239, 68, 68, 0.95) 0%, rgba(180, 40, 40, 0.98) 60%, rgba(120, 30, 30, 0.98) 100%);
  box-shadow:
    inset 0 0.14vmin 0.2vmin rgba(255, 255, 255, 0.18),
    0 0 0.6vmin rgba(239, 68, 68, 0.2);
  text-shadow: 0 0.16vmin 0.14vmin rgba(0, 0, 0, 0.6);
  animation: shake 0.4s ease-out;
}

.answer-button:disabled {
  cursor: default;
  pointer-events: none;
}

/* ── Progress Panel ─────────────────────────────────────────── */
.progress-panel {
  position: absolute;
  left: 34.8%;
  bottom: 17%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 1.2vmin;
  align-items: center;
  width: 32.2%;
  padding: 0.35vmin 1.2vmin;
  color: #f6e7bd;
  font-size: clamp(11px, 1vw, 17px);
  font-weight: 900;
  text-shadow: 0 0.16vmin 0.12vmin rgba(0, 0, 0, 0.75);
  background: rgba(13, 38, 34, 0.55);
  backdrop-filter: blur(6px);
  border: 0.1vmin solid rgba(240, 201, 74, 0.15);
  border-radius: 999px;
}

.progress-track {
  height: 1.2vmin;
  overflow: hidden;
  background: rgba(7, 20, 15, 0.9);
  border: 0.12vmin solid rgba(240, 201, 74, 0.25);
  border-radius: 999px;
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  background:
    linear-gradient(90deg, #4ade80, #a3e635, #f0c94a);
  border-radius: inherit;
  box-shadow:
    0 0 0.7vmin rgba(74, 222, 128, 0.5),
    inset 0 0.04vmin 0.08vmin rgba(255, 255, 255, 0.3);
  transition: width 260ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Reward Chip ────────────────────────────────────────────── */
/* ── Reward Chip — magical fragment treasure card ──────────── */
.reward-chip {
  position: absolute;
  right: 5.4%;
  bottom: 14%;
  z-index: 8;
  display: grid;
  gap: 0.6vmin;
  justify-items: center;
  align-content: center;
  width: 10.5%;
  min-height: 13%;
  padding: 1.2vmin 1vmin 1vmin;
  color: #ffdc74;
  text-align: center;
  font-size: clamp(10px, 0.95vw, 16px);
  font-weight: 900;
  text-shadow:
    0 0.14vmin 0.12vmin rgba(0, 0, 0, 0.8),
    0 0 0.5vmin rgba(240, 201, 74, 0.25);
  /* Frosted glass card */
  background:
    radial-gradient(ellipse at 50% 40%, rgba(240, 201, 74, 0.12) 0%, transparent 70%),
    linear-gradient(180deg,
      rgba(20, 30, 20, 0.55) 0%,
      rgba(12, 20, 14, 0.65) 100%);
  backdrop-filter: blur(8px);
  border: 0.12vmin solid rgba(240, 201, 74, 0.35);
  border-radius: 1.4vmin;
  box-shadow:
    0 0.6vmin 1vmin rgba(0, 0, 0, 0.4),
    0 0 1.2vmin rgba(240, 201, 74, 0.12),
    inset 0 0.06vmin 0.1vmin rgba(255, 255, 255, 0.06);
  animation: reward-card-breathe 3s ease-in-out infinite;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease;
}

/* Subtle inner glow ring behind the fragment */
.reward-chip::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 62%;
  aspect-ratio: 1;
  content: "";
  background: radial-gradient(circle,
    rgba(96, 165, 250, 0.18) 0%,
    rgba(96, 165, 250, 0.06) 50%,
    transparent 70%);
  border-radius: 50%;
  transform: translate(-50%, -48%);
  animation: glow-ring-pulse 2s ease-in-out infinite;
  pointer-events: none;
}

/* Sparkle dots around the card border */
.reward-chip::after {
  position: absolute;
  inset: -0.2vmin;
  content: "";
  border-radius: inherit;
  padding: 0.15vmin;
  background: linear-gradient(
    135deg,
    rgba(240, 201, 74, 0.5) 0%,
    transparent 30%,
    transparent 60%,
    rgba(240, 201, 74, 0.4) 80%,
    transparent 100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: border-sparkle-rotate 4s linear infinite;
  pointer-events: none;
}

.reward-chip span {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.3vmin;
  color: #ffe9a0;
  font-family: var(--font-display);
  font-size: clamp(13px, 1.15vw, 19px);
  font-weight: 400;
  letter-spacing: 0.1em;
  line-height: 1;
  text-shadow:
    0 0.12vmin 0.1vmin rgba(0, 0, 0, 0.7),
    0 0 0.5vmin rgba(240, 201, 74, 0.4);
}

/* Tiny sparkle stars flanking the label */
.reward-chip span::before {
  content: "✦";
  font-size: 0.6em;
  color: #fde68a;
  animation: star-twinkle 1.5s ease-in-out infinite;
  text-shadow: 0 0 0.4vmin rgba(240, 201, 74, 0.8);
}

.reward-chip span::after {
  content: "✦";
  font-size: 0.5em;
  color: #fde68a;
  animation: star-twinkle 1.5s ease-in-out 0.5s infinite;
  text-shadow: 0 0 0.35vmin rgba(240, 201, 74, 0.7);
}

/* Fragment image */
.reward-chip img {
  position: relative;
  z-index: 1;
  width: 55%;
  height: auto;
  animation: fragment-float-reward-chip 2.2s ease-in-out infinite;
  filter:
    drop-shadow(0 0.3vmin 0.25vmin rgba(0, 0, 0, 0.55))
    drop-shadow(0 0 1vmin rgba(96, 165, 250, 0.55))
    drop-shadow(0 0 1.8vmin rgba(96, 165, 250, 0.25));
}

/* Reward amount text */
.reward-chip strong {
  position: relative;
  z-index: 1;
  display: block;
  color: #ffe27a;
  font-size: clamp(13px, 1.2vw, 20px);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow:
    0 0.14vmin 0.12vmin rgba(0, 0, 0, 0.8),
    0 0 0.6vmin rgba(240, 201, 74, 0.45);
}

/* ── Reward Card Animations ─────────────────────────────── */
@keyframes reward-card-breathe {
  0%, 100% {
    box-shadow:
      0 0.6vmin 1vmin rgba(0, 0, 0, 0.4),
      0 0 1.2vmin rgba(240, 201, 74, 0.12),
      inset 0 0.06vmin 0.1vmin rgba(255, 255, 255, 0.06);
  }
  50% {
    box-shadow:
      0 0.6vmin 1vmin rgba(0, 0, 0, 0.45),
      0 0 1.8vmin rgba(240, 201, 74, 0.22),
      0 0 3vmin rgba(96, 165, 250, 0.1),
      inset 0 0.06vmin 0.1vmin rgba(255, 255, 255, 0.1);
  }
}

@keyframes glow-ring-pulse {
  0%, 100% {
    opacity: 0.6;
    transform: translate(-50%, -48%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -48%) scale(1.15);
  }
}

@keyframes border-sparkle-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes star-twinkle {
  0%, 100% {
    opacity: 0.4;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

@keyframes fragment-float-reward-chip {
  0%, 100% {
    filter:
      drop-shadow(0 0.3vmin 0.25vmin rgba(0, 0, 0, 0.55))
      drop-shadow(0 0 1vmin rgba(96, 165, 250, 0.55))
      drop-shadow(0 0 1.8vmin rgba(96, 165, 250, 0.25));
    transform: translateY(0) scale(1);
  }
  35% {
    filter:
      drop-shadow(0 0.3vmin 0.25vmin rgba(0, 0, 0, 0.55))
      drop-shadow(0 0 1.6vmin rgba(96, 165, 250, 0.75))
      drop-shadow(0 0 2.6vmin rgba(96, 165, 250, 0.4));
    transform: translateY(-5%) scale(1.06);
  }
  70% {
    filter:
      drop-shadow(0 0.3vmin 0.25vmin rgba(0, 0, 0, 0.5))
      drop-shadow(0 0 0.8vmin rgba(96, 165, 250, 0.45))
      drop-shadow(0 0 1.4vmin rgba(96, 165, 250, 0.2));
    transform: translateY(-1.5%) scale(0.98);
  }
}

/* Hover interaction on desktop */
@media (hover: hover) {
  .reward-chip:hover {
    transform: translateY(-3%) scale(1.04);
    box-shadow:
      0 0.8vmin 1.4vmin rgba(0, 0, 0, 0.5),
      0 0 2vmin rgba(240, 201, 74, 0.3),
      0 0 3.5vmin rgba(96, 165, 250, 0.15),
      inset 0 0.08vmin 0.12vmin rgba(255, 255, 255, 0.1);
  }
}

/* ── Thinking Bubble (wrong answer hint) ────────────────────── */
.thinking-bubble {
  position: absolute;
  left: 20.6%;
  bottom: 47%;
  z-index: 9;
  min-width: 16%;
  padding: 1.2vmin 1.6vmin;
  color: #4a2a19;
  background: rgba(255, 246, 220, 0.95);
  border: 0.18vmin solid rgba(192, 146, 42, 0.4);
  border-radius: 2vmin;
  box-shadow:
    0 0.6vmin 0.7vmin rgba(0, 0, 0, 0.28),
    inset 0 0.06vmin 0.1vmin rgba(255, 255, 255, 0.5);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8%) scale(0.94);
  visibility: hidden;
  transition:
    opacity 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.thinking-bubble::after {
  position: absolute;
  left: 18%;
  bottom: -1.2vmin;
  width: 2vmin;
  height: 2vmin;
  background: inherit;
  border-right: inherit;
  border-bottom: inherit;
  content: "";
  transform: rotate(45deg);
}

.thinking-bubble span,
.thinking-bubble strong {
  display: block;
  line-height: 1.25;
}

.thinking-bubble span {
  font-size: clamp(12px, 1.15vw, 18px);
  font-weight: 900;
  color: #5a3a28;
}

.thinking-bubble strong {
  margin-top: 0.3vmin;
  color: #9b2d2b;
  font-size: clamp(13px, 1.35vw, 22px);
  font-weight: 900;
}

.thinking-bubble.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

/* ── Success Layer ──────────────────────────────────────────── */
.success-layer {
  position: absolute;
  inset: 0;
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-cream);
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(240, 201, 74, 0.08) 0%, transparent 60%),
    rgba(5, 16, 17, 0.35);
  backdrop-filter: blur(2px);
  animation: success-enter 0.5s ease-out;
}

.stage.is-success .question-layer,
.stage.is-success .reward-chip,
.stage.is-success .thinking-bubble {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.success-layer[hidden],
.pause-layer[hidden] {
  display: none;
}

.success-layer h2 {
  position: absolute;
  top: 7.2%;
  left: 50%;
  margin: 0;
  color: #ffd564;
  font-family: var(--font-display);
  font-size: clamp(36px, 4.8vw, 72px);
  font-weight: 400;
  letter-spacing: 0.1em;
  text-shadow:
    0 0.3vmin 0.18vmin rgba(70, 33, 0, 0.9),
    0 0 1.4vmin rgba(255, 190, 52, 0.65),
    0 0 3vmin rgba(255, 190, 52, 0.25);
  transform: translateX(-50%);
  animation: title-glow 2s ease-in-out infinite;
}

/* Parchment card for success */
.success-card {
  position: absolute;
  top: 23%;
  left: 50%;
  display: grid;
  justify-items: center;
  width: 28%;
  min-height: 47%;
  padding: 2.8% 2.5% 1.8%;
  background:
    linear-gradient(180deg,
      rgba(40, 30, 15, 0.75) 0%,
      rgba(30, 22, 12, 0.8) 50%,
      rgba(20, 16, 10, 0.85) 100%);
  border: 0.16vmin solid rgba(240, 201, 74, 0.5);
  border-radius: 1.2vmin;
  box-shadow:
    0 0 3vmin rgba(240, 201, 74, 0.25),
    0 0 6vmin rgba(0, 0, 0, 0.4),
    inset 0 0 3vmin rgba(240, 201, 74, 0.06),
    inset 0 0.06vmin 0.1vmin rgba(255, 255, 255, 0.08);
  transform: translateX(-50%);
  animation: card-rise 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.success-card strong {
  color: #fff5cb;
  font-family: var(--font-display);
  font-size: clamp(38px, 4.5vw, 62px);
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1;
  text-shadow:
    0 0.2vmin 0.16vmin rgba(0, 0, 0, 0.7),
    0 0 1.2vmin rgba(240, 201, 74, 0.35);
}

.success-card span {
  margin-top: 0.8vmin;
  color: #ffe59d;
  font-size: clamp(16px, 1.85vw, 28px);
  font-weight: 900;
}

.success-card img {
  width: 26%;
  margin-top: 1.4vmin;
  animation: fragment-float 1.8s ease-in-out infinite;
  filter:
    drop-shadow(0 0.3vmin 0.3vmin rgba(0, 0, 0, 0.5))
    drop-shadow(0 0 1vmin rgba(96, 165, 250, 0.55));
}

.success-card p {
  margin: 1.2vmin 0 0;
  padding: 0.5vmin 2.4vmin;
  color: #ffe07b;
  background:
    linear-gradient(180deg, rgba(192, 146, 42, 0.6) 0%, rgba(140, 80, 20, 0.7) 100%);
  border: 0.1vmin solid rgba(240, 201, 74, 0.35);
  border-radius: 999px;
  font-size: clamp(15px, 1.7vw, 28px);
  font-weight: 900;
  text-shadow: 0 0.12vmin 0.1vmin rgba(0, 0, 0, 0.5);
}

/* ── Continue Button ────────────────────────────────────────── */
.continue-button {
  position: absolute;
  right: 3.4%;
  bottom: 4.2%;
  width: 16.6%;
  aspect-ratio: 500 / 161;
  filter:
    drop-shadow(0 0.6vmin 0.45vmin rgba(0, 0, 0, 0.55))
    drop-shadow(0 0 0.6vmin rgba(240, 201, 74, 0.3));
  transition:
    transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1),
    filter 180ms ease;
}

.continue-button:hover,
.continue-button:focus-visible {
  transform: translateY(-4%) scale(1.03);
  filter:
    drop-shadow(0 0.7vmin 0.5vmin rgba(0, 0, 0, 0.6))
    drop-shadow(0 0 1vmin rgba(240, 201, 74, 0.5));
}

.continue-button:focus-visible {
  outline: 0.25vmin solid rgba(255, 236, 161, 0.85);
  outline-offset: 0.4vmin;
}

/* ── Pause Layer ────────────────────────────────────────────── */
.pause-layer {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: pause-enter 0.3s ease-out;
}

.pause-frame {
  width: 43%;
  height: auto;
  opacity: 0.98;
  filter:
    drop-shadow(0 1vmin 0.9vmin rgba(0, 0, 0, 0.45))
    drop-shadow(0 0 0.6vmin rgba(240, 201, 74, 0.15));
}

.pause-actions {
  position: absolute;
  top: 45.8%;
  left: 50%;
  display: grid;
  gap: 1.3vmin;
  width: 28%;
  transform: translateX(-50%);
}

.pause-actions button,
.pause-actions a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.4vmin;
  width: 100%;
  height: 5.8vmin;
  min-height: 38px;
  max-height: 52px;
  overflow: hidden;
  color: #ffe6a2;
  text-decoration: none;
  text-shadow: 0 0.18vmin 0.14vmin rgba(0, 0, 0, 0.85);
  background:
    linear-gradient(180deg,
      rgba(55, 35, 16, 0.98) 0%,
      rgba(35, 20, 10, 0.98) 100%);
  border: 0.2vmin solid rgba(240, 201, 74, 0.7);
  border-radius: 0.8vmin;
  box-shadow:
    inset 0 0.1vmin 0.16vmin rgba(255, 232, 164, 0.3),
    inset 0 -0.24vmin 0.26vmin rgba(0, 0, 0, 0.25),
    0 0.4vmin 0.5vmin rgba(0, 0, 0, 0.25);
  font-size: clamp(16px, 1.42vw, 24px);
  font-weight: 900;
  transition:
    transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.pause-actions button::before,
.pause-actions a::before {
  display: grid;
  width: 3.4vmin;
  min-width: 28px;
  aspect-ratio: 1;
  place-items: center;
  color: #ffda78;
  font-size: 1.15em;
  line-height: 1;
  text-shadow: 0 0.16vmin 0.12vmin rgba(0, 0, 0, 0.7);
}

.pause-actions button::after,
.pause-actions a::after {
  content: attr(aria-label);
}

.pause-actions img {
  display: none;
}

#resumeButton {
  color: #fff1b6;
  background:
    linear-gradient(180deg,
      rgba(24, 80, 140, 0.98) 0%,
      rgba(12, 42, 88, 0.98) 100%);
  border-color: rgba(240, 201, 74, 0.85);
  box-shadow:
    inset 0 0.1vmin 0.16vmin rgba(255, 255, 255, 0.2),
    0 0 0.8vmin rgba(96, 165, 250, 0.15);
}

#resumeButton::before {
  content: "▶";
}

#restartButton::before {
  content: "↻";
}

#settingsButton::before {
  content: "⚙";
}

.pause-actions a::before {
  content: "↪";
}

.pause-actions button:hover,
.pause-actions button:focus-visible,
.pause-actions a:hover,
.pause-actions a:focus-visible {
  transform: translateY(-4%) scale(1.02);
  border-color: rgba(240, 201, 74, 0.95);
  box-shadow:
    inset 0 0.1vmin 0.16vmin rgba(255, 232, 164, 0.35),
    inset 0 -0.24vmin 0.26vmin rgba(0, 0, 0, 0.25),
    0 0.5vmin 0.8vmin rgba(240, 201, 74, 0.2);
}

.pause-actions button:focus-visible,
.pause-actions a:focus-visible {
  outline: 0.22vmin solid rgba(255, 236, 161, 0.85);
  outline-offset: 0.3vmin;
}

/* ═══════════════════════════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════════════════════════ */

/* Fairy hover — gentle float */
@keyframes fairy-hover {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  30% {
    transform: translateY(-3.5%) rotate(0.8deg);
  }
  70% {
    transform: translateY(-1.5%) rotate(-0.5deg);
  }
}

/* Pause button breathing */
@keyframes pause-breathe {
  0%, 100% {
    filter:
      drop-shadow(0 0.6vmin 0.4vmin rgba(0, 0, 0, 0.55))
      drop-shadow(0 0 0.8vmin rgba(255, 232, 150, 0.35));
  }
  50% {
    filter:
      drop-shadow(0 0.7vmin 0.5vmin rgba(0, 0, 0, 0.6))
      drop-shadow(0 0 1.5vmin rgba(255, 232, 150, 0.7));
  }
}

/* Fragment float — magical bob */
@keyframes fragment-float {
  0%, 100% {
    filter:
      drop-shadow(0 0.3vmin 0.3vmin rgba(0, 0, 0, 0.5))
      drop-shadow(0 0 0.8vmin rgba(96, 165, 250, 0.5));
    transform: translateY(0) scale(1);
  }
  50% {
    filter:
      drop-shadow(0 0.3vmin 0.3vmin rgba(0, 0, 0, 0.5))
      drop-shadow(0 0 1.8vmin rgba(96, 165, 250, 0.85));
    transform: translateY(-3%) scale(1.05);
  }
}

/* Correct answer pulse */
@keyframes correct-pulse {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

/* Wrong answer shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-3%); }
  30% { transform: translateX(3%); }
  45% { transform: translateX(-2%); }
  60% { transform: translateX(2%); }
  75% { transform: translateX(-0.8%); }
}

/* Success layer entrance */
@keyframes success-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Card rise animation */
@keyframes card-rise {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(6%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

/* Title glow pulse */
@keyframes title-glow {
  0%, 100% {
    text-shadow:
      0 0.3vmin 0.18vmin rgba(70, 33, 0, 0.9),
      0 0 1.4vmin rgba(255, 190, 52, 0.65),
      0 0 3vmin rgba(255, 190, 52, 0.25);
  }
  50% {
    text-shadow:
      0 0.3vmin 0.18vmin rgba(70, 33, 0, 0.9),
      0 0 2vmin rgba(255, 190, 52, 0.8),
      0 0 4vmin rgba(255, 190, 52, 0.4);
  }
}

/* Pause layer entrance */
@keyframes pause-enter {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(4px);
  }
}

/* ═══════════════════════════════════════════════════════════════
   Responsive — Mobile Portrait
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 760px) and (orientation: portrait) {
  .stage {
    width: min(100vw, 150.41vh);
    aspect-ratio: 1280 / 851;
  }

  .scene-bg {
    width: 100%;
    max-width: none;
    transform: none;
  }

  .pause-button {
    width: 13%;
    top: 2%;
    right: 1%;
  }

  .hero-image {
    left: -8%;
    width: 45%;
  }

  .npc-image,
  .npc-image.is-fairy {
    right: -2%;
    bottom: 45%;
    width: 35%;
  }

  .scene-label {
    top: 2.3%;
    width: 64%;
    max-width: none;
    min-height: 16%;
    padding: 0 3%;
    font-size: clamp(13px, 3.2vw, 17px);
  }

  .npc-bubble {
    top: 13%;
    left: 14%;
    width: 72%;
    height: 20%;
  }

  .bubble-copy {
    inset: 27% 10% 16%;
  }

  .bubble-copy p {
    font-size: clamp(16px, 4vw, 22px);
  }

  .bubble-copy strong {
    font-size: clamp(24px, 6vw, 34px);
  }

  .answers-panel {
    left: 5%;
    bottom: 20%;
    width: 90%;
    height: 17%;
  }

  .answer-button {
    font-size: clamp(14px, 3.5vw, 18px);
    border-radius: 1vmin;
  }

  .progress-panel {
    left: 12%;
    bottom: 11%;
    width: 76%;
    font-size: clamp(13px, 3.5vw, 18px);
  }

  .reward-chip {
    right: 2%;
    bottom: 3%;
    width: 26%;
    min-height: 14%;
    padding: 1.5vmin 1.2vmin;
    font-size: clamp(13px, 3.2vw, 18px);
    border-radius: 1.8vmin;
  }

  .reward-chip span {
    font-size: clamp(15px, 3.8vw, 20px);
  }

  .reward-chip strong {
    font-size: clamp(15px, 4vw, 22px);
  }

  .reward-chip img {
    width: 50%;
  }

  .thinking-bubble {
    left: 27%;
    bottom: 45%;
  }

  .success-card {
    top: 28%;
    width: 65%;
  }

  .continue-button {
    right: 8%;
    bottom: 7%;
    width: 38%;
  }

  .pause-frame {
    width: 80%;
  }

  .pause-actions {
    top: 45.5%;
    width: 52%;
    gap: 1.5vmin;
  }

  .pause-actions button,
  .pause-actions a {
    height: 6.5vmin;
    min-height: 42px;
    font-size: clamp(18px, 4vw, 22px);
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .stage {
    width: min(100vw, 150.41vh);
    aspect-ratio: 1280 / 851;
  }
}

/* ── Reduced Motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
