:root {
  color-scheme: light;
  --ink: #294f4c;
  --muted: #6d807a;
  --cream: #f7efd9;
  --paper: #fffdf7;
  --line: #dfd4b6;
  --green: #4c9b75;
  --green-dark: #34785e;
  --yellow: #efb640;
  --coral: #eb7568;
  --blue: #5aa6cf;
  --shadow: 0 18px 42px rgba(74, 62, 38, 0.12), 0 5px 0 rgba(151, 124, 71, 0.13);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 0; background: var(--cream); }

body {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18px 18px, rgba(255,255,255,.74) 0 2px, transparent 2.5px) 0 0 / 34px 34px,
    linear-gradient(135deg, #fbf4df, #f3e7c8);
}

button { font: inherit; }
button:focus-visible { outline: 4px solid rgba(86, 164, 204, .42); outline-offset: 3px; }

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

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0; color: var(--ink); border: 0; background: transparent; cursor: pointer; text-align: left; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; color: #fff; background: var(--coral); border: 4px solid #fff8e7; border-radius: 18px 21px 17px 20px; box-shadow: 0 5px 0 rgba(122,83,51,.15); transform: rotate(-3deg); }
.brand-mark svg { width: 29px; fill: currentColor; }
.brand b { display: block; font-size: 20px; letter-spacing: -.35px; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 8px; }
.top-button { min-height: 46px; padding: 10px 16px; border: 2px solid rgba(134,119,83,.19); border-radius: 15px; background: rgba(255,253,247,.72); color: var(--ink); font-weight: 800; cursor: pointer; }
.top-button span { margin-left: 5px; color: var(--green-dark); }
.top-button:hover, .top-button.is-active { background: #fff; border-color: rgba(76,155,117,.45); transform: translateY(-1px); }

.paper-card { border: 2px solid rgba(189,164,108,.37); background: rgba(255,253,247,.95); border-radius: 37px; box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 8px; color: #a16f1c; font-size: 13px; font-weight: 900; letter-spacing: 2px; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { margin-top: 0; color: #224b49; letter-spacing: -.8px; }

.hero { min-height: 470px; display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(340px, .88fr); overflow: hidden; position: relative; }
.hero::before { content: ""; position: absolute; width: 260px; height: 260px; border: 46px solid rgba(239,182,64,.12); border-radius: 50%; left: -130px; bottom: -155px; }
.hero-copy { padding: 58px 24px 46px 56px; position: relative; z-index: 1; }
.hero h1 { max-width: 650px; margin-bottom: 17px; font-size: clamp(40px, 5vw, 64px); line-height: .98; }
.hero-text { max-width: 620px; margin: 0; color: #58716d; font-size: 19px; line-height: 1.55; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.button { min-height: 50px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 13px 20px; border: 0; border-radius: 16px; font-weight: 900; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button svg, .card-link svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.button.primary { color: #fff; background: var(--green); box-shadow: 0 6px 0 var(--green-dark); }
.button.primary:hover { background: #438d6b; transform: translateY(-2px); }
.button.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--green-dark); }
.button.secondary { color: var(--ink); border: 2px solid #d9ceb1; background: #fffaf0; box-shadow: 0 4px 0 #e1d4b5; }
.button.secondary:hover { background: #fff; transform: translateY(-2px); }
.button.hint { color: #664a16; background: #ffe6a4; box-shadow: 0 5px 0 #d7a839; }
.button.hint:hover { background: #ffdc7e; transform: translateY(-2px); }
.button:disabled { cursor: default; opacity: .55; transform: none !important; }
.hero-stats { display: flex; gap: 24px; margin: 34px 0 0; padding: 0; list-style: none; }
.hero-stats li { display: flex; align-items: baseline; gap: 6px; }
.hero-stats b { font-family: Georgia, serif; color: var(--coral); font-size: 29px; }
.hero-stats span { color: var(--muted); font-size: 14px; }
.hero-art { position: relative; display: grid; place-items: center; min-height: 470px; background: linear-gradient(145deg, #dcebd9 0 65%, #f4cf84 65%); }
.family-preview { position: relative; width: min(365px, 88%); aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: #fff8df; overflow: hidden; }
.sunburst { position: absolute; inset: -15%; opacity: .55; background: repeating-conic-gradient(from -8deg, rgba(240,185,68,.28) 0 12deg, transparent 12deg 25deg); }
.family-preview .animal { position: absolute; width: 72%; height: 72%; object-fit: contain; filter: drop-shadow(0 10px 10px rgba(53,55,37,.17)); }
.family-preview .mother { left: 4%; top: 2%; }
.family-preview .baby { width: 47%; height: 47%; right: 1%; bottom: 2%; }
.paper-label { position: absolute; left: 8%; bottom: 8%; padding: 8px 14px; color: #fff; background: var(--coral); border: 3px solid #fff7e5; border-radius: 7px; font-weight: 900; letter-spacing: 2px; transform: rotate(-5deg); box-shadow: 0 5px 8px rgba(77,52,31,.14); }
.sample-word { position: absolute; right: 9%; bottom: 8%; display: flex; gap: 7px; transform: rotate(3deg); }
.sample-word span { padding: 11px 15px; border: 3px solid #fff; border-radius: 10px; background: #5aa6cf; color: #fff; font-size: 21px; font-weight: 900; box-shadow: 0 5px 0 #337ca4; }
.sample-word span:last-child { background: #efb640; box-shadow: 0 5px 0 #c98b20; }

.how { margin-top: 22px; padding: 31px 38px 34px; }
.section-heading { margin: 34px 0 19px; }
.how .section-heading { margin-top: 0; }
.section-heading h2 { margin-bottom: 0; font-size: 31px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.steps article { min-width: 0; display: flex; align-items: center; gap: 14px; padding: 17px; border: 2px dashed #e2d5b5; border-radius: 19px; background: #fffaf0; }
.steps article > span { flex: 0 0 auto; width: 43px; height: 43px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-family: Georgia, serif; font-size: 21px; font-weight: 900; }
.steps b { display: block; margin-bottom: 3px; }
.steps p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.35; }
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.level-card { min-width: 0; position: relative; display: flex; flex-direction: column; min-height: 350px; padding: 27px; overflow: hidden; border: 2px solid rgba(104,82,40,.17); border-radius: 29px; box-shadow: 0 11px 0 rgba(104,82,40,.13); }
.level-card.coral { background: #fde2da; }
.level-card.blue { background: #deedf1; }
.level-card.green { background: #e3eddb; }
.level-number { position: absolute; right: 17px; top: 7px; color: rgba(39,78,74,.13); font-family: Georgia, serif; font-size: 88px; font-weight: 900; line-height: 1; }
.level-copy { position: relative; z-index: 1; }
.level-copy p { margin: 0 0 7px; color: #8b7551; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.level-copy h3 { margin-bottom: 7px; font-size: 26px; }
.level-copy span { color: #627773; line-height: 1.45; }
.level-demo { display: flex; flex-wrap: wrap; gap: 7px; min-height: 76px; align-items: center; margin: 24px 0 18px; }
.level-demo i { padding: 10px 13px; border: 3px solid #fffaf0; border-radius: 11px; background: var(--yellow); box-shadow: 0 5px 0 #c48c26; color: #fff; font-style: normal; font-size: 20px; font-weight: 900; transform: rotate(-2deg); }
.level-demo i:nth-child(even) { background: var(--blue); box-shadow-color: #347da3; transform: rotate(2deg); }
.level-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: auto; color: #607570; font-size: 13px; font-weight: 800; }
.level-meta span:last-child { color: #b47d1d; }
.card-link { min-height: 48px; display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; margin-top: 14px; padding: 10px 15px; border: 0; border-radius: 14px; color: #fff; background: var(--green); font-weight: 900; cursor: pointer; }
.card-link:hover { background: var(--green-dark); transform: translateY(-1px); }
.grownup-note { max-width: 760px; margin: 28px auto 0; color: #6c7f79; text-align: center; line-height: 1.55; }

.game-shell { padding: 26px 30px 32px; }
.game-topline { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; }
.round-button { width: 48px; height: 48px; border: 2px solid #ded2b5; border-radius: 16px; background: #fff9eb; color: var(--ink); font-size: 36px; line-height: 1; cursor: pointer; }
.round-button:hover { background: #fff; transform: translateX(-2px); }
.progress-copy span { display: block; color: #a47727; font-size: 12px; font-weight: 900; letter-spacing: 1.5px; text-transform: uppercase; }
.progress-copy b { display: block; margin-top: 3px; }
.progress-count { display: flex; align-items: baseline; gap: 4px; color: #7b8c86; }
.progress-count b { color: var(--coral); font: 900 28px Georgia, serif; }
.progress-track { height: 8px; margin: 15px 0 24px 62px; border-radius: 9px; background: #eee6d2; overflow: hidden; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--yellow), var(--coral)); transition: width .3s ease; }
.challenge { display: grid; grid-template-columns: minmax(290px, .74fr) minmax(0, 1.26fr); gap: 26px; }
.animal-stage { display: flex; flex-direction: column; align-items: center; min-width: 0; padding: 22px 18px 18px; border-radius: 28px; background: #eef2da; text-align: center; }
.stage-note { align-self: flex-start; padding: 6px 11px; border-radius: 9px; color: #fff; background: var(--coral); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; transform: rotate(-3deg); }
.portrait-ring { position: relative; width: min(315px, 100%); aspect-ratio: 1; margin-top: 3px; border-radius: 50%; overflow: hidden; background: #fff7dc; }
.portrait-ring img { position: relative; z-index: 1; width: 100%; height: 100%; padding: 5%; object-fit: contain; filter: drop-shadow(0 10px 10px rgba(47,55,38,.18)); }
.animal-stage p { margin: 8px 0 0; color: #647873; line-height: 1.4; }
.word-workbench { min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 17px 5px; }
.word-workbench h1 { margin-bottom: 22px; font-size: clamp(29px, 4vw, 43px); }
.slots, .tile-tray { display: flex; flex-wrap: wrap; gap: 9px; }
.slots { min-height: 76px; padding: 11px; border: 2px dashed #d8c9a5; border-radius: 19px; background: #fffaf0; }
.slot, .word-tile { min-width: 68px; min-height: 52px; padding: 8px 13px; border-radius: 13px; font-weight: 900; letter-spacing: .5px; cursor: pointer; }
.slot { border: 2px dashed #cfc2a2; color: #a99877; background: rgba(255,255,255,.58); }
.slot > span { display: grid; place-items: center; width: 23px; height: 23px; margin: auto; border-radius: 50%; color: #aa9875; background: #ede4d1; font-size: 12px; }
.slot.filled { border: 3px solid #fff; color: #fff; background: var(--blue); box-shadow: 0 5px 0 #367ea4; }
.slot.filled:hover { transform: translateY(-2px) rotate(-1deg); }
.slot.wrong { background: var(--coral); box-shadow: 0 5px 0 #ba5148; animation: nudge .34s ease; }
.tile-tray { min-height: 77px; margin-top: 15px; padding: 12px; align-items: center; justify-content: center; border-radius: 19px; background: #edf3e7; }
.word-tile { border: 3px solid #fff; color: #fff; background: var(--yellow); box-shadow: 0 5px 0 #c58d25; }
.word-tile:nth-child(3n) { background: var(--green); box-shadow-color: var(--green-dark); transform: rotate(1deg); }
.word-tile:nth-child(3n+1) { transform: rotate(-1deg); }
.word-tile:hover { transform: translateY(-3px) rotate(0); }
.word-tile.used { visibility: hidden; pointer-events: none; }
.slots.many, .tile-tray.many { gap: 6px; }
.slots.many .slot, .tile-tray.many .word-tile { min-width: 47px; padding: 7px 9px; }
.message { min-height: 58px; display: flex; align-items: center; gap: 10px; margin-top: 17px; padding: 10px 14px; border-radius: 15px; color: #607570; background: #f7f2e7; }
.message > span { flex: 0 0 auto; width: 33px; height: 33px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #9aab9f; font-weight: 900; }
.message p { margin: 0; line-height: 1.35; }
.message.error { color: #884941; background: #fde4df; }
.message.error > span { background: var(--coral); }
.message.hinted, .message.notice { color: #76561c; background: #fff0c5; }
.message.hinted > span, .message.notice > span { background: var(--yellow); }
.message.success { color: #2f7258; background: #dff2e7; }
.message.success > span { background: var(--green); }
.game-actions { display: flex; justify-content: space-between; gap: 13px; margin-top: 17px; }

.success-card { display: grid; grid-template-columns: auto 1fr 240px auto; align-items: center; gap: 22px; margin-top: 22px; padding: 22px 27px; overflow: hidden; }
.success-stamp { padding: 10px 14px; border: 3px solid #fff; border-radius: 10px; color: #fff; background: var(--green); box-shadow: 0 5px 0 var(--green-dark); font-weight: 900; transform: rotate(-5deg); }
.success-copy h2 { margin-bottom: 5px; font-size: 31px; }
.success-copy p:last-child { margin: 0; color: var(--muted); line-height: 1.4; }
.family-pair { position: relative; height: 130px; }
.family-pair img { position: absolute; width: 135px; height: 125px; object-fit: contain; filter: drop-shadow(0 7px 7px rgba(41,55,39,.15)); }
.family-pair img:first-child { left: 0; top: 0; }
.family-pair img:last-child { right: 0; bottom: -3px; width: 105px; height: 105px; }

.result { min-height: 520px; display: grid; grid-template-columns: .85fr 1.15fr; overflow: hidden; }
.result-art { position: relative; display: grid; place-items: center; padding: 35px; background: #e4eddc; }
.result-family { width: min(390px, 95%); }
.ribbon { position: absolute; right: 8%; bottom: 12%; padding: 10px 16px; border: 3px solid #fff; border-radius: 9px; color: #fff; background: var(--coral); font-weight: 900; transform: rotate(-4deg); }
.result-copy { align-self: center; padding: 48px 45px; }
.result-copy h1 { margin-bottom: 10px; font-size: clamp(37px, 5vw, 57px); line-height: 1.02; }
.result-copy > p { color: var(--muted); font-size: 18px; line-height: 1.5; }
.stars { display: flex; gap: 7px; margin: 15px 0; }
.stars span { color: #e3dcc8; font-size: 46px; text-shadow: 0 3px 0 #c7bea5; }
.stars span.earned { color: var(--yellow); text-shadow: 0 3px 0 #c4871d; }
.result dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 23px 0; }
.result dl div { padding: 12px; border-radius: 14px; background: #f7f1e3; text-align: center; }
.result dt { color: var(--muted); font-size: 12px; }
.result dd { margin: 4px 0 0; color: var(--ink); font: 900 25px Georgia, serif; }
.result-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.text-button { padding: 8px 4px; border: 0; background: transparent; color: var(--green-dark); font-weight: 900; text-decoration: underline; cursor: pointer; }

.atlas-head { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 35px 42px; }
.atlas-head h1 { margin-bottom: 8px; font-size: 44px; }
.atlas-head p:last-child { max-width: 680px; margin: 0; color: var(--muted); line-height: 1.5; }
.atlas-counter { flex: 0 0 auto; width: 140px; height: 140px; display: grid; place-content: center; border: 9px solid #f5d98d; border-radius: 50%; background: #fff8e6; text-align: center; box-shadow: inset 0 0 0 3px #fff; }
.atlas-counter b { color: var(--coral); font: 900 41px Georgia, serif; }
.atlas-counter span { color: var(--muted); font-size: 12px; }
.atlas-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 17px; margin-top: 22px; }
.atlas-card { min-width: 0; min-height: 330px; position: relative; padding: 20px; border: 2px solid rgba(182,157,101,.34); border-radius: 25px; background: #fffdf7; box-shadow: 0 8px 0 rgba(109,90,55,.11); overflow: hidden; }
.atlas-card::before { content: ""; position: absolute; left: 18px; right: 18px; top: 14px; border-top: 2px dashed #e8ddc5; }
.page-number { position: absolute; right: 14px; top: 19px; z-index: 2; color: #b29564; font: 900 14px Georgia, serif; }
.atlas-family { position: relative; height: 176px; margin-top: 13px; border-radius: 50% 45% 50% 46%; background: #eef2df; overflow: hidden; }
.atlas-family img { position: absolute; width: 68%; height: 96%; left: 0; top: 0; object-fit: contain; filter: drop-shadow(0 7px 7px rgba(45,55,39,.13)); }
.atlas-family img:last-child { width: 45%; height: 62%; left: auto; right: 3%; top: auto; bottom: 0; }
.atlas-card h2 { margin: 14px 0 5px; font-size: 24px; letter-spacing: 1px; }
.atlas-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.atlas-card.locked { display: grid; place-content: center; text-align: center; background: rgba(255,253,247,.7); }
.lock-mark { width: 96px; height: 96px; display: grid; place-items: center; margin: 0 auto 15px; border: 3px dashed #cfbea0; border-radius: 50%; color: #c0ae8b; background: #f5efdf; font: 900 43px Georgia, serif; }
.atlas-actions { display: flex; justify-content: center; margin-top: 28px; }

@keyframes nudge { 0%,100% { transform: translateX(0); } 33% { transform: translateX(-5px); } 66% { transform: translateX(5px); } }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-copy { padding: 43px 38px 35px; }
  .hero-art { min-height: 360px; }
  .level-grid { grid-template-columns: 1fr; }
  .level-card { min-height: 0; }
  .steps { grid-template-columns: 1fr; }
  .challenge { grid-template-columns: 1fr; }
  .portrait-ring { width: min(280px, 80vw); }
  .success-card { grid-template-columns: auto 1fr; }
  .family-pair { display: none; }
  .success-card .button { grid-column: 1 / -1; }
  .result { grid-template-columns: 1fr; }
  .result-art { min-height: 380px; }
  .atlas-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .app { width: min(100% - 18px, 1120px); padding-top: 9px; }
  .topbar { align-items: flex-start; gap: 8px; }
  .brand-mark { width: 45px; height: 45px; border-radius: 15px; }
  .brand b { font-size: 16px; }
  .brand small { display: none; }
  .top-actions { gap: 5px; }
  .top-button { min-height: 44px; padding: 8px 10px; font-size: 13px; }
  .paper-card { border-radius: 26px; }
  .hero-copy { padding: 31px 22px 26px; }
  .hero h1 { font-size: 40px; }
  .hero-text { font-size: 16px; }
  .hero-actions .button { width: 100%; }
  .hero-stats { gap: 12px; justify-content: space-between; }
  .hero-stats li { display: block; text-align: center; }
  .hero-stats span { display: block; }
  .hero-art { min-height: 330px; }
  .sample-word { right: 4%; }
  .how { padding: 25px 17px; }
  .section-heading h2 { font-size: 27px; }
  .level-card { padding: 23px 19px; border-radius: 24px; }
  .game-shell { padding: 18px 11px 22px; }
  .game-topline { gap: 9px; }
  .progress-copy b { font-size: 14px; }
  .progress-track { margin-left: 0; }
  .animal-stage { padding: 13px 10px; }
  .portrait-ring { width: min(235px, 75vw); }
  .word-workbench { padding: 15px 0 0; }
  .word-workbench h1 { margin-bottom: 15px; font-size: 27px; }
  .slots, .tile-tray { justify-content: center; gap: 6px; padding: 8px; }
  .slot, .word-tile { min-width: 55px; min-height: 48px; padding: 6px 10px; font-size: 15px; }
  .slots.many .slot, .tile-tray.many .word-tile { min-width: 39px; min-height: 45px; padding: 5px 7px; }
  .message { font-size: 14px; }
  .game-actions { flex-direction: column-reverse; }
  .game-actions .button { width: 100%; }
  .success-card { grid-template-columns: 1fr; padding: 22px 18px; text-align: center; }
  .success-stamp { justify-self: center; }
  .success-copy h2 { font-size: 28px; }
  .result-art { min-height: 330px; padding: 25px; }
  .result-copy { padding: 34px 21px; }
  .result-copy h1 { font-size: 39px; }
  .result dl { gap: 5px; }
  .result dl div { padding: 9px 5px; }
  .result dt { font-size: 10px; }
  .result-actions .button, .result-actions .text-button { width: 100%; }
  .atlas-head { align-items: flex-start; padding: 28px 20px; }
  .atlas-head h1 { font-size: 35px; }
  .atlas-counter { width: 95px; height: 95px; border-width: 6px; }
  .atlas-counter b { font-size: 30px; }
  .atlas-counter span { font-size: 9px; }
  .atlas-grid { grid-template-columns: 1fr; gap: 13px; }
  .atlas-card { min-height: 300px; }
}

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