:root {
  --ink: #244f49;
  --muted: #6b807b;
  --paper: #fffdf7;
  --cream: #f7efdc;
  --line: #ddd1af;
  --green: #4f9477;
  --green-dark: #276550;
  --gold: #e2ad4b;
  --gold-soft: #fff1bf;
  --coral: #dc7062;
  --purple: #796ca2;
  --sea: #6d9fad;
  --shadow: 0 18px 42px rgba(67, 69, 47, .13);
}

* { box-sizing: border-box; }
html {
  min-width: 320px;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 11% 12%, rgba(245, 201, 91, .2), transparent 25rem),
    radial-gradient(circle at 90% 25%, rgba(112, 181, 194, .2), transparent 30rem),
    #f8f5e9;
  color: var(--ink);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
.page-pattern {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .3;
  pointer-events: none;
  background-image: radial-gradient(#d7c897 1px, transparent 1px);
  background-size: 24px 24px;
}
.app {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 48px;
}
.topbar {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 17px;
  background: var(--paper);
  box-shadow: 0 6px 0 rgba(123, 99, 57, .13);
}
.brand-mark svg { width: 43px; height: 43px; }
.brand strong, .brand small { display: block; }
.brand strong { font: 700 14px Georgia, serif; letter-spacing: .12em; }
.brand small { margin-top: 3px; color: #8d7048; font-size: 11px; }
.sound-button, .primary-button, .secondary-button, .hint-button {
  min-height: 48px;
  border-radius: 15px;
  cursor: pointer;
  font-weight: 700;
}
.sound-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px;
  border: 2px solid var(--line);
  background: var(--paper);
}
.sound-button:hover, .secondary-button:hover, .hint-button:hover:not(:disabled) {
  border-color: #bba76f;
  background: #fffaf0;
}
.sound-button:focus-visible, .primary-button:focus-visible, .secondary-button:focus-visible,
.hint-button:focus-visible, .choice-card:focus-visible, .route-card button:focus-visible {
  outline: 4px solid rgba(63, 145, 117, .28);
  outline-offset: 3px;
}
.hero {
  display: grid;
  min-height: 488px;
  grid-template-columns: 1.05fr .95fr;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 38px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 52px;
}
.eyebrow {
  margin: 0 0 10px;
  color: #8d6b3e;
  font: 700 12px Georgia, serif;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.hero h1 {
  max-width: 650px;
  margin: 0;
  font-size: clamp(45px, 5.1vw, 66px);
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: 1.03;
}
.hero-copy > p:not(.eyebrow) {
  max-width: 590px;
  margin: 22px 0 27px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.55;
}
.hero-actions, .result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.primary-button, .secondary-button, .hint-button {
  padding: 13px 21px;
  border: 2px solid transparent;
}
.primary-button {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 7px 0 var(--green-dark);
  color: #fff;
}
.primary-button:hover { background: #438e70; }
.primary-button:active { box-shadow: 0 3px 0 var(--green-dark); }
.secondary-button { border-color: var(--line); background: var(--paper); }
.hint-button { border-color: #d9b65c; background: #fff6d9; color: #805a1d; }
.hint-button:disabled { cursor: default; opacity: .48; }
.hero-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.hero-progress strong { color: var(--ink); font: 700 31px Georgia, serif; }
.hero-art {
  position: relative;
  display: grid;
  min-width: 0;
  place-items: center;
  padding: 28px;
  background: linear-gradient(150deg, #eee0b8, #e1eadb);
}
.hero-art .castle-scene {
  width: min(475px, 100%);
  filter: drop-shadow(0 18px 15px rgba(71, 58, 34, .16));
}
.map-stamp {
  position: absolute;
  right: 31px;
  bottom: 27px;
  padding: 10px 14px;
  rotate: -4deg;
  border: 2px solid #b8843c;
  background: #fff4ce;
  color: #8c6332;
  font: 700 11px/1.35 Georgia, serif;
  letter-spacing: .11em;
  text-align: center;
}
.history-note {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 48px;
  padding: 16px 20px;
  border: 2px solid #e3c97f;
  border-radius: 22px;
  background: #fff5d5;
}
.history-note > span { color: #4d8a7a; font-size: 27px; }
.history-note p, .history-note strong, .history-note small { display: block; margin: 0; }
.history-note strong { margin-bottom: 3px; font-size: 15px; }
.history-note small { color: #77735f; font-size: 13px; line-height: 1.45; }
.section-heading, .journal-heading, .choices-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}
.section-heading h2, .journal-heading h2, .choices-heading h2 {
  margin: 0;
  font-size: clamp(31px, 4vw, 44px);
  font-weight: 700;
  letter-spacing: -.035em;
}
.section-heading > p, .choices-heading > p {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  text-align: right;
}
.routes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 17px;
  margin-top: 22px;
}
.route-card {
  display: flex;
  min-width: 0;
  min-height: 290px;
  flex-direction: column;
  padding: 22px;
  border: 3px solid var(--line);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 9px 0 rgba(119, 98, 54, .15);
}
.route-1 { background: linear-gradient(145deg, #fffdf7, #eef6e9); }
.route-2 { background: linear-gradient(145deg, #fffdf7, #fff0d8); }
.route-3 { background: linear-gradient(145deg, #fffdf7, #eee8f8); }
.route-head, .route-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.route-head > span {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 3px solid rgba(75, 159, 126, .22);
  border-radius: 18px;
  background: rgba(255, 255, 255, .7);
  color: var(--green);
  font-size: 27px;
}
.route-head b { color: var(--muted); font-size: 13px; }
.route-card .eyebrow { margin-top: 24px; }
.route-card h3 { margin: 0; font-size: 27px; letter-spacing: -.025em; }
.route-card > p:not(.eyebrow) { margin: 11px 0 24px; color: var(--muted); line-height: 1.5; }
.route-foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px dashed #d9cfb3;
}
.route-foot span { color: #a07434; font: 700 11px Georgia, serif; letter-spacing: .05em; text-transform: uppercase; }
.route-foot button {
  min-height: 46px;
  padding: 0 16px;
  border: 2px solid var(--green);
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}
.route-foot button:hover { background: #3f8b6e; }
.journal {
  margin-top: 58px;
  padding: 30px;
  border: 3px solid var(--line);
  border-radius: 34px;
  background: rgba(255, 253, 247, .9);
}
.journal-heading strong { font: 700 28px Georgia, serif; }
.journal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}
.journal-item {
  display: flex;
  min-width: 0;
  min-height: 70px;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 2px dashed #ded8c7;
  border-radius: 17px;
  color: #9d9b90;
}
.journal-item > span {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border-radius: 13px;
  background: #f0eee7;
  font-weight: 700;
}
.journal-item small, .journal-item b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.journal-item small { margin-bottom: 3px; font-size: 10px; }
.journal-item b { font-size: 13px; }
.journal-item.is-open { border-style: solid; border-color: #b9d8c8; color: var(--ink); background: #f0f8f1; }
.journal-item.is-open > span { background: var(--green); color: #fff; }
.game-shell, .result {
  border: 3px solid var(--line);
  border-radius: 38px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.game-shell { padding: 30px; }
.game-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
}
.game-heading h1 {
  margin: 0;
  font-size: clamp(37px, 4.8vw, 56px);
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: 1.05;
}
.progress-box {
  display: flex;
  width: min(360px, 42%);
  align-items: center;
  gap: 14px;
}
.progress-box > span {
  height: 16px;
  flex: 1;
  overflow: hidden;
  border-radius: 99px;
  background: #e5e1d5;
}
.progress-box i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.progress-box b { flex: 0 0 auto; font-size: 18px; }
.challenge {
  display: grid;
  grid-template-columns: .95fr 1.05fr;
  overflow: hidden;
  margin-top: 25px;
  border: 3px solid var(--line);
  border-radius: 31px;
}
.challenge-art { display: grid; min-width: 0; place-items: center; padding: 20px; background: #eaf1df; }
.challenge-art .castle-scene { width: 100%; max-height: 390px; }
.challenge-copy { display: flex; min-width: 0; flex-direction: column; justify-content: center; padding: 34px; background: #fffaf0; }
.challenge-copy h2 { margin: 0; font-size: clamp(23px, 2.6vw, 31px); font-weight: 600; line-height: 1.3; }
.question {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 24px;
  padding: 16px;
  border-radius: 18px;
  background: #eef6e9;
  line-height: 1.4;
}
.question > span { display: grid; width: 40px; height: 40px; flex: 0 0 40px; place-items: center; border-radius: 50%; background: var(--green); color: #fff; font: 700 23px Georgia, serif; }
.choices-heading { margin-top: 36px; }
.choices-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 20px; }
.choice-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 225px;
  flex-direction: column;
  align-items: center;
  padding: 16px 17px 20px;
  border: 3px solid #ded8c8;
  border-radius: 25px;
  background: #fff;
  box-shadow: 0 8px 0 rgba(118, 103, 66, .15);
  cursor: pointer;
  text-align: center;
}
.choice-card:hover:not(:disabled) { border-color: #a8cdbb; background: #fbfff9; }
.choice-card:disabled { cursor: default; opacity: 1; }
.choice-number {
  position: absolute;
  top: 13px;
  left: 13px;
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 10px;
  background: #eef1e9;
  color: var(--muted);
  font-weight: 700;
}
.choice-art { display: block; width: 124px; max-width: 46%; }
.choice-art svg { display: block; width: 100%; }
.choice-copy b, .choice-copy small { display: block; }
.choice-copy b { font-size: 19px; line-height: 1.25; }
.choice-copy small { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.choice-card.is-wrong { border-color: #df8e85; background: #fff0ed; }
.choice-card.is-wrong .choice-number { background: var(--coral); color: #fff; }
.choice-card.is-hinted { border-color: #dfb650; background: #fff9e7; }
.choice-card.is-hinted .choice-number { background: var(--gold); color: #fff; }
.choice-card.is-correct { border-color: #69a98c; background: #edf8f0; box-shadow: 0 8px 0 rgba(54, 118, 88, .22); }
.choice-card.is-correct .choice-number { background: var(--green); color: #fff; }
.feedback-zone { margin-top: 16px; }
.feedback {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 20px;
  border: 3px solid;
  border-radius: 25px;
}
.feedback.error { border-color: #df938b; background: #fff0ed; }
.feedback.hint { border-color: #e0bb5f; background: #fff7de; }
.feedback.success { border-color: #8ec1a6; background: #edf8f0; }
.feedback-icon { display: grid; width: 55px; height: 55px; place-items: center; border-radius: 17px; color: #fff; font-size: 29px; }
.feedback.error .feedback-icon { background: var(--coral); }
.feedback.hint .feedback-icon { background: var(--gold); }
.feedback.success .feedback-icon { background: var(--green); }
.feedback strong { display: block; font-size: 18px; }
.feedback p { margin: 6px 0 0; color: var(--muted); line-height: 1.45; }
.feedback small { display: block; margin-top: 7px; color: #806f4a; line-height: 1.4; }
.primary-button.compact { min-width: 196px; }
.game-actions { display: flex; justify-content: space-between; gap: 14px; margin-top: 16px; }
.result {
  display: flex;
  min-height: 720px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  text-align: center;
}
.result-art { width: min(510px, 100%); margin-bottom: 22px; }
.result-art .castle-scene { display: block; width: 100%; }
.result h1 { max-width: 800px; margin: 0; font-size: clamp(39px, 5.3vw, 62px); font-weight: 700; letter-spacing: -.045em; line-height: 1.05; }
.result > p:not(.eyebrow) { max-width: 700px; margin: 18px auto 0; color: var(--muted); font-size: 18px; line-height: 1.5; }
.stars { display: flex; gap: 6px; margin: 24px 0; color: #d9d5c9; font-size: 48px; }
.stars .earned { color: var(--gold); text-shadow: 0 4px 0 #c58b2d; }
.result-stats { display: grid; width: min(720px, 100%); grid-template-columns: repeat(3, 1fr); gap: 12px; }
.result-stats span { padding: 16px; border: 2px solid #d8e2d2; border-radius: 20px; background: #f0f6eb; }
.result-stats b, .result-stats small { display: block; }
.result-stats b { font: 700 30px Georgia, serif; }
.result-stats small { margin-top: 3px; color: var(--muted); }
.result-actions { justify-content: center; margin-top: 28px; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-copy { padding: 42px; }
  .hero-art { min-height: 390px; }
  .routes-grid, .journal-grid { grid-template-columns: 1fr 1fr; }
  .challenge { grid-template-columns: 1fr; }
  .challenge-art .castle-scene { max-height: 340px; }
  .choices-grid { grid-template-columns: 1fr; }
  .choice-card { min-height: 0; flex-direction: row; gap: 13px; padding: 15px 18px 15px 53px; text-align: left; }
  .choice-art { width: 104px; flex: 0 0 104px; max-width: none; }
}

@media (max-width: 660px) {
  .app { width: min(100% - 20px, 1120px); padding-top: 10px; }
  .topbar { align-items: flex-start; }
  .brand strong { max-width: 180px; font-size: 12px; }
  .brand small { font-size: 10px; }
  .brand-mark { width: 48px; height: 48px; }
  .sound-button { width: 50px; padding: 0; justify-content: center; }
  .sound-button b { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .hero { min-height: 0; border-radius: 29px; }
  .hero-copy { padding: 29px 24px 25px; }
  .hero h1 { font-size: clamp(39px, 12.5vw, 52px); }
  .hero-copy > p:not(.eyebrow) { margin: 17px 0 23px; font-size: 16px; }
  .hero-actions > button { width: 100%; }
  .hero-art { min-height: 290px; padding: 17px; }
  .map-stamp { right: 18px; bottom: 18px; }
  .history-note { align-items: flex-start; margin-bottom: 38px; }
  .section-heading, .journal-heading, .choices-heading, .game-heading { align-items: flex-start; flex-direction: column; }
  .section-heading > p, .choices-heading > p { text-align: left; }
  .routes-grid, .journal-grid { grid-template-columns: 1fr; }
  .route-card { min-height: 270px; }
  .journal { padding: 21px 16px; }
  .game-shell { padding: 20px 14px; border-radius: 28px; }
  .game-heading { gap: 16px; }
  .game-heading h1 { font-size: 39px; }
  .progress-box { width: 100%; }
  .challenge { margin-top: 20px; border-radius: 24px; }
  .challenge-art { padding: 10px; }
  .challenge-copy { padding: 24px 18px; }
  .challenge-copy h2 { font-size: 22px; }
  .choices-heading { margin-top: 29px; gap: 8px; }
  .choices-heading h2 { font-size: 34px; }
  .choice-card { align-items: center; padding-left: 49px; }
  .choice-art { width: 82px; flex-basis: 82px; }
  .choice-copy b { font-size: 17px; }
  .feedback { grid-template-columns: auto minmax(0, 1fr); padding: 16px; }
  .feedback-icon { width: 48px; height: 48px; }
  .feedback .compact { grid-column: 1 / -1; width: 100%; }
  .game-actions { flex-direction: column-reverse; }
  .game-actions button { width: 100%; }
  .result { min-height: 650px; padding: 30px 18px; border-radius: 29px; }
  .result h1 { font-size: 40px; }
  .result-stats { grid-template-columns: 1fr; }
  .result-actions button { width: 100%; }
}

@media (max-width: 400px) {
  .hero h1 { font-size: 40px; }
  .hero-art { min-height: 252px; }
  .route-foot { align-items: flex-end; }
  .route-foot span { max-width: 105px; }
  .choice-art { width: 68px; flex-basis: 68px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}


