@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap");
:root {
  --ink: #252337;
  --purple: #7652cc;
  --cream: #fbf9f4;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #b79aff;
  outline-offset: 4px;
}
aside {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  border-right: 1px solid #e8e4dc;
  padding: 38px 26px;
  display: flex;
  flex-direction: column;
}
.brand {
  font:
    800 49px "Outfit",
    sans-serif;
  letter-spacing: -4px;
  color: var(--ink);
  text-decoration: none;
}
.brand span {
  color: var(--purple);
  font-size: 35px;
  margin-left: 5px;
}
.tagline {
  font-size: 12px;
  color: #8a8593;
  margin: 6px 0 45px;
}
nav {
  display: grid;
  gap: 12px;
}
nav a,
nav button {
  text-align: left;
  padding: 14px;
  border: 0;
  background: none;
  text-decoration: none;
  color: #827b8b;
  font-weight: 600;
  font-size: 14px;
  border-radius: 12px;
}
nav .active {
  background: #eee7fa;
  color: #6847b6;
}
.sidebar-bottom {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}
.avatar {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e9ddff;
  color: #7751bf;
  font-weight: 700;
}
small {
  display: block;
  color: #8a8593;
  font-size: 10px;
  margin-top: 4px;
}
main {
  margin-left: 220px;
  padding: 32px 48px 20px;
  max-width: 1600px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e8e4dc;
  padding-bottom: 26px;
}
.breadcrumb {
  font-size: 10px;
  letter-spacing: 1.3px;
  color: #918999;
}
.breadcrumb span {
  padding: 0 17px;
  color: #bfb6c6;
}
header button {
  border: 1px solid #e8e4dc;
  background: transparent;
  border-radius: 25px;
  padding: 8px 12px;
  color: #756b80;
  font-size: 12px;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(370px, 1.1fr) minmax(310px, 0.9fr);
  gap: 55px;
  max-width: 1120px;
  margin: 42px auto;
}
.lesson-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.7px;
  color: var(--purple);
}
.counter {
  font-size: 11px;
  color: #9d94a5;
}
.progress {
  height: 4px;
  background: #eae4ef;
  border-radius: 4px;
  margin: 16px 0 31px;
  overflow: hidden;
}
.progress i {
  display: block;
  width: 33.3%;
  height: 100%;
  background: #9876de;
  transition: width 0.5s;
}
.context {
  display: flex;
  gap: 9px;
  font-size: 10px;
  color: #867793;
}
.context span:first-child,
.context span:last-child {
  background: #f0ebf5;
  border-radius: 6px;
  padding: 5px 8px;
}
.context span:nth-child(2) {
  padding-top: 5px;
}
h1 {
  font:
    600 clamp(36px, 3.8vw, 57px) / 1.08 "Outfit",
    sans-serif;
  letter-spacing: -1.8px;
  margin: 21px 0 14px;
}
.intro {
  font-size: 13px;
  color: #8b8191;
  line-height: 1.7;
  max-width: 350px;
  margin-bottom: 27px;
}
.question-box {
  background: #fff;
  border: 1px solid #e7e0ec;
  border-radius: 19px;
  padding: 25px;
  box-shadow: 0 5px 0 #f0ebf2;
}
.question-label {
  font-size: 9px;
  color: #93879e;
  letter-spacing: 1.5px;
  font-weight: 700;
}
h2 {
  font:
    500 20px/1.5 "Outfit",
    sans-serif;
  margin: 12px 0 22px;
}
.answers {
  display: grid;
  gap: 10px;
}
.answer {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  background: white;
  border: 1.5px solid #e8e3ed;
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 14px;
  transition: 0.18s;
}
.answer .letter {
  display: grid;
  place-items: center;
  border: 1px solid #e6dfec;
  border-radius: 6px;
  min-width: 26px;
  height: 26px;
  font-size: 11px;
  color: #9b8da9;
}
.answer:hover {
  border-color: #b89ddd;
  background: #fbf8ff;
}
.answer.selected {
  border-color: #8661cf;
  background: #f3edff;
}
.answer.selected .letter {
  background: #8661cf;
  color: #fff;
  border-color: #8661cf;
}
.answer.correct {
  border-color: #42a58a;
  background: #edfaf4;
}
.answer.incorrect {
  border-color: #d69b7c;
  background: #fff6ee;
}
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}
.text-button {
  border: 0;
  background: none;
  color: #998b9e;
  font-size: 11px;
  padding: 8px 0;
  margin-right: auto;
}
.help-button {
  border: 0;
  background: #eee8f6;
  color: #78618e;
  border-radius: 10px;
  padding: 13px;
  font-size: 11px;
  font-weight: 600;
}
.primary {
  background: var(--purple);
  color: white;
  border: 0;
  border-bottom: 4px solid #58369d;
  border-radius: 11px;
  padding: 13px 17px;
  font-size: 12px;
  font-weight: 700;
}
.primary span {
  margin-left: 15px;
}
.primary:disabled {
  opacity: 0.4;
  cursor: default;
}
.primary:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}
.footnote {
  text-align: center;
  font-size: 10px;
  color: #a69aab;
  margin-top: 20px;
}
.companion {
  position: relative;
  align-self: center;
  min-width: 0;
  padding: 35px 0 0;
  text-align: center;
}
.companion:before {
  content: "";
  position: absolute;
  inset: 65px -12px 155px;
  border-radius: 48% 48% 45% 45%;
  background: #f0e9f7;
  z-index: -2;
}
.speech {
  display: inline-block;
  position: relative;
  background: white;
  border: 1px solid #e8def1;
  border-radius: 16px;
  padding: 13px 22px;
  font-size: 12px;
  color: #847095;
  line-height: 1.5;
  transform: rotate(-4deg);
  margin-bottom: -15px;
  z-index: 2;
}
.speech:after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  background: white;
  border-right: 1px solid #e8def1;
  border-bottom: 1px solid #e8def1;
  transform: rotate(45deg);
  bottom: -7px;
  left: 55%;
}
svg {
  display: block;
  width: 100%;
  max-height: 390px;
  overflow: visible;
}
.cat {
  transform-origin: 210px 405px;
  animation: breathe 3.5s ease-in-out infinite;
}
.head {
  transform-origin: 210px 240px;
  animation: headtilt 7s ease-in-out infinite;
}
.eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 5s infinite;
}
.tail {
  transform-origin: 150px 370px;
  animation: tail 4s ease-in-out infinite;
}
.star {
  transform-origin: 335px 95px;
  animation: star 4s ease-in-out infinite;
}
.arm {
  transform-origin: 250px 265px;
}
.celebrate .cat {
  animation: jump 0.65s ease-in-out 2;
}
.celebrate .arm {
  animation: wave 0.4s ease-in-out 3;
}
.celebrate .star {
  animation: star 0.5s ease-in-out 3;
}
.thinking .head {
  animation: headtilt 1s ease-in-out infinite;
}
.character-caption h3 {
  font: 600 23px "Outfit";
  margin: 8px;
}
.character-caption p {
  font-size: 11px;
  color: #9986a5;
}
.mini-star {
  color: #aa8ad7;
}
.skill-path {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 10px;
  margin: 22px 0;
  color: #8d789f;
}
.skill-path span {
  padding: 7px 10px;
  border: 1px solid #e5dced;
  border-radius: 20px;
}
.skill-path b {
  font-size: 19px;
  color: #a98acb;
}
.stat {
  border-top: 1px solid #e7e0eb;
  margin: 0 20px;
  padding: 18px 0;
  display: flex;
  text-align: left;
  justify-content: space-between;
  align-items: center;
}
.stat div span {
  display: block;
  font-size: 8px;
  letter-spacing: 1.4px;
  color: #ac9bb7;
}
.stat strong {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-top: 7px;
  color: #786487;
}
.stat-icon {
  font-size: 32px;
  color: #aa8bd0;
}
.spark {
  position: absolute;
  color: #b496d9;
}
.s1 {
  top: 155px;
  left: 10px;
  font-size: 30px;
}
.s2 {
  top: 290px;
  right: 0;
  font-size: 19px;
}
.s3 {
  top: 70px;
  right: 36px;
  font-size: 23px;
}
footer {
  border-top: 1px solid #e8e4dc;
  display: flex;
  justify-content: space-between;
  padding-top: 20px;
  font-size: 8px;
  letter-spacing: 1.5px;
  color: #a79eac;
}
#feedback:empty {
  display: none;
}
#feedback {
  margin-top: 18px;
  border-radius: 10px;
  background: #f2edf9;
  padding: 13px;
  font-size: 12px;
  line-height: 1.6;
  color: #6d528a;
}
#help {
  margin-top: 15px;
  font-size: 13px;
  line-height: 1.7;
  background: #fff8e6;
  padding: 15px;
  border-radius: 12px;
  color: #876b34;
}
dialog {
  border: 1px solid #e4d8f1;
  border-radius: 22px;
  max-width: 480px;
  padding: 30px;
  background: var(--cream);
  color: var(--ink);
}
dialog::backdrop {
  background: #25233766;
  backdrop-filter: blur(5px);
}
dialog p {
  font-size: 14px;
  line-height: 1.7;
  color: #897495;
}
#closeMap {
  float: right;
  border: 0;
  background: none;
  font-size: 24px;
}
.map-row {
  background: #eee5fa;
  padding: 20px;
  border-radius: 12px;
  font-size: 13px;
}
.particle {
  position: fixed;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 20;
  animation: confetti 1.3s ease-out forwards;
}
@keyframes breathe {
  50% {
    transform: scale(1.015, 1.02);
  }
}
@keyframes blink {
  0%,
  43%,
  47%,
  100% {
    transform: scaleY(1);
  }
  45% {
    transform: scaleY(0.08);
  }
}
@keyframes headtilt {
  0%,
  80%,
  100% {
    transform: rotate(0);
  }
  88% {
    transform: rotate(-4deg);
  }
}
@keyframes tail {
  50% {
    transform: rotate(-6deg);
  }
}
@keyframes star {
  50% {
    transform: translateY(-8px) rotate(9deg);
  }
}
@keyframes jump {
  45% {
    transform: translateY(-27px) rotate(-4deg);
  }
  75% {
    transform: scale(1.04, 0.96);
  }
}
@keyframes wave {
  50% {
    transform: rotate(-12deg);
  }
}
@keyframes confetti {
  to {
    transform: translate(var(--x), var(--y)) rotate(300deg);
    opacity: 0;
  }
}
@media (min-width: 1500px) {
  main {
    margin-right: auto;
  }
}
@media (max-width: 1100px) {
  aside {
    width: 175px;
    padding: 30px 18px;
  }
  main {
    margin-left: 175px;
    padding: 27px;
  }
  .workspace {
    gap: 25px;
    grid-template-columns: minmax(340px, 1.2fr) minmax(240px, 0.8fr);
  }
  .actions {
    gap: 8px;
  }
  .primary {
    padding: 12px;
  }
  .primary span {
    margin-left: 5px;
  }
  .help-button {
    padding: 12px 9px;
  }
  .breadcrumb {
    font-size: 8px;
  }
}
@media (max-width: 800px) {
  aside {
    display: none;
  }
  main {
    margin: 0;
    padding: 20px;
  }
  .breadcrumb {
    font-size: 8px;
    letter-spacing: 0.7px;
  }
  .breadcrumb span {
    padding: 0 8px;
  }
  .workspace {
    display: flex;
    flex-direction: column-reverse;
    margin: 20px auto;
    max-width: 520px;
    gap: 14px;
  }
  .companion {
    width: 100%;
    padding: 0;
    min-height: 130px;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .companion:before {
    inset: 8px 0 0 50%;
    border-radius: 30px;
  }
  .companion svg {
    width: 155px;
    height: 165px;
    margin-top: -12px;
    order: 2;
  }
  .speech {
    font-size: 11px;
    margin: 0;
    transform: rotate(-3deg);
  }
  .character-caption,
  .skill-path,
  .stat,
  .spark {
    display: none;
  }
  .lesson .progress {
    margin-bottom: 22px;
  }
  h1 {
    font-size: 40px;
    margin: 16px 0 10px;
  }
  h1 br {
    display: none;
  }
  .intro {
    margin-bottom: 20px;
  }
  .question-box {
    padding: 20px;
  }
  .actions {
    justify-content: space-between;
  }
  .primary {
    padding: 13px 16px;
  }
  .footnote {
    font-size: 9px;
  }
  footer {
    margin-top: 25px;
    font-size: 7px;
  }
  header {
    padding-bottom: 17px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}
/* Viewport composition: the character and response remain together. */
body {
  height: 100dvh;
  overflow: hidden;
}
aside {
  width: 184px;
  padding: 27px 22px;
}
main {
  height: 100dvh;
  margin-left: 184px;
  max-width: none;
  padding: 22px 34px 12px;
  display: flex;
  flex-direction: column;
}
header {
  flex: none;
  padding-bottom: 16px;
}
.workspace {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1080px;
  margin: 20px auto 10px;
  gap: 42px;
  align-items: center;
  grid-template-columns: minmax(340px, 1.15fr) minmax(260px, 0.85fr);
}
.lesson {
  min-height: 0;
}
.progress {
  margin: 11px 0 18px;
}
h1 {
  font-size: clamp(30px, 3.3vw, 46px);
  margin: 14px 0 9px;
}
.intro {
  margin: 0 0 18px;
  font-size: 12px;
}
.question-box {
  padding: 19px;
}
h2 {
  font-size: 18px;
  margin: 9px 0 16px;
}
.answer {
  padding: 9px 12px;
}
.answers {
  gap: 8px;
}
.actions {
  margin-top: 18px;
}
.footnote {
  margin: 12px 0 0;
}
.companion {
  padding: 0;
  align-self: center;
}
.companion:before {
  inset: 25px 0 80px;
  border-radius: 48%;
}
.speech {
  font-weight: 600;
  min-height: 57px;
  margin-bottom: 0;
}
.companion svg {
  height: min(43dvh, 360px);
  width: 100%;
  max-height: none;
}
.character-caption h3 {
  font-size: 20px;
  margin: 4px;
}
.character-caption p {
  margin: 6px 0;
  font-size: 11px;
}
.skill-path {
  margin: 14px 0;
}
.stat {
  padding: 12px 0;
  margin: 0 22px;
}
footer {
  flex: none;
  padding-top: 12px;
}
.s1 {
  top: 110px;
}
.s2 {
  top: 240px;
}
.s3 {
  top: 55px;
}
.happy-eyes,
.success-mouth,
.think-mouth,
.worry-brows,
.reaction-mark {
  display: none;
}
.blush {
  opacity: 0.3;
}
.cat,
.head,
.tail,
.star,
.eyes {
  animation: none;
  transform-box: view-box;
}
.cat {
  transform-origin: 194px 378px;
  animation: idleBreath 4s ease-in-out infinite;
}
.head {
  transform-origin: 192px 220px;
}
.eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: softBlink 6s infinite;
}
.tail {
  transform-origin: 141px 340px;
  animation: tailSway 5s ease-in-out infinite;
}
.arm {
  transform-origin: 245px 260px;
}
.star {
  transform-origin: 320px 70px;
  animation: starFloat 4s ease-in-out infinite;
}
.thinking .head {
  animation: consider 0.55s ease-out forwards;
}
.thinking .pupil {
  transform: translate(0, -5px);
}
.thinking .normal-mouth {
  display: none;
}
.thinking .think-mouth,
.thinking .worry-brows {
  display: block;
}
.celebrate .eyes,
.celebrate .normal-mouth,
.encourage .normal-mouth {
  display: none;
}
.celebrate .happy-eyes,
.celebrate .success-mouth,
.celebrate .reaction-mark {
  display: block;
}
.celebrate .blush {
  opacity: 0.8;
}
.celebrate .cat {
  animation: bigWin 1.1s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.celebrate .arm {
  animation: pawCheer 1s ease-in-out;
}
.celebrate .hat {
  transform-origin: 190px 85px;
  animation: hatPop 1.1s ease-in-out;
}
.celebrate .star {
  animation: starWin 1.2s ease-out;
}
.encourage .think-mouth {
  display: block;
}
.encourage .head {
  animation: nod 0.8s ease-in-out;
}
.ground {
  transform-origin: 190px 385px;
}
.celebrate .ground {
  animation: shadowWin 1.1s ease-in-out;
}
.particle {
  width: 11px;
  height: 11px;
  box-shadow: 0 0 1px #fff;
  animation: confetti 1.7s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}
.particle:nth-child(3n) {
  border-radius: 50%;
  width: 8px;
  height: 8px;
}
.particle:nth-child(4n) {
  clip-path: polygon(
    50% 0,
    62% 35%,
    100% 50%,
    62% 65%,
    50% 100%,
    38% 65%,
    0 50%,
    38% 35%
  );
  width: 19px;
  height: 19px;
}
#feedback {
  margin-top: 12px;
  padding: 10px 12px;
  font-size: 12px;
}
#help {
  max-height: 120px;
  overflow: auto;
  margin-top: 10px;
  padding: 12px;
  font-size: 12px;
}
#help[hidden] {
  display: none;
}
@keyframes idleBreath {
  50% {
    transform: translateY(-2px) scale(1.006, 1.008);
  }
}
@keyframes softBlink {
  0%,
  40%,
  44%,
  100% {
    transform: scaleY(1);
  }
  42% {
    transform: scaleY(0.04);
  }
}
@keyframes tailSway {
  50% {
    transform: rotate(-4deg);
  }
}
@keyframes starFloat {
  50% {
    transform: translateY(-5px) rotate(4deg);
  }
}
@keyframes consider {
  to {
    transform: rotate(-6deg) translateY(2px);
  }
}
@keyframes bigWin {
  0% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.08, 0.9);
  }
  38% {
    transform: translateY(-43px) rotate(-7deg) scale(0.97, 1.04);
  }
  60% {
    transform: translateY(-20px) rotate(4deg);
  }
  78% {
    transform: scale(1.09, 0.9);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes pawCheer {
  30%,
  65% {
    transform: rotate(-20deg);
  }
  48%,
  80% {
    transform: rotate(4deg);
  }
}
@keyframes hatPop {
  35% {
    transform: translateY(-14px) rotate(-10deg);
  }
  65% {
    transform: translateY(-3px) rotate(5deg);
  }
}
@keyframes starWin {
  40% {
    transform: translateY(-14px) rotate(22deg) scale(1.2);
  }
  100% {
    transform: none;
  }
}
@keyframes shadowWin {
  38% {
    transform: scaleX(0.7);
    opacity: 0.4;
  }
}
@keyframes nod {
  40% {
    transform: rotate(5deg);
  }
  75% {
    transform: rotate(-2deg);
  }
}
@media (max-height: 740px) and (min-width: 801px) {
  main {
    padding-top: 15px;
  }
  .workspace {
    margin-top: 13px;
    gap: 30px;
  }
  h1 {
    font-size: 34px;
    line-height: 1.05;
  }
  h1 br {
    display: none;
  }
  .intro {
    margin-bottom: 10px;
  }
  .context {
    font-size: 9px;
  }
  .question-box {
    padding: 15px;
  }
  h2 {
    font-size: 17px;
    margin-bottom: 10px;
  }
  .answer {
    padding: 7px 10px;
  }
  .actions {
    margin-top: 13px;
  }
  .progress {
    margin-bottom: 12px;
  }
  .companion svg {
    height: 38dvh;
  }
  .stat,
  .skill-path {
    display: none;
  }
  .footnote {
    margin-top: 9px;
  }
}
@media (max-width: 800px) {
  main {
    margin: 0;
    padding: 12px 16px 10px;
  }
  header {
    padding-bottom: 10px;
  }
  .breadcrumb {
    font-size: 8px;
  }
  .workspace {
    display: flex;
    flex-direction: column-reverse;
    justify-content: flex-end;
    gap: 6px;
    margin: 8px auto 0;
    max-width: 520px;
    width: 100%;
    min-height: 0;
  }
  .companion {
    height: clamp(110px, 22dvh, 195px);
    min-height: 0;
    flex: none;
    width: 100%;
    padding: 0;
    display: flex;
    justify-content: center;
    gap: 12px;
    align-items: center;
  }
  .companion svg {
    width: 165px;
    height: 100%;
    max-height: 195px;
    order: 2;
    margin: 0;
  }
  .companion:before {
    inset: 0 8% 0 40%;
    border-radius: 30px;
  }
  .speech {
    margin: 0;
    font-size: 11px;
    min-height: 0;
    padding: 12px 15px;
  }
  .lesson {
    width: 100%;
    flex: none;
  }
  .lesson-top {
    margin-top: 1px;
  }
  .progress {
    margin: 8px 0 10px;
  }
  .context {
    display: none;
  }
  h1 {
    font-size: 29px;
    line-height: 1.05;
    margin: 9px 0 7px;
    letter-spacing: -0.8px;
  }
  .intro {
    font-size: 11px;
    margin-bottom: 11px;
    line-height: 1.4;
    max-width: none;
  }
  .question-box {
    padding: 15px;
    border-radius: 15px;
  }
  h2 {
    font-size: 17px;
    line-height: 1.35;
    margin: 8px 0 12px;
  }
  .answer {
    padding: 8px 10px;
    font-size: 13px;
  }
  .answer .letter {
    height: 24px;
    min-width: 24px;
  }
  .answers {
    gap: 7px;
  }
  .actions {
    margin-top: 13px;
    gap: 9px;
  }
  .help-button {
    font-size: 10px;
    padding: 12px 9px;
  }
  .primary {
    font-size: 11px;
    padding: 12px 13px;
  }
  .text-button {
    font-size: 10px;
  }
  .footnote {
    font-size: 9px;
    margin-top: 10px;
  }
  footer {
    display: none;
  }
  #help {
    max-height: 88px;
  }
  #feedback {
    font-size: 11px;
    padding: 8px 10px;
    margin-top: 9px;
  }
  .character-caption,
  .skill-path,
  .stat {
    display: none;
  }
}
@media (max-width: 800px) and (max-height: 700px) {
  .companion {
    height: 110px;
  }
  .companion svg {
    width: 125px;
  }
  h1 {
    font-size: 25px;
    margin: 6px 0;
  }
  .intro {
    display: none;
  }
  .question-box {
    padding: 12px;
  }
  h2 {
    font-size: 15px;
    margin: 5px 0 9px;
  }
  .question-label {
    font-size: 8px;
  }
  .answer {
    padding: 6px 9px;
  }
  .actions {
    margin-top: 10px;
  }
  .footnote {
    display: none;
  }
  .lesson-top .eyebrow {
    font-size: 9px;
  }
  #help {
    max-height: 66px;
  }
  .progress {
    margin: 7px 0;
  }
  .speech {
    font-size: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}

