:root {
  color-scheme: light;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  --ink: #244f47;
  --muted: #6b817b;
  --paper: #fffdf6;
  --line: #ddd2b4;
  --green: #4f9c76;
  --green-dark: #2e7458;
  --gold: #e9b34c;
  --coral: #df7164;
  --shadow: 0 18px 42px rgba(56, 75, 65, .14);
  --soft-shadow: 0 8px 20px rgba(56, 75, 65, .1);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  background: #f5f5e9;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background:
    radial-gradient(circle at 7% 8%, rgba(235, 180, 76, .18) 0 140px, transparent 143px),
    radial-gradient(circle at 94% 7%, rgba(82, 151, 166, .17) 0 165px, transparent 168px),
    linear-gradient(145deg, #f3f6e8, #fffaf0 55%, #edf3ed);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .13;
  background-image: radial-gradient(circle, rgba(52, 91, 78, .4) 1.4px, transparent 1.6px);
  background-size: 31px 31px;
  content: "";
  pointer-events: none;
}

button { color: inherit; font: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible { outline: 4px solid rgba(235, 180, 76, .68); outline-offset: 4px; }
h1, h2, h3, p { margin-top: 0; }

.app {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 50px;
}

.topbar,
.brand,
.top-actions,
.notebook-button,
.hero-actions,
.section-heading,
.route-foot,
.game-heading,
.progress-wrap,
.scene-top,
.feedback,
.game-footer,
.mini-progress,
.result-actions,
.result-stats,
.notebook-heading {
  display: flex;
  align-items: center;
}

.topbar {
  min-height: 62px;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 19px;
}

.brand {
  min-width: 0;
  gap: 12px;
  padding: 0;
  text-align: left;
  background: none;
  border: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 55px;
  height: 55px;
  place-items: center;
  padding: 5px;
  background: #fff5ce;
  border: 3px solid #ddcda4;
  border-radius: 18px;
  box-shadow: 0 7px 14px rgba(57, 79, 69, .13);
  rotate: -3deg;
}

.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand strong,
.brand small,
.notebook-button b,
.notebook-button small { display: block; }
.brand strong { overflow: hidden; font-family: Georgia, serif; font-size: 23px; text-overflow: ellipsis; white-space: nowrap; }
.brand small { margin-top: 3px; color: #8b7049; font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.top-actions { flex: 0 0 auto; gap: 8px; }

.icon-button,
.notebook-button {
  min-height: 49px;
  color: var(--ink);
  background: rgba(255, 253, 246, .95);
  border: 2px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 6px 14px rgba(61, 78, 68, .08);
}

.icon-button { width: 49px; padding: 0; font-size: 23px; }
.notebook-button { gap: 9px; padding: 5px 13px; text-align: left; }
.notebook-button > span:first-child { display: grid; width: 30px; height: 30px; place-items: center; color: #fff; background: var(--green); border-radius: 10px; font-weight: 900; }
.notebook-button b { font-size: 12px; line-height: 1.05; }
.notebook-button small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.eyebrow {
  margin: 0 0 8px;
  color: #8c6535;
  font-family: Georgia, serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.hint-button,
.route-button {
  display: inline-flex;
  min-height: 53px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  font-weight: 900;
  border-radius: 16px;
  transition: translate 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary-button { color: #fff; background: var(--green); border: 0; box-shadow: 0 8px 0 var(--green-dark), 0 15px 25px rgba(47, 116, 88, .18); }
.primary-button.compact { min-height: 47px; flex: 0 0 auto; margin-left: auto; padding-inline: 17px; box-shadow: 0 5px 0 var(--green-dark); }
.secondary-button { color: var(--ink); background: #fffdf6; border: 2px solid #d9d2bc; box-shadow: 0 5px 0 #ddd6c3; }
.hint-button { width: 100%; min-height: 49px; margin-top: 14px; color: #72531b; background: #fff4ca; border: 2px solid #e3b953; box-shadow: 0 5px 0 #d6a640; }
.route-button { min-height: 45px; padding-inline: 17px; color: #fff; background: var(--accent); border: 0; box-shadow: 0 5px 0 color-mix(in srgb, var(--accent), #24483f 30%); }

.primary-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover,
.hint-button:not(:disabled):hover,
.route-button:not(:disabled):hover,
.icon-button:not(:disabled):hover,
.notebook-button:not(:disabled):hover { translate: 0 -2px; }
.primary-button:not(:disabled):active,
.secondary-button:not(:disabled):active,
.hint-button:not(:disabled):active,
.route-button:not(:disabled):active { translate: 0 3px; box-shadow: none; }

.hero {
  display: grid;
  min-height: 414px;
  grid-template-columns: minmax(0, 1.08fr) minmax(400px, .92fr);
  align-items: center;
  overflow: hidden;
  background: linear-gradient(120deg, #fffaf0 0 54%, #e7f3ec 54% 100%);
  border: 3px solid #ded4b5;
  border-radius: 38px;
  box-shadow: var(--shadow);
}

.hero-copy { padding: 44px 0 40px 45px; }
.hero h1 { max-width: 610px; margin-bottom: 18px; font-size: clamp(38px, 4.4vw, 54px); font-weight: 800; line-height: 1.04; letter-spacing: -.035em; }
.hero-copy > p:not(.eyebrow) { max-width: 570px; margin-bottom: 25px; color: var(--muted); font-size: 18px; font-weight: 600; line-height: 1.5; }
.hero-actions { flex-wrap: wrap; gap: 12px; }
.hero-progress { display: flex; align-items: center; gap: 12px; margin-top: 31px; color: var(--muted); }
.hero-progress strong { color: var(--ink); font-family: Georgia, serif; font-size: 42px; line-height: 1; }
.hero-progress span { font-size: 13px; }
.hero-visual { min-width: 0; padding: 20px 20px 13px 8px; }
.hero-svg { display: block; width: 100%; height: auto; }

.safety-note,
.adult-note {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 19px;
  padding: 18px 22px;
  background: #fff3c7;
  border: 2px solid #e4c36d;
  border-radius: 23px;
}

.safety-note > span,
.adult-note > span { display: grid; flex: 0 0 auto; width: 48px; height: 48px; place-items: center; background: #fffdf6; border-radius: 15px; font-size: 23px; }
.safety-note strong,
.adult-note strong { display: block; margin-bottom: 3px; font-size: 15px; }
.safety-note p,
.adult-note p { margin: 0; color: #786f59; font-size: 13px; line-height: 1.45; }

.routes-section,
.steps-section { margin-top: 48px; }
.section-heading { justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2 { margin-bottom: 0; font-size: clamp(31px, 4vw, 46px); line-height: 1; }
.section-heading > p { max-width: 310px; margin: 0; color: var(--muted); font-size: 14px; font-weight: 700; line-height: 1.45; text-align: right; }
.routes-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }

.route-card {
  overflow: hidden;
  min-width: 0;
  background: var(--paper);
  border: 3px solid #dfd5b8;
  border-radius: 29px;
  box-shadow: 0 10px 0 #ddd6be, var(--soft-shadow);
}

.route-preview { position: relative; color: var(--accent); background: color-mix(in srgb, var(--accent), #fff 88%); border-bottom: 1px solid #e2d9c1; }
.route-preview > span { position: absolute; top: 18px; right: 18px; display: grid; width: 48px; height: 48px; place-items: center; background: #fffdf6; border: 3px solid color-mix(in srgb, var(--accent), #fff 45%); border-radius: 15px; font-size: 23px; box-shadow: var(--soft-shadow); }
.route-preview svg { display: block; width: 100%; height: auto; }
.route-copy { padding: 21px 23px 25px; }
.route-copy h3 { margin-bottom: 9px; font-size: 27px; line-height: 1.05; }
.route-copy > p:not(.eyebrow) { min-height: 63px; margin-bottom: 22px; color: var(--muted); font-size: 14px; font-weight: 600; line-height: 1.5; }
.route-foot { justify-content: space-between; gap: 9px; padding-top: 17px; border-top: 1px dashed #ddd3b8; }
.route-foot > span { color: var(--muted); font-size: 11px; }
.route-foot b { color: var(--ink); font-size: 14px; }

.steps-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.steps-grid article { display: flex; min-height: 122px; align-items: center; gap: 13px; padding: 19px; background: rgba(255, 253, 246, .84); border: 2px solid #e0d7bf; border-radius: 23px; }
.steps-grid article > span { display: grid; flex: 0 0 auto; width: 43px; height: 43px; place-items: center; color: #fff; background: var(--green); border-radius: 14px; font-family: Georgia, serif; font-size: 21px; font-weight: 800; }
.steps-grid h3 { margin-bottom: 5px; font-size: 16px; }
.steps-grid p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.game-shell {
  padding: 31px;
  background: rgba(255, 253, 246, .97);
  border: 3px solid #ded4b5;
  border-radius: 34px;
  box-shadow: var(--shadow);
}

.game-heading { justify-content: space-between; gap: 24px; margin-bottom: 23px; }
.game-heading h1 { margin: 0; font-size: clamp(32px, 4vw, 46px); line-height: 1; }
.progress-wrap { flex: 0 0 auto; gap: 13px; }
.progress-track { width: 300px; height: 13px; overflow: hidden; background: #e5e1d4; border-radius: 20px; }
.progress-track span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.progress-wrap b { min-width: 40px; font-size: 15px; }

.lesson-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(360px, .86fr); align-items: start; gap: 19px; }
.street-card,
.question-panel { min-width: 0; background: #fffdf7; border: 2px solid #ded5bd; border-radius: 27px; }
.street-card { overflow: hidden; padding: 16px; }
.scene-top { justify-content: space-between; gap: 12px; margin-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 800; }
.scene-top b { color: var(--accent); }
.street-scene { overflow: hidden; aspect-ratio: 760 / 480; background: #dfeceb; border: 3px solid color-mix(in srgb, var(--accent), #fff 45%); border-radius: 22px; }
.street-scene svg { display: block; width: 100%; height: 100%; }
.route-dots { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px; margin-top: 14px; }
.route-dots span { height: 8px; background: #e6e1d3; border-radius: 8px; }
.route-dots .done { background: #82b396; }
.route-dots .current { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 76%); }

.question-panel { display: flex; flex-direction: column; padding: 23px; }
.question-panel h2 { margin-bottom: 9px; font-size: clamp(25px, 3vw, 34px); line-height: 1.08; }
.question-copy { margin-bottom: 17px; color: var(--muted); font-size: 15px; font-weight: 700; line-height: 1.45; }
.answers-grid { display: grid; gap: 10px; }

.answer-card {
  display: grid;
  min-height: 72px;
  grid-template-columns: 38px 1fr 25px;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--ink);
  text-align: left;
  background: #fff;
  border: 2px solid #dcd7c8;
  border-radius: 18px;
  box-shadow: 0 5px 0 #ded9c9;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.answer-card > span { display: grid; width: 36px; height: 36px; place-items: center; color: #fff; background: #6f9990; border-radius: 11px; font-weight: 900; }
.answer-card b { font-size: 14px; line-height: 1.25; }
.answer-card i { font-style: normal; font-size: 19px; font-weight: 900; text-align: center; }
.answer-card:not(:disabled):hover { background: #f1f8f0; border-color: #85b39c; }
.answer-card.is-wrong { color: #903d36; background: #fff0ed; border-color: #e4968e; box-shadow: 0 5px 0 #ecc1bb; }
.answer-card.is-hinted { background: #fff6cf; border-color: #dfb84f; box-shadow: 0 0 0 5px rgba(235, 188, 76, .17), 0 5px 0 #e4cd88; }
.answer-card.is-correct { color: #236047; background: #edf8ec; border-color: #72af8e; box-shadow: 0 5px 0 #add2bc; }

.feedback {
  min-height: 94px;
  justify-content: flex-start;
  gap: 13px;
  margin-top: 15px;
  padding: 14px;
  background: #f4f2e9;
  border: 2px solid #d9d4c3;
  border-radius: 19px;
}

.feedback > span { display: grid; flex: 0 0 auto; width: 45px; height: 45px; place-items: center; background: #fff; border-radius: 14px; font-size: 21px; font-weight: 900; }
.feedback > div { min-width: 0; }
.feedback strong { display: block; margin-bottom: 3px; font-size: 14px; }
.feedback p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.feedback small { display: block; margin-top: 5px; color: #766d54; font-size: 11px; line-height: 1.35; }
.feedback.error { color: #8b4039; background: #fff0ed; border-color: #e49a92; }
.feedback.hint { color: #72551d; background: #fff6d3; border-color: #e2bd62; }
.feedback.success {
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr);
  align-items: start;
  color: #245f48;
  background: #edf8ed;
  border-color: #84b79a;
}
.feedback.success .primary-button.compact {
  width: 100%;
  grid-column: 1 / -1;
  margin: 5px 0 0;
}

.game-footer { justify-content: space-between; gap: 18px; margin-top: 21px; }
.mini-progress { gap: 8px; color: var(--muted); font-size: 12px; }
.mini-progress span { font-size: 23px; }

.result-card {
  min-height: 680px;
  padding: 48px 44px;
  text-align: center;
  background: rgba(255, 253, 246, .97);
  border: 3px solid #ded4b5;
  border-radius: 38px;
  box-shadow: var(--shadow);
}

.result-sign { width: 210px; margin: 0 auto 10px; }
.result-sign svg { display: block; width: 100%; }
.result-card h1 { margin-bottom: 13px; font-size: clamp(39px, 5vw, 60px); line-height: 1; }
.result-card > p:not(.eyebrow) { max-width: 750px; margin: 0 auto; color: var(--muted); font-size: 17px; font-weight: 700; line-height: 1.5; }
.stars { margin: 22px 0; font-size: 48px; letter-spacing: 8px; }
.stars span { color: #ddd7c8; text-shadow: 0 4px 0 #c9c2af; }
.stars .on { color: #efb541; text-shadow: 0 4px 0 #d69725; }
.result-stats { max-width: 800px; justify-content: center; gap: 13px; margin: 0 auto 29px; }
.result-stats div { display: grid; min-height: 92px; flex: 1 1 0; place-content: center; background: #eff5ea; border: 2px solid #cfe0c9; border-radius: 20px; }
.result-stats strong { font-family: Georgia, serif; font-size: 30px; }
.result-stats span { color: var(--muted); font-size: 11px; font-weight: 800; }
.result-actions { justify-content: center; flex-wrap: wrap; gap: 12px; }

.notebook-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  padding: 34px 38px;
  background: linear-gradient(135deg, #fff9ed, #eaf5ec);
  border: 3px solid #ddd2b4;
  border-radius: 32px;
  box-shadow: var(--shadow);
}

.notebook-hero h1 { max-width: 700px; margin-bottom: 12px; font-size: clamp(34px, 4.6vw, 52px); line-height: 1.03; }
.notebook-hero p:not(.eyebrow) { max-width: 680px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.notebook-hero > strong { display: grid; min-width: 155px; min-height: 115px; place-content: center; text-align: center; background: #fff; border: 3px solid #bdd9c7; border-radius: 27px; font-family: Georgia, serif; font-size: 45px; box-shadow: var(--soft-shadow); }
.notebook-hero small { display: block; margin-top: 5px; color: var(--muted); font-family: "Trebuchet MS", sans-serif; font-size: 11px; }
.notebook-group { margin-top: 27px; padding: 26px; background: rgba(255, 253, 246, .94); border: 3px solid color-mix(in srgb, var(--accent), #fff 57%); border-radius: 31px; box-shadow: var(--soft-shadow); }
.notebook-heading { gap: 13px; margin-bottom: 20px; }
.notebook-heading > span { display: grid; width: 55px; height: 55px; place-items: center; background: color-mix(in srgb, var(--accent), #fff 83%); border-radius: 17px; font-size: 26px; }
.notebook-heading h2 { margin: 0; font-size: 30px; }
.notebook-heading .eyebrow { margin-bottom: 4px; }
.notebook-heading > b { margin-left: auto; color: var(--accent); font-size: 18px; }
.rules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rule-card { display: flex; min-height: 120px; align-items: flex-start; gap: 13px; padding: 16px; background: #fff; border: 2px solid #ded8c6; border-radius: 19px; }
.rule-card > span { display: grid; flex: 0 0 auto; width: 40px; height: 40px; place-items: center; color: #fff; background: var(--accent); border-radius: 13px; font-weight: 900; }
.rule-card small,
.rule-card strong { display: block; }
.rule-card small { margin-bottom: 4px; color: #8a7655; font-size: 9px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.rule-card strong { margin-bottom: 4px; font-size: 14px; }
.rule-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.rule-card.is-locked { background: #f3f0e7; border-style: dashed; opacity: .73; }
.rule-card.is-locked > span { background: #aaa89d; }

@media (max-width: 980px) {
  .hero { grid-template-columns: minmax(0, 1fr) 360px; }
  .hero-copy { padding-left: 33px; }
  .routes-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .route-card:last-child { grid-column: 1 / -1; max-width: 540px; justify-self: center; }
  .steps-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson-grid { grid-template-columns: 1fr; }
  .street-scene { max-height: 500px; }
}

@media (max-width: 760px) {
  .app { width: min(100% - 22px, 1120px); padding-top: 12px; }
  .hero { grid-template-columns: 1fr; }
  .hero-copy { padding: 34px 30px 12px; }
  .hero-visual { max-width: 510px; margin: 0 auto; padding: 0 25px 20px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading > p { max-width: 500px; text-align: left; }
  .routes-grid { grid-template-columns: 1fr; }
  .route-card:last-child { grid-column: auto; max-width: none; }
  .route-copy > p:not(.eyebrow) { min-height: 0; }
  .game-shell { padding: 23px; }
  .game-heading { align-items: flex-start; flex-direction: column; }
  .progress-wrap { width: 100%; }
  .progress-track { width: auto; flex: 1 1 auto; }
  .rules-grid { grid-template-columns: 1fr; }
  .notebook-hero { align-items: stretch; flex-direction: column; }
  .notebook-hero > strong { min-height: 88px; }
}

@media (max-width: 560px) {
  .app { width: calc(100% - 20px); }
  .topbar { min-height: 56px; }
  .brand { gap: 8px; }
  .brand-mark { width: 46px; height: 46px; border-radius: 15px; }
  .brand strong { font-size: 18px; }
  .brand small { display: none; }
  .notebook-button { width: 46px; min-height: 46px; padding: 5px; justify-content: center; }
  .notebook-button > span:last-child { display: none; }
  .icon-button { width: 46px; min-height: 46px; }
  .hero { border-radius: 29px; }
  .hero-copy { padding: 29px 24px 8px; }
  .hero h1 { font-size: 37px; }
  .hero-copy > p:not(.eyebrow) { font-size: 16px; }
  .hero-actions { align-items: stretch; flex-direction: column; }
  .hero-actions button { width: 100%; }
  .hero-progress { margin-top: 24px; }
  .safety-note { align-items: flex-start; padding: 16px; }
  .routes-section,
  .steps-section { margin-top: 38px; }
  .section-heading h2 { font-size: 34px; }
  .steps-grid { grid-template-columns: 1fr; }
  .steps-grid article { min-height: 100px; }
  .route-foot { align-items: stretch; flex-direction: column; }
  .route-button { width: 100%; }
  .game-shell { padding: 16px; border-radius: 28px; }
  .game-heading h1 { font-size: 34px; }
  .street-card { padding: 11px; border-radius: 22px; }
  .street-scene { aspect-ratio: 760 / 560; }
  .street-scene svg { object-fit: cover; }
  .question-panel { padding: 18px; border-radius: 22px; }
  .question-panel h2 { font-size: 29px; }
  .answer-card { min-height: 78px; grid-template-columns: 36px 1fr 20px; padding-inline: 10px; }
  .answer-card b { font-size: 13px; }
  .feedback { align-items: flex-start; flex-wrap: wrap; }
  .feedback .primary-button.compact { width: 100%; margin: 4px 0 0; }
  .game-footer { align-items: stretch; flex-direction: column; }
  .game-footer .secondary-button { width: 100%; }
  .mini-progress { justify-content: center; }
  .result-card { min-height: 0; padding: 30px 18px; border-radius: 29px; }
  .result-sign { width: 170px; }
  .result-card h1 { font-size: 41px; }
  .result-stats { align-items: stretch; flex-direction: column; }
  .result-actions { align-items: stretch; flex-direction: column; }
  .result-actions button { width: 100%; }
  .notebook-hero { padding: 25px 22px; border-radius: 27px; }
  .notebook-hero h1 { font-size: 36px; }
  .notebook-group { padding: 17px; border-radius: 25px; }
  .notebook-heading h2 { font-size: 24px; }
  .rule-card { min-height: 126px; }
  .adult-note { align-items: flex-start; padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
