:root {
  color-scheme: light;
  --paper: #fff8ea;
  --ink: #202124;
  --muted: #69716f;
  --line: #ded8c8;
  --surface: #ffffff;
  --teal: #1f8a84;
  --blue: #2f6bb2;
  --red: #d95838;
  --yellow: #f1b84b;
  --green: #68b58f;
  --shadow: 0 20px 48px rgba(42, 36, 22, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  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;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 0 40px;
  border-bottom: 2px solid rgba(32, 33, 36, 0.08);
  background: rgba(255, 248, 234, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 900;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 22px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  color: #56615d;
  font-size: 15px;
  font-weight: 800;
}

.nav-links a:hover,
.back-link:hover {
  color: var(--teal);
}

.container {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.play-hero,
.topic-stage {
  min-height: calc(100vh - 64px);
  display: grid;
  align-items: center;
  padding: 36px 0;
}

.hero-grid,
.topic-stage-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.75fr) minmax(420px, 1fr);
  gap: 36px;
  align-items: center;
}

.hero-copy,
.topic-title {
  display: grid;
  gap: 18px;
  align-content: center;
}

.eyebrow {
  margin: 0;
  color: #a33e27;
  font-size: 14px;
  font-weight: 900;
}

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

h1 {
  line-height: 1;
  font-size: 76px;
  font-weight: 950;
}

h2 {
  line-height: 1.12;
  font-size: 36px;
}

h3 {
  line-height: 1.16;
  font-size: 28px;
}

.lead {
  max-width: 460px;
  color: #4a514e;
  font-size: 22px;
  font-weight: 700;
}

.primary-link,
.topic-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 18px;
  font-weight: 900;
}

.primary-link:hover,
.topic-link:hover {
  background: var(--teal);
}

.hero-definition {
  display: grid;
  gap: 6px;
  max-width: 520px;
  padding: 14px 16px;
  border: 2px solid #e1dbc9;
  border-radius: 8px;
  background: #fffdf8;
}

.hero-definition strong {
  color: #a33e27;
  font-size: 18px;
  font-weight: 950;
}

.hero-definition span {
  color: #3f4845;
  font-size: 18px;
  font-weight: 800;
}

.hero-definition code,
.definition-card code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #eef1ef;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.number-lab {
  --value-pos: 35%;
}

.lab-board {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 2px solid #2f2f2f;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.scene-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.scene-tab {
  min-height: 44px;
  border: 2px solid #d8d0bd;
  border-radius: 8px;
  background: #fffdf7;
  color: #3d4542;
  cursor: pointer;
  font-weight: 900;
}

.scene-tab.is-active {
  border-color: var(--teal);
  background: #dff4ef;
  color: #0e5e58;
}

.value-readout {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  align-items: center;
}

.value-readout > span {
  display: grid;
  min-height: 84px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 50px;
  font-weight: 950;
}

.value-readout small {
  color: #363f3c;
  font-size: 23px;
  font-weight: 900;
}

.visual-stage {
  display: grid;
  gap: 12px;
}

.scene-art {
  width: 100%;
  height: 220px;
  border: 2px solid #e1dbc9;
  border-radius: 8px;
  background: #f7fbff;
}

.number-strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(21, 1fr);
  min-height: 46px;
  align-items: center;
  border-radius: 8px;
  background: linear-gradient(90deg, #eaf2ff 0 47.5%, #202124 47.5% 52.5%, #ffece6 52.5% 100%);
  overflow: hidden;
}

.number-strip::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--value-pos);
  width: 4px;
  background: var(--yellow);
  transform: translateX(-2px);
}

.number-strip span {
  position: relative;
  z-index: 1;
  text-align: center;
  color: #242a28;
  font-size: 13px;
  font-weight: 900;
}

.number-strip .zero {
  color: white;
}

.number-slider {
  width: 100%;
  accent-color: var(--teal);
  cursor: pointer;
}

.lab-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.lab-facts div {
  min-height: 72px;
  padding: 12px;
  border-radius: 8px;
  background: #f6efe0;
}

.lab-facts span {
  display: block;
  color: #69716f;
  font-size: 13px;
  font-weight: 900;
}

.lab-facts strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.1;
}

.quick-scenes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 0 0 42px;
}

