:root {
  --ink: #162033;
  --muted: #667085;
  --paper: #f4f8fb;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --grid: #dbe4f0;
  --axis: #4e5b70;
  --blueprint: #2864d9;
  --coral: #ee6545;
  --green: #15936d;
  --gold: #d99725;
  --violet: #7958d7;
  --aqua: #28b8a7;
  --shadow: 0 18px 44px rgba(22, 32, 51, 0.12);
  --glow: 0 0 34px rgba(40, 184, 167, 0.38);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: clip;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  font-family:
    "Aptos", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    linear-gradient(135deg, rgba(40, 100, 217, 0.12), rgba(40, 184, 167, 0.12) 48%, rgba(238, 101, 69, 0.1)),
    var(--paper);
}

button,
select,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
.mode-card:focus-visible,
.answer-choice:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid #f4b740;
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: 12px;
  transform: translateY(-140%);
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: var(--radius);
  z-index: 5;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0 26px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: var(--radius);
  color: white;
  background: linear-gradient(135deg, var(--blueprint), var(--aqua));
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(40, 100, 217, 0.24);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blueprint);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
  overflow-wrap: break-word;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.05rem, 2.3vw, 1.55rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 5vw, 4.85rem);
  line-height: 0.96;
  letter-spacing: 0;
  max-width: 900px;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.hero-screen {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  min-height: calc(100vh - 90px);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  width: min(820px, 100%);
  margin: 0 auto;
  padding: clamp(26px, 5vw, 64px) 0;
  text-align: center;
}

.creator-copy {
  width: min(980px, 100%);
}

.hero-copy > p:not(.eyebrow) {
  max-width: 720px;
  margin-inline: auto;
  color: var(--muted);
  font-size: clamp(1.02rem, 1.6vw, 1.2rem);
  line-height: 1.6;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
  margin-top: 24px;
}

.mode-card,
.graph-card,
.question-card,
.teacher-panel,
.results-screen,
.hero-board {
  border: 1px solid rgba(22, 32, 51, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.mode-card {
  min-height: 116px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 252, 255, 0.92));
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.mode-card:hover {
  transform: translateY(-2px);
  border-color: rgba(40, 100, 217, 0.36);
  box-shadow: 0 22px 56px rgba(22, 32, 51, 0.15);
}

.mode-card[aria-pressed="true"] {
  border-color: rgba(40, 100, 217, 0.65);
  background: linear-gradient(180deg, #eef5ff, #ffffff);
  box-shadow: 0 18px 42px rgba(40, 100, 217, 0.18);
}

.mode-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1rem;
}

.mode-card span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.hero-board {
  align-self: center;
  min-width: 0;
  min-height: 560px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff, #f6fbff);
}

.board-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-board svg {
  width: 100%;
  height: min(62vh, 500px);
  min-height: 430px;
  display: block;
}

.creator-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.55fr) 1fr;
  gap: 18px;
  align-items: stretch;
  margin: 24px 0 0;
}

.avatar-card,
.intro-screen,
.scene-card {
  border: 1px solid rgba(22, 32, 51, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.avatar-card {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 260px;
  padding: 20px;
}

.avatar-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.4;
}

.avatar-preview,
.hero-sprite {
  position: relative;
  width: 104px;
  height: 132px;
}

.avatar-aura {
  position: absolute;
  inset: 18px 0 auto;
  height: 88px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(40, 184, 167, 0.34), rgba(40, 184, 167, 0));
  filter: blur(2px);
}

.avatar-head {
  position: absolute;
  left: 34px;
  top: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffd7b5;
  border: 3px solid var(--ink);
  z-index: 2;
}

.avatar-body {
  position: absolute;
  left: 25px;
  top: 51px;
  width: 56px;
  height: 58px;
  border-radius: 14px 14px 8px 8px;
  background: var(--blueprint);
  border: 3px solid var(--ink);
  z-index: 2;
}

.avatar-legs {
  position: absolute;
  left: 33px;
  top: 102px;
  width: 40px;
  height: 22px;
  border-radius: 0 0 12px 12px;
  background: var(--ink);
  z-index: 1;
}

.avatar-power {
  position: absolute;
  right: 2px;
  top: 54px;
  width: 12px;
  height: 58px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: var(--glow);
  transform: rotate(28deg);
  z-index: 3;
}

.creator-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.choice-set {
  display: grid;
  gap: 8px;
  margin: 0;
  border: 0;
  padding: 0;
  text-align: left;
}

.choice-set legend {
  margin-bottom: 4px;
  color: var(--blueprint);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.choice-set label {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 8px;
  border: 1px solid rgba(22, 32, 51, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  padding: 10px 12px;
  cursor: pointer;
}

.choice-set label:has(input:checked) {
  border-color: rgba(40, 100, 217, 0.62);
  background: #eef5ff;
  color: var(--blueprint);
  font-weight: 900;
}

.begin-button {
  width: min(280px, 100%);
  margin: 22px auto 0;
}

.intro-screen {
  width: min(760px, 100%);
  margin: min(14vh, 120px) auto 0;
  padding: clamp(26px, 5vw, 48px);
  text-align: center;
}

.intro-screen h2 {
  margin-inline: auto;
  font-size: clamp(2.2rem, 6vw, 4.6rem);
}

.intro-screen p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.55;
}

.scene-card {
  overflow: hidden;
  padding: 16px;
}

.scene-topline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
}

.scene-topline h2 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1.05;
}

.power-chip {
  flex: 0 0 auto;
  border: 1px solid rgba(22, 32, 51, 0.12);
  border-radius: 999px;
  background: #f8fbff;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 900;
}

.side-scroller {
  position: relative;
  height: 210px;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, #cfeeff 0 52%, #c6ead9 52% 100%);
  border: 1px solid rgba(22, 32, 51, 0.1);
}

.scene-sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 26%, rgba(255, 255, 255, 0.92) 0 28px, transparent 30px),
    radial-gradient(circle at 78% 20%, rgba(255, 255, 255, 0.7) 0 18px, transparent 20px);
}

.scene-path {
  position: absolute;
  left: -4%;
  right: -4%;
  bottom: 0;
  height: 66px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.32) 25%, transparent 25%) 0 0 / 28px 28px,
    #6bbf8b;
  border-top: 5px solid #3d9468;
}

.hero-sprite {
  position: absolute;
  left: 12%;
  bottom: 38px;
  transform: scale(0.92);
  transform-origin: bottom center;
}

.enemy-sprite {
  position: absolute;
  right: 15%;
  bottom: 58px;
  width: 94px;
  height: 94px;
}

.enemy-core {
  position: absolute;
  inset: 10px;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), transparent),
    var(--coral);
  transform: rotate(10deg);
  box-shadow: 0 16px 28px rgba(238, 101, 69, 0.24);
}

.enemy-eye {
  position: absolute;
  left: 34px;
  top: 36px;
  width: 26px;
  height: 14px;
  border-radius: 999px;
  background: var(--ink);
}

.power-burst {
  position: absolute;
  left: 34%;
  top: 42%;
  width: 120px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--aqua), transparent);
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left center;
}

.scene-correct .hero-sprite {
  animation: hero-attack 700ms ease both;
}

.scene-correct .enemy-sprite {
  animation: enemy-defeat 700ms ease both;
}

.scene-correct .power-burst {
  animation: power-strike 700ms ease both;
}

.scene-wrong .hero-sprite {
  animation: hero-hit 620ms ease both;
}

.scene-wrong .enemy-sprite {
  animation: enemy-bump 620ms ease both;
}

.enemy-track {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.enemy-marker {
  display: grid;
  place-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #e8eef7;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.enemy-marker.current {
  background: #fff4db;
  color: #8a5a13;
  box-shadow: 0 0 0 2px rgba(217, 151, 37, 0.24);
}

.enemy-marker.defeated {
  background: var(--green);
  color: white;
}

@keyframes hero-attack {
  0%,
  100% {
    transform: translateX(0) scale(0.92);
  }
  45% {
    transform: translateX(54px) scale(0.96);
  }
}

@keyframes enemy-defeat {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0.25;
    transform: translateY(26px) rotate(12deg) scale(0.74);
  }
}

@keyframes power-strike {
  0% {
    opacity: 0;
    transform: scaleX(0);
  }
  25%,
  70% {
    opacity: 1;
    transform: scaleX(1);
  }
  100% {
    opacity: 0;
    transform: scaleX(1.1);
  }
}

@keyframes hero-hit {
  0%,
  100% {
    transform: translateX(0) rotate(0deg) scale(0.92);
  }
  45% {
    transform: translateX(-26px) rotate(-7deg) scale(0.9);
  }
}

@keyframes enemy-bump {
  0%,
  100% {
    transform: translateX(0);
  }
  45% {
    transform: translateX(-18px);
  }
}

.ghost-button,
.secondary-button,
.primary-button {
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid rgba(22, 32, 51, 0.16);
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
}

.ghost-button,
.secondary-button {
  background: var(--panel);
  color: var(--ink);
}

.primary-button {
  border-color: transparent;
  background: linear-gradient(135deg, var(--blueprint), var(--violet));
  color: white;
  box-shadow: 0 12px 28px rgba(40, 100, 217, 0.24);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.teacher-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.45fr) 1fr;
  gap: 24px;
  margin-bottom: 24px;
  padding: 22px;
}

.teacher-panel[hidden],
.play-screen[hidden],
.results-screen[hidden],
.hero-screen[hidden] {
  display: none;
}

.teacher-panel h2 {
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 1.08;
  margin-bottom: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 18px;
  align-items: start;
}

.field {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

select {
  width: 100%;
  min-height: 44px;
  border: 2px solid rgba(24, 32, 42, 0.22);
  border-radius: var(--radius);
  background: white;
  padding: 8px 10px;
}

.function-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.function-picker legend {
  grid-column: 1 / -1;
  margin-bottom: 8px;
  font-weight: 800;
}

.function-picker label {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
}

.play-screen {
  display: grid;
  gap: 18px;
}

.game-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.game-header h2 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.8rem);
  line-height: 1.05;
}

.score-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.score-strip span {
  min-height: 38px;
  padding: 8px 12px;
  border: 2px solid rgba(24, 32, 42, 0.14);
  border-radius: var(--radius);
  background: var(--panel);
  font-weight: 800;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.72fr);
  gap: 18px;
  align-items: start;
}

.play-screen.no-graph .game-layout {
  grid-template-columns: minmax(0, 720px);
  justify-content: center;
}

.graph-card,
.question-card {
  min-width: 0;
  padding: 18px;
}

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

.legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.swatch {
  display: inline-block;
  width: 22px;
  height: 4px;
  margin-right: 6px;
  vertical-align: middle;
}

.f-swatch {
  background: var(--blueprint);
}

.g-swatch {
  background: var(--coral);
}

.main-graph {
  display: block;
  width: 100%;
  aspect-ratio: 1.18 / 1;
  min-height: 360px;
}

