:root {
  color-scheme: light;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
  --ink: #314d49;
  --muted: #71817d;
  --paper: #fffdf8;
  --line: #ded5b9;
  --green: #58a87a;
  --gold: #e4aa53;
  --coral: #e87b6a;
  --purple: #8875b0;
  --blue: #609fbd;
  --shadow: 0 19px 44px rgba(61, 75, 69, .14);
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: #f3f7ee; }
body { min-width: 320px; min-height: 100vh; margin: 0; overflow-x: hidden; color: var(--ink); background: radial-gradient(circle at 8% 12%, rgba(228, 170, 83, .18) 0 150px, transparent 152px), radial-gradient(circle at 94% 31%, rgba(96, 159, 189, .13) 0 180px, transparent 182px), linear-gradient(145deg, #f1f7ec, #fff9ee 55%, #f2eff9); }
body::before { position: fixed; inset: 0; z-index: -1; opacity: .14; background-image: radial-gradient(#739087 1.2px, transparent 1.2px); background-size: 29px 29px; content: ""; }
button, textarea { color: inherit; font: inherit; }
button:not(:disabled) { cursor: pointer; }
button:focus-visible, textarea:focus-visible { outline: 4px solid rgba(228, 170, 83, .72); outline-offset: 4px; }
h1, h2, p { margin-top: 0; }
.app { width: min(1120px, calc(100% - 32px)); min-height: 100vh; margin: 0 auto; padding: 20px 0 48px; }
.loading-card { display: grid; min-height: 320px; place-items: center; align-content: center; gap: 12px; margin-top: 60px; background: var(--paper); border: 3px solid var(--line); border-radius: 42px; box-shadow: var(--shadow); }
.loading-card span { font-size: 64px; }
.loading-card p { color: var(--muted); font-weight: 900; }
.topbar, .brand, .top-actions, .section-heading, .game-head, .panel-heading, .feedback-card, .animal-note { display: flex; align-items: center; }
.topbar { min-height: 68px; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.brand { gap: 12px; padding: 0; text-align: left; background: none; border: 0; }
.brand-mark { display: grid; width: 56px; height: 56px; place-items: center; font-size: 29px; background: #fff0c8; border: 3px solid #dbc891; border-radius: 19px; box-shadow: 0 7px 16px rgba(65, 84, 76, .12); transform: rotate(-4deg); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 24px; font-weight: 900; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.top-actions { gap: 10px; }
.top-spark { color: var(--coral); font-size: 30px; }
.sound-button, .back-button { min-width: 48px; min-height: 48px; font-weight: 900; background: rgba(255, 253, 248, .95); border: 2px solid var(--line); border-radius: 17px; }
.sound-button { display: flex; align-items: center; gap: 8px; padding: 0 16px; font-size: 13px; }
.back-button { padding: 0; font-size: 22px; }
.eyebrow { margin: 0 0 8px; color: #3d7f65; font-family: Georgia, serif; font-size: 12px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.primary-button, .secondary-button, .hint-button { min-width: 44px; min-height: 52px; border-radius: 17px; font-weight: 900; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 22px; color: white; background: #409875; border: 0; box-shadow: 0 8px 0 #2e795e; }
.primary-button:active { transform: translateY(4px); box-shadow: 0 4px 0 #2e795e; }
.primary-button.compact { min-height: 46px; margin-left: auto; box-shadow: none; }
.secondary-button { padding: 0 21px; background: white; border: 2px solid var(--line); }
.hint-button { padding: 0 18px; background: #fff1c5; border: 2px solid #dcc36c; }

.hero { display: grid; min-height: 510px; align-items: center; grid-template-columns: 1.05fr .95fr; gap: 45px; padding: clamp(42px, 6vw, 70px); overflow: hidden; background: rgba(255, 253, 248, .97); border: 3px solid var(--line); border-radius: 46px; box-shadow: var(--shadow); }
.hero h1 { max-width: 610px; margin-bottom: 19px; font-size: clamp(46px, 5.5vw, 67px); font-weight: 900; letter-spacing: -.055em; line-height: .98; }
.hero-copy > p:not(.eyebrow) { max-width: 560px; margin-bottom: 27px; color: var(--muted); font-size: 18px; font-weight: 800; line-height: 1.52; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 28px; }
.hero-facts span { color: var(--muted); font-size: 13px; font-weight: 900; }
.hero-facts strong { margin-right: 4px; color: var(--ink); font-size: 24px; }
.hero-art { position: relative; min-height: 360px; }
.hero-book { position: absolute; inset: 20px 0; display: grid; grid-template-columns: 1fr 1fr; filter: drop-shadow(0 18px 20px rgba(52, 70, 62, .16)); transform: rotate(2deg); }
.book-page { position: relative; min-width: 0; padding: 38px 25px; background: #fffdf5; border: 3px solid #d9d0b3; }
.left-page { border-radius: 35px 8px 8px 35px; box-shadow: inset -12px 0 20px rgba(80, 69, 40, .07); }
.right-page { display: flex; align-items: center; flex-direction: column; justify-content: center; border-radius: 8px 35px 35px 8px; box-shadow: inset 12px 0 20px rgba(80, 69, 40, .06); }
.chapter { color: #a47047; font-family: Georgia, serif; font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.left-page p { margin-top: 18px; font-family: Georgia, serif; font-size: 16px; font-weight: 700; line-height: 1.55; }
.writing-line { display: block; height: 7px; margin-top: 14px; background: #ebe5d2; border-radius: 6px; }
.writing-line.short { width: 68%; }
.right-page img { width: 150px; height: 150px; object-fit: contain; }
.right-page strong { margin-top: 8px; text-align: center; }
.thought { position: absolute; top: 27px; right: 25px; display: grid; width: 48px; height: 48px; place-items: center; color: white; font-family: Georgia, serif; font-size: 29px; background: var(--purple); border-radius: 50% 50% 50% 12px; }
.bookmark { position: absolute; top: -12px; left: 49%; z-index: 2; width: 30px; height: 90px; background: var(--coral); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); }

.how-section, .levels-section { margin-top: 30px; padding: 38px; background: rgba(255, 253, 248, .83); border: 2px solid rgba(222, 213, 185, .85); border-radius: 36px; }
.section-heading { justify-content: space-between; gap: 30px; margin-bottom: 24px; }
.section-heading h2 { margin: 0; font-size: 31px; }
.section-heading > p { max-width: 440px; margin: 0; color: var(--muted); font-size: 14px; font-weight: 800; text-align: right; }
.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.steps-grid article { display: flex; min-height: 110px; align-items: center; gap: 15px; padding: 19px; background: white; border: 2px solid var(--line); border-radius: 24px; }
.steps-grid article > b { display: grid; flex: 0 0 42px; height: 42px; place-items: center; color: white; background: var(--green); border-radius: 14px; }
.steps-grid strong, .steps-grid small { display: block; }
.steps-grid strong { margin-bottom: 5px; font-size: 17px; }
.steps-grid small { color: var(--muted); font-size: 13px; font-weight: 800; line-height: 1.35; }
.levels-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.level-card { display: flex; min-width: 0; min-height: 390px; padding: 19px; text-align: left; background: white; border: 3px solid var(--line); border-radius: 29px; box-shadow: 0 10px 0 #ded7bf; transition: transform .18s ease; flex-direction: column; }
.level-card:hover { transform: translateY(-4px); }
.level-card.green { --card-accent: var(--green); }
.level-card.gold { --card-accent: var(--gold); }
.level-card.purple { --card-accent: var(--purple); }
.level-top { display: flex; align-items: center; justify-content: space-between; }
.level-top > b { display: grid; width: 45px; height: 45px; place-items: center; color: white; background: var(--card-accent); border-radius: 15px; }
.level-top small { color: var(--muted); font-weight: 900; }
.level-picture { position: relative; display: grid; height: 135px; place-items: center; margin: 15px 0; overflow: hidden; background: color-mix(in srgb, var(--card-accent) 15%, white); border-radius: 23px; }
.level-picture img { width: 128px; height: 128px; object-fit: contain; }
.level-picture i { position: absolute; top: 12px; right: 12px; display: grid; width: 42px; height: 42px; place-items: center; font-size: 23px; background: white; border: 2px solid var(--line); border-radius: 14px; font-style: normal; }
.level-copy { flex: 1; }
.level-copy small, .level-copy strong, .level-copy > span { display: block; }
.level-copy small { color: var(--card-accent); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.level-copy strong { margin: 7px 0; font-size: 22px; }
.level-copy > span { color: var(--muted); font-size: 14px; font-weight: 800; line-height: 1.4; }
.level-go { display: flex; min-height: 48px; align-items: center; justify-content: space-between; margin-top: 14px; padding: 0 15px; color: white; font-weight: 900; background: var(--card-accent); border-radius: 15px; }
.animal-note { gap: 22px; margin: 28px auto 0; padding: 17px 27px; background: #e8f2e6; border: 2px solid #b9d1b7; border-radius: 28px; }
.animal-note img { width: 88px; height: 88px; object-fit: contain; }
.animal-note strong, .animal-note span { display: block; }
.animal-note strong { margin-bottom: 5px; font-size: 18px; }
.animal-note span { color: var(--muted); font-size: 14px; font-weight: 800; line-height: 1.4; }

.game-shell { padding: clamp(24px, 4vw, 44px); background: var(--paper); border: 3px solid var(--line); border-radius: 42px; box-shadow: var(--shadow); }
.game-head { justify-content: space-between; gap: 25px; }
.game-head h1 { margin-bottom: 8px; font-size: clamp(36px, 5vw, 55px); letter-spacing: -.04em; line-height: 1; }
.game-head > div:first-child > p:last-child { margin: 0; color: var(--muted); font-weight: 800; }
.round-badge { display: grid; flex: 0 0 82px; height: 82px; place-items: center; align-content: center; color: white; background: var(--accent); border: 7px solid color-mix(in srgb, var(--accent) 24%, white); border-radius: 50%; }
.round-badge strong { font-size: 25px; line-height: 1; }
.round-badge span { font-size: 10px; font-weight: 900; }
.progress-dots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 27px 0 19px; }
.progress-dots span { height: 8px; background: #e8e3d4; border-radius: 8px; }
.progress-dots .done { background: var(--green); }
.progress-dots .current { background: var(--accent); }
.mode-tabs { display: grid; max-width: 670px; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 auto 21px; padding: 6px; background: #f0ede2; border-radius: 19px; }
.mode-tabs button { min-height: 48px; padding: 7px 12px; font-weight: 900; background: transparent; border: 0; border-radius: 14px; }
.mode-tabs button.active { background: white; box-shadow: 0 5px 13px rgba(54, 69, 62, .1); }
.story-workspace { display: grid; align-items: start; grid-template-columns: minmax(280px, .85fr) minmax(390px, 1.35fr); gap: 18px; }
.story-card, .writing-panel { min-width: 0; padding: 25px; border: 3px solid var(--line); border-radius: 30px; }
.story-card { position: relative; background: #f1f6eb; }
.page-number { display: inline-flex; min-height: 32px; align-items: center; padding: 0 12px; color: #567566; font-family: Georgia, serif; font-size: 11px; font-weight: 900; letter-spacing: .12em; background: white; border-radius: 11px; }
.story-scene { position: relative; display: grid; height: 205px; place-items: center; margin: 15px 0 18px; overflow: hidden; background: color-mix(in srgb, var(--scene) 14%, white); border: 3px solid color-mix(in srgb, var(--scene) 32%, white); border-radius: 28px; }
.story-scene::before, .story-scene::after { position: absolute; width: 150px; height: 150px; background: color-mix(in srgb, var(--scene) 18%, transparent); border-radius: 50%; content: ""; }
.story-scene::before { bottom: -70px; left: -40px; }
.story-scene::after { top: -80px; right: -30px; }
.story-scene img { z-index: 1; width: 175px; height: 175px; object-fit: contain; }
.story-scene > span { position: absolute; top: 16px; left: 17px; z-index: 2; display: grid; width: 48px; height: 48px; place-items: center; font-size: 26px; background: white; border-radius: 16px; }
.story-card h2 { margin-bottom: 10px; font-size: 25px; }
.story-card > p { margin-bottom: 18px; font-family: Georgia, serif; font-size: 17px; font-weight: 700; line-height: 1.56; }
.story-question { display: block; padding: 13px 16px; color: #805f3e; font-weight: 900; background: #fff1cc; border-left: 5px solid var(--gold); border-radius: 8px 15px 15px 8px; }
.writing-panel { background: #fffaf0; border-color: #e4d7ae; }
.panel-heading { justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.panel-heading h2 { margin: 0; font-size: 27px; }
.ending-options { display: grid; gap: 12px; }
.ending-option { display: grid; min-height: 75px; align-items: center; grid-template-columns: 43px 1fr; gap: 13px; padding: 12px 16px; text-align: left; background: white; border: 3px solid #ded8c4; border-radius: 20px; box-shadow: 0 6px 0 #ddd6be; }
.ending-option > span { display: grid; width: 39px; height: 39px; place-items: center; color: white; font-weight: 900; background: #78938a; border-radius: 13px; }
.ending-option strong { font-size: 15px; line-height: 1.35; }
.ending-option.is-wrong { color: #9a5b52; background: #fff0ed; border-color: #df8d81; box-shadow: none; }
.ending-option.is-correct { background: #e8f5e9; border-color: var(--green); box-shadow: none; }
.ending-option.is-hinted { border-color: var(--gold); box-shadow: 0 0 0 6px rgba(228, 170, 83, .23); animation: pulse 1s ease infinite; }
.feedback-card { min-height: 82px; gap: 13px; margin-top: 18px; padding: 13px 16px; background: #eef4eb; border: 2px solid #c7d7c2; border-radius: 21px; }
.feedback-card > span { display: grid; flex: 0 0 45px; height: 45px; place-items: center; font-size: 23px; background: white; border-radius: 15px; }
.feedback-card p { flex: 1; margin: 0; }
.feedback-card strong, .feedback-card small { display: block; }
.feedback-card small { margin-top: 3px; color: var(--muted); font-weight: 800; line-height: 1.35; }
.feedback-card.retry { background: #fff1ed; border-color: #e8aaa0; }
.feedback-card.success { background: #e9f5ec; border-color: #9dc5a7; }
.text-count { display: grid; min-width: 64px; min-height: 44px; place-items: center; color: var(--muted); font-weight: 900; background: white; border: 2px solid var(--line); border-radius: 14px; }
.starter-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 13px; }
.starter-list button { min-height: 44px; padding: 7px 13px; color: #6e607f; font-size: 13px; font-weight: 900; background: #f0eaf7; border: 2px solid #cabce0; border-radius: 15px; }
.story-editor > span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.story-editor textarea { width: 100%; min-height: 174px; padding: 17px; resize: vertical; font-family: Georgia, serif; font-size: 17px; font-weight: 700; line-height: 1.5; background: white; border: 3px solid var(--line); border-radius: 20px; }

.result-card { max-width: 880px; margin: 38px auto; padding: clamp(30px, 5vw, 55px); text-align: center; background: var(--paper); border: 3px solid var(--line); border-radius: 42px; box-shadow: var(--shadow); }
.result-art { position: relative; display: grid; width: 160px; height: 145px; place-items: center; margin: 0 auto 14px; background: #ecf4e8; border-radius: 50% 50% 43% 43%; }
.result-art img { width: 150px; height: 150px; object-fit: contain; }
.result-art span { position: absolute; top: 4px; right: -8px; display: grid; width: 45px; height: 45px; place-items: center; color: white; background: var(--coral); border-radius: 50%; }
.result-card h1 { margin-bottom: 12px; font-size: clamp(36px, 5vw, 53px); letter-spacing: -.04em; line-height: 1; }
.result-card > p:not(.eyebrow) { color: var(--muted); font-weight: 800; line-height: 1.45; }
.result-stars { margin: 17px 0; color: var(--gold); font-size: 36px; letter-spacing: 5px; }
.result-stars span { color: #ddd7c3; }
.story-collection { display: grid; gap: 9px; margin: 20px 0; text-align: left; }
.story-collection article { display: grid; align-items: center; grid-template-columns: 38px 1fr 38px; gap: 12px; padding: 12px 15px; background: #f5f4eb; border-radius: 17px; }
.story-collection article > b, .story-collection article > i { display: grid; width: 36px; height: 36px; place-items: center; color: white; background: var(--green); border-radius: 12px; font-style: normal; }
.story-collection article > i { color: #74618e; background: #eee7f6; }
.story-collection p { margin: 0; }
.story-collection strong, .story-collection span { display: block; }
.story-collection span { margin-top: 2px; color: var(--muted); font-family: Georgia, serif; font-size: 13px; font-weight: 700; line-height: 1.35; }
.result-stats, .result-actions { display: flex; justify-content: center; gap: 13px; }
.result-stats { margin: 22px 0; }
.result-stats > span { min-width: 120px; padding: 12px; background: #f1f5ec; border-radius: 17px; }
.result-stats strong, .result-stats small { display: block; }
.result-stats strong { font-size: 25px; }
.result-stats small { color: var(--muted); font-weight: 800; }

@keyframes pulse { 50% { box-shadow: 0 0 0 3px rgba(228, 170, 83, .28); } }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-copy { text-align: center; }
  .hero-copy > p, .hero h1 { margin-right: auto; margin-left: auto; }
  .hero-facts { justify-content: center; }
  .hero-art { min-height: 350px; }
  .steps-grid { grid-template-columns: 1fr; }
  .levels-grid { grid-template-columns: 1fr; }
  .level-card { display: grid; min-height: 0; grid-template-columns: 80px 145px 1fr; column-gap: 17px; }
  .level-top { display: contents; }
  .level-top > b { grid-column: 1; grid-row: 1 / span 2; align-self: center; }
  .level-top small { grid-column: 1; grid-row: 3; text-align: center; }
  .level-picture { height: 125px; grid-column: 2; grid-row: 1 / span 3; margin: 0; }
  .level-copy { grid-column: 3; grid-row: 1 / span 2; }
  .level-go { grid-column: 3; grid-row: 3; }
  .story-workspace { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .app { width: min(100% - 20px, 1120px); padding-top: 10px; }
  .topbar { min-height: 58px; margin-bottom: 10px; }
  .brand-mark { width: 48px; height: 48px; font-size: 24px; border-radius: 16px; }
  .brand strong { font-size: 18px; }
  .brand small, .sound-button span:last-child, .top-spark { display: none; }
  .sound-button { width: 48px; padding: 0; justify-content: center; }
  .hero { min-height: 0; gap: 22px; padding: 34px 20px; border-radius: 31px; }
  .hero h1 { font-size: clamp(39px, 12vw, 55px); }
  .hero-copy > p:not(.eyebrow) { font-size: 16px; }
  .hero-facts { gap: 8px; }
  .hero-facts span { padding: 8px 10px; background: #f5f4eb; border-radius: 12px; }
  .hero-art { min-height: 300px; }
  .book-page { padding: 28px 15px; }
  .left-page p { font-size: 14px; }
  .right-page img { width: 115px; height: 115px; }
  .right-page strong { font-size: 13px; }
  .thought { top: 17px; right: 13px; width: 39px; height: 39px; }
  .how-section, .levels-section { margin-top: 18px; padding: 24px 15px; border-radius: 28px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .section-heading > p { text-align: left; }
  .level-card { display: flex; min-height: 370px; }
  .level-top { display: flex; width: 100%; }
  .level-picture { width: 100%; height: 135px; margin: 13px 0; }
  .animal-note { align-items: flex-start; padding: 15px; }
  .animal-note img { width: 70px; height: 70px; }
  .game-shell { padding: 22px 13px; border-radius: 29px; }
  .game-head { align-items: flex-start; }
  .game-head h1 { font-size: 36px; }
  .game-head > div:first-child > p:last-child { font-size: 14px; }
  .round-badge { flex-basis: 67px; height: 67px; border-width: 5px; }
  .mode-tabs { grid-template-columns: 1fr; }
  .story-card, .writing-panel { padding: 17px; border-radius: 24px; }
  .story-scene { height: 185px; }
  .story-card > p { font-size: 16px; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .hint-button { width: 100%; }
  .ending-option { min-height: 70px; padding: 10px; }
  .feedback-card { align-items: flex-start; flex-wrap: wrap; }
  .feedback-card .primary-button { width: 100%; margin-left: 0; }
  .result-card { margin: 22px auto; padding: 29px 16px; border-radius: 29px; }
  .story-collection article { grid-template-columns: 36px 1fr; }
  .story-collection article > i { display: none; }
  .result-stats { flex-wrap: wrap; }
  .result-stats > span { min-width: 95px; flex: 1; }
  .result-actions { flex-direction: column-reverse; }
}

@media (max-width: 420px) {
  .brand { gap: 8px; }
  .brand strong { font-size: 17px; }
  .hero-book { inset: 15px -5px; }
  .book-page { padding: 25px 12px; }
  .left-page p { font-size: 13px; }
  .chapter { font-size: 9px; }
  .game-head h1 { font-size: 33px; }
  .game-head > div:first-child > p:last-child { display: none; }
  .round-badge { flex-basis: 61px; height: 61px; }
  .ending-option { grid-template-columns: 36px 1fr; }
  .ending-option > span { width: 34px; height: 34px; }
  .ending-option strong { font-size: 14px; }
}

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