:root {
  --paper: #f6f3eb;
  --paper-deep: #eee9da;
  --white: #fffefa;
  --ink: #15362e;
  --ink-soft: #455d54;
  --forest: #163f35;
  --forest-deep: #0e2d26;
  --sage: #d8e4d4;
  --sage-deep: #73947b;
  --gold: #dcaa70;
  --line: #d8dbcf;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "DM Sans", sans-serif; -webkit-font-smoothing: antialiased; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--gold); color: var(--forest-deep); }
:focus-visible { outline: 3px solid #9a7548; outline-offset: 4px; }
.shell { width: min(100% - 80px, 1240px); margin-inline: auto; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--forest); color: white; padding: 12px 18px; }
.skip-link:focus { top: 12px; }
.topline { height: 34px; padding: 0 max(40px, calc((100vw - 1240px) / 2)); display: flex; align-items: center; justify-content: space-between; background: var(--forest-deep); color: #e1e9dd; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.site-header { border-bottom: 1px solid var(--line); }
.nav-wrap { min-height: 85px; display: flex; justify-content: space-between; align-items: center; gap: 30px; }
.brand { display: inline-flex; align-items: center; gap: 13px; font-family: Fraunces, Georgia, serif; font-size: 30px; font-weight: 600; letter-spacing: -.03em; line-height: .8; white-space: nowrap; }
.brand small { display: block; margin-top: 9px; font: 700 9px "DM Sans", sans-serif; letter-spacing: .24em; text-transform: uppercase; }
.brand-mark { width: 35px; height: 35px; display: flex; align-items: flex-end; gap: 3px; transform: rotate(-23deg); }
.brand-mark i { display: block; width: 10px; border-radius: 8px 8px 2px 2px; background: var(--forest); }
.brand-mark i:nth-child(1) { height: 18px; }.brand-mark i:nth-child(2) { height: 29px; }.brand-mark i:nth-child(3) { height: 24px; }
.header-actions { display: flex; align-items: center; gap: 30px; }
.back-link { font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--forest); padding-bottom: 4px; }
.back-link span { margin-right: 8px; }
.sound-toggle { border: 1px solid #b9cbbb; background: transparent; color: var(--ink); border-radius: 99px; min-height: 42px; padding: 8px 15px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 9px; }
.sound-toggle:hover { background: var(--sage); }
.sound-icon, .sound-icon svg { display: block; width: 20px; height: 20px; }
.sound-toggle[aria-pressed="false"] .sound-icon { opacity: .45; }
.game-shell { padding-top: 72px; padding-bottom: 120px; }
.game-intro { display: grid; grid-template-columns: 1.1fr .65fr; gap: 12%; align-items: end; margin-bottom: 60px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: Fraunces, Georgia, serif; font-weight: 500; letter-spacing: -.03em; }
h1 { font-size: clamp(56px, 6vw, 88px); line-height: 1.02; margin-bottom: 0; }
h1 em { font-weight: 400; color: var(--sage-deep); }
.game-intro > p { color: var(--ink-soft); font-size: 16px; line-height: 1.75; max-width: 410px; margin: 0 0 5px; }
.game-view { scroll-margin-top: 28px; min-height: 520px; }
.game-view h2:focus { outline: none; }
.map-layout { display: grid; grid-template-columns: .68fr 1fr; gap: 9%; border-top: 1px solid #b7c9b8; padding-top: 45px; }
.map-copy h2 { font-size: clamp(37px, 3.7vw, 55px); line-height: 1.12; margin: 0 0 18px; }
.map-copy > p { color: var(--ink-soft); line-height: 1.75; max-width: 355px; font-size: 15px; }
.progress-summary { margin-top: 78px; display: flex; flex-direction: column; gap: 3px; }
.progress-summary strong { font: 500 67px Fraunces, Georgia, serif; line-height: 1; letter-spacing: -.04em; }
.progress-summary strong span { font-size: 29px; color: #78917e; }
.progress-summary > span { color: var(--ink-soft); font-size: 13px; }
.map-copy .save-note { margin-top: 24px; font-size: 11px; color: #5b7864; }
.chapter-list { border-top: 1px solid var(--line); }
.chapter-row { width: 100%; min-height: 100px; display: grid; grid-template-columns: 54px 1fr auto 24px; align-items: center; gap: 20px; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); padding: 18px 10px; transition: background .16s ease, padding-left .16s cubic-bezier(.23, 1, .32, 1); }
.chapter-row:not(:disabled):hover { background: #e9eee4; padding-left: 20px; }
.chapter-row:active:not(:disabled) { background: #dde9d9; }
.chapter-row:disabled { cursor: not-allowed; }
.chapter-number { font: 500 35px Fraunces, Georgia, serif; color: #94ad97; }
.chapter-info strong { display: block; font: 500 25px Fraunces, Georgia, serif; letter-spacing: -.025em; }
.chapter-info small { display: block; color: var(--ink-soft); margin-top: 5px; font-size: 12px; }
.chapter-arrow { font-size: 21px; font-weight: 400; text-align: right; }
.star-score { color: #9b652d; font-size: 18px; letter-spacing: .06em; white-space: nowrap; }
.star-empty { color: #819587; }
.is-locked .chapter-number, .is-locked .chapter-info, .is-locked .chapter-arrow { opacity: .48; }
.lock-label { font-size: 11px; color: #64786d; text-transform: uppercase; letter-spacing: .09em; }
.reset-link, .quiet-link { color: var(--ink); background: none; border: 0; border-bottom: 1px solid currentColor; padding: 0 0 5px; font-size: 12px; font-weight: 700; }
.reset-link { margin-top: 40px; color: #657e6c; }
.quiet-link:hover, .reset-link:hover { color: #6b906e; }
.story-layout { display: grid; grid-template-columns: 1.15fr .7fr; min-height: 500px; background: var(--white); }
.story-main { padding: clamp(32px, 5vw, 74px); display: flex; flex-direction: column; align-items: flex-start; }
.chapter-meta { display: flex; gap: 20px; font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: #66816c; }
.chapter-meta span + span::before { content: "·"; margin-right: 20px; }
.story-main h2 { font-size: clamp(45px, 5vw, 68px); margin: 58px 0 22px; line-height: 1.08; }
.story-text { max-width: 640px; font: 400 clamp(19px, 2vw, 25px)/1.6 Fraunces, Georgia, serif; color: #355548; margin-bottom: 42px; }
.story-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: auto; }
.game-button { min-height: 52px; display: inline-flex; align-items: center; justify-content: space-between; gap: 26px; padding: 15px 19px; border: 0; background: var(--forest); color: white; border-radius: 2px; font-size: 13px; font-weight: 700; transition: background .16s ease, transform .16s cubic-bezier(.23, 1, .32, 1); }
.game-button:hover { background: #285d4d; transform: translateY(-2px); }.game-button:active { transform: scale(.98); }
.read-button { min-height: 46px; display: inline-flex; align-items: center; gap: 9px; color: var(--forest); background: transparent; border: 0; padding: 9px 5px; font-size: 12px; font-weight: 700; }
.read-button svg { width: 18px; height: 18px; }.read-button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 4px; }.read-button:disabled { opacity: .42; cursor: not-allowed; }
.story-aside { position: relative; background: #c6d7c4; display: flex; flex-direction: column; align-items: center; justify-content: center; font: 500 clamp(45px, 5vw, 72px)/1.1 Fraunces, Georgia, serif; letter-spacing: -.03em; overflow: hidden; }
.story-aside::before, .story-aside::after { content: ""; position: absolute; border: 1px solid #8fab91; width: 450px; height: 450px; border-radius: 50%; }
.story-aside::after { width: 290px; height: 290px; }
.story-aside > span, .story-aside > em { z-index: 1; }.story-aside em { color: #3b7150; font-weight: 400; }
.story-aside b { position: absolute; right: 23px; bottom: 14px; font: 500 92px Fraunces, Georgia, serif; opacity: .25; }
.story-layout + .quiet-link { margin-top: 28px; }
.quiz-layout { padding: clamp(28px, 5vw, 64px); background: var(--white); max-width: 1000px; margin-inline: auto; }
.quiz-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.question-progress { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 60px; padding-bottom: 18px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 700; color: #587663; }
.steps { display: flex; gap: 5px; }.step { display: block; width: 33px; height: 4px; background: #d6dfd3; }.step.is-current { background: #63916b; }
.quiz-layout h2 { max-width: 840px; font-size: clamp(33px, 3.7vw, 52px); line-height: 1.22; margin: 32px 0 32px; }
.math-visual { display: grid; grid-template-columns: 1fr 46px 1fr; align-items: center; gap: 18px; background: #eaf0e7; padding: clamp(18px, 3vw, 30px); min-height: 190px; }
.count-group { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 7px; }
.count-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: #486a54; }
.count-group b { font-size: 13px; font-weight: 700; }
.counter-grid { min-height: 70px; max-width: 172px; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 6px; }
.counter { width: 17px; height: 17px; border-radius: 50%; background: #48805a; box-shadow: inset -2px -2px 0 #2e6942; }
.counter.is-taken { background: transparent; box-shadow: inset 0 0 0 1.5px #8fae92; opacity: .65; }
.place-value { min-height: 70px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; }
.ten-rods, .one-counters { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; }
.ten-rod { min-width: 36px; height: 23px; display: inline-grid; place-items: center; background: #3f7852; color: white; border-radius: 2px; font: normal 700 11px "DM Sans", sans-serif; }
.one-counter { width: 10px; height: 10px; border-radius: 50%; background: #5c9368; }
.math-symbol { font: 400 38px Fraunces, Georgia, serif; text-align: center; color: #547961; }
.visual-note { margin: 10px 0 0; font-size: 12px; color: #52715c; text-align: center; }
.answer-prompt { font-size: 12px; font-weight: 700; margin: 30px 0 13px; }
.answers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.answers button { min-height: 82px; background: var(--paper); color: var(--forest); border: 1px solid #b3c8b5; font: 500 35px Fraunces, Georgia, serif; font-variant-numeric: tabular-nums; transition: background .16s ease, transform .16s cubic-bezier(.23, 1, .32, 1), border-color .16s ease; }
.answers button:hover:not(:disabled) { background: #ddebd8; transform: translateY(-2px); border-color: #699070; }
.answers button:active:not(:disabled) { transform: scale(.98); }
.answers button.is-correct { background: var(--forest); color: white; border-color: var(--forest); }
.answers button.is-wrong { background: #f1e8df; color: #6d6258; border-color: #d9c9bc; }
.answers button:disabled { cursor: default; }.answers button:disabled:not(.is-correct, .is-wrong) { opacity: .55; }
.feedback { min-height: 31px; margin: 14px 0 0; font-size: 14px; font-weight: 700; }
.feedback.is-hint { color: #795b35; }.feedback.is-success { color: #245b3c; }
.question-actions { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 10px; }
.next-button[hidden] { display: none; }
.reward-layout { display: grid; grid-template-columns: .45fr 1fr; gap: 8%; background: #dce8d8; padding: clamp(32px, 5vw, 72px); }
.reward-mark { align-self: start; justify-self: center; font: 300 clamp(150px, 20vw, 300px)/.8 Fraunces, Georgia, serif; color: #6d9c72; }
.reward-intro { font-size: 11px; font-weight: 700; letter-spacing: .17em; text-transform: uppercase; color: #4e7959; }
.reward-layout h2 { font-size: clamp(46px, 5.5vw, 76px); margin-bottom: 19px; }
.reward-layout > div:last-child > p:not(.reward-intro) { font-size: 17px; line-height: 1.6; color: #345846; }
.reward-stars { margin: 18px 0 35px; }.reward-stars .star-score { font-size: 32px; }
blockquote { margin: 0 0 15px; border-top: 1px solid #9bb99b; padding-top: 28px; }
blockquote p { font: italic 400 clamp(21px, 2.4vw, 30px)/1.5 Fraunces, Georgia, serif; margin-bottom: 9px; }
blockquote cite { font-size: 12px; font-style: normal; font-weight: 700; color: #4e7158; }
.reward-layout .reflection { font-size: 14px !important; margin-bottom: 40px; }
.finish-layout { min-height: 470px; background: var(--forest); color: white; padding: clamp(42px, 6vw, 84px); position: relative; overflow: hidden; }
.finish-layout h2 { max-width: 680px; font-size: clamp(48px, 5.6vw, 76px); line-height: 1.1; position: relative; z-index: 1; }
.finish-layout p { max-width: 540px; color: #d4e2d3; font-size: 17px; line-height: 1.7; position: relative; z-index: 1; }
.finish-layout .game-button { background: #d7e8ae; color: var(--forest); margin-top: 18px; position: relative; z-index: 1; }
.finish-layout .game-button:hover { background: #eef7d3; }
.finish-pattern { position: absolute; right: -15px; bottom: -135px; font: 400 430px/1 Fraunces, Georgia, serif; color: #3b6a50; }
.game-footer { background: var(--forest-deep); color: #dbe8da; padding: 28px 0; font-size: 12px; }
.game-footer .shell { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.game-footer a { border-bottom: 1px solid #9eb8a3; padding-bottom: 4px; }.game-footer a span { margin-left: 12px; }

@media (max-width: 850px) {
  .shell { width: min(100% - 48px, 700px); }
  .topline { padding-inline: 24px; }
  .game-intro { grid-template-columns: 1fr; gap: 22px; }
  .map-layout { grid-template-columns: 1fr; gap: 25px; }
  .map-copy { display: grid; grid-template-columns: 1fr auto; gap: 0 30px; align-items: start; }
  .map-copy h2, .map-copy > p { grid-column: 1; }
  .progress-summary { grid-column: 2; grid-row: 1 / span 2; margin-top: 0; }
  .map-copy .save-note { grid-column: 1 / -1; margin: 0; }
  .story-layout { grid-template-columns: 1fr; }
  .story-aside { display: none; }
  .story-main h2 { margin-top: 35px; }
  .reward-layout { grid-template-columns: 1fr; }
  .reward-mark { display: none; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 36px, 470px); }
  .topline { padding-inline: 18px; }.topline span:last-child { display: none; }
  .nav-wrap { min-height: 75px; }.brand { font-size: 24px; }.brand small { font-size: 7px; }
  .brand-mark { transform: rotate(-23deg) scale(.86); margin-right: -4px; }
  .header-actions { gap: 10px; }.back-link { font-size: 0; border: 0; padding: 10px; }.back-link span { font-size: 24px; margin: 0; }
  .sound-toggle { padding: 8px 10px; }.sound-label { display: none; }
  .game-shell { padding-top: 45px; padding-bottom: 80px; }
  h1 { font-size: clamp(48px, 13vw, 68px); }
  .game-intro { margin-bottom: 42px; }.game-intro > p { font-size: 14px; }
  .map-layout { padding-top: 28px; }.map-copy { grid-template-columns: 1fr; }
  .map-copy h2, .map-copy > p, .map-copy .save-note { grid-column: 1; }
  .progress-summary { grid-column: 1; grid-row: auto; flex-direction: row; align-items: baseline; margin: 6px 0 16px; gap: 12px; }
  .progress-summary strong { font-size: 43px; }.progress-summary strong span { font-size: 20px; }
  .chapter-row { grid-template-columns: 38px 1fr 22px; gap: 12px; min-height: 88px; padding-inline: 0; }
  .chapter-number { font-size: 26px; }.chapter-info strong { font-size: 21px; }.chapter-result { grid-column: 2; grid-row: 2; margin-top: -12px; }.chapter-arrow { grid-column: 3; grid-row: 1 / span 2; }
  .chapter-row:not(:disabled):hover { padding-left: 7px; }
  .story-main { padding: 30px 24px; min-height: 460px; }.story-main h2 { font-size: 43px; }.story-text { font-size: 20px; }
  .story-actions { align-items: flex-start; flex-direction: column; gap: 8px; }
  .quiz-layout { padding: 28px 20px; }.quiz-head { flex-direction: column; gap: 14px; }
  .question-progress { margin-top: 37px; }.quiz-layout h2 { font-size: 31px; }
  .math-visual { grid-template-columns: 1fr 25px 1fr; gap: 5px; padding: 16px 8px; min-height: 150px; }
  .counter-grid { max-width: 120px; gap: 4px; }.counter { width: 13px; height: 13px; }
  .ten-rod { min-width: 28px; height: 20px; font-size: 10px; }.math-symbol { font-size: 29px; }.count-group b { font-size: 11px; }
  .answers button { min-height: 70px; font-size: 30px; }.question-actions { flex-wrap: wrap; }.next-button { width: 100%; }
  .reward-layout { padding: 34px 25px; }.reward-layout h2 { font-size: 50px; }
  .finish-layout { min-height: 480px; padding: 40px 26px; }.finish-pattern { font-size: 320px; bottom: -100px; right: -50px; }
  .game-footer .shell { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .chapter-row, .game-button, .answers button { transition: none; }
}
