:root {
  color-scheme: light;
  --paper: #fffdf8;
  --ink: #162033;
  --soft-ink: #536078;
  --line: rgba(20, 27, 46, 0.14);
  --theme-a: #22d3ee;
  --theme-b: #8b5cf6;
  --theme-c: #a3e635;
  --theme-dark: #13162b;
  --radius: 28px;
  --shadow: 0 28px 80px rgba(17, 24, 39, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #f6f8ff;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    ui-rounded, "Avenir Next Rounded", "Nunito", "Trebuchet MS", "Arial Rounded MT Bold", system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(115deg, color-mix(in srgb, var(--theme-a) 16%, transparent), transparent 34%),
    linear-gradient(245deg, color-mix(in srgb, var(--theme-b) 16%, transparent), transparent 38%),
    linear-gradient(180deg, #fffaf0, #eef6ff 54%, #f8fbff);
  transition: background 280ms ease;
}

body[data-theme="kpop"] {
  --theme-dark: #261142;
  background:
    linear-gradient(115deg, rgba(255, 79, 216, 0.22), transparent 34%),
    linear-gradient(245deg, rgba(24, 214, 255, 0.18), transparent 42%),
    linear-gradient(180deg, #fff1fb, #f7f1ff 52%, #ecfbff);
}

body[data-theme="gaming"] {
  --theme-dark: #101a36;
  background:
    linear-gradient(115deg, rgba(34, 211, 238, 0.2), transparent 34%),
    linear-gradient(245deg, rgba(163, 230, 53, 0.16), transparent 42%),
    linear-gradient(180deg, #eefcff, #f1f3ff 52%, #f7ffef);
}

body[data-theme="football"] {
  --theme-dark: #0d3522;
  background:
    linear-gradient(115deg, rgba(34, 197, 94, 0.2), transparent 34%),
    linear-gradient(245deg, rgba(250, 204, 21, 0.18), transparent 42%),
    linear-gradient(180deg, #f1fff6, #eff7ff 52%, #fffbea);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.app {
  width: min(1180px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 38px;
}

.screen[hidden] {
  display: none;
}

.home-screen {
  display: grid;
  min-height: calc(100vh - 60px);
  align-content: center;
  gap: 28px;
}

.home-copy {
  max-width: 920px;
  margin: 0 auto;
  text-align: center;
}

.eyebrow,
.question-kicker {
  color: color-mix(in srgb, var(--theme-b) 76%, #111);
  font-size: 0.82rem;
  font-weight: 1000;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-top: 10px;
  color: var(--theme-dark);
  font-size: clamp(3.2rem, 10vw, 8.2rem);
  line-height: 0.88;
  letter-spacing: 0;
}

.home-copy > p:last-child {
  max-width: 720px;
  margin: 22px auto 0;
  color: var(--soft-ink);
  font-size: clamp(1.08rem, 2.2vw, 1.42rem);
  font-weight: 820;
  line-height: 1.45;
}

.theme-select {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.theme-card {
  position: relative;
  min-height: 290px;
  padding: 24px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
  color: var(--ink);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--card-a) 22%, #fff), color-mix(in srgb, var(--card-b) 16%, #fff)),
    var(--paper);
  text-align: left;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.theme-card::before {
  position: absolute;
  inset: auto -28px -42px auto;
  width: 180px;
  height: 130px;
  border-radius: 46px;
  content: "";
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.42) 0 12px, transparent 12px 24px),
    linear-gradient(135deg, var(--card-a), var(--card-b));
  transform: rotate(-10deg);
}

.theme-card > * {
  position: relative;
  z-index: 1;
}

.theme-card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 34px 90px rgba(17, 24, 39, 0.24);
}

.theme-card .icon {
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  border: 4px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  color: #071015;
  background: linear-gradient(135deg, var(--card-c), var(--card-a));
  font-size: 2rem;
  font-weight: 1000;
  box-shadow: 0 14px 34px color-mix(in srgb, var(--card-a) 28%, transparent);
}

.theme-card h2 {
  margin-top: 20px;
  color: var(--theme-dark);
  font-size: clamp(1.7rem, 3vw, 2.75rem);
  line-height: 0.96;
}

.theme-card p {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  max-width: 28ch;
  color: #334155;
  font-size: 1.02rem;
  font-weight: 820;
  line-height: 1.42;
}

.game-screen {
  display: grid;
  min-height: calc(100vh - 60px);
  grid-template-rows: auto auto 1fr;
}

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
}

.quiet-button,
.primary-button {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  font-weight: 1000;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.quiet-button {
  padding: 0 18px;
  color: var(--theme-dark);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.08);
}

.quiet-button:hover,
.primary-button:hover {
  transform: translateY(-2px);
}

.mission-counter {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  text-align: right;
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.08);
}

.mission-counter span,
.mission-counter strong {
  display: block;
}

.mission-counter span {
  color: var(--soft-ink);
  font-size: 0.82rem;
  font-weight: 950;
}

.mission-counter strong {
  margin-top: 1px;
  color: var(--theme-dark);
  font-size: 1.08rem;
}

.progress-dots {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 18px;
}

.dot {
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
}

.dot.done {
  background: linear-gradient(90deg, var(--theme-c), var(--theme-a));
}

.dot.current {
  background: var(--theme-a);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--theme-a) 18%, transparent);
}

.universe-stage {
  position: relative;
  display: grid;
  min-height: 700px;
  place-items: center;
  padding: clamp(16px, 3vw, 34px);
  border-radius: 48px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--theme-a) 15%, #fff), color-mix(in srgb, var(--theme-b) 12%, #fff)),
    rgba(255, 255, 255, 0.62);
  box-shadow: 0 30px 100px rgba(17, 24, 39, 0.16);
  overflow: hidden;
}