.parent-label {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.equation-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.equation-stack div {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border: 1px solid rgba(22, 32, 51, 0.12);
  border-radius: var(--radius);
  background: #f8fbff;
  padding: 8px 10px;
}

.equation-stack span {
  color: var(--muted);
  font-weight: 800;
}

.equation-stack strong {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: clamp(0.95rem, 2vw, 1.08rem);
  overflow-wrap: anywhere;
}

.prompt {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.4;
}

.answers {
  display: grid;
  gap: 10px;
}

.answer-choice {
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(22, 32, 51, 0.14);
  border-radius: var(--radius);
  background: white;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.answer-choice[aria-pressed="true"] {
  border-color: var(--blueprint);
  background: #eef5ff;
}

.answer-choice.correct {
  border-color: var(--green);
  background: #eaf8f2;
}

.answer-choice.incorrect {
  border-color: var(--coral);
  background: #fff0ec;
}

.feedback {
  margin-top: 14px;
  border-left: 5px solid var(--gold);
  border-radius: var(--radius);
  background: #fff7df;
  padding: 12px;
  color: #4b3820;
  line-height: 1.45;
}

.feedback.success {
  border-color: var(--green);
  background: #eaf8f2;
  color: #174b3e;
}

.feedback.error {
  border-color: var(--coral);
  background: #fff0ec;
  color: #682719;
}

.action-row,
.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.results-screen {
  max-width: 720px;
  margin: 8vh auto 0;
  padding: clamp(24px, 5vw, 46px);
  text-align: center;
}

.results-screen h2 {
  margin-inline: auto;
  font-size: clamp(2.4rem, 7vw, 5rem);
}

.results-screen p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.55;
}

.results-actions {
  justify-content: center;
}

.axis-line {
  stroke: var(--axis);
  stroke-width: 1.5;
}

.grid-line {
  stroke: var(--grid);
  stroke-width: 1;
}

.tick-label {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.curve-f,
.curve-g {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.curve-f {
  stroke: var(--blueprint);
}

.curve-g {
  stroke: var(--coral);
}

.point-marker {
  fill: white;
  stroke-width: 3;
}

.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: 920px) {
  .hero-screen,
  .game-layout,
  .teacher-panel {
    grid-template-columns: 1fr;
  }

  .hero-screen {
    min-height: 0;
  }

  .creator-layout {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    padding-bottom: 0;
  }

  .hero-board {
    min-height: 0;
  }

  .hero-board svg {
    min-height: 320px;
    height: 360px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 921px) and (max-height: 820px) {
  .app-shell {
    padding-top: 24px;
    padding-bottom: 24px;
  }

  .play-screen {
    gap: 14px;
  }

  .scene-card {
    padding: 12px;
  }

  .scene-topline {
    margin-bottom: 8px;
  }

  .scene-topline h2 {
    font-size: 1.55rem;
  }

  .side-scroller {
    height: 158px;
  }

  .scene-path {
    height: 52px;
  }

  .hero-sprite {
    bottom: 24px;
    transform: scale(0.74);
  }

  .enemy-sprite {
    bottom: 35px;
    transform: scale(0.82);
    transform-origin: bottom center;
  }

  .enemy-track {
    margin-top: 10px;
  }

  .enemy-marker {
    min-height: 24px;
  }

  .game-header h2 {
    font-size: 2.15rem;
  }

  .graph-card,
  .question-card {
    padding: 16px;
  }

  .main-graph {
    min-height: 300px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: calc(100vw - 32px);
    max-width: 1180px;
    padding-top: 10px;
  }

  .topbar,
  .game-header,
  .graph-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 29px;
  }

  .mode-grid,
  .function-picker,
  .creator-options {
    grid-template-columns: 1fr;
  }

  .mode-card {
    min-height: 96px;
  }

  .score-strip {
    justify-content: flex-start;
  }

  .main-graph {
    min-height: 300px;
  }

  .question-card,
  .graph-card,
  .teacher-panel {
    padding: 14px;
  }

  .hero-copy h2 {
    font-size: 1.38rem;
    line-height: 1.04;
  }

  .hero-copy > p:not(.eyebrow) {
    font-size: 0.9rem;
    line-height: 1.55;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }
}

/* Game-stage pass: gameplay should read as a world first, with the math as the encounter UI. */
body.is-playing {
  height: 100vh;
  overflow: hidden;
  background: #17203a;
}

body.is-playing .app-shell {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  padding: 0;
}

body.is-playing main {
  min-height: 100vh;
}

.play-screen {
  min-height: 100vh;
}

.game-world {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: #17203a;
}

.game-world::before,
.game-world::after {
  position: absolute;
  inset: auto 0 0;
  content: "";
  pointer-events: none;
}

.game-world::before {
  height: 56%;
  background:
    linear-gradient(180deg, transparent 0 56%, rgba(255, 255, 255, 0.08) 57% 58%, transparent 59%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 92px);
  opacity: 0.55;
  z-index: 2;
}

.game-world::after {
  height: 34%;
  background:
    radial-gradient(ellipse at 18% 100%, rgba(45, 67, 74, 0.8) 0 19%, transparent 20%),
    radial-gradient(ellipse at 82% 100%, rgba(35, 57, 62, 0.72) 0 23%, transparent 24%);
  z-index: 1;
}

.side-scroller {
  position: absolute;
  inset: 0;
  height: auto;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, #8dd7ff 0%, #b7e7ff 28%, #d4f0d7 58%, #58734e 58.5%, #2e4c3e 100%);
}

.scene-sky {
  position: absolute;
  inset: 0 0 30%;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.75) 0 2px, transparent 3px),
    radial-gradient(circle at 68% 14%, rgba(255, 255, 255, 0.65) 0 2px, transparent 3px),
    radial-gradient(circle at 88% 25%, rgba(255, 255, 255, 0.55) 0 1px, transparent 2px),
    linear-gradient(180deg, rgba(36, 82, 143, 0.08), transparent 52%);
  z-index: 0;
}

.scene-sun {
  position: absolute;
  right: 10%;
  top: 7%;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff8c9 0 38%, rgba(255, 214, 108, 0.5) 39% 60%, transparent 62%);
  filter: drop-shadow(0 0 30px rgba(255, 221, 125, 0.7));
  z-index: 1;
}

.cloud {
  position: absolute;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow:
    24px -10px 0 8px rgba(255, 255, 255, 0.72),
    55px -3px 0 3px rgba(255, 255, 255, 0.68);
  z-index: 1;
}

.cloud-one {
  left: 8%;
  top: 13%;
  width: 86px;
}

.cloud-two {
  left: 58%;
  top: 18%;
  width: 112px;
  opacity: 0.64;
}

.mountain {
  position: absolute;
  left: -5%;
  right: -5%;
  bottom: 31%;
  height: 32%;
  clip-path: polygon(0 100%, 9% 58%, 17% 78%, 28% 36%, 40% 83%, 53% 42%, 65% 78%, 79% 30%, 92% 74%, 100% 48%, 100% 100%);
  z-index: 1;
}

