:root {
  color-scheme: light;
  --ink: #1d2433;
  --muted: #5d6a7c;
  --paper: #fffdf8;
  --line: rgba(29, 36, 51, 0.12);
  --yellow: #f8c545;
  --green: #36b37e;
  --blue: #3d8bfd;
  --coral: #ff7a6b;
  --lilac: #8f7cf6;
  --shadow: 0 18px 45px rgba(35, 50, 80, 0.16);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #f2f7f4;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  overflow-x: hidden;
}

.hero-band {
  position: relative;
  min-height: 330px;
  padding: max(18px, env(safe-area-inset-top)) clamp(18px, 4vw, 48px) 34px;
  overflow: hidden;
  background: linear-gradient(180deg, #85d7ff 0%, #dbf6ff 60%, #f2f7f4 100%);
}

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

.sun {
  position: absolute;
  right: 9%;
  top: 72px;
  width: 86px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 34%, #fff8b4, var(--yellow) 62%, #f4a82b);
  box-shadow: 0 0 0 18px rgba(248, 197, 69, 0.18);
}

.cloud {
  position: absolute;
  width: 118px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  width: 52px;
  height: 52px;
  left: 20px;
  top: -26px;
}

.cloud::after {
  width: 62px;
  height: 62px;
  right: 18px;
  top: -32px;
}

.cloud-a {
  left: 10%;
  top: 90px;
}

.cloud-b {
  right: 24%;
  top: 164px;
  transform: scale(0.72);
}

.island {
  position: absolute;
  bottom: 24px;
  width: 210px;
  height: 92px;
  border-radius: 50% 50% 42% 42%;
  background: linear-gradient(180deg, #58c783 0%, #3f9f63 62%, #b87448 63%, #8f5634 100%);
  box-shadow: inset 0 -14px rgba(29, 36, 51, 0.08);
}

.island::before {
  content: "";
  position: absolute;
  left: 34px;
  top: -42px;
  width: 42px;
  height: 56px;
  border-radius: 50% 50% 12px 12px;
  background: var(--green);
  box-shadow: 62px 10px 0 #6bd18e, 108px -4px 0 #2fa56d;
}

.island-a {
  left: 6%;
}

.island-b {
  right: 10%;
  bottom: 4px;
  transform: scale(0.76);
  opacity: 0.86;
}

.top-bar,
.hero-content,
.progress-band,
.name-band,
.map-band,
.play-band,
.reward-band {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button,
.player-chip,
.text-button,
button {
  min-height: 44px;
  border-radius: 8px;
}

.icon-button {
  width: 48px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(35, 50, 80, 0.12);
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 20px rgba(35, 50, 80, 0.12);
  font-weight: 700;
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--yellow);
  color: #7c4a00;
}

.hero-content {
  display: grid;
  grid-template-columns: 1fr 210px;
  align-items: end;
  gap: 22px;
  min-height: 230px;
  padding-top: 36px;
}

.eyebrow {
  margin: 0 0 8px;
  font-weight: 800;
  color: #19597c;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(46px, 8vw, 86px);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 560px;
  margin-bottom: 0;
  color: #32465f;
  font-size: clamp(18px, 2.6vw, 23px);
  line-height: 1.55;
  font-weight: 650;
}

.mascot {
  justify-self: end;
  width: min(210px, 28vw);
  aspect-ratio: 1;
  border-radius: 42% 58% 48% 52%;
  background: linear-gradient(145deg, #ffffff, #ffd66d 55%, #ff9c60);
  box-shadow: var(--shadow);
  transform: rotate(-7deg);
}

.mascot-face {
  position: relative;
  width: 100%;
  height: 100%;
}

.mascot-face span {
  position: absolute;
  top: 42%;
  width: 18px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--ink);
}

.mascot-face span:first-child {
  left: 34%;
}

.mascot-face span:last-child {
  right: 34%;
}

.mascot-face::after {
  content: "";
  position: absolute;
  left: 37%;
  top: 58%;
  width: 26%;
  height: 12%;
  border-bottom: 7px solid var(--ink);
  border-radius: 50%;
}

.progress-band {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: -22px;
}

.stat,
.name-band,
.question-card,
.reward-scene {
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.stat {
  min-height: 92px;
  padding: 16px;
  border-radius: 8px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.stat strong {
  font-size: 30px;
}

.stat span {
  color: var(--muted);
  font-weight: 700;
}

.name-band {
  margin-top: 18px;
  padding: 18px;
  border-radius: 8px;
}

.name-band label {
  display: block;
  margin-bottom: 10px;
  font-weight: 800;
}

.name-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 48px;
  border: 2px solid rgba(29, 36, 51, 0.16);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
}

button {
  padding: 0 18px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

button:active {
  transform: translateY(1px) scale(0.99);
}

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

.map-band,
.play-band,
.reward-band {
  margin-top: 28px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.section-title h2,
.play-header h2,
.reward-scene h2 {
  margin-bottom: 4px;
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: 0;
}

.section-title p,
.play-header p,
.reward-scene p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 650;
  line-height: 1.45;
}

.world-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stage-card {
  position: relative;
  min-height: 238px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 10px 28px rgba(35, 50, 80, 0.1);
  display: grid;
  align-content: space-between;
}

.stage-card::before {
  content: "";
  position: absolute;
  inset: auto -16px -34px -16px;
  height: 110px;
  background: var(--stage-color);
  opacity: 0.18;
  border-radius: 50% 50% 0 0;
  pointer-events: none;
}

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

.stage-card.locked {
  filter: grayscale(0.82);
}

.stage-number {
  position: absolute;
  top: 18px;
  right: 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.stage-art {
  position: relative;
  width: 92px;
  aspect-ratio: 1;
  border-radius: 26px 26px 34px 34px;
  background: var(--stage-color);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 42px;
  font-weight: 900;
  box-shadow: inset 0 -10px rgba(29, 36, 51, 0.1);
}

.stage-card h3 {
  margin: 14px 0 8px;
  font-size: 24px;
  letter-spacing: 0;
}

.stage-card p {
  min-height: 44px;
  margin-bottom: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.stage-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stars {
  color: #d89200;
  font-size: 22px;
  letter-spacing: 0;
}

.stage-card button {
  min-width: 96px;
  background: var(--stage-color);
}

.stage-card.locked button {
  background: #6f7785;
}

.play-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.text-button,
.secondary-button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.hearts {
  min-width: 96px;
  text-align: right;
  color: var(--coral);
  font-size: 24px;
}

.question-card {
  border-radius: 8px;
  padding: clamp(18px, 4vw, 34px);
}

.question-visual {
  min-height: 96px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}

.question-visual.is-empty {
  display: none;
}

.token-group {
  min-width: 84px;
  max-width: 46%;
  min-height: 72px;
  padding: 10px;
  border: 2px dashed rgba(29, 36, 51, 0.14);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 6px;
}

.count-token {
  display: grid;
  place-items: center;
  width: 34px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ffe08a;
  box-shadow: inset 0 -4px rgba(124, 74, 0, 0.12);
  color: #815400;
  font-size: 18px;
}

.count-token.taken-away {
  opacity: 0.38;
  text-decoration: line-through 3px var(--coral);
}

.question {
  margin-bottom: 22px;
  text-align: center;
  font-size: clamp(44px, 8vw, 78px);
  font-weight: 900;
  letter-spacing: 0;
}

.question.question-prompt {
  font-size: clamp(26px, 4vw, 38px);
}

.visual-shape {
  min-height: 210px;
  display: grid;
  align-content: center;
  gap: 10px;
}

.shape-equation,
.shape-question {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.5vw, 14px);
  min-height: 62px;
  font-size: clamp(28px, 5vw, 46px);
}

.shape-question {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 2px dashed rgba(29, 36, 51, 0.12);
}

.shape-token {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  line-height: 1;
  filter: drop-shadow(0 5px 4px rgba(29, 36, 51, 0.12));
}

.shape-1 {
  color: #e14f55;
}

.shape-2 {
  color: #267dc4;
}

.shape-3 {
  color: #d98700;
}

.shape-4 {
  color: #3c9c6d;
}

.shape-5 {
  color: #d84d89;
}

.shape-6 {
  color: #765bd3;
}

.math-sign {
  min-width: 24px;
  color: var(--ink);
  text-align: center;
  font-weight: 900;
}

.visual-vertical {
  min-height: 240px;
}

.vertical-stack {
  width: 174px;
  display: grid;
  justify-items: end;
  font-variant-numeric: tabular-nums;
}

.vertical-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 64px);
  justify-content: end;
  min-height: 66px;
  font-size: 48px;
  line-height: 1.2;
  font-weight: 900;
}

.vertical-result {
  padding-top: 8px;
  border-top: 5px solid var(--ink);
}

.vertical-operator {
  position: absolute;
  left: -34px;
  top: 0;
  color: var(--coral);
}

.digit-cell {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
}

.missing-digit {
  border: 3px solid var(--blue);
  background: #eaf4ff;
  color: var(--blue);
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.answer-grid button {
  min-height: 72px;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  border: 2px solid rgba(29, 36, 51, 0.12);
  box-shadow: 0 8px 18px rgba(35, 50, 80, 0.08);
  font-size: clamp(26px, 4vw, 38px);
}

.answer-grid button.correct {
  background: #dff8eb;
  border-color: var(--green);
}

.answer-grid button.wrong {
  background: #ffe7e4;
  border-color: var(--coral);
}

.feedback {
  min-height: 56px;
  margin-top: 12px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  text-align: center;
}

.reward-band {
  display: grid;
  place-items: center;
}

.reward-scene {
  position: relative;
  width: min(620px, 100%);
  min-height: 360px;
  padding: 68px 30px 36px;
  overflow: hidden;
  border-radius: 8px;
  text-align: center;
}

.reward-back {
  position: absolute;
  z-index: 3;
  left: 20px;
  top: 18px;
}

.reward-burst {
  position: relative;
  z-index: 2;
  font-size: 72px;
  color: #d89200;
  animation: pop 0.7s ease both;
}

.reward-scene h2,
.reward-scene p,
.reward-actions {
  position: relative;
  z-index: 2;
}

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

.confetti {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  left: var(--x);
  top: -24px;
  width: 10px;
  height: 18px;
  border-radius: 2px;
  background: var(--confetti-color);
  opacity: 0;
}

.celebrating .confetti span {
  animation: confetti-fall var(--duration) cubic-bezier(0.2, 0.7, 0.4, 1) var(--delay) forwards;
}

.celebrating .reward-scene {
  animation: reward-arrive 0.55s ease both;
}

.celebrating .reward-burst {
  animation: star-shine 0.9s ease 0.12s both;
}

.is-hidden {
  display: none;
}

@keyframes pop {
  0% {
    transform: scale(0.4) rotate(-18deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.12) rotate(4deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes reward-arrive {
  from {
    transform: translateY(24px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes star-shine {
  0% {
    transform: scale(0.2) rotate(-35deg);
    opacity: 0;
  }
  55% {
    transform: scale(1.35) rotate(12deg);
    text-shadow: 0 0 0 rgba(248, 197, 69, 0);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
    text-shadow: 0 0 28px rgba(248, 197, 69, 0.8);
  }
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, -18px, 0) rotate(0deg);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    transform: translate3d(28px, 390px, 0) rotate(var(--turn));
    opacity: 0;
  }
}

@media (hover: hover) {
  button:hover {
    box-shadow: 0 10px 22px rgba(35, 50, 80, 0.15);
    transform: translateY(-1px);
  }
}

@media (max-width: 860px) {
  .hero-content {
    grid-template-columns: minmax(0, 1fr) 170px;
  }

  .hero-copy {
    max-width: 520px;
    font-size: 19px;
  }

  .mascot {
    width: 150px;
  }

  .island-a {
    left: -60px;
    bottom: -26px;
    opacity: 0.58;
  }

  .island-b {
    right: 3%;
    bottom: -12px;
  }

  .world-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .answer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .hero-band {
    min-height: 360px;
  }

  .hero-content {
    grid-template-columns: 1fr;
    align-items: center;
  }

  .mascot {
    position: absolute;
    right: 10px;
    bottom: 8px;
    width: 118px;
  }

  .progress-band {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-title,
  .play-header {
    align-items: stretch;
  }

  .section-title {
    display: block;
  }

  .world-map {
    grid-template-columns: 1fr;
  }

  .play-header {
    grid-template-columns: 1fr auto;
  }

  .play-header > div {
    grid-column: 1 / -1;
    order: 3;
  }

  .hearts {
    align-self: center;
  }

  .reward-scene {
    padding-inline: 18px;
  }

  .reward-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .reward-actions button {
    padding-inline: 10px;
  }
}

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