:root {
  color-scheme: light;
  --ink: #1b2530;
  --muted: #5a6c78;
  --paper: #fff8df;
  --line: #7c613e;
  --accent: #2f8f4e;
  --accent-strong: #1f6d39;
  --mark: #f8d34d;
  --good: #2f8f57;
  --bad: #b13d30;
  --dirt: #7b5132;
  --grass: #52a545;
  --shadow: 0 12px 0 rgba(42, 28, 18, 0.18), 0 18px 34px rgba(42, 28, 18, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #8bd4ef 0 360px, #94c36d 360px 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 3px solid #16371f;
  border-radius: 4px;
  color: #fff;
  background: var(--accent);
  padding: 0 16px;
  box-shadow: inset 0 -4px rgba(0, 0, 0, 0.18), 0 4px 0 #16371f;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hidden {
  display: none !important;
}

.landing-shell,
.profile-shell {
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 24px;
  align-items: stretch;
  min-height: calc(100vh - 56px);
}

.landing-copy,
.portal-scene,
.profile-gate {
  border: 4px solid #2b1b13;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.landing-copy {
  display: grid;
  align-content: center;
  gap: 18px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px) 0 0 / 24px 24px,
    #d7aa63;
  padding: clamp(24px, 5vw, 48px);
}

.landing-copy h1 {
  font-size: clamp(3rem, 7vw, 5.8rem);
}

.landing-text {
  max-width: 34rem;
  margin: 0;
  color: #3f3328;
  font-size: 1.15rem;
  line-height: 1.45;
  font-weight: 700;
}

#landingAction {
  width: min(220px, 100%);
  min-height: 56px;
  font-size: 1.1rem;
}

.portal-scene {
  overflow: hidden;
  min-height: 560px;
  background: #87d8ff;
}

.landing-sky {
  position: relative;
  height: 100%;
  min-height: inherit;
  overflow: hidden;
  background: linear-gradient(180deg, #87d8ff 0 68%, #5aa749 68% 100%);
}

.landing-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 120px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 30px 30px,
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 30px 30px,
    linear-gradient(180deg, var(--grass) 0 30px, var(--dirt) 30px 100%);
}

.problem-block {
  position: absolute;
  bottom: 150px;
  display: grid;
  width: 78px;
  height: 54px;
  place-items: center;
  border: 4px solid #2b1b13;
  background: #fff8df;
  color: #2b1b13;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: inset 0 -8px rgba(0, 0, 0, 0.12);
  animation: solveBlock 6s infinite steps(1, end);
}

.block-one {
  left: 22%;
  animation-delay: 0.8s;
}

.block-two {
  left: 44%;
  animation-delay: 2.1s;
}

.block-three {
  left: 63%;
  animation-delay: 3.2s;
}

.portal {
  position: absolute;
  right: 8%;
  bottom: 116px;
  width: 112px;
  height: 190px;
  border: 10px solid #2b1b13;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.25) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(180deg, #7c3fc4, #35c4e8);
  box-shadow: 0 0 0 8px #53326f, 0 0 28px rgba(53, 196, 232, 0.8);
}

.portal span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent 0 35%, rgba(255, 255, 255, 0.28) 35% 48%, transparent 48% 100%);
  animation: portalPulse 1.2s infinite steps(2, end);
}

.landing-character {
  position: absolute;
  left: 8%;
  bottom: 128px;
  width: 82px;
  height: 140px;
  animation: heroWalk 6s infinite linear;
}

.landing-character span {
  position: absolute;
  display: block;
  border: 3px solid #2b1b13;
  box-shadow: inset 0 -5px rgba(0, 0, 0, 0.18);
}

.landing-character .head {
  left: 23px;
  top: 0;
  width: 36px;
  height: 36px;
  background: #c48a5a;
}

.landing-character .head::before,
.landing-character .head::after {
  position: absolute;
  top: 14px;
  width: 5px;
  height: 5px;
  background: #151515;
  content: "";
}

.landing-character .head::before {
  left: 9px;
}

.landing-character .head::after {
  right: 9px;
}

.landing-character .body {
  left: 19px;
  top: 39px;
  width: 44px;
  height: 50px;
  background: #2f8f4e;
}

.landing-character .arm {
  top: 44px;
  width: 18px;
  height: 48px;
  background: #c48a5a;
}