.illustrated-explorer {
  position: relative;
  height: min(43dvh, 360px);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: 50% 90%;
}
.illustrated-explorer img {
  display: block;
  object-fit: contain;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 0 #d8c5eb44);
}
.illustrated-explorer.celebrate {
  animation: artWin 0.85s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.illustrated-explorer.thinking {
  transform: rotate(-2deg);
  transition: transform 0.25s;
}
.illustrated-explorer.encourage {
  animation: artNod 0.7s ease-in-out;
}
@keyframes artWin {
  0% {
    transform: scale(1);
  }
  20% {
    transform: scale(1.04, 0.96);
  }
  50% {
    transform: translateY(-18px) rotate(-3deg);
  }
  75% {
    transform: translateY(0) scale(1.03, 0.98);
  }
  100% {
    transform: none;
  }
}
@keyframes artNod {
  50% {
    transform: rotate(3deg);
  }
  100% {
    transform: none;
  }
}
@media (max-width: 800px) {
  .illustrated-explorer {
    width: 165px;
    height: 100%;
    max-height: 195px;
    order: 2;
    flex: none;
  }
}
@media (max-width: 800px) and (max-height: 700px) {
  .illustrated-explorer {
    width: 125px;
  }
}
@media (max-height: 740px) and (min-width: 801px) {
  .illustrated-explorer {
    height: 38dvh;
  }
}

.sprite-frame {
  height: 100%;
  aspect-ratio: 1;
  background-image: url(explorer-sprites.png);
  background-size: 200% 200%;
  background-position: 0 0;
  background-repeat: no-repeat;
}
.thinking .sprite-frame {
  background-position: 100% 0;
}
.celebrate .sprite-frame {
  background-position: 0 100%;
}
.encourage .sprite-frame {
  background-position: 100% 100%;
}
.illustrated-explorer.thinking {
  transform: none;
}
.illustrated-explorer .sprite-frame {
  filter: drop-shadow(0 5px 0 #d8c5eb33);
}
/* Keep navigation reachable when feedback expands. */
.lesson {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow: hidden;
}
.question-box {
  min-height: 80px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1 1 auto;
}
.lesson-top,
.progress,
.context,
h1,
.intro,
.actions,
.footnote {
  flex-shrink: 0;
}
.actions {
  position: relative;
  z-index: 3;
  background: var(--cream);
  padding: 4px 0;
  flex: none;
}
.primary {
  min-height: 44px;
}
.text-button,
.help-button {
  min-height: 44px;
}
#help {
  max-height: none;
  overflow: visible;
}
#feedback {
  flex: none;
}
@media (max-width: 800px) {
  .workspace {
    justify-content: flex-start;
  }
  .companion {
    height: clamp(85px, 18dvh, 145px);
  }
  .lesson {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
  }
  .question-box {
    flex: 1 1 auto;
    min-height: 90px;
  }
  .footnote {
    display: none;
  }
  .actions {
    margin-top: 8px;
    padding-bottom: max(3px, env(safe-area-inset-bottom));
  }
  .companion .speech {
    font-size: 10px;
  }
  .intro {
    margin-bottom: 8px;
  }
}
@media (max-width: 800px) and (max-height: 600px) {
  .companion {
    height: 76px;
  }
  h1 {
    font-size: 22px;
  }
  .question-box {
    padding: 10px;
  }
  .intro,
  .context {
    display: none;
  }
  .companion .speech {
    padding: 8px 10px;
  }
  header {
    padding-bottom: 6px;
  }
  .workspace {
    margin-top: 4px;
  }
}
/* Focused lesson layout */
body {
  background: #fffdf9;
}
aside,
footer,
.breadcrumb,
.character-caption,
.skill-path,
.stat,
.footnote,
.context,
.intro,
.spark {
  display: none !important;
}
main {
  margin: 0 auto;
  padding: 24px 30px 0;
  max-width: 1100px;
  height: 100dvh;
}
header {
  border: 0;
  padding: 0;
  justify-content: flex-end;
  height: 32px;
  position: absolute;
  right: 30px;
  top: 18px;
  z-index: 5;
}
header button {
  background: #fffdf9;
}
header button span {
  display: none;
}
.workspace {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  max-width: 650px;
  margin: 0 auto;
  padding-top: 58px;
  padding-bottom: 110px;
  gap: 0;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}
