:root {
  --ink: #172030;
  --muted: #596474;
  --paper: #fff8df;
  --blue: #3177d4;
  --teal: #20a394;
  --green: #7bc35f;
  --yellow: #ffd158;
  --red: #ef6b54;
  --violet: #8c74d6;
  --line: rgba(23, 32, 48, 0.18);
  --heavy: #172030;
  --shadow: 0 18px 0 rgba(23, 32, 48, 0.08), 0 28px 70px rgba(35, 46, 69, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Trebuchet MS", "Comic Sans MS", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 209, 88, 0.38) 0 90px, transparent 92px),
    linear-gradient(180deg, #d9f3ff 0 48%, #e9f8d6 48% 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.topbar,
.section-head,
.round-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  margin-bottom: 18px;
  padding: 14px 18px;
  border: 3px solid var(--heavy);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 7px 0 rgba(23, 32, 48, 0.12);
}

.eyebrow {
  margin: 0 0 5px;
  color: #087f74;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
  text-shadow: 0 4px 0 rgba(255, 209, 88, 0.55);
}

h2 {
  margin-bottom: 8px;
  font-size: 28px;
}

.learner-switch {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 3px solid var(--heavy);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
}

.reward-dock {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, max-content)) 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.reward-pill,
.badge-token {
  border: 3px solid var(--heavy);
  border-radius: 999px;
  background: white;
  box-shadow: 0 6px 0 rgba(23, 32, 48, 0.14);
}

.reward-pill {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-weight: 900;
}

.reward-pill strong {
  color: var(--violet);
  font-size: 26px;
}

.reward-icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--heavy);
}

.star-shape {
  background: var(--yellow);
  clip-path: polygon(50% 0, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
}

.gem-shape {
  background: var(--teal);
  clip-path: polygon(50% 0, 100% 38%, 78% 100%, 22% 100%, 0 38%);
}

.bolt-shape {
  background: var(--red);
  clip-path: polygon(48% 0, 88% 0, 58% 43%, 90% 43%, 35% 100%, 45% 57%, 12% 57%);
}

.badge-strip {
  display: flex;
  min-height: 52px;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.badge-token {
  padding: 8px 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  background: #fff0b8;
}

.profile-chip,
.secondary-action,
.primary-action,
.choice-button,
.sound-button {
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 800;
}

.profile-chip {
  min-width: 86px;
  padding: 10px 16px;
  background: transparent;
}

.profile-chip.is-active {
  color: white;
  background: var(--violet);
  box-shadow: inset 0 -4px 0 rgba(23, 32, 48, 0.18);
}

.hero-stage {
  display: grid;
  grid-template-columns: minmax(320px, 0.78fr) minmax(380px, 1.22fr);
  gap: 18px;
  align-items: stretch;
}

.quest-card,
.map-panel,
.play-area,
.mistake-book,
.stat-tile {
  min-width: 0;
  border: 2px solid var(--line);
  border: 3px solid var(--heavy);
  background: rgba(255, 250, 240, 0.94);
  box-shadow: var(--shadow);
}

.quest-card {
  position: relative;
  display: flex;
  min-height: 348px;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 248, 223, 0.96), rgba(255, 255, 255, 0.9)),
    var(--paper);
}

.quest-card::after {
  content: "";
  position: absolute;
  right: -26px;
  bottom: -34px;
  width: 160px;
  height: 160px;
  border: 18px solid rgba(49, 119, 212, 0.16);
  border-radius: 50%;
}