.landing-character .arm-left {
  left: 0;
  animation: armSwing 0.55s infinite steps(2, end);
}

.landing-character .arm-right {
  right: 0;
  animation: armSwing 0.55s infinite steps(2, end) reverse;
}

.landing-character .leg {
  top: 88px;
  width: 20px;
  height: 48px;
  background: #315d9a;
}

.landing-character .leg-left {
  left: 20px;
  animation: legSwing 0.55s infinite steps(2, end);
}

.landing-character .leg-right {
  right: 20px;
  animation: legSwing 0.55s infinite steps(2, end) reverse;
}

@keyframes heroWalk {
  0% {
    left: 7%;
    transform: scale(0.62);
  }
  18% {
    left: 22%;
    transform: scale(0.7);
  }
  38% {
    left: 43%;
    transform: scale(0.82);
  }
  58% {
    left: 62%;
    transform: scale(0.94);
  }
  78% {
    left: 80%;
    opacity: 1;
    transform: scale(1);
  }
  86% {
    left: 88%;
    opacity: 0;
    transform: scale(1.08);
  }
  100% {
    left: 88%;
    opacity: 0;
    transform: scale(1.08);
  }
}

@keyframes armSwing {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(8px);
  }
}

@keyframes legSwing {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}

@keyframes solveBlock {
  0%, 24% {
    background: #fff8df;
  }
  25%, 100% {
    background: var(--mark);
  }
}

