:root {
  --ink: #17211f;
  --muted: #60706b;
  --paper: #fbf7eb;
  --sand: #f0dfb8;
  --green: #3aa66f;
  --green-dark: #1d6d4d;
  --cyan: #4bb8c8;
  --blue: #325f9e;
  --coral: #e96f52;
  --yellow: #f0b84b;
  --mist: #9aa5a1;
  --line: #d7d4c6;
  --panel: rgba(255, 252, 241, 0.92);
  --shadow: 0 18px 50px rgba(35, 45, 40, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  background:
    linear-gradient(0deg, rgba(247, 241, 223, 0.8), rgba(247, 241, 223, 0.8)),
    radial-gradient(circle at 24px 24px, rgba(23, 33, 31, 0.08) 2px, transparent 0);
  background-size: auto, 48px 48px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid rgba(23, 33, 31, 0.1);
  background: rgba(251, 247, 235, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  background: transparent;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--yellow);
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--ink);
}

.brand strong,
.user-copy strong,
.stage-goal strong,
.progress-chip strong {
  display: block;
}

.brand small,
.user-copy span,
.stage-goal span,
.progress-chip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.user-state {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--cyan);
  color: #062b31;
  font-weight: 900;
}

.stage-goal,
.progress-chip {
  min-width: 140px;
  padding: 10px 12px;
  border: 1px solid rgba(23, 33, 31, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
}

main {
  overflow: hidden;
}

.view {
  display: none;
  min-height: calc(100vh - 82px);
  padding: clamp(24px, 4vw, 58px);
}

.view-active {
  display: block;
}

.world-intro,
.level-hero {
  max-width: 820px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--coral);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 900px;
  margin-bottom: 14px;
  font-size: clamp(34px, 5vw, 68px);
  line-height: 1.02;
  letter-spacing: 0;
}