.lesson {
  display: contents;
}
.lesson-top {
  position: absolute;
  left: 0;
  right: 0;
  top: 10px;
}
.lesson-top .eyebrow {
  font-size: 11px;
  letter-spacing: 1.3px;
}
.counter {
  font-weight: 700;
}
.progress {
  position: absolute;
  left: 0;
  right: 0;
  top: 30px;
  margin: 0;
  height: 12px;
  background: #eee8f3;
  border-radius: 20px;
}
.progress i {
  background: #9270d7;
  border-radius: 20px;
  box-shadow: inset 0 3px 0 #ad8fe7;
}
h1 {
  font:
    700 27px/1.2 "Outfit",
    sans-serif;
  letter-spacing: -0.6px;
  margin: 5px 0 18px;
  align-self: start;
}
h1 br {
  display: none;
}
.companion {
  position: absolute;
  top: 103px;
  left: 0;
  width: 150px;
  height: 160px;
  display: block;
  padding: 0;
  z-index: 1;
  pointer-events: none;
}
.companion:before {
  display: none;
}
.illustrated-explorer {
  width: 145px;
  height: 155px;
  max-height: none;
  display: block;
}
.sprite-frame {
  height: 100%;
  width: auto;
  aspect-ratio: 1;
}
.speech {
  display: none;
}
.question-box {
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  overflow: auto;
  min-height: 0;
}
.question-label {
  display: none;
}
h2 {
  margin: 6px 0 28px 170px;
  min-height: 145px;
  display: flex;
  align-items: center;
  font:
    500 22px/1.45 "Outfit",
    sans-serif;
  letter-spacing: -0.2px;
}
.answers {
  display: grid;
  gap: 12px;
  margin: 0 0 14px;
}
.answer {
  min-height: 62px;
  border: 2px solid #e5e0e8;
  border-bottom: 5px solid #e5e0e8;
  border-radius: 16px;
  padding: 12px 18px;
  background: #fff;
  font-size: 17px;
  color: #51475b;
  font-weight: 600;
}
.answer .letter {
  min-width: 30px;
  height: 30px;
  border: 2px solid #e8e2ee;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}
.answer:hover {
  background: #faf7ff;
  border-color: #d4c4ed;
}
.answer.selected {
  background: #f0e8ff;
  border-color: #b290e8;
  color: #7652b4;
}
.answer.selected .letter {
  background: white;
  color: #7652b4;
  border-color: #b290e8;
}
.answer.correct {
  background: #e9f8ef;
  border-color: #71bb90;
  color: #257c49;
}
.answer.incorrect {
  background: #fff0ed;
  border-color: #e9a394;
  color: #a54b3a;
}
.answer:disabled {
  opacity: 1;
  cursor: default;
}
.actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 92px;
  border-top: 2px solid #eee9f0;
  background: #fffdf9;
  display: flex;
  justify-content: center;
  gap: 22px;
  align-items: center;
  margin: 0;
  padding: 18px max(24px, calc((100vw - 650px) / 2));
  z-index: 10;
}
.text-button {
  margin: 0;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: #998da3;
}
.help-button {
  white-space: nowrap;
  padding: 15px 17px;
  background: #f3edf9;
  border-radius: 13px;
  font-size: 12px;
}
.primary {
  margin-left: auto;
  min-width: 185px;
  white-space: nowrap;
  min-height: 50px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 14px;
  border-bottom-width: 5px;
  padding: 14px 22px;
  background: #8056c5;
  border-color: #623b9f;
}
.primary:disabled {
  background: #e8e3eb;
  color: #aaa0af;
  opacity: 1;
  border-color: #d8d0dd;
}
#feedback {
  background: #eef8ef;
  color: #338051;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  padding: 12px 16px;
  margin: 2px 0 10px;
}
#help {
  flex: none;
  background: #fff5de;
  color: #866729;
  border-radius: 12px;
  margin: 0 0 10px;
  padding: 13px 16px;
  font-size: 13px;
  line-height: 1.6;
  max-height: none;
  overflow: visible;
}
#feedback:empty {
  display: none;
}
body:has(.incorrect) #feedback {
  background: #fff0ea;
  color: #a4593f;
}
body:has(.incorrect) .actions {
  background: #fff4ef;
  border-color: #f1d8cc;
}
body:has(.correct):not(:has(.incorrect)) .actions {
  background: #f0faef;
  border-color: #d1e8cc;
}
.question-box::-webkit-scrollbar {
  width: 5px;
}
.question-box::-webkit-scrollbar-thumb {
  background: #e3d7ef;
  border-radius: 8px;
}
@media (min-height: 850px) {
  .workspace {
    padding-top: 80px;
  }
  .companion {
    top: 135px;
    height: 185px;
    width: 180px;
  }
  .illustrated-explorer {
    height: 180px;
    width: 175px;
  }
  h2 {
    min-height: 190px;
    margin-left: 200px;
  }
  .answers {
    gap: 14px;
  }
  .answer {
    min-height: 68px;
  }
}
@media (max-width: 800px) {
  main {
    padding: 18px 20px 0;
    max-width: 650px;
  }
  .workspace {
    display: grid;
    grid-template-columns: 1fr;
    margin: 0;
    padding-top: 56px;
    padding-bottom: 100px;
    max-width: none;
    gap: 0;
    justify-content: stretch;
  }
  .companion {
    height: 135px;
    width: 125px;
    top: 104px;
    left: -5px;
    display: block;
  }
  .illustrated-explorer {
    width: 125px;
    height: 135px;
    max-height: none;
  }
  .lesson {
    display: contents;
  }
  h1 {
    font-size: 24px;
    margin: 8px 0 16px;
  }
  .question-box {
    padding: 0;
    min-height: 0;
    flex: none;
  }
  h2 {
    font-size: 19px;
    line-height: 1.4;
    margin: 4px 0 25px 130px;
    min-height: 130px;
    display: flex;
  }
  .answer {
    padding: 10px 14px;
    font-size: 15px;
    min-height: 56px;
    border-radius: 13px;
  }
  .answers {
    gap: 10px;
    margin-bottom: 12px;
  }
  .actions {
    min-height: 86px;
    padding: 14px 20px max(14px, env(safe-area-inset-bottom));
    gap: 12px;
  }
  .primary {
    min-width: 145px;
    padding: 12px 15px;
    font-size: 12px;
  }
  .primary span {
    margin-left: 8px;
  }
  .help-button {
    font-size: 11px;
    padding: 12px;
  }
  .text-button {
    font-size: 10px;
  }
  .progress {
    height: 11px;
  }
  .lesson-top .eyebrow {
    font-size: 10px;
  }
  .counter {
    font-size: 10px;
  }
  header {
    right: 14px;
    top: 9px;
  }
  #feedback {
    font-size: 12px;
    padding: 10px 12px;
  }
  #help {
    font-size: 12px;
    padding: 11px 12px;
  }
}
@media (max-width: 420px) {
  .actions {
    gap: 9px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .help-button {
    font-size: 10px;
    padding: 12px 9px;
  }
  .primary {
    min-width: 125px;
    font-size: 11px;
  }
  .text-button {
    font-size: 9px;
  }
  h2 {
    font-size: 18px;
    margin-left: 115px;
  }
  .companion {
    width: 110px;
  }
  .illustrated-explorer {
    width: 110px;
  }
}
@media (max-height: 700px) {
  .workspace {
    padding-top: 52px;
  }
  .companion {
    top: 94px;
    height: 110px;
    width: 105px;
  }
  .illustrated-explorer {
    height: 110px;
    width: 105px;
  }
  h1 {
    font-size: 23px;
    margin: 5px 0 10px;
  }
  h2 {
    min-height: 105px;
    margin: 0 0 15px 115px;
    font-size: 17px;
  }
  .answer {
    min-height: 47px;
    padding: 7px 11px;
  }
  .answers {
    gap: 8px;
  }
  .answer .letter {
    height: 26px;
    min-width: 26px;
  }
  .actions {
    min-height: 80px;
  }
  .question-box {
    min-height: 0;
  }
  .workspace {
    padding-bottom: 88px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}
/* Explorer is a supporting companion, leaving the question center stage. */
.companion {
  position: fixed;
  top: auto;
  bottom: 98px;
  left: auto;
  right: max(24px, calc((100vw - 900px) / 2));
  width: 94px;
  height: 100px;
  z-index: 4;
  pointer-events: none;
}
.illustrated-explorer {
  width: 94px;
  height: 100px;
  max-height: none;
}
.sprite-frame {
  height: 100%;
  width: 100%;
  aspect-ratio: 1;
}
h2 {
  margin: 10px 0 27px;
  min-height: 100px;
  font-size: 23px;
  max-width: 610px;
}
.workspace {
  padding-bottom: 120px;
}
.question-box {
  padding-right: 0;
}
.answers {
  margin-right: 0;
}
.particle {
  z-index: 30;
}
@media (min-width: 801px) {
  .companion {
    right: max(22px, calc((100vw - 900px) / 2));
    bottom: 100px;
  }
}
@media (max-width: 800px) {
  .companion {
    width: 76px;
    height: 80px;
    right: 15px;
    bottom: 94px;
    left: auto;
    top: auto;
  }
  .illustrated-explorer {
    width: 76px;
    height: 80px;
  }
  h2 {
    margin: 8px 0 22px;
    min-height: 95px;
    font-size: 21px;
    max-width: none;
  }
  .workspace {
    padding-bottom: 107px;
  }
  .question-box {
    padding-bottom: 70px;
  }
}
@media (max-width: 420px) {
  h2 {
    font-size: 20px;
    margin-left: 0;
  }
  .companion {
    width: 70px;
    height: 74px;
    right: 12px;
  }
  .illustrated-explorer {
    width: 70px;
    height: 74px;
  }
}
@media (max-height: 700px) {
  .companion {
    width: 65px;
    height: 69px;
    bottom: 86px;
    top: auto;
    left: auto;
  }
  .illustrated-explorer {
    width: 65px;
    height: 69px;
  }
  h2 {
    margin: 6px 0 17px;
    min-height: 75px;
    font-size: 19px;
  }
  .question-box {
    padding-bottom: 60px;
  }
  .workspace {
    padding-bottom: 94px;
  }
}
/* Supporting companion: lower left, with varied, restrained motion. */
.companion {
  left: max(18px, calc((100vw - 900px) / 2));
  right: auto;
  bottom: 100px;
}
.illustrated-explorer {
  will-change: transform;
  transform-origin: 50% 95%;
}
.illustrated-explorer.idle-breathe {
  animation: companionBreathe 3.2s ease-in-out;
}
.illustrated-explorer.idle-peek {
  animation: companionPeek 2.6s ease-in-out;
}
.illustrated-explorer.idle-sway {
  animation: companionSway 3.4s ease-in-out;
}
.illustrated-explorer.think-tilt {
  animation: companionThink 2.8s ease-in-out;
}
.illustrated-explorer.think-nod {
  animation: companionNod 2.5s ease-in-out;
}
.illustrated-explorer.think-pause {
  animation: companionPause 3s ease-in-out;
}
.illustrated-explorer.idle-breathe .sprite-frame,
.illustrated-explorer.idle-peek .sprite-frame,
.illustrated-explorer.idle-sway .sprite-frame {
  background-position: 0 0;
}
.illustrated-explorer.think-tilt .sprite-frame,
.illustrated-explorer.think-nod .sprite-frame,
.illustrated-explorer.think-pause .sprite-frame {
  background-position: 100% 0;
}
@keyframes companionBreathe {
  0%,
  100% {
    transform: none;
  }
  50% {
    transform: scale(1.015, 1.035) translateY(-1px);
  }
}
@keyframes companionPeek {
  0%,
  25%,
  100% {
    transform: none;
  }
  40%,
  65% {
    transform: translateY(-5px) rotate(4deg);
  }
  80% {
    transform: rotate(-2deg);
  }
}
@keyframes companionSway {
  0%,
  100% {
    transform: none;
  }
  30% {
    transform: rotate(-3deg);
  }
  70% {
    transform: rotate(3deg);
  }
}
@keyframes companionThink {
  0%,
  100% {
    transform: none;
  }
  35%,
  65% {
    transform: rotate(-6deg) translateY(-2px);
  }
}
@keyframes companionNod {
  0%,
  35%,
  100% {
    transform: none;
  }
  48% {
    transform: translateY(3px) rotate(3deg);
  }
  65% {
    transform: translateY(-2px) rotate(-2deg);
  }
}
@keyframes companionPause {
  0%,
  100% {
    transform: none;
  }
  30%,
  70% {
    transform: scale(1.02) rotate(2deg);
  }
}
@media (max-width: 800px) {
  .companion {
    left: 14px;
    right: auto;
    bottom: 94px;
  }
}
@media (max-height: 700px) {
  .companion {
    left: 12px;
    right: auto;
    bottom: 86px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .illustrated-explorer {
    animation: none !important;
    transform: none !important;
  }
}
.illustrated-explorer.celebrate.win-small {
  animation: smallWin 0.55s ease-out;
}
.illustrated-explorer.celebrate.win-three {
  animation: tripleWin 0.9s ease-in-out;
}
.illustrated-explorer.celebrate.win-five {
  animation: fiveWin 1.2s ease-in-out;
}
.illustrated-explorer.celebrate.win-ten {
  animation: tenWin 1.6s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes smallWin {
  40% {
    transform: translateY(-7px) rotate(-3deg);
  }
  75% {
    transform: scale(1.03, 0.97);
  }
}
@keyframes tripleWin {
  25% {
    transform: translateY(-17px) rotate(-6deg);
  }
  55% {
    transform: translateY(-7px) rotate(5deg);
  }
  80% {
    transform: scale(1.08, 0.94);
  }
}
@keyframes fiveWin {
  20% {
    transform: translateY(-22px) rotate(-9deg);
  }
  45% {
    transform: translateY(-8px) rotate(8deg);
  }
  65% {
    transform: translateY(-17px) rotate(-5deg);
  }
  85% {
    transform: scale(1.1, 0.92);
  }
}
@keyframes tenWin {
  15% {
    transform: scale(1.12, 0.88);
  }
  35% {
    transform: translateY(-36px) rotate(-12deg) scale(1.12);
  }
  55% {
    transform: translateY(-22px) rotate(12deg) scale(1.08);
  }
  75% {
    transform: translateY(-12px) rotate(-6deg);
  }
  90% {
    transform: scale(1.12, 0.9);
  }
}
@media (prefers-reduced-motion: reduce) {
  .illustrated-explorer {
    animation: none !important;
    transform: none !important;
  }
}
.companion.battle {
  position: fixed;
  left: 20px;
  right: auto;
  bottom: 94px;
  top: auto;
  width: 390px;
  height: 150px;
  display: block;
  z-index: 4;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(0deg, #f1e7fa 0, #f8f3fd 52%, transparent 53%);
  pointer-events: none;
}
.battle-status {
  position: absolute;
  left: 10px;
  top: 3px;
  font:
    600 10px "DM Sans",
    sans-serif;
  color: #8d78a5;
  letter-spacing: 0.2px;
}
.party {
  position: absolute;
  left: 0;
  bottom: 9px;
  width: 225px;
  height: 110px;
}
.fighter {
  position: absolute;
  width: 78px;
  height: 82px;
  bottom: 0;
  transform-origin: 50% 95%;
  transition: opacity 0.2s;
  will-change: transform;
}
.fighter i {
  display: block;
  width: 100%;
  height: 100%;
  background-image: var(--atlas, url(battle-cast.png));
  background-size: 400% 400%;
  background-position: calc(var(--cx, 0) * 100% / 3)
    calc(var(--cy, 0) * 100% / 3);
  background-repeat: no-repeat;
}
.role-builder {
  --atlas: url(builder-atlas.png);
}
.role-keeper {
  --atlas: url(keeper-atlas.png);
}
.role-explorer {
  --atlas: url(explorer-atlas.png);
}
.role-guide {
  --atlas: url(guide-atlas.png);
}
.party .fighter:nth-child(1) {
  left: 0;
  bottom: 18px;
  z-index: 1;
}
.party .fighter:nth-child(2) {
  left: 42px;
  bottom: 30px;
  z-index: 2;
}
.party .fighter:nth-child(3) {
  left: 83px;
  bottom: 12px;
  z-index: 3;
}
.party .fighter:nth-child(4) {
  left: 132px;
  bottom: 0;
  z-index: 4;
}
.party .fighter.active {
  filter: drop-shadow(0 3px 0 #aa7de7);
  z-index: 6;
}
.fighter:not(.active).ally {
  opacity: 0.85;
}
.rivals {
  position: absolute;
  right: 0;
  bottom: 10px;
  width: 130px;
  height: 100px;
}
.rival {
  transform: scaleX(-1);
}
.rival:first-child {
  left: 0;
  z-index: 3;
}
.rival:last-child {
  left: 48px;
  bottom: 18px;
  opacity: 0.8;
}
.battle-line {
  position: absolute;
  bottom: 10px;
  left: 12px;
  right: 12px;
  height: 3px;
  border-radius: 50%;
  background: #d9c5ea;
}
.battle-bolt {
  position: absolute;
  left: 185px;
  bottom: 49px;
  font-size: 27px;
  color: #eec354;
  opacity: 0;
  text-shadow: 0 0 8px #fff;
}
.battle-hit {
  position: absolute;
  right: 49px;
  bottom: 47px;
  font-size: 45px;
  color: #eab34e;
  opacity: 0;
}
.battle.striking .battle-bolt {
  animation: boltFly 0.55s 0.25s ease-in forwards;
}
.battle.striking .battle-hit {
  animation: hitFlash 0.45s 0.65s ease-out;
}
.rival.defeated {
  animation: rivalDefeat 0.55s ease-in forwards;
}
.ally.lunge {
  animation: allyLunge 0.8s ease-in-out;
}
.ally.recoil {
  animation: allyRecoil 0.7s ease-in-out;
}
.battle.counter .battle-bolt {
  animation: counterBolt 0.5s ease-in forwards;
}
.battle.swapping .party .active {
  animation: swapIn 0.45s ease-out;
}
.battle.big-hit .battle-hit {
  font-size: 65px;
  color: #c484f6;
}
.battle-status strong {
  color: #8153b4;
}
.question-box {
  padding-bottom: 155px;
}
@keyframes boltFly {
  0% {
    opacity: 0;
    transform: translateX(0) scale(0.5);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(115px) scale(1.3);
  }
}
@keyframes counterBolt {
  0% {
    opacity: 1;
    transform: translateX(110px);
  }
  100% {
    opacity: 0;
    transform: translateX(-50px);
  }
}
@keyframes hitFlash {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  30% {
    opacity: 1;
    transform: scale(1.3) rotate(25deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.9) rotate(60deg);
  }
}
@keyframes rivalDefeat {
  40% {
    filter: brightness(2);
    transform: scaleX(-1) rotate(-12deg);
  }
  100% {
    opacity: 0;
    transform: scaleX(-1) translateY(-25px) scale(0.2);
  }
}
@keyframes allyLunge {
  30% {
    transform: translateX(-7px) rotate(-5deg);
  }
  60% {
    transform: translateX(23px) rotate(6deg);
  }
  100% {
    transform: none;
  }
}
@keyframes allyRecoil {
  30% {
    transform: translateX(-13px) rotate(-10deg);
  }
  100% {
    transform: none;
  }
}
@keyframes swapIn {
  0% {
    opacity: 0.3;
    transform: translateY(14px);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}
@media (min-width: 1100px) {
  .companion.battle {
    left: max(20px, calc((100vw - 1050px) / 2));
    width: 360px;
    height: 140px;
  }
}
@media (max-width: 800px) {
  .companion.battle {
    left: 8px;
    bottom: 88px;
    width: 300px;
    height: 120px;
  }
  .party {
    width: 175px;
    height: 90px;
  }
  .fighter {
    width: 64px;
    height: 68px;
  }
  .party .fighter:nth-child(1) {
    left: 0;
    bottom: 11px;
  }
  .party .fighter:nth-child(2) {
    left: 31px;
    bottom: 24px;
  }
  .party .fighter:nth-child(3) {
    left: 63px;
    bottom: 8px;
  }
  .party .fighter:nth-child(4) {
    left: 101px;
    bottom: 0;
  }
  .rivals {
    width: 98px;
    height: 80px;
  }
  .rival:last-child {
    left: 35px;
  }
  .battle-status {
    font-size: 9px;
    top: 0;
  }
  .battle-bolt {
    left: 142px;
    bottom: 40px;
  }
  .battle-hit {
    right: 30px;
    bottom: 31px;
  }
  .question-box {
    padding-bottom: 125px;
  }
}
@media (max-height: 700px) {
  .companion.battle {
    bottom: 82px;
    height: 105px;
    width: 280px;
  }
  .battle-status {
    font-size: 8px;
  }
  .question-box {
    padding-bottom: 110px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .fighter,
  .fighter i {
    transition: none !important;
  }
  .battle-bolt,
  .battle-hit {
    display: none;
  }
  .rival.defeated {
    opacity: 0;
  }
}
:root {
  --accent: #8056c5;
  --accent-dark: #623b9f;
  --accent-soft: #f0e8ff;
  --accent-mid: #b290e8;
  --page-tint: #fffdf9;
}
[data-hero="builder"] {
  --accent: #366cda;
  --accent-dark: #2450a9;
  --accent-soft: #eaf1ff;
  --accent-mid: #93b3f3;
  --page-tint: #f8faff;
}
[data-hero="keeper"] {
  --accent: #178577;
  --accent-dark: #10695e;
  --accent-soft: #e3f6f0;
  --accent-mid: #76c5b8;
  --page-tint: #f6fcf9;
}
[data-hero="explorer"] {
  --accent: #8056c5;
  --accent-dark: #623b9f;
  --accent-soft: #f0e8ff;
  --accent-mid: #b290e8;
  --page-tint: #fcf9ff;
}
[data-hero="guide"] {
  --accent: #96611c;
  --accent-dark: #75470e;
  --accent-soft: #fff1cf;
  --accent-mid: #dfb75f;
  --page-tint: #fffaf0;
}
body,
.actions,
header button {
  background: var(--page-tint);
  transition: background-color 0.45s;
}
.primary {
  background: var(--accent);
  border-color: var(--accent-dark);
}
.progress i {
  background: var(--accent);
  box-shadow: inset 0 3px 0 var(--accent-mid);
}
.eyebrow {
  color: var(--accent);
}
.answer.selected {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
  color: var(--accent-dark);
}
.answer.selected .letter {
  border-color: var(--accent-mid);
  color: var(--accent-dark);
}
.answer:hover {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
}
.help-button {
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.companion.battle {
  background: linear-gradient(0deg, var(--accent-soft), transparent 85%);
}
.party .fighter.active {
  filter: drop-shadow(0 3px 0 var(--accent-mid));
}
.battle-status {
  color: var(--accent-dark);
}
.battle-line {
  background: var(--accent-mid);
}
.battle-bolt {
  color: var(--accent);
}
.actions {
  border-color: var(--accent-soft);
}
/* Battle is visual: no narrative captions. */
.battle-status {
  display: none !important;
}
.battle-xp {
  position: absolute;
  left: 8px;
  top: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--accent-dark);
  z-index: 8;
}
.battle-xp span {
  color: #eab743;
  font-size: 17px;
}
.enemy-health {
  position: absolute;
  right: 17px;
  top: 26px;
  width: 75px;
  height: 10px;
  background: #e0d4dd;
  border: 2px solid #554154;
  border-radius: 8px;
  overflow: visible;
  z-index: 8;
}
.enemy-health i {
  display: block;
  height: 100%;
  background: #d96274;
  border-radius: 6px;
  transition: width 0.35s;
}
.enemy-health span {
  position: absolute;
  top: -18px;
  left: 0;
  right: 0;
  font-size: 9px;
  font-weight: 800;
  color: #8e4659;
  text-align: center;
}
.boss .enemy-health {
  border-color: #5d355e;
}
.boss .enemy-health i {
  background: #b54d9a;
}
.rivals .fighter {
  background: none;
  transform: none;
  width: 100px;
  height: 100px;
  left: 8px;
  bottom: 0;
  opacity: 1;
}
.rival i {
  background-image: url(rival-atlas.png);
  background-size: 400% 200%;
  background-position: calc(var(--enemy-col, 0) * 100% / 3)
    calc(var(--enemy-row, 0) * 100%);
}
.rival:last-child {
  display: none;
}
.rivals {
  right: 0;
  bottom: 9px;
  width: 115px;
  height: 100px;
}
.rival.defeated {
  animation: evilDefeat 0.7s ease-in forwards;
}
.party .fighter.ally {
  width: 55px;
  height: 58px;
  opacity: 0.55;
  filter: saturate(0.55);
  bottom: 5px;
}
.party .fighter.ally:nth-child(1) {
  left: 0;
  bottom: 4px;
}
.party .fighter.ally:nth-child(2) {
  left: 32px;
  bottom: 10px;
}
.party .fighter.ally:nth-child(3) {
  left: 64px;
  bottom: 4px;
}
.party .fighter.ally.active {
  left: 100px;
  bottom: 0;
  width: 100px;
  height: 106px;
  opacity: 1;
  filter: drop-shadow(0 3px 0 var(--accent-mid));
  z-index: 8;
}
.party:after {
  content: "";
  position: absolute;
  left: 119px;
  bottom: 0;
  width: 62px;
  height: 9px;
  border: 2px solid var(--accent-mid);
  background: var(--accent-soft);
  border-radius: 50%;
  z-index: 0;
}
.xp-popup {
  position: absolute;
  right: 24px;
  bottom: 65px;
  font:
    800 19px "Outfit",
    sans-serif;
  color: #a56c0f;
  text-shadow: 0 2px white;
  opacity: 0;
  z-index: 15;
  pointer-events: none;
}
.earned-xp .xp-popup {
  animation: xpRise 1.5s ease-out forwards;
}
.regenerating .enemy-health {
  animation: regenPulse 0.8s ease-in-out 2;
}
.regenerating .enemy-health i {
  background: #67b58b;
}
.battle-hit {
  z-index: 12;
}
.battle-bolt {
  z-index: 10;
}
@keyframes xpRise {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.7);
  }
  20% {
    opacity: 1;
    transform: scale(1.15);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-35px);
  }
}
@keyframes regenPulse {
  50% {
    filter: drop-shadow(0 0 5px #55c98a);
    transform: scale(1.08);
  }
}
@keyframes evilDefeat {
  30% {
    filter: brightness(1.8);
    transform: rotate(10deg);
  }
  65% {
    opacity: 1;
    transform: translateY(-8px) scale(0.9);
  }
  100% {
    opacity: 0;
    transform: translateY(-20px) scale(0.1);
  }
}
@media (max-width: 800px) {
  .companion.battle {
    height: 128px;
    width: 310px;
  }
  .party .fighter.ally {
    width: 44px;
    height: 47px;
  }
  .party .fighter.ally:nth-child(1) {
    left: 0;
  }
  .party .fighter.ally:nth-child(2) {
    left: 25px;
  }
  .party .fighter.ally:nth-child(3) {
    left: 50px;
  }
  .party .fighter.ally.active {
    left: 77px;
    width: 82px;
    height: 87px;
  }
  .party:after {
    left: 90px;
    width: 52px;
  }
  .rivals {
    width: 100px;
    height: 85px;
  }
  .rivals .fighter {
    width: 85px;
    height: 85px;
    left: 0;
  }
  .enemy-health {
    right: 15px;
    top: 32px;
    width: 65px;
  }
  .battle-xp {
    font-size: 10px;
  }
  .xp-popup {
    right: 20px;
    font-size: 16px;
  }
  .question-box {
    padding-bottom: 130px;
  }
}
@media (max-height: 700px) {
  .companion.battle {
    height: 115px;
  }
  .enemy-health {
    top: 22px;
  }
  .question-box {
    padding-bottom: 118px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .xp-popup {
    animation: none !important;
  }
  .earned-xp .xp-popup {
    opacity: 1;
  }
  .rival.defeated {
    opacity: 0;
  }
  .enemy-health i {
    transition: none;
  }
}
/* Battle stage sits above the question; correct answers advance after combat. */
.companion.battle {
  position: fixed;
  top: 67px;
  bottom: auto;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: 360px;
  height: 140px;
  z-index: 4;
}
.workspace {
  padding-top: 224px;
}
.primary[hidden] {
  display: none !important;
}
.actions:has(.primary[hidden]) {
  justify-content: center;
}
.actions:has(.primary[hidden]) .help-button,
.actions:has(.primary[hidden]) .text-button {
  opacity: 0.4;
  cursor: default;
}
.question-box {
  padding-bottom: 12px;
}
.battle-xp {
  top: 0;
}
@media (min-height: 850px) {
  .workspace {
    padding-top: 244px;
  }
  .companion.battle {
    top: 80px;
    height: 150px;
  }
}
@media (max-width: 800px) {
  .companion.battle {
    top: 61px;
    bottom: auto;
    left: 50%;
    right: auto;
    width: 310px;
    height: 128px;
  }
  .workspace {
    padding-top: 197px;
  }
  .question-box {
    padding-bottom: 10px;
  }
  h1 {
    font-size: 22px;
    margin: 3px 0 8px;
  }
  h2 {
    min-height: 65px;
    margin: 7px 0 19px;
    font-size: 20px;
  }
}
@media (max-height: 700px) {
  .companion.battle {
    top: 56px;
    bottom: auto;
    left: 50%;
    width: 280px;
    height: 106px;
  }
  .workspace {
    padding-top: 169px;
  }
  h1 {
    font-size: 20px;
    margin: 2px 0 6px;
  }
  h2 {
    font-size: 18px;
    min-height: 55px;
    margin: 4px 0 13px;
  }
  .question-box {
    padding-bottom: 8px;
  }
}
.primary {
  display: none !important;
}
body:has(.incorrect) .primary:not([hidden]) {
  display: block !important;
}
.answer {
  touch-action: manipulation;
  user-select: none;
}
.actions {
  justify-content: center;
}
.actions .primary {
  margin-left: auto;
}
.answer.selected:not(:disabled) {
  flex-wrap: wrap;
}
.answer.selected:not(:disabled)::after {
  content: "Click again to answer";
  display: block;
  flex-basis: 100%;
  padding-left: 43px;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-dark);
  letter-spacing: 0;
  line-height: 1.3;
}
@media (pointer: coarse) {
  .answer.selected:not(:disabled)::after {
    content: "Tap again to answer";
  }
}
body:has(.incorrect) .primary:not([hidden]) {
  display: none !important;
}
.answer.incorrect:not(:disabled)::after {
  content: "Okay — click to continue";
  color: #a54b3a;
}
.answer.incorrect:not(:disabled) {
  cursor: pointer;
}
@media (pointer: coarse) {
  .answer.incorrect:not(:disabled)::after {
    content: "Okay — tap to continue";
  }
}