.world-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stage-beam,
.stage-star,
.game-tile,
.game-orb,
.pitch-ball,
.pitch-line {
  position: absolute;
  display: none;
}

body[data-theme="kpop"] .stage-beam {
  display: block;
  top: -80px;
  width: 150px;
  height: 780px;
  border-radius: 80px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--theme-a) 54%, transparent), transparent);
  opacity: 0.55;
  transform-origin: top center;
}

body[data-theme="kpop"] .stage-star {
  display: block;
  width: 84px;
  height: 84px;
  background: var(--theme-c);
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
  opacity: 0.82;
  filter: drop-shadow(0 12px 20px rgba(255, 79, 216, 0.22));
}

body[data-theme="kpop"] .star-one {
  left: 12%;
  bottom: 16%;
  transform: rotate(-14deg);
}

body[data-theme="kpop"] .star-two {
  right: 13%;
  top: 18%;
  width: 58px;
  height: 58px;
  transform: rotate(18deg);
}

body[data-theme="kpop"] .beam-one {
  left: 8%;
  transform: rotate(-18deg);
}

body[data-theme="kpop"] .beam-two {
  right: 8%;
  transform: rotate(18deg);
}

body[data-theme="gaming"] .game-tile {
  display: block;
  width: 170px;
  height: 120px;
  border: 4px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.25) 2px, transparent 2px),
    linear-gradient(rgba(255, 255, 255, 0.22) 2px, transparent 2px),
    linear-gradient(135deg, var(--theme-b), var(--theme-a));
  background-size: 28px 28px, 28px 28px, auto;
  box-shadow: 0 22px 44px rgba(17, 24, 39, 0.18);
}

body[data-theme="gaming"] .game-orb {
  display: block;
  width: 92px;
  height: 92px;
  border: 5px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  background:
    linear-gradient(135deg, var(--theme-c), var(--theme-a));
  box-shadow: 0 18px 38px rgba(17, 24, 39, 0.16);
}

body[data-theme="gaming"] .orb-one {
  left: 12%;
  bottom: 18%;
  transform: rotate(18deg);
}

body[data-theme="gaming"] .orb-two {
  right: 18%;
  top: 12%;
  width: 62px;
  height: 62px;
  border-radius: 20px;
  transform: rotate(-16deg);
}

body[data-theme="gaming"] .tile-one {
  left: 5%;
  top: 18%;
  transform: rotate(-9deg);
}

body[data-theme="gaming"] .tile-two {
  right: 6%;
  bottom: 14%;
  transform: rotate(8deg);
}

body[data-theme="football"] .pitch-line {
  display: block;
  border: 5px solid rgba(255, 255, 255, 0.68);
}

body[data-theme="football"] .line-one {
  inset: 64px 7% auto;
  height: 210px;
  border-radius: 34px;
}

body[data-theme="football"] .line-two {
  left: 50%;
  top: 64px;
  width: 5px;
  height: calc(100% - 128px);
  border-width: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
}

body[data-theme="football"] .pitch-ball {
  display: block;
  right: 11%;
  bottom: 16%;
  width: 92px;
  height: 92px;
  border: 7px solid var(--theme-dark);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--theme-dark) 0 14%, transparent 15%),
    conic-gradient(from 20deg, #fff 0 12%, #e9f0ff 12% 24%, #fff 24% 36%, #e9f0ff 36% 48%, #fff 48% 60%, #e9f0ff 60% 72%, #fff 72% 84%, #e9f0ff 84% 100%);
  box-shadow: 0 18px 32px rgba(17, 24, 39, 0.18);
}