.world-intro p,
.level-hero p {
  max-width: 720px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.map-stage {
  position: relative;
  min-height: 640px;
  margin-top: 28px;
  overflow: hidden;
  border: 2px solid rgba(23, 33, 31, 0.18);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.map-art {
  display: block;
  width: 100%;
  min-width: 980px;
  height: 640px;
}

.river {
  fill: none;
  stroke: #74c5cf;
  stroke-width: 46;
  stroke-linecap: round;
  opacity: 0.7;
}

.path-line {
  fill: none;
  stroke: #6b5138;
  stroke-width: 12;
  stroke-dasharray: 4 24;
  stroke-linecap: round;
}

.land {
  stroke: rgba(23, 33, 31, 0.32);
  stroke-width: 3;
}

.forest {
  fill: #84c878;
}

.mountain {
  fill: #90a8b7;
}

.city {
  fill: #f2c15b;
}

.lab {
  fill: #e68b72;
}

.reality {
  fill: #a8d7d2;
}

.level-node {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 174px;
  min-height: 88px;
  transform: translate(-50%, -50%);
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fffaf0;
  box-shadow: 5px 5px 0 var(--ink);
  transition:
    transform 0.2s ease,
    filter 0.2s ease;
}

.level-node:hover {
  transform: translate(-50%, -54%);
}

.level-node strong,
.level-node small {
  display: block;
}

.level-node small {
  margin-top: 4px;
  color: var(--muted);
}

.node-index {
  display: grid;
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}

.level-node.done {
  background: #dff1d8;
}

.level-node.current {
  background: #fff2c4;
  animation: breathe 2.2s ease-in-out infinite;
}

.level-node.locked {
  filter: grayscale(0.9);
  opacity: 0.72;
}

.current-quest {
  position: absolute;
  right: clamp(18px, 4vw, 48px);
  bottom: clamp(18px, 4vw, 42px);
  width: min(380px, calc(100% - 36px));
  padding: 22px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--ink);
}

.current-quest span {
  color: var(--coral);
  font-size: 13px;
  font-weight: 850;
}

.current-quest h2 {
  margin: 8px 0;
  font-size: 28px;
  line-height: 1.15;
}

.current-quest p {
  color: var(--muted);
  line-height: 1.6;
}

.primary-action,
.secondary-action,
.back-link {
  min-height: 44px;
  padding: 0 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-weight: 850;
  box-shadow: 4px 4px 0 var(--ink);
}

.primary-action {
  background: var(--green);
  color: #041d14;
}

.secondary-action,
.back-link {
  background: #fffaf0;
}

.back-link {
  margin-bottom: 28px;
}

.question-map {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 18px;
  margin-top: 34px;
}

.question-node {
  min-height: 230px;
  padding: 20px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fffaf0;
  box-shadow: 5px 5px 0 var(--ink);
}

.question-node:nth-child(2) {
  margin-top: 46px;
  background: #eaf5f3;
}

.question-node:nth-child(3) {
  margin-top: 10px;
  background: #fde7dd;
}

.question-node:nth-child(4) {
  margin-top: 64px;
  background: #e8f0db;
}

.question-node:nth-child(5) {
  margin-top: 28px;
  background: #fff0c6;
}

.question-node span {
  color: var(--blue);
  font-size: 13px;
  font-weight: 850;
}

.question-node h2 {
  margin: 14px 0 12px;
  font-size: 25px;
  line-height: 1.2;
}

.question-node p {
  color: var(--muted);
  line-height: 1.65;
}

.question-node button {
  margin-top: 8px;
  background: transparent;
  color: var(--green-dark);
  font-weight: 850;
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.lesson-rail {
  position: sticky;
  top: 112px;
  padding: 22px;
  border: 2px solid rgba(23, 33, 31, 0.16);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.82);
}

.lesson-rail h2 {
  font-size: 28px;
  line-height: 1.16;
}

.lesson-rail nav {
  display: grid;
  gap: 8px;
}

.step-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.step-pill.is-active {
  background: #e8f0db;
  font-weight: 850;
}

.step-dot {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
}

.lesson-stage {
  min-height: 620px;
  padding: clamp(22px, 4vw, 46px);
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fffaf0;
  box-shadow: var(--shadow);
}

.attention-meter {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 30px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.attention-meter div {
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 31, 0.18);
  border-radius: 999px;
  background: #ece4d1;
}

.attention-meter i {
  display: block;
  width: 15%;
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
  transition: width 0.25s ease;
}

.lesson-card {
  display: grid;
  gap: 24px;
}

.lesson-card h1 {
  font-size: clamp(32px, 5vw, 58px);
}

.lesson-card p,
.lesson-card li {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.75;
}

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

.mini-scene,
.logic-chain,
.experiment,
.dialogue {
  padding: 18px;
  border: 1px solid rgba(23, 33, 31, 0.16);
  border-radius: 8px;
  background: #f7f1df;
}

.mini-scene strong,
.logic-chain strong,
.experiment strong,
.dialogue strong {
  display: block;
  margin-bottom: 8px;
}

.dialogue {
  display: grid;
  gap: 10px;
}

.bubble {
  max-width: 84%;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  line-height: 1.6;
}

.bubble.ai {
  justify-self: end;
  background: #dff1d8;
}

.conflict {
  border-color: rgba(233, 111, 82, 0.46);
  background: #fde7dd;
}

.logic-chain {
  display: grid;
  gap: 10px;
}

.logic-chain span {
  display: block;
  padding: 14px;
  border-radius: 8px;
  background: #fffaf0;
  font-weight: 850;
}

.lesson-controls {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 30px;
}

@keyframes breathe {
  0%,
  100% {
    box-shadow: 5px 5px 0 var(--ink), 0 0 0 0 rgba(240, 184, 75, 0.72);
  }
  50% {
    box-shadow: 5px 5px 0 var(--ink), 0 0 0 14px rgba(240, 184, 75, 0);
  }
}

@media (max-width: 980px) {
  .topbar,
  .user-state {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .user-state {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .map-stage {
    overflow-x: auto;
  }

  .question-map,
  .lesson-layout,
  .experience-box {
    grid-template-columns: 1fr;
  }

  .question-node,
  .question-node:nth-child(n) {
    margin-top: 0;
  }

  .lesson-rail {
    position: static;
  }
}

@media (max-width: 640px) {
  .view {
    padding: 18px;
  }

  .brand {
    min-width: 0;
  }

  .stage-goal,
  .progress-chip {
    min-width: calc(50% - 7px);
  }

  h1 {
    font-size: 36px;
  }

  .map-stage {
    min-height: 720px;
  }

  .map-art {
    height: 720px;
  }

  .level-node {
    width: 154px;
  }

  .current-quest {
    position: sticky;
    left: 18px;
    bottom: 18px;
    margin-top: -210px;
  }
}