.quest-copy p:not(.eyebrow) {
  max-width: 34ch;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.mission-visual {
  position: absolute;
  right: 24px;
  top: 36px;
  width: 122px;
  height: 126px;
}

.rocket {
  position: absolute;
  left: 38px;
  top: 12px;
  width: 48px;
  height: 76px;
  border: 3px solid var(--heavy);
  border-radius: 28px 28px 12px 12px;
  background: linear-gradient(180deg, white 0 44%, var(--red) 44% 100%);
  transform: rotate(18deg);
  box-shadow: 0 7px 0 rgba(23, 32, 48, 0.15);
}

.rocket-window {
  position: absolute;
  left: 12px;
  top: 16px;
  width: 18px;
  height: 18px;
  border: 3px solid var(--heavy);
  border-radius: 50%;
  background: #99ddff;
}

.rocket-fin {
  position: absolute;
  bottom: -7px;
  width: 17px;
  height: 28px;
  border: 3px solid var(--heavy);
  background: var(--blue);
}

.rocket-fin.left {
  left: -13px;
  transform: skewY(22deg);
}

.rocket-fin.right {
  right: -13px;
  transform: skewY(-22deg);
}

.rocket-flame {
  position: absolute;
  left: 11px;
  bottom: -28px;
  width: 20px;
  height: 26px;
  border: 3px solid var(--heavy);
  border-radius: 0 0 50% 50%;
  background: var(--yellow);
}

.spark {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 3px solid var(--heavy);
  background: var(--yellow);
  transform: rotate(45deg);
}

.spark-a {
  left: 16px;
  top: 14px;
}

.spark-b {
  right: 8px;
  top: 70px;
  background: var(--green);
}

.spark-c {
  left: 8px;
  bottom: 10px;
  background: var(--teal);
}

.quest-actions {
  display: grid;
  gap: 9px;
}

.dictation-toggle,
.scope-toggle,
.order-toggle {
  display: grid;
  gap: 6px;
  padding: 5px;
  border: 3px solid var(--heavy);
  border-radius: 8px;
  background: white;
}

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

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

.scope-toggle {
  grid-template-columns: repeat(3, 1fr);
}

.mode-chip,
.scope-chip,
.order-chip {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.mode-chip.is-active,
.scope-chip.is-active,
.order-chip.is-active {
  color: white;
  background: var(--teal);
  box-shadow: inset 0 -4px 0 rgba(23, 32, 48, 0.18);
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.primary-action,
.secondary-action {
  min-height: 46px;
  padding: 0 14px;
  border: 3px solid var(--heavy);
  font-size: 15px;
}

.primary-action {
  color: white;
  background: var(--red);
  box-shadow: 0 8px 0 #a94737, inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.primary-action:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #a94737;
}

.secondary-action {
  background: #ffffff;
  box-shadow: 0 5px 0 rgba(23, 32, 48, 0.12);
}

.secondary-action.compact {
  min-height: 42px;
  font-size: 14px;
}

.map-panel {
  min-height: 348px;
  padding: 22px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(236, 248, 255, 0.94));
}

.map-panel::before {
  display: none;
}

.map-sky {
  display: none;
}

.sun,
.cloud {
  position: absolute;
}

.sun {
  top: 26px;
  right: 34px;
  width: 72px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid var(--heavy);
  background: var(--yellow);
  box-shadow: 0 0 0 14px rgba(255, 209, 88, 0.24);
}

.cloud {
  width: 110px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
}

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

.cloud::before {
  left: 18px;
  width: 42px;
  height: 42px;
}

.cloud::after {
  right: 18px;
  width: 54px;
  height: 54px;
}

.cloud-a {
  top: 68px;
  left: 38px;
}

.cloud-b {
  top: 134px;
  right: 130px;
  transform: scale(0.78);
}

.map-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.map-head h2 {
  margin-bottom: 0;
  font-size: 26px;
}

.map-note {
  padding: 8px 11px;
  border-radius: 999px;
  color: white;
  background: var(--violet);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

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

.unit-node {
  min-height: 118px;
  padding: 14px;
  border: 2px solid rgba(23, 32, 48, 0.18);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 6px 0 rgba(23, 32, 48, 0.08);
  text-align: left;
}

button.unit-node {
  width: 100%;
  color: inherit;
}

.unit-node.is-selected {
  border-color: var(--teal);
  background: #ecfffb;
  box-shadow: 0 6px 0 rgba(32, 163, 148, 0.18);
}

.unit-node strong {
  display: block;
  font-size: 34px;
  line-height: 1;
}

.unit-kicker,
.unit-count {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.unit-kicker {
  margin-bottom: 4px;
  color: var(--teal);
  font-weight: 900;
}

.unit-count {
  margin-top: 7px;
  font-weight: 800;
}

.unit-progress {
  display: block;
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 32, 48, 0.1);
}

.unit-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--yellow);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 18px 0;
}

.stat-tile {
  padding: 16px;
  background: #ffffff;
}

.stat-tile span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.stat-tile strong {
  display: block;
  margin-top: 4px;
  color: var(--violet);
  font-size: 36px;
}

.play-area,
.mistake-book {
  margin-top: 18px;
  padding: 22px;
}

.hearts {
  display: flex;
  gap: 6px;
}

.heart {
  width: 18px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--red);
}

.question-board {
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 3px solid var(--heavy);
  background: #ffffff;
  box-shadow: inset 0 0 0 8px rgba(255, 209, 88, 0.16);
}

.round-reward {
  width: max-content;
  padding: 8px 12px;
  border: 3px solid var(--heavy);
  border-radius: 999px;
  background: #fff0b8;
  font-weight: 900;
}

.question-type {
  width: max-content;
  padding: 7px 10px;
  border-radius: 999px;
  color: white;
  background: var(--violet);
  font-size: 13px;
  font-weight: 800;
}

.sound-button {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 3px solid var(--heavy);
  background: var(--yellow);
  box-shadow: 0 5px 0 rgba(23, 32, 48, 0.16);
}