.scene-chip {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 0 18px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.scene-chip strong {
  font-size: 20px;
}

.scene-chip span {
  font-size: 24px;
  font-weight: 950;
}

.path-section,
.topic-section,
.lesson-section,
.definition-section,
.advanced-section,
.teacher-notes {
  padding: 42px 0;
}

.section-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.path-line {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.path-step {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 82px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.path-step span,
.lesson-tile span {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  color: #1d1d1d;
  font-size: 22px;
  font-weight: 950;
}

.path-step strong {
  font-size: 24px;
}

.definition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.definition-card {
  display: grid;
  gap: 10px;
  min-height: 150px;
  padding: 20px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.definition-card strong {
  color: #a33e27;
  font-size: 28px;
  font-weight: 950;
}

.definition-card p {
  color: #3f4845;
  font-size: 18px;
  font-weight: 800;
}

.topic-grid,
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.topic-card,
.lesson-tile {
  display: grid;
  gap: 14px;
  min-height: 220px;
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.topic-card:hover,
.path-step:hover,
.lesson-tile:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.topic-symbol {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border-radius: 8px;
  background: #eaf2ff;
  color: var(--blue);
  font-size: 42px;
  font-weight: 950;
}

.card-kicker {
  color: #a33e27;
  font-size: 14px;
  font-weight: 900;
}

.focus-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.focus-list li {
  padding: 6px 10px;
  border-radius: 999px;
  background: #e7f5f2;
  color: #155e58;
  font-size: 14px;
  font-weight: 900;
}

.topic-stage {
  min-height: auto;
  padding-top: 54px;
}

.topic-title .back-link {
  width: fit-content;
  color: #5d6763;
  font-size: 15px;
  font-weight: 900;
}

.number-lab-compact .scene-art {
  height: 210px;
}

.number-lab-compact .value-readout > span {
  min-height: 78px;
}

.lesson-tile {
  min-height: 190px;
  align-content: start;
}

.lesson-tile strong {
  font-size: 23px;
}

.lesson-tile small {
  color: #58615e;
  font-size: 15px;
  font-weight: 800;
}

.lesson-grid-small .lesson-tile {
  min-height: 150px;
}

.later-section {
  padding-top: 12px;
}

.advanced-section {
  padding-top: 18px;
}

.advanced-grid {
  --sqrt-pos: 41.421356%;
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: stretch;
}

.advanced-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 2px solid #2f2f2f;
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: var(--shadow);
}

.advanced-panel-copy {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-radius: 8px;
  background: #f7e9ff;
}

.advanced-badge {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border-radius: 8px;
  background: #6f4fb0;
  color: white;
  font-size: 32px;
  font-weight: 950;
}

.repeat-badge {
  background: #1f8a84;
  font-size: 22px;
}

.advanced-panel-copy p {
  color: #47404f;
  font-size: 18px;
  font-weight: 800;
}

.sqrt-layout {
  display: grid;
  grid-template-columns: minmax(190px, 0.65fr) minmax(240px, 1fr);
  gap: 12px;
  align-items: stretch;
}

.sqrt-art {
  width: 100%;
  height: 210px;
  border: 2px solid #e1dbc9;
  border-radius: 8px;
  background: #f7fbff;
}

.svg-label {
  fill: #202124;
  font-size: 18px;
  font-weight: 900;
}

.sqrt-readout {
  display: grid;
  gap: 12px;
  align-content: center;
  min-height: 100%;
  padding: 18px;
  border-radius: 8px;
  background: #f6efe0;
}

.sqrt-readout strong {
  font-size: clamp(42px, 5vw, 68px);
  line-height: 1;
}

.sqrt-readout span {
  color: #5a635f;
  font-size: 18px;
  font-weight: 900;
}

.sqrt-numberline {
  position: relative;
  display: grid;
  gap: 8px;
  padding-top: 42px;
}

.sqrt-marker {
  position: absolute;
  top: 0;
  left: var(--sqrt-pos);
  z-index: 2;
  display: grid;
  min-width: 110px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #6f4fb0;
  color: white;
  text-align: center;
  transform: translateX(-50%);
}

.sqrt-marker strong {
  font-size: 22px;
  line-height: 1;
}

.sqrt-marker span {
  font-size: 12px;
  font-weight: 900;
}

.sqrt-track {
  position: relative;
  height: 54px;
  border-radius: 8px;
  background: linear-gradient(90deg, #eaf2ff 0 40%, #dcecff 40% 42%, #ffece6 42% 100%);
  overflow: hidden;
}

.sqrt-track::before {
  content: "";
  position: absolute;
  top: 26px;
  right: 18px;
  left: 18px;
  height: 4px;
  border-radius: 999px;
  background: #202124;
}

.sqrt-track i {
  position: absolute;
  top: 16px;
  bottom: 14px;
  width: 3px;
  background: rgba(32, 33, 36, 0.35);
  transform: translateX(-1px);
}

.sqrt-track b {
  position: absolute;
  top: 8px;
  bottom: 6px;
  left: var(--sqrt-pos);
  width: 6px;
  border-radius: 999px;
  background: #6f4fb0;
  transform: translateX(-3px);
}

.sqrt-ticks {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  color: #39413e;
  font-size: 14px;
  font-weight: 950;
}

.sqrt-ticks span {
  text-align: center;
}

.sqrt-control {
  display: grid;
  gap: 8px;
  color: #535c59;
  font-weight: 950;
}

.sqrt-slider {
  width: 100%;
  accent-color: #6f4fb0;
  cursor: pointer;
}

.repeat-panel {
  align-content: start;
}

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

.repeat-option {
  min-height: 46px;
  border: 2px solid #d8d0bd;
  border-radius: 8px;
  background: #fffdf7;
  color: #3d4542;
  cursor: pointer;
  font-weight: 950;
}

.repeat-option.is-active {
  border-color: var(--teal);
  background: #dff4ef;
  color: #0e5e58;
}

.repeat-result {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  min-height: 96px;
  padding: 16px;
  border-radius: 8px;
  background: #f6efe0;
  text-align: center;
}

.repeat-result strong {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

.repeat-result span {
  color: #5a635f;
  font-size: 30px;
  font-weight: 950;
}

.repeat-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 16px 16px 16px 38px;
  border-radius: 8px;
  background: #e7f5f2;
  color: #25413c;
  font-size: 16px;
  font-weight: 850;
}

.teacher-notes {
  padding-bottom: 80px;
}

.teacher-notes details {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.teacher-notes summary {
  cursor: pointer;
  padding: 18px 22px;
  font-size: 20px;
  font-weight: 950;
}

.topic-content {
  padding: 0 22px 28px;
}

.topic-content h2 {
  margin: 34px 0 12px;
  font-size: 28px;
}

.topic-content h3 {
  margin: 24px 0 10px;
  font-size: 22px;
}

.topic-content p,
.topic-content li {
  color: #424b48;
}

.topic-content ul,
.topic-content ol {
  padding-left: 24px;
}

.topic-content code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef1ef;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

pre {
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: #202124;
  color: #fff9ee;
}

.table-wrap {
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f6efe0;
}

@media (max-width: 900px) {
  .site-header {
    padding: 0 18px;
  }

  .hero-grid,
  .topic-stage-grid,
  .advanced-grid,
  .sqrt-layout {
    grid-template-columns: 1fr;
  }

  .play-hero {
    min-height: auto;
  }

  h1 {
    font-size: 58px;
  }

  .quick-scenes {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .container {
    width: calc(100% - 28px);
  }

  .brand span:last-child {
    display: none;
  }

  .nav-links {
    gap: 12px;
    font-size: 14px;
  }

  h1 {
    font-size: 48px;
  }

  h2 {
    font-size: 30px;
  }

  .lead {
    font-size: 19px;
  }

  .lab-board {
    padding: 16px;
  }

  .value-readout {
    grid-template-columns: 1fr;
  }

  .value-readout > span {
    min-height: 82px;
    font-size: 46px;
  }

  .value-readout small {
    font-size: 22px;
  }

  .scene-art {
    height: 180px;
  }

  .lab-facts {
    grid-template-columns: 1fr;
  }

  .topic-grid,
  .lesson-grid,
  .repeat-options {
    grid-template-columns: 1fr;
  }

  .advanced-panel-copy {
    grid-template-columns: 1fr;
  }

  .sqrt-readout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .sqrt-art {
    height: 170px;
  }

  .sqrt-marker {
    min-width: 92px;
  }

  .repeat-result {
    grid-template-columns: 1fr;
  }
}