.story-card {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(960px, 100%);
  padding: clamp(24px, 5vw, 58px);
  border: 5px solid rgba(255, 255, 255, 0.78);
  border-radius: 44px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.82)),
    var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}

.chapter-chip {
  display: inline-flex;
  justify-self: center;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 14px 6px 7px;
  border-radius: 999px;
  color: #fff;
  background: var(--theme-dark);
  font-size: 0.8rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.chapter-chip span {
  display: grid;
  min-width: 76px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  color: #071015;
  background: linear-gradient(135deg, var(--theme-c), var(--theme-a));
}

.story-card h2 {
  margin-top: 18px;
  color: var(--theme-dark);
  font-size: clamp(2.25rem, 5.6vw, 5.05rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.story-text {
  max-width: 805px;
  margin: 28px auto 0;
  color: #334155;
  font-size: clamp(1.22rem, 2.4vw, 1.68rem);
  font-weight: 830;
  line-height: 1.55;
  text-align: left;
}

.math-sentence {
  display: block;
  margin-top: 0.85em;
  color: var(--theme-dark);
  font-weight: 1000;
}

.math-note {
  max-width: 760px;
  margin: 24px auto 0;
  padding: clamp(16px, 2.4vw, 22px);
  border: 3px dashed color-mix(in srgb, var(--theme-a) 42%, #fff);
  border-radius: 30px 30px 30px 12px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--theme-c) 24%, #fff), color-mix(in srgb, var(--theme-a) 14%, #fff)),
    #fff;
  text-align: left;
}

.question-kicker {
  display: block;
}

.math-note p {
  margin-top: 8px;
  color: var(--theme-dark);
  font-size: clamp(1.02rem, 2vw, 1.22rem);
  font-weight: 950;
  line-height: 1.34;
}

.math-note small {
  display: block;
  max-width: 54ch;
  margin: 10px 0 0;
  color: #516077;
  font-size: 0.94rem;
  font-weight: 850;
  line-height: 1.34;
}

.answer-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  max-width: 600px;
  width: 100%;
  margin: 22px auto 0;
}

.answer-form input {
  min-height: 58px;
  width: 100%;
  padding: 0 18px;
  border: 3px solid color-mix(in srgb, var(--theme-a) 38%, #fff);
  border-radius: 999px;
  color: var(--theme-dark);
  background: #fff;
  font-size: 1.2rem;
  font-weight: 950;
  outline: none;
  box-shadow: inset 0 3px 0 rgba(17, 24, 39, 0.04);
}

.answer-form input:focus {
  border-color: var(--theme-b);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--theme-b) 16%, transparent);
}

.primary-button {
  padding: 0 22px;
  color: #071015;
  background: linear-gradient(135deg, var(--theme-c), var(--theme-a));
  box-shadow: 0 14px 30px color-mix(in srgb, var(--theme-a) 24%, transparent);
}

.feedback,
.solution {
  max-width: 730px;
  margin: 16px auto 0;
  padding: 14px 16px;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.45;
}

.feedback.correct {
  color: #07351c;
  background: #b9fbc7;
}

.feedback.wrong {
  color: #541220;
  background: #ffc0cc;
}

.solution {
  border: 2px solid color-mix(in srgb, var(--theme-a) 26%, #fff);
  color: #2b3448;
  background: #fff;
  text-align: left;
}

.solution strong {
  color: var(--theme-dark);
}

.solution ol {
  margin: 10px 0 0;
  padding-left: 1.3rem;
}

.solution li + li {
  margin-top: 6px;
}

.story-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

#confettiLayer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.confetti-piece {
  position: absolute;
  top: -18px;
  width: 10px;
  height: 16px;
  border-radius: 5px;
  background: var(--piece-color);
  animation: confetti-fall var(--fall-time) ease-in forwards;
}

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

@keyframes confetti-fall {
  to {
    transform: translate3d(var(--drift), 104vh, 0) rotate(680deg);
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .theme-select {
    grid-template-columns: 1fr;
  }

  .theme-card {
    min-height: 230px;
  }

  .universe-stage {
    min-height: 0;
    padding: 12px;
    border-radius: 30px;
  }

  .answer-form {
    grid-template-columns: 1fr;
  }

  .story-actions {
    display: grid;
  }
}

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

  .game-top {
    align-items: stretch;
  }

  .progress-dots {
    gap: 5px;
  }

  .dot {
    height: 10px;
  }

  .story-card {
    border-width: 3px;
    border-radius: 30px;
  }
}