@keyframes portalPulse {
  0%, 100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.profile-gate {
  display: grid;
  gap: 20px;
  min-height: calc(100vh - 56px);
  align-content: start;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 28px 28px,
    #d7aa63;
  padding: clamp(18px, 4vw, 36px);
}

.profile-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.profile-card,
.new-profile {
  border: 3px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.profile-card {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 16px;
}

.profile-card.editing {
  justify-items: stretch;
}

.profile-thumb {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  overflow: hidden;
  border: 3px solid #2b1b13;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-size: 1.35rem;
  font-weight: 900;
}

.profile-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-card strong {
  font-size: 1.25rem;
}

.profile-card span {
  color: var(--muted);
  font-weight: 800;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.profile-actions button {
  flex: 1 1 96px;
}

.profile-edit-form {
  display: grid;
  gap: 12px;
}

.profile-edit-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-edit-form input {
  min-height: 42px;
  border: 3px solid var(--line);
  border-radius: 4px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.profile-edit-form input[type="file"] {
  padding: 8px;
}

button.danger {
  border-color: #5b1f18;
  background: var(--bad);
  box-shadow: inset 0 -4px rgba(0, 0, 0, 0.18), 0 4px 0 #5b1f18;
}

button.danger:hover {
  background: #8f3026;
}

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

.new-profile {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 160px) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

.new-profile h2 {
  grid-column: 1 / -1;
}

.new-profile label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.new-profile input {
  min-height: 42px;
  border: 3px solid var(--line);
  border-radius: 4px;
  padding: 0 10px;
}

.topbar,
.game-stage,
.status,
.workspace {
  display: grid;
  gap: 16px;
}

.reading-focus > .topbar,
.reading-focus > .game-stage,
.reading-focus > .status {
  display: none;
}

.reading-page,
.math-page {
  min-height: calc(100vh - 48px);
}

.topbar {
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  margin-bottom: 18px;
}

.student-heading {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.avatar {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  overflow: hidden;
  border: 4px solid #2b1b13;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow);
  font-size: 2rem;
  font-weight: 850;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kicker,
.status-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.35);
}

h2 {
  font-size: 1.35rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

select,
.controls input,
.answer {
  min-height: 42px;
  border: 3px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
}

select,
.controls input {
  min-width: 118px;
  padding: 0 10px;
}

.controls input {
  width: 86px;
}

.upload-control {
  position: relative;
}

.upload-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.upload-control span {
  display: grid;
  min-width: 96px;
  min-height: 42px;
  place-items: center;
  border: 3px solid #16371f;
  border-radius: 4px;
  color: #fff;
  background: var(--accent);
  padding: 0 14px;
  box-shadow: inset 0 -4px rgba(0, 0, 0, 0.18), 0 4px 0 #16371f;
  cursor: pointer;
}

.upload-control:hover span {
  background: var(--accent-strong);
}

.game-stage {
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: stretch;
  margin-bottom: 18px;
}

.sky {
  position: relative;
  min-height: 320px;
  overflow: hidden;
  border: 4px solid #2b1b13;
  border-radius: 6px;
  background: linear-gradient(180deg, #87d8ff 0 67%, #5aa749 67% 100%);
  box-shadow: var(--shadow);
}

.sun,
.cloud,
.ground,
.avatar-wrap,
.shadow {
  position: absolute;
}

.sun {
  top: 28px;
  right: 38px;
  width: 58px;
  height: 58px;
  background: #ffe36a;
  box-shadow: 0 0 0 8px rgba(255, 227, 106, 0.35);
}

.cloud {
  width: 112px;
  height: 40px;
  background:
    linear-gradient(#fff, #fff) 0 16px / 112px 24px no-repeat,
    linear-gradient(#fff, #fff) 24px 0 / 40px 40px no-repeat,
    linear-gradient(#fff, #fff) 64px 8px / 32px 32px no-repeat;
  opacity: 0.9;
}

.cloud-one {
  top: 56px;
  left: 10%;
}

.cloud-two {
  top: 112px;
  right: 20%;
  transform: scale(0.72);
}

.ground {
  left: 0;
  right: 0;
  bottom: 0;
  height: 86px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(180deg, var(--grass) 0 24px, var(--dirt) 24px 100%);
}

.avatar-wrap {
  left: calc(var(--journey, 0) * 1%);
  bottom: 48px;
  width: 128px;
  height: 192px;
  transform: translateX(-50%) scale(var(--age-scale, 0.62));
  transform-origin: bottom center;
  transition: left 240ms ease, transform 240ms ease;
}

.avatar-wrap canvas {
  position: relative;
  z-index: 2;
  width: 128px;
  height: 192px;
  image-rendering: pixelated;
}

.shadow {
  left: 24px;
  right: 24px;
  bottom: -6px;
  z-index: 1;
  height: 14px;
  background: rgba(34, 23, 16, 0.32);
}

.quest-panel {
  display: grid;
  align-content: space-between;
  gap: 18px;
  border: 4px solid #2b1b13;
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px) 0 0 / 24px 24px,
    #d7aa63;
  padding: 18px;
  box-shadow: var(--shadow);
}

.quest-panel strong {
  display: block;
  margin-top: 6px;
  font-size: 2.3rem;
  line-height: 1;
}

.level-track {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.level-track span {
  min-width: 0;
  border: 3px solid #2b1b13;
  background: #f5df99;
  padding: 8px 4px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 850;
}

.level-track span.active {
  color: #fff;
  background: var(--accent);
}

.status {
  grid-template-columns: 1fr 1fr auto;
  align-items: stretch;
  margin-bottom: 20px;
}

.progress-card,
.task {
  border: 3px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.progress-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.progress-card strong {
  font-size: 1.4rem;
}

.meter {
  height: 16px;
  overflow: hidden;
  border: 2px solid #2b1b13;
  border-radius: 4px;
  background: #5d422c;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px) 0 0 / 14px 14px,
    var(--mark);
  transition: width 180ms ease;
}

.workspace {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  align-items: start;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 10px;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task {
  padding: 14px;
}

.math-summary {
  display: grid;
  gap: 8px;
}

.math-summary span {
  color: var(--muted);
  font-weight: 850;
}

.math-page .math-blaster {
  min-height: calc(100vh - 140px);
}

.math-page .blaster-arena {
  min-height: min(68vh, 620px);
}

.math-page .answer-tube {
  height: min(36vh, 260px);
  font-size: clamp(1.2rem, 3vw, 2rem);
}

.math-page .tube-problem {
  font-size: clamp(2rem, 5vw, 4rem);
}

.math-page .tube-player {
  bottom: calc(min(36vh, 260px) + 14px);
}

.math-blaster {
  display: grid;
  gap: 12px;
}

.blaster-arena {
  --tube-side: clamp(32px, 9vw, 128px);
  --tube-gap: clamp(18px, 4vw, 72px);
  --player-size: 54px;
  position: relative;
  min-height: 320px;
  overflow: hidden;
  border: 4px solid #2b1b13;
  border-radius: 6px;
  background:
    radial-gradient(circle at 18% 24%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 62% 18%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 84% 44%, #fff 0 2px, transparent 3px),
    linear-gradient(180deg, #18243a, #263f62);
}

.tube-problem {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 3;
  min-width: 190px;
  transform: translateX(-50%);
  border: 4px solid #2b1b13;
  background: var(--mark);
  padding: 10px 16px;
  box-shadow: inset 0 -6px rgba(0, 0, 0, 0.18);
  font-size: 1.65rem;
  font-weight: 900;
  text-align: center;
}

.tube-row {
  position: absolute;
  left: var(--tube-side);
  right: var(--tube-side);
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(46px, 1fr));
  gap: var(--tube-gap);
  align-items: end;
}

.answer-tube {
  position: relative;
  display: grid;
  height: 170px;
  min-width: 0;
  place-items: end center;
  border: 4px solid #2b1b13;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px) 0 0 / 16px 16px,
    #2f8f8d;
  padding: 0 4px 18px;
  box-shadow: inset 0 -6px rgba(0, 0, 0, 0.22);
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
}

.answer-tube::after {
  position: absolute;
  top: -28px;
  left: calc(-1 * var(--tube-gap));
  width: var(--tube-gap);
  height: 12px;
  border-top: 4px solid #2b1b13;
  border-bottom: 4px solid #2b1b13;
  background: #a7794b;
  content: "";
}

.answer-tube:first-child::after {
  display: none;
}

.answer-tube::before {
  position: absolute;
  top: -16px;
  left: -6px;
  right: -6px;
  height: 18px;
  border: 4px solid #2b1b13;
  border-radius: 8px;
  background: #7fd6d4;
  content: "";
}

.answer-tube.selected {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px) 0 0 / 16px 16px,
    #3da9c4;
  outline: 4px solid var(--mark);
  outline-offset: 3px;
}

.tube-player {
  position: absolute;
  left: calc(var(--tube-side) + ((100% - (2 * var(--tube-side))) * var(--tube-position, 10) / 100) - (var(--player-size) / 2));
  bottom: 184px;
  z-index: 2;
  width: var(--player-size);
  height: 86px;
  transition: left 220ms steps(4, end);
}

.stick-head,
.stick-body,
.stick-arm,
.stick-leg,
.eye,
.mouth {
  position: absolute;
  display: block;
}

.stick-head {
  top: 0;
  left: 12px;
  width: 30px;
  height: 30px;
  border: 4px solid #2b1b13;
  border-radius: 50%;
  background: #c48a5a;
}

.eye {
  top: 9px;
  width: 4px;
  height: 4px;
  background: #1b1b1b;
}

.left-eye {
  left: 7px;
}

.right-eye {
  right: 7px;
}

.mouth {
  left: 8px;
  bottom: 6px;
  width: 10px;
  height: 5px;
  border-bottom: 3px solid #7a2f2a;
}

.math-blaster.correct .mouth {
  border-bottom-color: #204b2b;
  border-radius: 0 0 999px 999px;
}

.math-blaster.wrong .mouth {
  bottom: 3px;
  border-top: 3px solid #7a2f2a;
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
}

.stick-body {
  top: 32px;
  left: 25px;
  width: 5px;
  height: 30px;
  background: #2b1b13;
}

.stick-arm,
.stick-leg {
  width: 5px;
  height: 26px;
  background: #2b1b13;
  transform-origin: top center;
}

.left-arm {
  top: 36px;
  left: 24px;
  transform: rotate(42deg);
}

.right-arm {
  top: 36px;
  right: 24px;
  transform: rotate(-42deg);
}

.left-leg {
  top: 59px;
  left: 25px;
  transform: rotate(28deg);
}

.right-leg {
  top: 59px;
  right: 25px;
  transform: rotate(-28deg);
}

.math-blaster.walking-right .left-leg,
.math-blaster.walking-left .right-leg {
  animation: walkLeg 220ms steps(2, end);
}

.math-blaster.walking-right .right-arm,
.math-blaster.walking-left .left-arm {
  animation: walkArm 220ms steps(2, end);
}

.math-blaster.correct.dropping .tube-player {
  animation: happyDrop 720ms steps(8, end);
}

.math-blaster.wrong.dropping .tube-player {
  animation: lavaDrop 980ms steps(10, end);
}

.math-blaster.dropping .left-arm,
.math-blaster.dropping .right-arm {
  animation: panicWave 180ms steps(2, end) infinite;
}

.math-blaster.correct .answer-tube.selected {
  background: var(--accent);
}

.math-blaster.wrong .answer-tube.selected {
  background: var(--bad);
}

.blaster-hud,
.blaster-controls {
  display: grid;
  gap: 8px;
}

.blaster-hud {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.blaster-hud span {
  color: var(--muted);
  font-weight: 850;
}

.blaster-controls {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

@keyframes tubeDrop {
  0% {
    transform: translateX(28px) translateY(0);
  }
  100% {
    transform: translateX(28px) translateY(142px);
  }
}

@keyframes happyDrop {
  0% {
    transform: translateY(0);
  }
  58% {
    transform: translateY(144px);
  }
  100% {
    transform: translateY(144px);
  }
}

@keyframes lavaDrop {
  0% {
    transform: translateY(0);
  }
  45% {
    transform: translateY(144px);
  }
  70% {
    transform: translateY(144px);
  }
  100% {
    transform: translateY(-74px);
  }
}

@keyframes panicWave {
  0%, 100% {
    transform: rotate(72deg);
  }
  50% {
    transform: rotate(-72deg);
  }
}

@keyframes walkLeg {
  0%, 100% {
    transform: rotate(36deg);
  }
  50% {
    transform: rotate(-34deg);
  }
}

@keyframes walkArm {
  0%, 100% {
    transform: rotate(-54deg);
  }
  50% {
    transform: rotate(54deg);
  }
}

.math-task label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 12px;
  align-items: center;
}

.prompt {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
  line-height: 1.4;
}

.answer {
  width: 92px;
  padding: 0 10px;
  text-align: center;
  font-weight: 800;
}

.result {
  display: block;
  min-height: 20px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.task.correct {
  border-color: rgba(47, 143, 87, 0.9);
}

.task.correct .result {
  color: var(--good);
}

.task.wrong {
  border-color: rgba(177, 61, 48, 0.9);
}

.task.wrong .result {
  color: var(--bad);
}

.story-card h3 {
  margin: 0 0 4px;
  font-size: 1.3rem;
}

.story-meta {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.story-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.reading-timer {
  display: inline-grid;
  min-height: 38px;
  place-items: center;
  border: 3px solid #2b1b13;
  border-radius: 4px;
  background: var(--mark);
  padding: 0 10px;
  font-size: 1rem;
}

.reading-instruction {
  min-width: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.story-text {
  display: grid;
  gap: 12px;
  max-height: 440px;
  overflow: auto;
  padding-right: 6px;
}

.story-text.full-story {
  max-height: none;
  overflow: visible;
}

.story-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.story-text p {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.55;
}

.question-task {
  display: grid;
  gap: 12px;
}

.question-task .title {
  display: block;
  font-size: 1.05rem;
}

.choices {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.choices label {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 2px solid rgba(124, 97, 62, 0.5);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.45);
  padding: 8px;
  cursor: pointer;
}

.choices input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

@media (max-width: 780px) {
  .landing-shell,
  .profile-shell {
    width: min(100vw - 20px, 680px);
    padding-top: 14px;
  }

  .landing-hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .landing-copy {
    min-height: 360px;
  }

  .portal-scene {
    min-height: 360px;
  }

  .landing-character {
    transform-origin: bottom center;
  }

  .problem-block {
    width: 64px;
    height: 48px;
    font-size: 0.82rem;
  }

  .portal {
    right: 5%;
    width: 84px;
    height: 150px;
  }

  .new-profile {
    grid-template-columns: 1fr;
  }

  .story-controls {
    grid-template-columns: 1fr;
  }

  .shell {
    width: min(100vw - 20px, 680px);
    padding-top: 14px;
  }

  .topbar,
  .game-stage,
  .status,
  .workspace {
    grid-template-columns: 1fr;
  }

  .student-heading {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .avatar {
    width: 70px;
    height: 70px;
    font-size: 1.65rem;
  }

  .sky {
    min-height: 270px;
  }

  .quest-panel {
    min-height: 150px;
  }

  .avatar-wrap {
    bottom: 42px;
  }

  .controls {
    justify-content: stretch;
  }

  .controls label {
    flex: 1 1 120px;
  }

  select,
  .controls input,
  .upload-control span {
    width: 100%;
  }

  #newDayButton {
    width: 100%;
  }
}