.sound-icon {
  width: 18px;
  height: 18px;
  border: 3px solid var(--ink);
  border-right: 0;
  border-radius: 4px 0 0 4px;
}

.prompt {
  margin: 0;
  font-size: clamp(25px, 4vw, 44px);
  font-weight: 900;
  line-height: 1.2;
}

.answer-zone {
  display: grid;
  gap: 10px;
}

.answer-row {
  display: flex;
  gap: 10px;
}

.answer-input {
  width: 100%;
  min-height: 58px;
  padding: 0 16px;
  border: 3px solid var(--heavy);
  border-radius: 8px;
  font-size: 24px;
  font-weight: 800;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice-button {
  min-height: 70px;
  padding: 12px;
  border: 3px solid var(--heavy);
  background: #f5fbff;
  box-shadow: 0 5px 0 rgba(23, 32, 48, 0.12);
  font-size: 18px;
  text-align: left;
}

.choice-button:hover {
  border-color: var(--blue);
}

.feedback {
  min-height: 28px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.feedback.good {
  color: var(--green);
}

.feedback.bad {
  color: var(--red);
}

.reward-pop {
  position: fixed;
  left: 50%;
  top: 24px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 32px));
  padding: 14px 18px;
  border: 3px solid var(--heavy);
  border-radius: 8px;
  background: #fff0b8;
  box-shadow: 0 8px 0 rgba(23, 32, 48, 0.18);
  font-weight: 900;
  text-align: center;
  transform: translateX(-50%);
  animation: pop-in 0.28s ease-out;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translate(-50%, -16px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.mistake-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.mistake-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 3px solid var(--heavy);
  border-radius: 8px;
  background: white;
}

.mistake-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mistake-item strong {
  font-size: 20px;
}

.masked-word {
  display: inline-block;
  min-width: 88px;
  padding: 3px 8px;
  border-radius: 6px;
  color: transparent;
  background: repeating-linear-gradient(135deg, #dfe7ec 0 8px, #eef3f5 8px 16px);
  user-select: none;
}

.mistake-item p {
  margin: 4px 0 0;
  color: var(--muted);
}

.mistake-badge {
  min-width: 80px;
  padding: 8px 10px;
  border-radius: 8px;
  color: white;
  background: var(--red);
  text-align: center;
  font-weight: 900;
}

.empty-state {
  padding: 18px;
  border: 3px dashed var(--line);
  color: var(--muted);
  background: white;
}

.study-card {
  margin-top: 18px;
  padding: 22px;
  border: 2px solid rgba(23, 32, 48, 0.18);
  background: linear-gradient(145deg, #fff8df, #ffffff);
  box-shadow: var(--shadow);
}

.study-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.study-head h2 {
  margin-bottom: 0;
  font-size: clamp(36px, 5vw, 58px);
}

.study-body {
  display: grid;
  gap: 14px;
}

.study-meaning {
  width: max-content;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: var(--teal);
  font-size: 22px;
  font-weight: 900;
}

.spell-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.spell-tile {
  min-width: 42px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: center;
  font-size: 24px;
  font-weight: 900;
}

.spell-tile.is-space {
  color: var(--muted);
  font-size: 15px;
}

.study-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 820px) {
  .topbar,
  .section-head,
  .round-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-stage,
  .stats-row {
    grid-template-columns: 1fr;
  }

  .reward-dock {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .reward-pill {
    min-width: 0;
    min-height: 40px;
    justify-content: flex-start;
    gap: 8px;
    padding: 6px 8px;
    font-size: 13px;
  }

  .reward-pill span:not(.reward-icon) {
    display: inline;
  }

  .reward-pill strong {
    font-size: 22px;
  }

  .reward-icon {
    width: 20px;
    height: 20px;
  }

  .badge-strip {
    width: 100%;
  }

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

  .quest-card,
  .map-panel {
    min-height: 300px;
  }

  .mission-visual {
    right: -10px;
    top: 42px;
    transform: scale(0.78);
    opacity: 0.9;
  }

  .quest-copy,
  .quest-actions {
    position: relative;
    z-index: 1;
  }

  .scope-toggle {
    grid-template-columns: 1fr;
  }

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

  .answer-row {
    flex-direction: column;
  }

  .book-actions {
    width: 100%;
    justify-content: stretch;
  }

  .book-actions .secondary-action {
    flex: 1 1 120px;
  }

  .mistake-item,
  .study-head {
    grid-template-columns: 1fr;
  }

  .mistake-actions {
    justify-content: space-between;
  }

  .trail {
    grid-template-columns: repeat(2, 1fr);
    inset: 112px 18px 24px;
    gap: 10px;
  }

  .unit-node {
    padding: 12px;
  }
}