.mountain-back {
  background: linear-gradient(180deg, #7ba6b4, #5e8d99);
  opacity: 0.58;
}

.mountain-mid {
  bottom: 25%;
  height: 27%;
  background: linear-gradient(180deg, #517e79, #3f685c);
  opacity: 0.82;
  transform: translateX(4%);
}

.ruin,
.tree {
  position: absolute;
  bottom: 30%;
  z-index: 2;
  opacity: 0.9;
}

.ruin {
  width: 96px;
  height: 122px;
  background:
    linear-gradient(90deg, transparent 0 17%, #6d7f82 18% 34%, transparent 35% 48%, #6d7f82 49% 66%, transparent 67%),
    linear-gradient(180deg, #91a2a5, #596e70);
  clip-path: polygon(8% 100%, 12% 22%, 28% 22%, 32% 0, 44% 0, 49% 22%, 68% 22%, 70% 8%, 84% 8%, 92% 100%);
}

.ruin-left {
  left: 5%;
}

.ruin-right {
  right: 7%;
  transform: scaleX(-1) scale(0.84);
  opacity: 0.55;
}

.tree {
  width: 70px;
  height: 142px;
}

.tree::before {
  position: absolute;
  left: 30px;
  bottom: 0;
  width: 12px;
  height: 78px;
  border-radius: 999px;
  background: #5a3f2f;
  content: "";
}

.tree::after {
  position: absolute;
  left: 2px;
  top: 0;
  width: 66px;
  height: 86px;
  border-radius: 52% 48% 45% 55%;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.18), transparent 20%),
    linear-gradient(135deg, #39a96f, #1d7759);
  box-shadow: 0 28px 0 -10px #2b8f62;
  content: "";
}

.tree-left {
  left: 19%;
}

.tree-right {
  right: 20%;
  transform: scale(0.78);
  opacity: 0.74;
}

.scene-path {
  position: absolute;
  left: -4%;
  right: -4%;
  bottom: 0;
  height: 178px;
  border-top: 8px solid #9ed06c;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 28%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.13) 0 18px, transparent 18px 54px),
    linear-gradient(180deg, #47764b, #253d36);
  box-shadow: inset 0 14px 0 rgba(43, 96, 62, 0.65);
  z-index: 4;
}

.path-trim {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 150px;
  height: 10px;
  background:
    repeating-linear-gradient(90deg, #d9c178 0 48px, #b89b55 48px 54px);
  box-shadow: 0 4px 0 rgba(50, 41, 31, 0.26);
  z-index: 5;
}

.scene-topline {
  position: absolute;
  left: max(24px, 5vw);
  right: max(24px, 5vw);
  top: 18px;
  z-index: 12;
  align-items: start;
  margin: 0;
  color: white;
  text-shadow: 0 2px 12px rgba(10, 20, 34, 0.35);
}

.scene-topline .eyebrow {
  color: #fff1b8;
}

.scene-topline h2 {
  max-width: 560px;
  font-size: clamp(1.25rem, 2vw, 1.85rem);
  line-height: 1.03;
}

.power-chip {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(18, 30, 54, 0.62);
  color: white;
  box-shadow: 0 12px 34px rgba(10, 20, 34, 0.2);
  backdrop-filter: blur(12px);
}

.encounter-panel {
  position: absolute;
  left: max(24px, 5vw);
  right: max(24px, 5vw);
  top: 88px;
  z-index: 10;
  display: grid;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 248, 255, 0.92));
  box-shadow:
    0 24px 60px rgba(16, 28, 50, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px);
}

.game-header h2 {
  font-size: clamp(1.35rem, 2.2vw, 2.15rem);
}

.game-layout {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.78fr);
  gap: 14px;
}

.play-screen.no-graph .game-layout {
  grid-template-columns: minmax(0, 780px);
}

.encounter-panel .graph-card,
.encounter-panel .question-card {
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
}

.graph-card {
  display: grid;
  min-height: 0;
}

.main-graph {
  min-height: 260px;
  max-height: 330px;
  border: 1px solid rgba(22, 32, 51, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.parent-label {
  margin-bottom: 8px;
}

.equation-stack {
  gap: 6px;
  margin-bottom: 10px;
}

.equation-stack div {
  min-height: 38px;
  background: rgba(255, 255, 255, 0.82);
}

.prompt {
  margin-bottom: 9px;
  font-size: 1rem;
}

.answers {
  gap: 8px;
}

.answer-choice {
  min-height: 46px;
  padding: 10px 12px;
  border-color: rgba(22, 32, 51, 0.16);
  background:
    linear-gradient(180deg, #ffffff, #f7f9fd);
  box-shadow: 0 2px 0 rgba(22, 32, 51, 0.08);
  font-weight: 650;
}

.answer-choice:hover:not(:disabled) {
  border-color: rgba(40, 100, 217, 0.44);
  transform: translateY(-1px);
}

.action-row {
  margin-top: 12px;
}

.feedback {
  margin-top: 10px;
  padding: 10px 12px;
}

.play-screen.answered .main-graph {
  min-height: 170px;
  max-height: 185px;
}

.play-screen.answered .answer-choice {
  min-height: 38px;
  padding: 7px 11px;
}

.play-screen.answered .equation-stack div {
  min-height: 34px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.play-screen.answered .feedback {
  max-height: 58px;
  overflow-y: auto;
}

.enemy-track {
  position: absolute;
  left: clamp(250px, 25vw, 360px);
  right: clamp(250px, 25vw, 360px);
  bottom: 14px;
  z-index: 11;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(18, 30, 54, 0.52);
  backdrop-filter: blur(12px);
}

.enemy-marker {
  min-height: 22px;
  background: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.78);
}

.enemy-marker.current {
  background: #fff0b4;
  color: #4f3511;
  box-shadow: 0 0 0 3px rgba(255, 240, 180, 0.22);
}

.enemy-marker.defeated {
  background: #34c38f;
}

.avatar-preview,
.hero-sprite {
  position: relative;
  width: 132px;
  height: 172px;
}

.avatar-card .avatar-preview {
  margin-top: 2px;
}

.avatar-aura {
  position: absolute;
  left: 5px;
  top: 22px;
  width: 122px;
  height: 122px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.65) 0 18%, rgba(76, 214, 187, 0.32) 19% 47%, transparent 65%);
  filter: blur(3px);
}

.avatar-cape {
  position: absolute;
  left: 30px;
  top: 60px;
  width: 74px;
  height: 82px;
  border-radius: 24px 18px 38px 32px;
  background: linear-gradient(145deg, #233451, #152038);
  transform: skewX(-8deg);
  z-index: 1;
}

.avatar-head {
  left: 46px;
  top: 20px;
  width: 42px;
  height: 44px;
  border: 3px solid #101828;
  border-radius: 46% 46% 48% 48%;
  background:
    radial-gradient(circle at 34% 34%, #ffe8d1 0 14%, transparent 15%),
    linear-gradient(180deg, #ffd9b8, #f1b584);
  box-shadow: inset -5px -6px 0 rgba(138, 78, 48, 0.12);
  z-index: 5;
}

.avatar-hair {
  position: absolute;
  left: 42px;
  top: 15px;
  width: 52px;
  height: 28px;
  border: 3px solid #101828;
  border-bottom: 0;
  border-radius: 24px 24px 8px 8px;
  background: #493027;
  z-index: 6;
}

.avatar-face {
  position: absolute;
  left: 56px;
  top: 40px;
  width: 22px;
  height: 8px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 4px 3px, #101828 0 2px, transparent 3px),
    radial-gradient(circle at 18px 3px, #101828 0 2px, transparent 3px);
  z-index: 7;
}

.avatar-body {
  left: 36px;
  top: 67px;
  width: 64px;
  height: 66px;
  border: 3px solid #101828;
  border-radius: 18px 18px 10px 10px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent 34%),
    linear-gradient(180deg, #397cff, #2552bf);
  box-shadow: inset -7px -8px 0 rgba(18, 34, 76, 0.18);
  z-index: 4;
}

.avatar-belt {
  position: absolute;
  left: 36px;
  top: 113px;
  width: 64px;
  height: 12px;
  border: 3px solid #101828;
  border-left-width: 0;
  border-right-width: 0;
  background:
    linear-gradient(90deg, #192236 0 42%, #f2bf53 43% 58%, #192236 59%);
  z-index: 7;
}

.avatar-arm {
  position: absolute;
  top: 75px;
  width: 18px;
  height: 58px;
  border: 3px solid #101828;
  border-radius: 999px;
  background: linear-gradient(180deg, #2f6df0, #183f9e);
  z-index: 3;
}

.avatar-arm-back {
  left: 25px;
  transform: rotate(11deg);
}

.avatar-arm-front {
  right: 24px;
  transform: rotate(-14deg);
  z-index: 8;
}

.avatar-legs {
  left: 42px;
  top: 126px;
  width: 54px;
  height: 28px;
  border-radius: 0 0 15px 15px;
  background:
    linear-gradient(90deg, #101828 0 44%, transparent 45% 55%, #101828 56%);
  z-index: 3;
}

.avatar-boot {
  position: absolute;
  top: 149px;
  width: 30px;
  height: 16px;
  border: 3px solid #101828;
  border-radius: 9px 9px 8px 8px;
  background: #253047;
  z-index: 6;
}

.avatar-boot-left {
  left: 35px;
}

.avatar-boot-right {
  left: 74px;
}

.avatar-power {
  right: 9px;
  top: 76px;
  width: 14px;
  height: 70px;
  border: 3px solid #101828;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.3), transparent 45%),
    linear-gradient(180deg, #ffe066, #df8b23);
  box-shadow: 0 0 26px rgba(255, 204, 79, 0.55);
  transform: rotate(28deg);
  z-index: 9;
}

.hero-sprite {
  --hero-scale: 0.95;
  position: absolute;
  left: 10%;
  bottom: 74px;
  z-index: 8;
  transform: scale(var(--hero-scale));
  transform-origin: bottom center;
  filter: drop-shadow(0 18px 18px rgba(8, 19, 30, 0.28));
}

.enemy-sprite {
  --enemy-scale: 1;
  position: absolute;
  right: 12%;
  bottom: 106px;
  width: 148px;
  height: 148px;
  z-index: 8;
  transform: scale(var(--enemy-scale));
  transform-origin: bottom center;
  filter: drop-shadow(0 22px 22px rgba(8, 19, 30, 0.26));
}

.enemy-shadow {
  position: absolute;
  left: 25px;
  right: 20px;
  bottom: -20px;
  height: 18px;
  border-radius: 50%;
  background: rgba(7, 17, 26, 0.26);
}

.enemy-shard {
  position: absolute;
  border: 3px solid #101828;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), transparent),
    #ff8a58;
  clip-path: polygon(50% 0, 100% 76%, 55% 100%, 0 72%);
  z-index: 1;
}

.enemy-shard-a {
  left: 18px;
  top: 8px;
  width: 30px;
  height: 48px;
  transform: rotate(-24deg);
}

.enemy-shard-b {
  right: 18px;
  top: 18px;
  width: 28px;
  height: 42px;
  transform: rotate(28deg);
}

.enemy-shard-c {
  left: 60px;
  bottom: 6px;
  width: 34px;
  height: 42px;
  transform: rotate(180deg);
}

.enemy-core {
  position: absolute;
  inset: 26px 22px 22px 22px;
  border: 4px solid #101828;
  border-radius: 31% 42% 35% 44%;
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.5) 0 10%, transparent 11%),
    linear-gradient(135deg, #ff9f6a 0%, #f35f4f 52%, #c93262 100%);
  box-shadow:
    inset -13px -15px 0 rgba(90, 21, 55, 0.22),
    0 0 0 8px rgba(255, 105, 86, 0.12);
  transform: rotate(10deg);
  z-index: 2;
}

.enemy-eye {
  left: 57px;
  top: 60px;
  width: 36px;
  height: 18px;
  border: 3px solid #101828;
  border-radius: 999px;
  background:
    radial-gradient(circle at 72% 45%, #fff 0 2px, transparent 3px),
    #101828;
  z-index: 3;
}

.enemy-mouth {
  position: absolute;
  left: 61px;
  top: 85px;
  width: 24px;
  height: 6px;
  border-radius: 999px;
  background: #101828;
  transform: rotate(8deg);
  z-index: 3;
}

.enemy-rune {
  position: absolute;
  width: 20px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 236, 153, 0.95);
  box-shadow: 0 0 10px rgba(255, 236, 153, 0.75);
  z-index: 4;
}

.enemy-rune-a {
  right: 41px;
  top: 43px;
  transform: rotate(22deg);
}

.enemy-rune-b {
  left: 43px;
  bottom: 44px;
  transform: rotate(-28deg);
}

.power-burst {
  left: 28%;
  top: auto;
  bottom: 182px;
  width: 36%;
  height: 22px;
  background:
    radial-gradient(circle at 96% 50%, rgba(255, 255, 255, 0.95) 0 8px, transparent 9px),
    linear-gradient(90deg, transparent, #ffe066, #5eead4, transparent);
  filter: drop-shadow(0 0 12px rgba(255, 224, 102, 0.75));
  z-index: 9;
}

.scene-correct .hero-sprite {
  animation: hero-attack-detailed 720ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.scene-correct .enemy-sprite {
  animation: enemy-defeat-detailed 720ms ease both;
}

.scene-wrong .hero-sprite {
  animation: hero-hit-detailed 620ms ease both;
}

.scene-wrong .enemy-sprite {
  animation: enemy-bump-detailed 620ms ease both;
}

@keyframes hero-attack-detailed {
  0%,
  100% {
    transform: translateX(0) translateY(0) scale(var(--hero-scale));
  }
  42% {
    transform: translateX(120px) translateY(-8px) scale(var(--hero-scale));
  }
}

@keyframes enemy-defeat-detailed {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(var(--enemy-scale));
  }
  100% {
    opacity: 0.18;
    transform: translateY(38px) rotate(18deg) scale(var(--enemy-scale)) scale(0.62);
  }
}

@keyframes hero-hit-detailed {
  0%,
  100% {
    transform: translateX(0) rotate(0deg) scale(var(--hero-scale));
  }
  45% {
    transform: translateX(-48px) rotate(-8deg) scale(var(--hero-scale));
  }
}

@keyframes enemy-bump-detailed {
  0%,
  100% {
    transform: translateX(0) translateY(0) scale(var(--enemy-scale));
  }
  45% {
    transform: translateX(-32px) translateY(-6px) scale(var(--enemy-scale));
  }
}

@media (max-width: 1180px), (max-height: 820px) {
  .scene-topline {
    left: 24px;
    right: 24px;
    top: 14px;
  }

  .encounter-panel {
    left: 24px;
    right: 24px;
    top: 78px;
    padding: 12px;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 0.82fr);
  }

  .main-graph {
    min-height: 225px;
    max-height: 270px;
  }

  .answer-choice {
    min-height: 42px;
    padding: 9px 11px;
  }

  .scene-path {
    height: 146px;
  }

  .path-trim {
    bottom: 126px;
  }

  .hero-sprite {
    --hero-scale: 0.72;
    bottom: 24px;
  }

  .enemy-sprite {
    --enemy-scale: 0.74;
    bottom: 42px;
  }

  .power-burst {
    bottom: 150px;
  }
}

/* Rendered-asset pass: use real game art instead of CSS shape sprites. */
.creator-layout {
  grid-template-columns: minmax(260px, 0.48fr) 1fr;
}

.creator-options {
  align-content: stretch;
  grid-template-columns: 1fr;
}

.creator-options .choice-set {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.creator-options .choice-set legend {
  grid-column: 1 / -1;
}

.creator-options .choice-set label {
  position: relative;
  min-height: 106px;
  align-items: end;
  overflow: hidden;
  padding: 12px 14px;
}

.creator-options .choice-set label::before {
  position: absolute;
  right: 8px;
  bottom: 0;
  width: 72px;
  height: 98px;
  background: center bottom / contain no-repeat;
  content: "";
  filter: drop-shadow(0 10px 10px rgba(22, 32, 51, 0.18));
}

img.avatar-preview {
  display: block;
  width: auto;
  height: 360px;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 22px 24px rgba(22, 32, 51, 0.15));
}

.side-scroller {
  background: url("assets/quest-background.png") center / cover no-repeat;
}

.scene-sky,
.scene-sun,
.cloud,
.mountain,
.ruin,
.tree,
.scene-path,
.path-trim {
  display: none;
}

.encounter-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-18px) scale(0.985);
  transition:
    opacity 260ms ease,
    transform 260ms ease;
}

.play-screen.encounter-active .encounter-panel,
.play-screen.answered .encounter-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.hero-sprite {
  --hero-scale: 1;
  left: 8%;
  bottom: 52px;
  width: 178px;
  height: 320px;
  background: none;
  transform: translateX(0) scale(var(--hero-scale));
}

.enemy-sprite {
  --enemy-scale: 1;
  right: 12%;
  bottom: 82px;
  width: 174px;
  height: 228px;
  background: none;
  transform: scale(var(--enemy-scale));
  transform-origin: bottom center;
}

.hero-sprite img,
.enemy-sprite img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  user-select: none;
  pointer-events: none;
}

.power-burst {
  bottom: 244px;
  height: 32px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 98% 50%, rgba(255, 255, 255, 0.98) 0 11px, transparent 12px),
    linear-gradient(90deg, transparent, rgba(255, 221, 98, 0.95), rgba(115, 214, 255, 0.9), transparent);
  mix-blend-mode: screen;
}

.play-screen.approaching .hero-sprite {
  animation: hero-walk-in 1250ms ease-out both;
}

.play-screen.approaching .enemy-sprite,
.play-screen.resolving .enemy-sprite {
  animation: enemy-idle 900ms ease-in-out infinite alternate;
}

.scene-correct .hero-sprite {
  animation: hero-asset-attack 1000ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.scene-correct .enemy-sprite {
  animation: enemy-asset-defeat 1050ms ease both;
}

.scene-wrong .hero-sprite {
  animation: hero-asset-hit 900ms ease both;
}

.scene-wrong .enemy-sprite {
  animation: enemy-asset-bump 900ms ease both;
}

@keyframes hero-walk-in {
  0% {
    transform: translateX(-130px) translateY(0) scale(var(--hero-scale));
  }
  35% {
    transform: translateX(-72px) translateY(-5px) scale(var(--hero-scale));
  }
  70% {
    transform: translateX(-24px) translateY(0) scale(var(--hero-scale));
  }
  100% {
    transform: translateX(0) translateY(-3px) scale(var(--hero-scale));
  }
}

@keyframes hero-asset-attack {
  0%,
  100% {
    transform: translateX(0) translateY(0) scale(var(--hero-scale));
  }
  42% {
    transform: translateX(170px) translateY(-18px) scale(var(--hero-scale));
  }
}

@keyframes hero-asset-hit {
  0%,
  100% {
    transform: translateX(0) rotate(0deg) scale(var(--hero-scale));
  }
  45% {
    transform: translateX(-70px) rotate(-5deg) scale(var(--hero-scale));
  }
}

@keyframes enemy-idle {
  from {
    transform: translateY(0) scale(var(--enemy-scale));
  }
  to {
    transform: translateY(-10px) scale(var(--enemy-scale));
  }
}

@keyframes enemy-asset-defeat {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(var(--enemy-scale));
    filter: drop-shadow(0 22px 22px rgba(8, 19, 30, 0.26));
  }
  100% {
    opacity: 0;
    transform: translateY(34px) rotate(10deg) scale(var(--enemy-scale)) scale(0.62);
    filter: drop-shadow(0 0 34px rgba(255, 217, 93, 0.8));
  }
}

@keyframes enemy-asset-bump {
  0%,
  100% {
    transform: translateX(0) translateY(0) scale(var(--enemy-scale));
  }
  45% {
    transform: translateX(-44px) translateY(-12px) scale(var(--enemy-scale));
  }
}

@media (max-width: 1180px), (max-height: 820px) {
  .hero-sprite {
    --hero-scale: 0.74;
    left: 8%;
    bottom: 16px;
  }

  .enemy-sprite {
    --enemy-scale: 0.72;
    right: 10%;
    bottom: 50px;
  }

  .power-burst {
    bottom: 194px;
  }

  .enemy-track {
    left: clamp(270px, 27vw, 380px);
    right: clamp(270px, 27vw, 380px);
  }
}

@media (max-width: 920px) {
  .creator-options .choice-set {
    grid-template-columns: 1fr;
  }

  img.avatar-preview {
    height: 300px;
  }
}

/* Character customization pass: fixed gear with model, skin, and hair choices. */
.creator-options {
  gap: 14px;
}

.creator-options .model-set {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.creator-options .swatch-set {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.model-set legend,
.swatch-set legend {
  grid-column: 1 / -1;
}

.creator-options .model-set label {
  min-height: 138px;
  padding: 12px 14px;
}

.creator-options .model-set label::before {
  width: 92px;
  height: 128px;
}

.creator-options .model-set label:has(input[value="boy"])::before {
  background-image: url("assets/hero-boy-light-blonde.png");
}

.creator-options .model-set label:has(input[value="girl"])::before {
  background-image: url("assets/hero-girl-light-blonde.png");
}

.creator-options .swatch-set label {
  min-height: 56px;
  align-items: center;
  padding: 10px 12px 10px 42px;
}

.creator-options .swatch-set label::before {
  display: none;
}

.creator-options .swatch-set label::after {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(22, 32, 51, 0.16);
  border-radius: 50%;
  content: "";
  transform: translateY(-50%);
  box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.38);
}

.skin-set label:has(input[value="light"])::after {
  background: #f0c29a;
}

.skin-set label:has(input[value="medium"])::after {
  background: #bf7b4f;
}

.skin-set label:has(input[value="deep"])::after {
  background: #70452f;
}

.hair-set label:has(input[value="blonde"])::after {
  background: #e8b84f;
}

.hair-set label:has(input[value="brown"])::after {
  background: #764224;
}

.hair-set label:has(input[value="black"])::after {
  background: #262529;
}

/* Animation polish: give students a visible approach, impact, and recovery beat. */
.play-screen.approaching .side-scroller {
  animation: world-drift 2200ms ease-out both;
}

.play-screen.approaching .hero-sprite {
  animation: hero-walk-in-polished 2200ms ease-out both;
}

.play-screen.approaching .enemy-sprite {
  animation: enemy-hover-polished 1200ms ease-in-out infinite alternate;
}

.play-screen.resolving .encounter-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-20px) scale(0.98);
}

.scene-correct .hero-sprite {
  animation: hero-sword-strike 2300ms cubic-bezier(0.17, 0.84, 0.32, 1) both;
}

.scene-correct .enemy-sprite {
  animation: enemy-crystal-break 2350ms ease both;
}

.scene-correct .power-burst {
  animation: sword-arc 1200ms 420ms ease-out both;
}

.scene-wrong .hero-sprite {
  animation: hero-stagger-polished 1900ms ease both;
}

.scene-wrong .enemy-sprite {
  animation: enemy-counter-polished 1900ms ease both;
}

.scene-wrong .power-burst {
  animation: enemy-pulse 850ms 260ms ease-out both;
}

@keyframes world-drift {
  0% {
    background-position: 46% center;
    filter: saturate(1.02);
  }
  100% {
    background-position: 50% center;
    filter: saturate(1.08);
  }
}

@keyframes hero-walk-in-polished {
  0% {
    transform: translateX(-170px) translateY(0) scale(var(--hero-scale));
  }
  18% {
    transform: translateX(-132px) translateY(-7px) scale(var(--hero-scale));
  }
  36% {
    transform: translateX(-92px) translateY(0) scale(var(--hero-scale));
  }
  56% {
    transform: translateX(-52px) translateY(-6px) scale(var(--hero-scale));
  }
  78% {
    transform: translateX(-18px) translateY(0) scale(var(--hero-scale));
  }
  100% {
    transform: translateX(0) translateY(-2px) scale(var(--hero-scale));
  }
}

@keyframes enemy-hover-polished {
  from {
    transform: translateY(0) rotate(-1deg) scale(var(--enemy-scale));
  }
  to {
    transform: translateY(-12px) rotate(2deg) scale(var(--enemy-scale));
  }
}

@keyframes hero-sword-strike {
  0% {
    transform: translateX(0) translateY(0) scale(var(--hero-scale));
  }
  16% {
    transform: translateX(18px) translateY(4px) scale(var(--hero-scale));
  }
  38% {
    transform: translateX(260px) translateY(-20px) scale(var(--hero-scale));
  }
  52% {
    transform: translateX(292px) translateY(-12px) scale(var(--hero-scale));
  }
  72% {
    transform: translateX(170px) translateY(0) scale(var(--hero-scale));
  }
  100% {
    transform: translateX(78px) translateY(0) scale(var(--hero-scale));
  }
}

@keyframes enemy-crystal-break {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(var(--enemy-scale));
    filter: drop-shadow(0 22px 22px rgba(8, 19, 30, 0.26));
  }
  36% {
    opacity: 1;
    transform: translateY(-14px) rotate(-3deg) scale(var(--enemy-scale)) scale(1.08);
    filter: drop-shadow(0 0 32px rgba(255, 232, 117, 0.85));
  }
  60% {
    opacity: 0.68;
    transform: translateY(8px) rotate(8deg) scale(var(--enemy-scale)) scale(0.88);
  }
  100% {
    opacity: 0;
    transform: translateY(64px) rotate(16deg) scale(var(--enemy-scale)) scale(0.38);
    filter: drop-shadow(0 0 44px rgba(255, 232, 117, 0.9));
  }
}

@keyframes sword-arc {
  0% {
    opacity: 0;
    transform: translateX(-90px) rotate(-8deg) scaleX(0);
  }
  28% {
    opacity: 1;
    transform: translateX(20px) rotate(-8deg) scaleX(0.72);
  }
  74% {
    opacity: 1;
    transform: translateX(160px) rotate(-8deg) scaleX(1.05);
  }
  100% {
    opacity: 0;
    transform: translateX(210px) rotate(-8deg) scaleX(1.15);
  }
}

@keyframes hero-stagger-polished {
  0%,
  100% {
    transform: translateX(0) translateY(0) rotate(0deg) scale(var(--hero-scale));
  }
  28% {
    transform: translateX(-82px) translateY(8px) rotate(-6deg) scale(var(--hero-scale));
  }
  55% {
    transform: translateX(-46px) translateY(0) rotate(3deg) scale(var(--hero-scale));
  }
  78% {
    transform: translateX(-12px) translateY(-4px) rotate(0deg) scale(var(--hero-scale));
  }
}

@keyframes enemy-counter-polished {
  0%,
  100% {
    transform: translateX(0) translateY(0) rotate(0deg) scale(var(--enemy-scale));
  }
  28% {
    transform: translateX(-82px) translateY(-20px) rotate(-5deg) scale(var(--enemy-scale)) scale(1.08);
  }
  55% {
    transform: translateX(-34px) translateY(-6px) rotate(3deg) scale(var(--enemy-scale));
  }
}

@keyframes enemy-pulse {
  0% {
    opacity: 0;
    transform: translateX(260px) rotate(180deg) scaleX(0);
  }
  45% {
    opacity: 0.9;
    transform: translateX(40px) rotate(180deg) scaleX(0.88);
  }
  100% {
    opacity: 0;
    transform: translateX(-80px) rotate(180deg) scaleX(1.1);
  }
}

/* Chromebook stage polish: keep the challenge above the action, not covering it. */
.encounter-panel {
  top: clamp(58px, 8vh, 74px);
  gap: 10px;
  max-height: min(42vh, 342px);
  padding: 12px 14px;
  overflow: hidden;
}

.encounter-panel .game-header {
  align-items: center;
}

.encounter-panel .game-header h2 {
  font-size: clamp(1.02rem, 1.55vw, 1.42rem);
  line-height: 1.08;
}

.encounter-panel .eyebrow {
  margin-bottom: 3px;
  font-size: 0.68rem;
}

.encounter-panel .score-strip span {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 0.82rem;
}

.encounter-panel .game-layout {
  grid-template-columns: minmax(0, 0.96fr) minmax(342px, 0.8fr);
  gap: 12px;
  align-items: stretch;
}

.encounter-panel .graph-heading {
  margin-bottom: 6px;
}

.encounter-panel .graph-heading h3 {
  font-size: 0.88rem;
}

.encounter-panel .legend {
  font-size: 0.76rem;
}

.encounter-panel .main-graph {
  height: min(27vh, 218px);
  min-height: 186px;
  max-height: 218px;
}

.encounter-panel .parent-label {
  margin-bottom: 5px;
  font-size: 0.78rem;
}

.encounter-panel .equation-stack {
  gap: 5px;
  margin-bottom: 7px;
}

.encounter-panel .equation-stack div {
  min-height: 32px;
  padding: 5px 8px;
}

.encounter-panel .equation-stack span {
  font-size: 0.78rem;
}

.encounter-panel .equation-stack strong {
  font-size: 0.88rem;
}

.encounter-panel .prompt {
  margin-bottom: 7px;
  font-size: 0.9rem;
  line-height: 1.26;
}

.encounter-panel .answers {
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.encounter-panel .answer-choice {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.86rem;
  line-height: 1.22;
}

.encounter-panel .feedback {
  max-height: 58px;
  margin-top: 7px;
  padding: 8px 10px;
  overflow-y: auto;
  font-size: 0.84rem;
}

.encounter-panel .action-row {
  margin-top: 8px;
}

.encounter-panel .primary-button,
.encounter-panel .secondary-button {
  min-height: 34px;
  padding: 8px 12px;
  font-size: 0.84rem;
}

.hero-sprite::before,
.hero-sprite::after,
.enemy-sprite::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.hero-sprite::after,
.enemy-sprite::after {
  left: 14%;
  right: 14%;
  bottom: 5px;
  height: 28px;
  border-radius: 50%;
  background: rgba(16, 25, 29, 0.2);
  filter: blur(10px);
  transform: scaleX(1.05);
  z-index: 0;
}

.hero-sprite::before {
  left: -22px;
  bottom: 42px;
  width: 80px;
  height: 24px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 16% 62%, rgba(229, 216, 178, 0.72) 0 7px, transparent 8px),
    radial-gradient(circle at 44% 48%, rgba(229, 216, 178, 0.56) 0 5px, transparent 6px),
    radial-gradient(circle at 72% 64%, rgba(229, 216, 178, 0.48) 0 6px, transparent 7px);
  opacity: 0;
  z-index: 0;
}

.hero-sprite img,
.enemy-sprite img {
  position: relative;
  z-index: 1;
}

.play-screen.approaching .hero-sprite::before {
  animation: walk-dust 2200ms ease-out both;
}

.scene-correct .side-scroller {
  animation: victory-camera 2600ms ease-out both;
}

.scene-wrong .side-scroller {
  animation: hit-camera 2200ms ease both;
}

.scene-correct .hero-sprite::before {
  animation: landing-dust 1100ms 620ms ease-out both;
}

.scene-correct .enemy-sprite::after {
  animation: shadow-pop 2350ms ease both;
}

@keyframes walk-dust {
  0%,
  14% {
    opacity: 0;
    transform: translateX(-28px) scale(0.55);
  }
  30%,
  56% {
    opacity: 0.7;
    transform: translateX(-8px) scale(0.95);
  }
  78% {
    opacity: 0.38;
    transform: translateX(12px) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translateX(30px) scale(1.18);
  }
}

@keyframes landing-dust {
  0% {
    opacity: 0;
    transform: translateX(190px) scale(0.5);
  }
  36% {
    opacity: 0.78;
    transform: translateX(232px) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateX(286px) scale(1.7);
  }
}

@keyframes victory-camera {
  0%,
  100% {
    filter: saturate(1.08) brightness(1);
  }
  46% {
    filter: saturate(1.18) brightness(1.04);
  }
}

@keyframes hit-camera {
  0%,
  100% {
    transform: translateX(0);
    filter: saturate(1.06);
  }
  16% {
    transform: translateX(-7px);
  }
  29% {
    transform: translateX(6px);
    filter: saturate(0.92);
  }
  42% {
    transform: translateX(-3px);
  }
}

@keyframes shadow-pop {
  0% {
    opacity: 1;
    transform: scaleX(1.05);
  }
  52% {
    opacity: 0.62;
    transform: scaleX(0.7);
  }
  100% {
    opacity: 0;
    transform: scaleX(0.3);
  }
}

/* Rigged hero pass: layered image masks create legs, stance, and a real sword swing. */
.hero-sprite {
  --hero-url: url("assets/hero-boy-light-blonde.png");
  bottom: 112px;
  isolation: isolate;
  will-change: transform;
}

.enemy-sprite {
  bottom: 132px;
}

.power-burst {
  bottom: 316px;
}

.hero-source {
  display: none !important;
}

.hero-part {
  position: absolute;
  inset: 0;
  background: var(--hero-url) center bottom / contain no-repeat;
  pointer-events: none;
  will-change: transform;
}

.hero-body {
  z-index: 3;
  clip-path: inset(0 0 31% 0);
  transform-origin: 50% 62%;
}

.hero-left-leg {
  z-index: 2;
  clip-path: polygon(27% 54%, 50% 54%, 53% 100%, 26% 100%, 22% 80%);
  transform-origin: 42% 60%;
}

.hero-right-leg {
  z-index: 2;
  clip-path: polygon(48% 54%, 72% 54%, 76% 100%, 48% 100%, 45% 80%);
  transform-origin: 58% 60%;
}

.hero-sword-swing {
  position: absolute;
  left: 82px;
  top: 142px;
  z-index: 5;
  width: 138px;
  height: 14px;
  border: 1px solid rgba(93, 67, 28, 0.38);
  border-radius: 999px;
  background:
    linear-gradient(90deg, #7b5028 0 10px, #fff5be 11px 18px, #d8efff 19px 78%, rgba(255, 255, 255, 0.92));
  box-shadow:
    0 0 14px rgba(255, 244, 184, 0.72),
    0 5px 9px rgba(12, 20, 32, 0.16);
  opacity: 0;
  transform: rotate(-28deg) scaleX(0.78);
  transform-origin: 10px 50%;
  pointer-events: none;
  will-change: transform, opacity;
}

.hero-sword-swing::after {
  position: absolute;
  right: -12px;
  top: 1px;
  width: 16px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  content: "";
  filter: blur(2px);
}

.play-screen.approaching .hero-body {
  animation: rig-body-walk 520ms ease-in-out infinite;
}

.play-screen.approaching .hero-left-leg {
  animation: rig-leg-left 520ms ease-in-out infinite;
}

.play-screen.approaching .hero-right-leg {
  animation: rig-leg-right 520ms ease-in-out infinite;
}

.play-screen.encounter-active .hero-body,
.play-screen.answered .hero-body {
  animation: rig-fighting-stance 1050ms ease-in-out infinite alternate;
}

.play-screen.encounter-active .hero-left-leg,
.play-screen.answered .hero-left-leg {
  transform: translateX(-4px) rotate(-4deg);
}

.play-screen.encounter-active .hero-right-leg,
.play-screen.answered .hero-right-leg {
  transform: translateX(5px) rotate(5deg);
}

.play-screen.encounter-active .hero-sword-swing,
.play-screen.answered .hero-sword-swing {
  opacity: 0.72;
  transform: rotate(-34deg) scaleX(0.82);
}

.scene-correct .hero-body {
  animation: rig-attack-body 2300ms cubic-bezier(0.17, 0.84, 0.32, 1) both;
}

.scene-correct .hero-left-leg {
  animation: rig-attack-left-leg 2300ms ease both;
}

.scene-correct .hero-right-leg {
  animation: rig-attack-right-leg 2300ms ease both;
}

.scene-correct .hero-sword-swing {
  animation: rig-sword-slash 1500ms 260ms cubic-bezier(0.16, 0.86, 0.22, 1) both;
}

.scene-wrong .hero-body {
  animation: rig-hit-body 1900ms ease both;
}

.scene-wrong .hero-left-leg {
  animation: rig-hit-left-leg 1900ms ease both;
}

.scene-wrong .hero-right-leg {
  animation: rig-hit-right-leg 1900ms ease both;
}

@keyframes rig-body-walk {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-5px) rotate(-1.2deg);
  }
}

@keyframes rig-leg-left {
  0%,
  100% {
    transform: translateX(-4px) rotate(-13deg);
  }
  50% {
    transform: translateX(7px) rotate(14deg);
  }
}

@keyframes rig-leg-right {
  0%,
  100% {
    transform: translateX(7px) rotate(13deg);
  }
  50% {
    transform: translateX(-5px) rotate(-14deg);
  }
}

@keyframes rig-fighting-stance {
  0% {
    transform: translateY(0) rotate(-1.6deg);
  }
  100% {
    transform: translateY(-4px) rotate(1deg);
  }
}

@keyframes rig-attack-body {
  0% {
    transform: translateY(0) rotate(-2deg);
  }
  24% {
    transform: translateY(5px) rotate(-7deg);
  }
  42% {
    transform: translateY(-12px) rotate(9deg);
  }
  70% {
    transform: translateY(-4px) rotate(4deg);
  }
  100% {
    transform: translateY(0) rotate(0deg);
  }
}

@keyframes rig-attack-left-leg {
  0% {
    transform: translateX(-5px) rotate(-7deg);
  }
  36% {
    transform: translateX(10px) rotate(18deg);
  }
  100% {
    transform: translateX(3px) rotate(4deg);
  }
}

@keyframes rig-attack-right-leg {
  0% {
    transform: translateX(6px) rotate(8deg);
  }
  36% {
    transform: translateX(-10px) rotate(-17deg);
  }
  100% {
    transform: translateX(2px) rotate(3deg);
  }
}

@keyframes rig-sword-slash {
  0% {
    opacity: 0.84;
    transform: translateX(-8px) translateY(8px) rotate(-72deg) scaleX(0.76);
  }
  34% {
    opacity: 1;
    transform: translateX(34px) translateY(-12px) rotate(-18deg) scaleX(1.06);
  }
  58% {
    opacity: 0.95;
    transform: translateX(72px) translateY(10px) rotate(28deg) scaleX(1.12);
  }
  100% {
    opacity: 0;
    transform: translateX(112px) translateY(18px) rotate(42deg) scaleX(0.9);
  }
}

@keyframes rig-hit-body {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  28% {
    transform: translateY(8px) rotate(-8deg);
  }
  58% {
    transform: translateY(-3px) rotate(4deg);
  }
}

@keyframes rig-hit-left-leg {
  0%,
  100% {
    transform: translateX(-4px) rotate(-4deg);
  }
  28% {
    transform: translateX(-14px) rotate(-18deg);
  }
}

@keyframes rig-hit-right-leg {
  0%,
  100% {
    transform: translateX(5px) rotate(5deg);
  }
  28% {
    transform: translateX(12px) rotate(18deg);
  }
}

.stage-enhanced .play-screen.approaching .side-scroller,
.stage-enhanced .scene-correct .side-scroller,
.stage-enhanced .scene-wrong .side-scroller,
.stage-enhanced .play-screen.approaching .hero-sprite,
.stage-enhanced .scene-correct .hero-sprite,
.stage-enhanced .scene-wrong .hero-sprite,
.stage-enhanced .play-screen.approaching .enemy-sprite,
.stage-enhanced .play-screen.resolving .enemy-sprite,
.stage-enhanced .scene-correct .enemy-sprite,
.stage-enhanced .scene-wrong .enemy-sprite,
.stage-enhanced .scene-correct .power-burst,
.stage-enhanced .scene-wrong .power-burst {
  animation: none;
}

/* Retro trial pass: intentional pixel art avoids fake joints on rendered portraits. */
.stage-pixel .avatar-preview,
.stage-pixel .hero-part,
.stage-pixel .hero-sword-swing,
.stage-pixel .hero-source {
  display: none !important;
}

.stage-pixel .side-scroller {
  background: url("assets/quest-background-pixel.png") center / cover no-repeat;
  image-rendering: auto;
}

.pixel-hero {
  --skin-color: #f0b989;
  --hair-color: #e8bd4b;
  --jacket-color: #23406f;
  --shirt-color: #f5e9cc;
  --pants-color: #a57645;
  --boot-color: #4a2e22;
  --outline-color: #151925;
  position: relative;
  width: 96px;
  height: 150px;
  image-rendering: pixelated;
  transform-origin: 50% 100%;
}

.avatar-pixel {
  width: 170px;
  height: 245px;
  transform: scale(1.35);
}

.stage-pixel-hero {
  position: absolute;
  inset: 0;
}

.pixel-hero span {
  position: absolute;
  display: block;
  box-sizing: border-box;
}

.pixel-shadow {
  left: 14px;
  bottom: 1px;
  width: 68px;
  height: 10px;
  border-radius: 0;
  background: rgba(20, 27, 34, 0.28);
  filter: blur(2px);
}

.pixel-leg {
  bottom: 21px;
  width: 16px;
  height: 42px;
  border: 4px solid var(--outline-color);
  background: var(--pants-color);
  transform-origin: 50% 8px;
}

.pixel-front-leg {
  left: 43px;
  z-index: 3;
}

.pixel-back-leg {
  left: 27px;
  z-index: 2;
  filter: brightness(0.86);
}

.pixel-boot {
  bottom: 7px;
  width: 24px;
  height: 17px;
  border: 4px solid var(--outline-color);
  background: var(--boot-color);
}

.pixel-front-boot {
  left: 43px;
  z-index: 4;
}

.pixel-back-boot {
  left: 23px;
  z-index: 2;
}

.pixel-body {
  left: 25px;
  bottom: 58px;
  z-index: 5;
  width: 41px;
  height: 49px;
  border: 4px solid var(--outline-color);
  background:
    linear-gradient(90deg, var(--jacket-color) 0 38%, var(--shirt-color) 39% 58%, var(--jacket-color) 59% 100%);
  box-shadow:
    inset -8px 0 0 rgba(0, 0, 0, 0.12),
    0 -5px 0 var(--shirt-color);
}

.pixel-pack {
  left: 12px;
  bottom: 62px;
  z-index: 3;
  width: 20px;
  height: 37px;
  border: 4px solid var(--outline-color);
  background: #6b4a2e;
}

.pixel-head {
  left: 34px;
  bottom: 105px;
  z-index: 7;
  width: 34px;
  height: 34px;
  border: 4px solid var(--outline-color);
  background: var(--skin-color);
  box-shadow:
    inset -7px 0 0 rgba(0, 0, 0, 0.12),
    0 8px 0 -4px var(--skin-color);
}

.pixel-hair {
  left: 28px;
  bottom: 126px;
  z-index: 8;
  width: 45px;
  height: 22px;
  border: 4px solid var(--outline-color);
  background: var(--hair-color);
  box-shadow:
    8px 17px 0 -5px var(--hair-color),
    -5px 17px 0 -5px var(--hair-color),
    18px 5px 0 -6px var(--hair-color);
}

.hero-sprite[data-model="girl"] .pixel-hair,
.avatar-pixel[data-model="girl"] .pixel-hair {
  width: 49px;
  height: 24px;
  box-shadow:
    20px 19px 0 -4px var(--hair-color),
    -7px 20px 0 -5px var(--hair-color),
    28px 7px 0 -8px var(--hair-color);
}

.pixel-eye {
  left: 57px;
  bottom: 119px;
  z-index: 9;
  width: 6px;
  height: 6px;
  background: #111827;
  box-shadow: 2px 2px 0 rgba(255, 255, 255, 0.55);
}

.pixel-arm {
  bottom: 68px;
  width: 15px;
  height: 39px;
  border: 4px solid var(--outline-color);
  background: var(--jacket-color);
  transform-origin: 50% 8px;
}

.pixel-back-arm {
  left: 15px;
  z-index: 4;
  transform: rotate(14deg);
  filter: brightness(0.82);
}

.pixel-front-arm {
  left: 60px;
  z-index: 8;
  transform: rotate(-22deg);
}

.pixel-sword {
  left: 67px;
  bottom: 73px;
  z-index: 6;
  width: 54px;
  height: 8px;
  border: 3px solid var(--outline-color);
  background: #e7f7ff;
  box-shadow:
    -7px 0 0 #916338,
    8px 0 0 rgba(255, 255, 255, 0.55);
  transform: rotate(-18deg);
  transform-origin: 2px 50%;
}

.pixel-slash {
  left: 88px;
  bottom: 83px;
  z-index: 10;
  width: 86px;
  height: 35px;
  border-top: 8px solid rgba(255, 248, 174, 0.98);
  border-right: 8px solid rgba(120, 227, 255, 0.88);
  opacity: 0;
  transform: rotate(20deg) scaleX(0.2);
  transform-origin: left center;
  filter: drop-shadow(0 0 11px rgba(255, 247, 156, 0.9));
}

.stage-pixel .hero-sprite {
  bottom: 106px;
  width: 150px;
  height: 230px;
}

.stage-pixel .enemy-sprite {
  bottom: 128px;
  width: 154px;
  height: 180px;
}

.stage-pixel .enemy-sprite img {
  display: none;
}

.stage-pixel .power-burst {
  bottom: 295px;
}

.pixel-enemy {
  --enemy-main: #f35c3f;
  --enemy-dark: #842f3a;
  --enemy-bright: #ffb548;
  --enemy-glow: #ffe66a;
  position: absolute;
  inset: 0;
  image-rendering: pixelated;
  transform-origin: 50% 100%;
}

.enemy-sprite[data-enemy="pyramid"] .pixel-enemy {
  --enemy-main: #8d6cf2;
  --enemy-dark: #46316e;
  --enemy-bright: #44d2ff;
  --enemy-glow: #b9fff6;
}

.enemy-sprite[data-enemy="star"] .pixel-enemy {
  --enemy-main: #f0a436;
  --enemy-dark: #7b4721;
  --enemy-bright: #ffef8a;
  --enemy-glow: #fff3a8;
}

.pixel-enemy span {
  position: absolute;
  display: block;
  box-sizing: border-box;
}

.pixel-enemy-shadow {
  left: 22px;
  right: 20px;
  bottom: 2px;
  height: 14px;
  background: rgba(20, 27, 34, 0.26);
  filter: blur(3px);
}

.pixel-enemy-body {
  left: 32px;
  bottom: 23px;
  z-index: 3;
  width: 92px;
  height: 92px;
  border: 7px solid #171926;
  background:
    linear-gradient(90deg, transparent 0 64%, rgba(255, 255, 255, 0.18) 65% 78%, transparent 79%),
    linear-gradient(180deg, var(--enemy-bright), var(--enemy-main) 40%, var(--enemy-dark));
  box-shadow:
    0 0 0 7px rgba(255, 196, 86, 0.12),
    0 0 26px rgba(255, 132, 52, 0.6);
}

.enemy-sprite[data-enemy="pyramid"] .pixel-enemy-body {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  border: 0;
  background:
    linear-gradient(135deg, var(--enemy-bright) 0 18%, transparent 19%),
    linear-gradient(180deg, var(--enemy-main), var(--enemy-dark));
  box-shadow:
    inset 0 0 0 7px #171926,
    0 0 26px rgba(68, 210, 255, 0.58);
}

.enemy-sprite[data-enemy="star"] .pixel-enemy-body {
  clip-path: polygon(50% 0, 62% 32%, 96% 35%, 70% 57%, 78% 92%, 50% 73%, 22% 92%, 30% 57%, 4% 35%, 38% 32%);
  border: 0;
  background: linear-gradient(180deg, var(--enemy-bright), var(--enemy-main) 52%, var(--enemy-dark));
  box-shadow:
    inset 0 0 0 7px #171926,
    0 0 28px rgba(255, 239, 138, 0.68);
}

.pixel-enemy-core {
  left: 62px;
  bottom: 55px;
  z-index: 5;
  width: 32px;
  height: 26px;
  background: rgba(255, 255, 255, 0.16);
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.14),
    0 0 18px var(--enemy-glow);
}

.pixel-enemy-eye {
  bottom: 69px;
  z-index: 6;
  width: 11px;
  height: 20px;
  background: var(--enemy-glow);
  box-shadow: 0 0 10px var(--enemy-glow);
}

.pixel-enemy-eye-left {
  left: 58px;
}

.pixel-enemy-eye-right {
  left: 89px;
}

.pixel-enemy-spike {
  z-index: 2;
  width: 25px;
  height: 25px;
  border: 5px solid #171926;
  background: var(--enemy-main);
}

.pixel-enemy-spike-top {
  left: 66px;
  bottom: 115px;
  transform: rotate(45deg);
}

.pixel-enemy-spike-left {
  left: 13px;
  bottom: 58px;
  transform: rotate(45deg);
}

.pixel-enemy-spike-right {
  right: 10px;
  bottom: 58px;
  transform: rotate(45deg);
}

.stage-pixel .play-screen.approaching .pixel-body {
  animation: pixel-body-walk 480ms steps(2, end) infinite;
}

.stage-pixel .play-screen.approaching .pixel-front-leg {
  animation: pixel-front-leg-walk 480ms steps(2, end) infinite;
}

.stage-pixel .play-screen.approaching .pixel-back-leg {
  animation: pixel-back-leg-walk 480ms steps(2, end) infinite;
}

.stage-pixel .play-screen.approaching .pixel-front-boot {
  animation: pixel-front-boot-walk 480ms steps(2, end) infinite;
}

.stage-pixel .play-screen.approaching .pixel-back-boot {
  animation: pixel-back-boot-walk 480ms steps(2, end) infinite;
}

.stage-pixel .play-screen.approaching .pixel-front-arm {
  animation: pixel-front-arm-walk 480ms steps(2, end) infinite;
}

.stage-pixel .play-screen.approaching .pixel-back-arm {
  animation: pixel-back-arm-walk 480ms steps(2, end) infinite;
}

.stage-pixel .play-screen.encounter-active .pixel-body,
.stage-pixel .play-screen.answered .pixel-body {
  animation: pixel-ready-body 760ms steps(2, end) infinite;
}

.stage-pixel .play-screen.encounter-active .pixel-front-leg,
.stage-pixel .play-screen.answered .pixel-front-leg {
  transform: translateX(6px) rotate(-6deg);
}

.stage-pixel .play-screen.encounter-active .pixel-back-leg,
.stage-pixel .play-screen.answered .pixel-back-leg {
  transform: translateX(-5px) rotate(8deg);
}

.stage-pixel .play-screen.encounter-active .pixel-front-arm,
.stage-pixel .play-screen.answered .pixel-front-arm {
  transform: rotate(-48deg);
}

.stage-pixel .play-screen.encounter-active .pixel-sword,
.stage-pixel .play-screen.answered .pixel-sword {
  transform: rotate(-42deg);
}

.stage-pixel .scene-correct .pixel-body {
  animation: pixel-attack-body 980ms steps(4, end) both;
}

.stage-pixel .scene-correct .pixel-front-leg {
  animation: pixel-attack-front-leg 980ms steps(4, end) both;
}

.stage-pixel .scene-correct .pixel-back-leg {
  animation: pixel-attack-back-leg 980ms steps(4, end) both;
}

.stage-pixel .scene-correct .pixel-front-arm {
  animation: pixel-attack-front-arm 980ms steps(4, end) both;
}

.stage-pixel .scene-correct .pixel-sword {
  animation: pixel-sword-strike 980ms steps(4, end) both;
}

.stage-pixel .scene-correct .pixel-slash {
  animation: pixel-slash 720ms steps(3, end) 260ms both;
}

.stage-pixel .scene-wrong .pixel-body {
  animation: pixel-hurt-body 900ms steps(3, end) both;
}

.stage-pixel .scene-wrong .pixel-front-leg,
.stage-pixel .scene-wrong .pixel-back-leg {
  animation: pixel-hurt-leg 900ms steps(3, end) both;
}

@keyframes pixel-body-walk {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes pixel-front-leg-walk {
  0%,
  100% {
    transform: translateX(-5px) rotate(15deg);
  }
  50% {
    transform: translateX(8px) rotate(-16deg);
  }
}

@keyframes pixel-back-leg-walk {
  0%,
  100% {
    transform: translateX(8px) rotate(-13deg);
  }
  50% {
    transform: translateX(-5px) rotate(16deg);
  }
}

@keyframes pixel-front-boot-walk {
  0%,
  100% {
    transform: translateX(-10px);
  }
  50% {
    transform: translateX(10px);
  }
}

@keyframes pixel-back-boot-walk {
  0%,
  100% {
    transform: translateX(10px);
  }
  50% {
    transform: translateX(-9px);
  }
}

@keyframes pixel-front-arm-walk {
  0%,
  100% {
    transform: rotate(-11deg);
  }
  50% {
    transform: rotate(-38deg);
  }
}

@keyframes pixel-back-arm-walk {
  0%,
  100% {
    transform: rotate(30deg);
  }
  50% {
    transform: rotate(8deg);
  }
}

@keyframes pixel-ready-body {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes pixel-attack-body {
  0% {
    transform: translateX(0) translateY(0);
  }
  25% {
    transform: translateX(-8px) translateY(4px);
  }
  50% {
    transform: translateX(18px) translateY(-7px);
  }
  100% {
    transform: translateX(6px) translateY(0);
  }
}

@keyframes pixel-attack-front-leg {
  0% {
    transform: translateX(5px) rotate(-6deg);
  }
  50% {
    transform: translateX(14px) rotate(-24deg);
  }
  100% {
    transform: translateX(7px) rotate(-9deg);
  }
}

@keyframes pixel-attack-back-leg {
  0% {
    transform: translateX(-5px) rotate(8deg);
  }
  50% {
    transform: translateX(-12px) rotate(22deg);
  }
  100% {
    transform: translateX(-4px) rotate(8deg);
  }
}

@keyframes pixel-attack-front-arm {
  0% {
    transform: rotate(-64deg);
  }
  38% {
    transform: rotate(-114deg);
  }
  62% {
    transform: rotate(42deg);
  }
  100% {
    transform: rotate(-28deg);
  }
}

@keyframes pixel-sword-strike {
  0% {
    transform: rotate(-78deg);
  }
  38% {
    transform: rotate(-130deg) translateX(-3px);
  }
  62% {
    transform: rotate(18deg) translateX(12px);
  }
  100% {
    transform: rotate(-20deg);
  }
}

@keyframes pixel-slash {
  0% {
    opacity: 0;
    transform: translateX(-18px) rotate(-28deg) scaleX(0.15);
  }
  42% {
    opacity: 1;
    transform: translateX(18px) rotate(5deg) scaleX(1.1);
  }
  100% {
    opacity: 0;
    transform: translateX(92px) rotate(18deg) scaleX(1.35);
  }
}

@keyframes pixel-hurt-body {
  0%,
  100% {
    transform: translateX(0) translateY(0);
  }
  35% {
    transform: translateX(-14px) translateY(8px);
  }
  68% {
    transform: translateX(-6px) translateY(-3px);
  }
}

@keyframes pixel-hurt-leg {
  0%,
  100% {
    transform: rotate(0);
  }
  35% {
    transform: rotate(-18deg);
  }
}

/* Open-source sprite-sheet pass: real animated character art. */
.stage-pixel .pixel-hero,
.stage-pixel .avatar-pixel {
  display: none !important;
}

.sheet-hero {
  --hero-sheet: url("assets/hero-knight.png");
  width: 48px;
  height: 48px;
  background-image: var(--hero-sheet);
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 384px 288px;
  image-rendering: pixelated;
}

.avatar-sheet-hero {
  display: block;
  margin: 34px auto 44px;
  transform: scale(5.2);
  transform-origin: center;
}

.stage-sheet-hero {
  position: absolute;
  left: 42px;
  bottom: 18px;
  z-index: 9;
  transform: scale(5.05);
  transform-origin: bottom center;
  animation: sheet-idle 760ms steps(8) infinite;
}

.stage-sheet-hero[data-action="move"] {
  background-position-y: -48px;
  animation: sheet-move 720ms steps(8) infinite;
}

.stage-sheet-hero[data-action="idle"] {
  background-position-y: 0;
  animation: sheet-idle 760ms steps(8) infinite;
}

.stage-sheet-hero[data-action="attack"] {
  background-position-y: -96px;
  animation: sheet-attack 620ms steps(8) infinite;
}

.stage-sheet-hero[data-action="damaged"] {
  background-position-y: -192px;
  animation: sheet-damaged 620ms steps(8) 1;
}

.stage-pixel .hero-sprite {
  bottom: 104px;
  width: 252px;
  height: 250px;
}

.stage-pixel .hero-sprite::before,
.stage-pixel .hero-sprite::after {
  display: none;
}

@keyframes sheet-idle {
  from {
    background-position-x: 0;
  }
  to {
    background-position-x: -384px;
  }
}

@keyframes sheet-move {
  from {
    background-position-x: 0;
  }
  to {
    background-position-x: -384px;
  }
}

@keyframes sheet-attack {
  from {
    background-position-x: 0;
  }
  to {
    background-position-x: -384px;
  }
}

@keyframes sheet-damaged {
  from {
    background-position-x: 0;
  }
  to {
    background-position-x: -384px;
  }
}

/* Pixel model polish: cleaner chibi side-view silhouette with readable gear. */
.stage-pixel .creator-options .model-set label::before {
  display: none;
}

.stage-pixel .choice-set label {
  overflow: visible;
}

.stage-pixel .avatar-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(244, 249, 255, 0.9));
}

.pixel-hero {
  width: 116px;
  height: 158px;
  filter: drop-shadow(0 8px 0 rgba(18, 24, 34, 0.16));
}

.avatar-pixel {
  width: 170px;
  height: 236px;
  margin-top: 8px;
  transform: scale(1.55);
}

.pixel-shadow {
  left: 22px;
  bottom: 1px;
  width: 74px;
  height: 9px;
  background: rgba(16, 23, 32, 0.22);
}

.pixel-body {
  left: 42px;
  bottom: 55px;
  width: 42px;
  height: 48px;
  border-width: 4px;
  background:
    linear-gradient(90deg, #14213a 0 18%, var(--jacket-color) 19% 42%, var(--shirt-color) 43% 57%, var(--jacket-color) 58% 100%);
  box-shadow:
    inset -7px 0 0 rgba(0, 0, 0, 0.18),
    0 8px 0 -4px #6f4b2f,
    -5px 3px 0 #15233e,
    5px 3px 0 #15233e;
}

.pixel-body::before,
.pixel-body::after,
.pixel-hair::before,
.pixel-hair::after,
.pixel-head::before,
.pixel-head::after {
  position: absolute;
  display: block;
  content: "";
}

.pixel-body::before {
  left: 9px;
  right: 9px;
  top: 24px;
  height: 5px;
  background: #6f4b2f;
  box-shadow: 10px 0 0 #d3a75f;
}

.pixel-body::after {
  left: 5px;
  bottom: -12px;
  width: 30px;
  height: 14px;
  background: #233c68;
  clip-path: polygon(0 0, 100% 0, 82% 100%, 14% 100%);
}

.pixel-pack {
  left: 22px;
  bottom: 57px;
  width: 25px;
  height: 43px;
  border-width: 4px;
  background:
    linear-gradient(180deg, #7d5a34, #4e3626);
  box-shadow: -7px 11px 0 -3px #253a60;
}

.pixel-head {
  left: 48px;
  bottom: 103px;
  width: 40px;
  height: 36px;
  border-width: 4px;
  background:
    linear-gradient(90deg, var(--skin-color) 0 72%, color-mix(in srgb, var(--skin-color), #5d3829 20%) 73% 100%);
  box-shadow:
    8px 8px 0 -4px var(--skin-color),
    13px 15px 0 -8px var(--skin-color);
}

.pixel-head::before {
  right: -8px;
  top: 15px;
  width: 8px;
  height: 7px;
  border: 3px solid var(--outline-color);
  border-left: 0;
  background: var(--skin-color);
}

.pixel-head::after {
  right: 4px;
  bottom: -10px;
  width: 14px;
  height: 11px;
  border-left: 4px solid var(--outline-color);
  border-right: 4px solid var(--outline-color);
  background: var(--skin-color);
}

.pixel-hair {
  left: 39px;
  bottom: 126px;
  width: 52px;
  height: 22px;
  border-width: 4px;
  background: var(--hair-color);
  box-shadow:
    -8px 7px 0 -3px var(--outline-color),
    -4px 10px 0 -3px var(--hair-color),
    9px -5px 0 -5px var(--hair-color),
    21px -2px 0 -6px var(--hair-color),
    36px 9px 0 -6px var(--hair-color);
}

.pixel-hair::before {
  left: 10px;
  bottom: -12px;
  width: 36px;
  height: 12px;
  background:
    linear-gradient(90deg, transparent 0 18%, var(--hair-color) 19% 49%, transparent 50% 58%, var(--hair-color) 59% 100%);
}

.pixel-hair::after {
  right: -11px;
  top: 10px;
  width: 13px;
  height: 14px;
  background: var(--hair-color);
  box-shadow: 0 0 0 4px var(--outline-color);
}

.hero-sprite[data-model="girl"] .pixel-hair,
.avatar-pixel[data-model="girl"] .pixel-hair {
  left: 38px;
  width: 54px;
  height: 23px;
  box-shadow:
    -8px 7px 0 -3px var(--outline-color),
    -4px 10px 0 -3px var(--hair-color),
    10px -5px 0 -5px var(--hair-color),
    22px -3px 0 -6px var(--hair-color),
    39px 9px 0 -5px var(--hair-color);
}

.hero-sprite[data-model="girl"] .pixel-hair::after,
.avatar-pixel[data-model="girl"] .pixel-hair::after {
  right: -17px;
  top: 13px;
  width: 18px;
  height: 28px;
  background: var(--hair-color);
  box-shadow:
    0 0 0 4px var(--outline-color),
    0 20px 0 -5px var(--hair-color);
}

.pixel-eye {
  left: 75px;
  bottom: 119px;
  width: 6px;
  height: 8px;
  background: #111827;
  box-shadow:
    2px 2px 0 rgba(255, 255, 255, 0.68),
    -20px 0 0 -1px #111827;
}

.pixel-arm {
  bottom: 69px;
  width: 16px;
  height: 39px;
  border-width: 4px;
  background: var(--jacket-color);
}

.pixel-back-arm {
  left: 28px;
  z-index: 4;
  transform: rotate(20deg);
}

.pixel-front-arm {
  left: 75px;
  z-index: 9;
  transform: rotate(-42deg);
}

.pixel-arm::after {
  position: absolute;
  left: 2px;
  bottom: -8px;
  width: 10px;
  height: 10px;
  background: var(--skin-color);
  box-shadow: 0 0 0 3px var(--outline-color);
  content: "";
}

.pixel-leg {
  bottom: 23px;
  width: 17px;
  height: 39px;
  border-width: 4px;
}

.pixel-front-leg {
  left: 57px;
}

.pixel-back-leg {
  left: 41px;
}

.pixel-boot {
  bottom: 8px;
  width: 28px;
  height: 17px;
  border-width: 4px;
}

.pixel-front-boot {
  left: 55px;
}

.pixel-back-boot {
  left: 35px;
}

.pixel-sword {
  left: 83px;
  bottom: 82px;
  width: 64px;
  height: 7px;
  border-width: 3px;
  background:
    linear-gradient(90deg, #c9f3ff, #ffffff 58%, #93d8f2);
  box-shadow:
    -8px 0 0 #7a5331,
    -13px 0 0 #d8a94c,
    12px 0 0 rgba(255, 255, 255, 0.5);
  transform: rotate(-23deg);
}

.stage-pixel .play-screen.encounter-active .pixel-front-arm,
.stage-pixel .play-screen.answered .pixel-front-arm {
  transform: rotate(-58deg);
}

.stage-pixel .play-screen.encounter-active .pixel-sword,
.stage-pixel .play-screen.answered .pixel-sword {
  transform: rotate(-38deg);
}

.stage-pixel .hero-sprite {
  width: 158px;
  height: 222px;
}

@media (max-height: 820px) {
  .app-shell {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .hero-screen {
    min-height: auto;
  }

  .creator-copy {
    width: min(1040px, 100%);
  }

  .creator-copy.hero-copy {
    padding-top: 12px;
    padding-bottom: 18px;
  }

  .creator-copy h2 {
    margin-bottom: 8px;
    font-size: clamp(2.25rem, 4.8vw, 3.8rem);
  }

  .creator-copy > p:not(.eyebrow) {
    margin-bottom: 10px;
    font-size: 1rem;
    line-height: 1.35;
  }

  .creator-layout {
    grid-template-columns: 220px 1fr;
    gap: 14px;
    margin-top: 12px;
  }

  .avatar-card {
    min-height: 0;
    padding: 14px;
  }

  img.avatar-preview {
    height: 235px;
  }

  .avatar-card p {
    font-size: 0.86rem;
  }

  .model-set label {
    min-height: 74px;
  }

  .model-set label::before {
    width: 48px;
    height: 66px;
  }

  .creator-options {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .creator-options .model-set {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .creator-options .swatch-set {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .creator-options .model-set label,
  .creator-options .swatch-set label {
    min-height: 42px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .creator-options .model-set label {
    min-height: 72px;
  }

  .creator-options .model-set label::before {
    width: 50px;
    height: 68px;
  }

  .mode-grid {
    gap: 10px;
    margin-top: 12px;
  }

  .mode-card {
    min-height: 76px;
    padding: 12px;
  }

  .mode-card strong {
    margin-bottom: 4px;
    font-size: 0.9rem;
  }

  .mode-card span {
    font-size: 0.78rem;
    line-height: 1.22;
  }

  .begin-button {
    margin-top: 14px;
  }

  .encounter-panel {
    top: 58px;
    max-height: 350px;
  }

  .encounter-panel .main-graph {
    height: 190px;
    min-height: 176px;
  }

  .hero-sprite {
    bottom: 108px;
  }

  .enemy-sprite {
    bottom: 128px;
  }
}

/* Final sprite sheet overrides, kept last so older prototype rules cannot win. */
.stage-pixel .avatar-preview,
.stage-pixel .avatar-pixel,
.stage-pixel .pixel-hero,
.stage-pixel .hero-part,
.stage-pixel .hero-sword-swing,
.stage-pixel .hero-source {
  display: none !important;
}

.stage-pixel .class-set {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stage-pixel .class-set label {
  min-height: 72px;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
}

.stage-pixel .avatar-sheet-hero {
  display: block !important;
  margin: 78px auto 88px;
  transform: scale(5.25);
  transform-origin: center;
}

.stage-pixel .stage-sheet-hero {
  display: block !important;
  left: 42px;
  bottom: 22px;
  transform: scale(5.1);
  transform-origin: bottom center;
}

.stage-pixel .stage-sheet-hero[data-action="attack"] {
  background-position-y: -144px;
}

.stage-pixel .hero-sprite {
  bottom: 148px;
  width: 252px;
  height: 250px;
}

.stage-pixel .enemy-sprite {
  bottom: 150px;
  width: 154px;
  height: 180px;
}

@media (max-height: 820px) {
  .stage-pixel .hero-sprite {
    bottom: 148px;
    width: 252px;
    height: 250px;
  }

  .stage-pixel .enemy-sprite {
    bottom: 150px;
    width: 154px;
    height: 180px;
  }
}

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

/* Classroom cleanup pass: graph-first encounter UI and simpler boss equation blanks. */
.hero-copy > p:not(.eyebrow) {
  max-width: 640px;
}

.encounter-panel .game-header {
  display: block;
}

.encounter-panel .game-header .eyebrow,
.encounter-panel .score-strip,
.scene-topline .power-chip,
.encounter-panel .graph-heading {
  display: none !important;
}

.encounter-panel .game-header h2 {
  margin: 0 0 8px;
  font-size: clamp(1.02rem, 1.5vw, 1.32rem);
  line-height: 1.15;
}

.encounter-panel .game-layout {
  grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.72fr);
  gap: 14px;
}

.encounter-panel .graph-card {
  grid-template-columns: minmax(0, 1fr) minmax(132px, 0.22fr);
  align-items: stretch;
  gap: 10px;
}

.encounter-panel .main-graph {
  height: min(34vh, 288px);
  min-height: 238px;
  max-height: 288px;
}

.graph-equations {
  display: grid;
  align-content: start;
  gap: 8px;
}

.graph-equation {
  margin: 0;
  border: 2px solid currentColor;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  padding: 9px 10px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  box-shadow: 0 10px 20px rgba(22, 32, 51, 0.08);
}

.graph-equation span {
  display: block;
  margin-bottom: 4px;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  font-size: 0.74rem;
  font-weight: 900;
}

.graph-equation strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.graph-equation-f {
  color: var(--blueprint);
}

.graph-equation-g {
  color: var(--coral);
}

.graph-equation[hidden],
.graph-equation.is-hidden {
  display: none !important;
}

.question-card .parent-label,
.question-card .equation-stack {
  display: none !important;
}

.encounter-panel .question-card .parent-label,
.encounter-panel .question-card .equation-stack,
.encounter-panel .question-card .equation-stack div {
  display: none !important;
}

.play-screen.no-graph .encounter-panel .question-card .parent-label {
  display: block !important;
}

.play-screen.no-graph .encounter-panel .question-card .equation-stack {
  display: grid !important;
}

.play-screen.no-graph .encounter-panel .question-card .equation-stack div {
  display: grid !important;
}

.landing-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

.landing-actions .begin-button {
  margin: 0;
}

.question-card .prompt {
  margin-top: 0;
  font-size: clamp(1rem, 1.25vw, 1.14rem);
}

.boss-entry {
  gap: 10px;
}

.boss-template {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 7px;
  border: 2px solid rgba(22, 32, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 12px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: clamp(1rem, 1.35vw, 1.22rem);
  font-weight: 900;
}

.boss-template label {
  display: grid;
  gap: 4px;
  min-width: 54px;
}

.boss-template label span {
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}

.boss-template input {
  width: 58px;
  min-height: 42px;
  border: 2px solid rgba(40, 100, 217, 0.26);
  border-radius: 8px;
  background: white;
  padding: 6px;
  text-align: center;
  font: inherit;
}

.boss-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.hero-sword-swing,
.stage-pixel .hero-sword-swing,
.stage-pixel .scene-correct .hero-sword-swing,
.play-screen.encounter-active .hero-sword-swing,
.play-screen.answered .hero-sword-swing {
  display: none !important;
  visibility: hidden !important;
  animation: none !important;
}

@media (min-width: 921px) and (max-height: 820px) {
  .encounter-panel {
    top: 52px;
    max-height: min(48vh, 372px);
  }

  .encounter-panel .main-graph {
    height: min(36vh, 276px);
    min-height: 228px;
    max-height: 276px;
  }
}

/* Open-source platformer character pass. Kept last to override earlier prototypes. */
.stage-pixel .avatar-sheet-hero,
.stage-pixel .stage-sheet-hero,
.stage-pixel .avatar-pixel,
.stage-pixel .pixel-hero,
.stage-pixel .pixel-enemy,
.stage-pixel .hero-part {
  display: none !important;
}

.stage-pixel .avatar-card {
  overflow: hidden;
  min-height: 318px;
  background:
    radial-gradient(circle at 50% 72%, rgba(32, 46, 66, 0.12) 0 68px, transparent 69px),
    linear-gradient(180deg, #fffdf7, #edf8ff);
}

.stage-pixel .avatar-preview {
  display: block !important;
  width: auto;
  height: 230px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 18px 12px rgba(18, 28, 44, 0.18));
}

.stage-pixel .class-set {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stage-pixel .class-set label {
  min-height: 68px;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  border: 2px solid rgba(22, 32, 51, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 251, 255, 0.9));
  box-shadow: 0 10px 22px rgba(22, 32, 51, 0.08);
}

.stage-pixel .class-set input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.stage-pixel .class-set label img {
  width: auto;
  height: 104px;
  object-fit: contain;
  filter: drop-shadow(0 10px 8px rgba(18, 28, 44, 0.16));
}

.stage-pixel .class-set label span {
  font-weight: 900;
}

.stage-pixel .hero-sprite {
  --hero-scale: 1.42;
  left: 15%;
  bottom: 158px;
  z-index: 24;
  width: 120px;
  height: 165px;
  transform-origin: 50% 100%;
  pointer-events: none;
}

.stage-pixel .hero-source {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: block !important;
  width: auto;
  height: 165px;
  max-width: none;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  image-rendering: auto;
  filter: drop-shadow(0 16px 10px rgba(8, 16, 28, 0.28));
}

.stage-pixel .enemy-sprite {
  --enemy-scale: 1.34;
  right: 17%;
  bottom: 158px;
  z-index: 23;
  width: 120px;
  height: 165px;
  transform-origin: 50% 100%;
  pointer-events: none;
}

.stage-pixel .enemy-sprite img {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: block !important;
  width: auto;
  height: 165px;
  max-width: none;
  transform: translateX(-50%) scaleX(-1);
  transform-origin: 50% 100%;
  image-rendering: auto;
  filter:
    drop-shadow(0 16px 10px rgba(8, 16, 28, 0.3))
    saturate(1.08);
}

.stage-pixel .enemy-sprite[data-enemy="blue"] img {
  filter:
    drop-shadow(0 16px 10px rgba(8, 16, 28, 0.3))
    hue-rotate(155deg)
    saturate(1.25);
}

.stage-pixel .enemy-sprite[data-enemy="red"] img {
  filter:
    drop-shadow(0 16px 10px rgba(8, 16, 28, 0.3))
    hue-rotate(305deg)
    saturate(1.35)
    brightness(1.04);
}

.stage-pixel .enemy-sprite[data-enemy="elite"] img {
  filter:
    drop-shadow(0 0 18px rgba(255, 230, 90, 0.75))
    drop-shadow(0 16px 10px rgba(8, 16, 28, 0.3))
    hue-rotate(245deg)
    saturate(1.45)
    brightness(1.1);
}

.stage-pixel .enemy-sprite[data-enemy="boss"] {
  --enemy-scale: 1.72;
}

.stage-pixel .enemy-sprite[data-enemy="boss"] img {
  filter:
    drop-shadow(0 0 24px rgba(255, 216, 88, 0.8))
    drop-shadow(0 20px 14px rgba(8, 16, 28, 0.38))
    hue-rotate(280deg)
    saturate(1.55)
    brightness(0.9);
}

.stage-pixel .hero-sprite::after,
.stage-pixel .enemy-sprite::after {
  position: absolute;
  left: 50%;
  bottom: -4px;
  display: block;
  width: 74px;
  height: 14px;
  border-radius: 50%;
  background: rgba(8, 16, 28, 0.22);
  transform: translateX(-50%);
  content: "";
  filter: blur(3px);
}

.stage-pixel .hero-sword-swing {
  position: absolute;
  left: 62px;
  bottom: 76px;
  z-index: 4;
  display: block !important;
  width: 126px;
  height: 62px;
  border-top: 12px solid rgba(255, 240, 147, 0.95);
  border-right: 12px solid rgba(132, 220, 255, 0.78);
  border-radius: 50%;
  opacity: 0;
  visibility: hidden;
  transform: rotate(-20deg) scale(0.28);
  transform-origin: 0 50%;
  filter: drop-shadow(0 0 18px rgba(255, 226, 109, 0.88));
}

.stage-pixel .scene-correct .hero-sword-swing {
  visibility: visible;
  animation: kenney-slash 920ms cubic-bezier(0.16, 1, 0.3, 1) 350ms both;
}

.boss-entry {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.boss-entry label {
  color: var(--ink);
  font-weight: 900;
}

.boss-entry input {
  min-height: 52px;
  width: 100%;
  border: 2px solid rgba(22, 32, 51, 0.18);
  border-radius: var(--radius);
  background: white;
  padding: 10px 12px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 1rem;
}

.boss-entry input:disabled {
  opacity: 0.72;
}

.stage-pixel .scene-path {
  bottom: 0;
  height: 176px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 36%),
    repeating-linear-gradient(100deg, transparent 0 42px, rgba(27, 42, 63, 0.18) 43px 46px),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(27, 42, 63, 0.16) 32px 35px),
    linear-gradient(180deg, #9eb8c1, #657f87);
  border-top: 7px solid rgba(239, 247, 241, 0.82);
  box-shadow:
    inset 0 18px 0 rgba(255, 255, 255, 0.18),
    0 -16px 22px rgba(26, 92, 75, 0.18);
}

.stage-pixel .path-trim {
  bottom: 176px;
}

.stage-pixel .power-burst {
  left: 33%;
  top: auto;
  bottom: 250px;
  z-index: 25;
}

@keyframes kenney-slash {
  0% {
    opacity: 0;
    transform: translateX(-18px) rotate(-42deg) scale(0.2);
  }
  38% {
    opacity: 1;
    transform: translateX(18px) rotate(-6deg) scale(0.92);
  }
  100% {
    opacity: 0;
    transform: translateX(86px) rotate(18deg) scale(1.18);
  }
}

@media (max-height: 820px) {
  .stage-pixel .avatar-preview {
    height: 205px;
  }

  .stage-pixel .hero-sprite {
    bottom: 142px;
    width: 110px;
    height: 150px;
  }

  .stage-pixel .hero-source {
    height: 150px;
  }

  .stage-pixel .enemy-sprite {
    bottom: 142px;
    width: 110px;
    height: 150px;
  }

  .stage-pixel .enemy-sprite img {
    height: 150px;
  }

  .stage-pixel .scene-path {
    height: 158px;
  }

  .stage-pixel .path-trim {
    bottom: 158px;
  }

  .stage-pixel .power-burst {
    bottom: 224px;
  }
}

/* Final cleanup overrides. */
.encounter-panel .game-header {
  display: none !important;
}

.encounter-panel .game-layout {
  grid-template-columns: minmax(0, 1.38fr) minmax(330px, 0.72fr) !important;
  gap: 14px;
}

.encounter-panel .graph-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(132px, 0.22fr);
  align-items: stretch;
  gap: 10px;
}

.encounter-panel .graph-heading,
.encounter-panel .score-strip,
.scene-topline .power-chip,
.question-card .parent-label,
.question-card .equation-stack {
  display: none !important;
}

body .play-screen.no-graph .encounter-panel .question-card .parent-label {
  display: block !important;
}

body .play-screen.no-graph .encounter-panel .question-card .equation-stack,
body .play-screen.no-graph .encounter-panel .question-card .equation-stack div {
  display: grid !important;
}

.temporary-level-select {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.temporary-level-select button {
  border: 1px solid rgba(67, 89, 112, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  min-height: 34px;
  padding: 6px 12px;
}

.temporary-level-select button:hover {
  border-color: rgba(40, 100, 217, 0.5);
  background: #eef5ff;
}

.boss-submit-button {
  justify-self: start;
  min-width: 210px;
}

.encounter-panel .main-graph {
  height: min(35vh, 292px) !important;
  min-height: 238px !important;
  max-height: 292px !important;
}

.graph-equations {
  display: grid;
  align-content: start;
  gap: 8px;
}

.graph-equation {
  margin: 0;
  border: 2px solid currentColor;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 9px 10px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  box-shadow: 0 10px 20px rgba(22, 32, 51, 0.08);
}

.graph-equation span {
  display: block;
  margin-bottom: 4px;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  font-size: 0.74rem;
  font-weight: 900;
}

.graph-equation strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.graph-equation-f {
  color: var(--blueprint);
}

.graph-equation-g {
  color: var(--coral);
}

.question-card .prompt {
  margin: 0 0 10px;
  font-size: clamp(1rem, 1.24vw, 1.14rem);
  line-height: 1.28;
}

.boss-template {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 7px;
  border: 2px solid rgba(22, 32, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  padding: 12px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: clamp(1rem, 1.35vw, 1.22rem);
  font-weight: 900;
}

.boss-template label {
  display: grid;
  gap: 4px;
  min-width: 54px;
}

.boss-template label span {
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}

.boss-template input {
  width: 58px;
  min-height: 42px;
  border: 2px solid rgba(40, 100, 217, 0.26);
  border-radius: 8px;
  background: white;
  padding: 6px;
  text-align: center;
  font: inherit;
}

.boss-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.hero-sword-swing,
.hero-sword-swing::before,
.hero-sword-swing::after,
.stage-pixel .hero-sword-swing,
.stage-pixel .hero-sword-swing::before,
.stage-pixel .hero-sword-swing::after,
.stage-pixel .scene-correct .hero-sword-swing {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  animation: none !important;
}

@media (min-width: 921px) and (max-height: 820px) {
  .encounter-panel {
    top: 52px;
    max-height: min(48vh, 372px);
  }

  .encounter-panel .main-graph {
    height: min(36vh, 276px) !important;
    min-height: 228px !important;
    max-height: 276px !important;
  }
}

/* Chromebook hotfix: keep boss controls visible at normal browser zoom. */
.encounter-panel {
  overflow-y: auto;
}

.play-screen.boss-active .encounter-panel {
  top: 34px;
  max-height: calc(100vh - 290px);
}

.play-screen.boss-active .encounter-panel .main-graph {
  height: min(27vh, 210px) !important;
  min-height: 180px !important;
  max-height: 210px !important;
}

.play-screen.boss-active .boss-entry {
  gap: 6px;
}

.play-screen.boss-active .boss-entry > p {
  margin: 0;
  line-height: 1.24;
}

.play-screen.boss-active .boss-template {
  padding: 9px;
  gap: 5px;
}

.play-screen.boss-active .boss-template input {
  min-height: 36px;
}

.play-screen.boss-active .action-row #nextButton {
  display: none;
}

.stage-pixel .hero-sprite {
  bottom: 116px !important;
}

.stage-pixel .enemy-sprite {
  bottom: 118px !important;
}

.stage-pixel .power-burst {
  bottom: 196px !important;
}
