:root {
  --paper: #fffdf6;
  --ink: #23483a;
  --muted: #66776e;
  --green: #3f8e67;
  --green-soft: #e7f4e8;
  --orange: #df8d55;
  --orange-soft: #fff0e6;
  --gold: #e2b84f;
  --line: #e6dac4;
  --shadow: 0 20px 48px rgba(58, 73, 61, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at 84% 5%, #dff0d9 0 9%, transparent 31%), radial-gradient(circle at 8% 18%, #ffedb9 0 9%, transparent 34%), linear-gradient(145deg, #fffaf0, #f0f1e7); font-family: "Trebuchet MS", Arial, sans-serif; }
button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 4px solid rgba(226, 184, 79, .58); outline-offset: 3px; }

.app { width: min(1120px, calc(100% - 32px)); margin: 22px auto 38px; }
.game-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; padding: 0 5px; }
.game-brand { display: inline-flex; min-width: 0; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.game-brand > span:last-child { display: grid; min-width: 0; gap: 2px; }
.game-brand strong { overflow: hidden; font-size: 22px; line-height: 1.06; text-overflow: ellipsis; white-space: nowrap; }
.game-brand small { color: var(--muted); font-size: 13px; }
.game-icon { display: grid; width: 57px; height: 57px; flex: none; place-items: center; border-radius: 18px; color: white; background: linear-gradient(145deg, #d39455, #7c8659); box-shadow: 0 9px 18px rgba(111, 109, 69, .25); }
.game-icon svg { width: 39px; height: 39px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.35; }
.age-pill { flex: none; padding: 10px 14px; border: 2px solid #efd8a7; border-radius: 999px; color: #795e2d; background: #fff6dc; font-weight: 900; }

.screen { display: none; padding: 31px; overflow: hidden; border: 1px solid rgba(224, 211, 187, .88); border-radius: 34px; background: rgba(255, 253, 246, .97); box-shadow: var(--shadow); }
.screen.is-active { display: block; }
.eyebrow { margin: 0 0 8px; color: #a66d25; font-size: 12px; font-weight: 1000; letter-spacing: .12em; }
h1, h2, h3, p { text-wrap: pretty; }
h1, h2, h3 { margin-top: 0; line-height: 1.06; }
h1 { margin-bottom: 18px; font-size: clamp(42px, 5.2vw, 66px); letter-spacing: -.045em; }
h2 { margin-bottom: 7px; font-size: clamp(31px, 4vw, 46px); letter-spacing: -.035em; }
h3 { margin-bottom: 10px; font-size: 27px; }

.primary-button, .secondary-button, .route-button, .hide-button, .hint-button, .next-button, .round-button, .text-button { border: 0; cursor: pointer; font-weight: 1000; transition: transform .16s ease, box-shadow .16s ease, background .16s ease, opacity .16s ease; }
.primary-button, .route-button, .hide-button, .next-button { display: inline-flex; min-height: 50px; align-items: center; justify-content: center; gap: 9px; padding: 13px 18px; border-radius: 16px; color: white; background: linear-gradient(145deg, #4c9a71, #337b5a); box-shadow: 0 8px 17px rgba(51, 123, 90, .22); }
.primary-button:hover, .route-button:hover, .hide-button:hover, .next-button:hover { transform: translateY(-2px); box-shadow: 0 11px 23px rgba(51, 123, 90, .28); }
.secondary-button { min-height: 50px; padding: 12px 17px; border: 2px solid #cbded1; border-radius: 16px; background: #eff8f1; }
.text-button { padding: 12px 2px 0; color: #517064; background: transparent; }

.home-screen.is-active { display: grid; grid-template-columns: minmax(0, .84fr) minmax(430px, 1.16fr); gap: 24px 36px; align-items: center; }
.hero-copy > p:not(.eyebrow) { max-width: 505px; margin: 0 0 24px; color: var(--muted); font-size: 19px; line-height: 1.48; }
.hero-scene { min-width: 0; }
.hero-scene .place-scene { box-shadow: 0 16px 30px rgba(45, 65, 51, .18); transform: rotate(1deg); }
.hero-scene .place-slot small, .route-preview .place-slot small { display: none; }
.how-strip { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; padding-top: 8px; }
.how-strip article { display: flex; min-height: 98px; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: #fffdf8; }
.how-strip article > b { display: grid; width: 38px; height: 38px; flex: none; place-items: center; border-radius: 13px; color: white; background: var(--orange); transform: rotate(-3deg); }
.how-strip article span { display: grid; gap: 4px; }
.how-strip article strong { line-height: 1.1; }
.how-strip article small { color: var(--muted); line-height: 1.25; }

.section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 23px; }
.section-title > p { margin: 0 0 5px; color: #587066; font-weight: 900; }
.route-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; align-items: stretch; }
.route-card { display: flex; min-width: 0; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: white; box-shadow: 0 10px 25px rgba(62, 76, 62, .08); }
.route-preview { position: relative; min-height: 210px; overflow: hidden; background: var(--route-soft); }
.route-preview .place-scene { position: absolute; inset: 0; height: auto; border: 0; border-radius: 0; aspect-ratio: auto; }
.route-preview .place-slot { transform: translate(-50%, -50%) scale(.82); }
.route-count { position: absolute; z-index: 9; top: 12px; right: 12px; display: grid; width: 52px; height: 52px; place-items: center; border: 4px solid rgba(255,255,255,.9); border-radius: 16px; color: white; background: var(--route-accent); font-size: 22px; font-weight: 1000; box-shadow: 0 5px 12px rgba(48,61,48,.16); transform: rotate(3deg); }
.route-copy { display: flex; min-height: 288px; flex: 1; flex-direction: column; padding: 17px; }
.route-copy h3 { font-size: 25px; }
.route-copy > p:not(.eyebrow) { min-height: 76px; margin: 0 0 15px; color: var(--muted); line-height: 1.37; }
.route-progress { height: 9px; margin-top: auto; overflow: hidden; border-radius: 999px; background: #eee7da; }
.route-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #edaf45, var(--route-accent)); }
.route-meta { display: flex; justify-content: space-between; margin: 7px 1px 14px; color: #617269; font-size: 12px; font-weight: 900; }
.route-button { width: 100%; background: linear-gradient(145deg, color-mix(in srgb, var(--route-accent), white 9%), var(--route-accent)); }

.task-head { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 13px; }
.task-head h2 { margin: 0; font-size: clamp(28px, 4vw, 42px); }
.round-button { display: grid; width: 46px; height: 46px; place-items: center; border: 2px solid #d9e4d9; border-radius: 50%; background: #f4f8f2; font-size: 25px; }
.counter { padding: 9px 12px; border-radius: 999px; color: #476c59; background: var(--green-soft); font-weight: 1000; }
.task-progress { height: 8px; margin: 16px 0 20px; overflow: hidden; border-radius: 999px; background: #eee7d9; }
.task-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #e8ad48, #4c9b72); transition: width .25s ease; }

.memory-board { display: grid; grid-template-columns: minmax(0, 1.38fr) minmax(300px, .62fr); gap: 20px; align-items: start; }
.scene-card { padding: 12px; border: 1px solid #dcd3c2; border-radius: 27px; background: linear-gradient(150deg, #e6dfd1, #fffaf0); }
.place-scene { position: relative; overflow: hidden; aspect-ratio: 16 / 10; border: 7px solid white; border-radius: 22px; background: #d8eadb; }
.scene-background { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scene-shade { position: absolute; z-index: 1; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(32,62,42,.1)); }
.place-slot { position: absolute; z-index: 3; width: 21%; aspect-ratio: 1 / 1.04; transform: translate(-50%, -50%); }
.place-scene[data-count="4"] .place-slot { width: 18%; }
.place-scene[data-count="5"] .place-slot { width: 15.5%; }
.felt-mat { position: absolute; right: 0; bottom: 3%; left: 0; height: 31%; border: 3px dashed rgba(255,255,255,.68); border-radius: 46% 46% 38% 38%; background: var(--mat-color); box-shadow: inset 0 -5px 0 rgba(82,64,48,.11), 0 7px 10px rgba(43,57,42,.18); transform: perspective(120px) rotateX(22deg); transition: box-shadow .18s ease, filter .18s ease, transform .18s ease; }
.place-slot::after { position: absolute; z-index: 1; right: 12%; bottom: 6%; left: 12%; height: 11%; border-radius: 50%; background: rgba(36,49,36,.2); content: ""; filter: blur(4px); }
.place-animal { position: absolute; z-index: 3; right: 8%; bottom: 12%; left: 8%; width: 84%; height: 81%; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 7px 6px rgba(34,48,36,.2)); transform-origin: center bottom; transition: opacity .18s ease, transform .18s ease; }
.place-animal.is-mirrored { transform: scaleX(-1); }
.place-slot small { position: absolute; z-index: 5; bottom: -24px; left: 50%; width: max-content; max-width: 150px; padding: 3px 7px 4px; border: 1px solid rgba(255,255,255,.94); border-radius: 999px; color: #24483a; background: rgba(255,251,235,.92); box-shadow: 0 2px 7px rgba(49,55,38,.16); font-size: clamp(12px, 1.45vw, 16px); font-weight: 1000; line-height: 1.05; text-align: center; text-shadow: 0 1px 0 white; white-space: nowrap; transform: translateX(-50%); }
.place-slot.is-edge-left small { left: 0; transform: none; }
.place-slot.is-edge-right small { right: 0; left: auto; transform: none; }
.place-slot.is-active .felt-mat { border-width: 4px; border-style: solid; border-color: #fffbe8; box-shadow: 0 0 0 4px #d98b16, 0 0 0 11px rgba(255,224,67,.88), 0 0 30px 18px rgba(255,184,35,.62), inset 0 0 0 3px rgba(255,255,255,.58), inset 0 -5px 0 rgba(82,64,48,.1), 0 10px 17px rgba(43,57,42,.24); filter: saturate(1.3) brightness(1.13) contrast(1.06); transform: perspective(120px) rotateX(22deg) scale(1.1); animation: active-mat-pulse 1.3s ease-in-out infinite; }
.place-slot.is-correct .felt-mat { border-color: rgba(235,255,235,.92); box-shadow: 0 0 0 5px rgba(83,165,109,.22), 0 7px 10px rgba(43,57,42,.18); }
.place-slot.is-correct::before { position: absolute; z-index: 7; top: 0; right: 3%; display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; color: white; background: #4c9b6d; content: "✓"; font-weight: 1000; }
.scene-note { min-height: 38px; margin: 9px 8px 0; color: var(--muted); font-size: 14px; line-height: 1.35; text-align: center; }

.guide-card { padding: 21px; border: 1px solid var(--line); border-radius: 24px; background: white; box-shadow: 0 10px 24px rgba(54,70,58,.08); }
.guide-card h3 { font-size: 27px; }
.place-progress { display: flex; align-items: center; gap: 8px; min-height: 58px; margin: 13px 0 15px; padding: 10px; border-radius: 16px; background: #f3eee4; }
.place-dot { position: relative; display: grid; width: 40px; height: 40px; flex: 1; max-width: 53px; place-items: center; border: 2px dashed #c9bda8; border-radius: 13px; color: #8c7c64; background: #fffaf0; font-weight: 1000; }
.place-dot.is-current { border-style: solid; border-color: #e6b94b; color: #755b1f; background: #fff2b8; box-shadow: 0 0 0 4px rgba(230,185,75,.16); }
.place-dot.is-correct { border-style: solid; border-color: #61a878; color: white; background: #58a171; }
.feedback { display: grid; gap: 4px; min-height: 110px; padding: 14px; border-radius: 16px; color: #5d6f65; background: #f4f1e8; line-height: 1.3; }
.feedback b { color: var(--ink); }
.feedback.is-warn { color: #835533; background: var(--orange-soft); }
.feedback.is-warn b { color: #974c25; }
.feedback.is-hint { color: #725c21; background: #fff6d2; }
.feedback.is-success { color: #31634a; background: var(--green-soft); }
.task-actions { display: grid; gap: 9px; margin-top: 13px; }
.hide-button { width: 100%; background: linear-gradient(145deg, #c1844e, #a66a36); box-shadow: 0 8px 17px rgba(157,94,43,.22); }
.hint-button { display: inline-flex; min-height: 49px; align-items: center; justify-content: center; gap: 7px; padding: 11px 12px; border: 2px solid #ead69d; border-radius: 15px; background: #fff7dc; }
.hint-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.next-button { width: 100%; }

.candidate-panel { grid-column: 1 / -1; padding: 18px; border: 1px solid var(--line); border-radius: 24px; background: linear-gradient(145deg, #fffdf8, #f6f2e7); }
.candidate-panel > header { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; margin-bottom: 13px; }
.candidate-panel h3 { margin: 0; font-size: 25px; }
.candidate-panel header small { color: var(--muted); font-weight: 900; }
.candidate-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.candidate-grid[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.candidate-grid[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.candidate-card { position: relative; display: grid; min-width: 0; min-height: 140px; padding: 8px 8px 11px; place-items: center; border: 3px solid #e7ddca; border-radius: 20px; color: var(--ink); background: white; box-shadow: 0 7px 14px rgba(51,66,54,.08); cursor: pointer; transition: transform .15s ease, border-color .15s ease, background .15s ease, opacity .15s ease; }
.candidate-card:hover:not(:disabled) { border-color: #e5bd58; transform: translateY(-3px); }
.candidate-card img { width: 100%; height: 92px; object-fit: contain; filter: drop-shadow(0 5px 4px rgba(42,53,43,.16)); }
.candidate-card b { overflow: hidden; max-width: 100%; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.candidate-card.is-wrong { border-color: #e99a6f; background: #fff0e8; animation: card-wiggle .32s ease 2; }
.candidate-card.is-hint { border-color: #e3b840; background: #fff3bd; box-shadow: 0 0 0 6px rgba(231,187,63,.2), 0 8px 18px rgba(52,63,49,.12); transform: translateY(-4px); }
.candidate-card.is-used { border-color: #79b48b; background: #e9f6e9; opacity: .62; }
.candidate-card.is-used::after { position: absolute; top: 7px; right: 7px; display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; color: white; background: #4c9b6d; content: "✓"; font-weight: 1000; }
@keyframes card-wiggle { 33% { transform: translateX(-5px); } 66% { transform: translateX(5px); } }
@keyframes active-mat-pulse { 50% { box-shadow: 0 0 0 5px #d1770d, 0 0 0 14px rgba(255,228,77,.94), 0 0 34px 22px rgba(255,169,28,.68), inset 0 0 0 3px rgba(255,255,255,.68), inset 0 -5px 0 rgba(82,64,48,.1), 0 11px 19px rgba(43,57,42,.26); transform: perspective(120px) rotateX(22deg) scale(1.14); } }

.result-screen.is-active { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(300px, .72fr); gap: 30px; align-items: center; }
.result-scene .place-scene { box-shadow: 0 16px 28px rgba(46,67,52,.18); transform: rotate(-1deg); }
.result-copy > p:not(.eyebrow) { color: var(--muted); font-size: 18px; line-height: 1.5; }
.result-facts { display: flex; gap: 10px; margin: 18px 0; }
.result-facts span { padding: 10px 13px; border-radius: 13px; background: #f2eadb; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 1024px) {
  .home-screen.is-active { grid-template-columns: minmax(0, .84fr) minmax(390px, 1.16fr); }
  .memory-board { grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr); }
  .route-preview { min-height: 190px; }
  .route-copy { min-height: 310px; }
  .place-slot { width: 23%; }
  .place-scene[data-count="4"] .place-slot { width: 19%; }
  .place-scene[data-count="5"] .place-slot { width: 16%; }
}

@media (max-width: 860px) {
  .home-screen.is-active, .result-screen.is-active { grid-template-columns: 1fr; }
  .hero-scene { width: min(100%, 650px); justify-self: center; }
  .memory-board { grid-template-columns: 1fr; }
  .guide-card { display: grid; grid-template-columns: minmax(0, .82fr) minmax(270px, 1.18fr); gap: 0 14px; }
  .guide-card .eyebrow, .guide-card h3, .place-progress { grid-column: 1; }
  .feedback, .task-actions { grid-column: 2; }
  .feedback { grid-row: 1 / span 3; }
  .task-actions { align-self: end; }
  .candidate-panel { grid-column: 1; }
}

@media (max-width: 760px) {
  .app { width: min(1120px, calc(100% - 20px)); margin-top: 16px; }
  .game-head { align-items: flex-start; }
  .game-brand small { display: none; }
  .game-icon { width: 48px; height: 48px; border-radius: 15px; }
  .screen { padding: 19px; border-radius: 25px; }
  .hero-copy h1 { font-size: clamp(38px, 11vw, 53px); }
  .how-strip { grid-template-columns: 1fr; }
  .how-strip article { min-height: 72px; }
  .route-preview { min-height: 160px; }
  .route-copy { min-height: 330px; }
  .section-title { align-items: flex-start; flex-direction: column; }
  .candidate-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .candidate-grid[data-count="4"], .candidate-grid[data-count="5"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .route-grid { grid-template-columns: 1fr; }
  .route-preview { min-height: 220px; }
  .route-copy { min-height: 280px; }
  .route-copy > p:not(.eyebrow) { min-height: 0; }
  .guide-card { display: block; }
  .feedback { min-height: 84px; }
  .place-scene { aspect-ratio: 10 / 12; }
  .place-slot { width: 29%; }
  .place-scene[data-count="4"] .place-slot { width: 24%; }
  .place-scene[data-count="5"] .place-slot { width: 20%; }
  .candidate-card { min-height: 118px; }
  .candidate-card img { height: 72px; }
}

@media (max-width: 430px) {
  .app { width: min(1120px, calc(100% - 14px)); }
  .game-head { gap: 7px; }
  .game-brand { gap: 8px; }
  .game-brand strong { font-size: 16px; }
  .age-pill { padding: 8px 9px; font-size: 12px; }
  .screen { padding: 13px; border-radius: 21px; }
  .hero-copy > p:not(.eyebrow) { font-size: 17px; }
  .task-head { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 8px; }
  .round-button { width: 39px; height: 39px; }
  .task-head h2 { font-size: 24px; }
  .counter { padding: 7px 8px; font-size: 12px; }
  .scene-card { padding: 7px; border-radius: 20px; }
  .place-scene { border-width: 5px; border-radius: 18px; }
  .scene-note { font-size: 12px; }
  .guide-card { padding: 14px; border-radius: 20px; }
  .guide-card h3 { font-size: 23px; }
  .place-progress { gap: 5px; min-height: 54px; padding: 8px; }
  .place-dot { width: 34px; height: 34px; font-size: 13px; }
  .feedback { font-size: 14px; }
  .candidate-panel { padding: 12px; border-radius: 19px; }
  .candidate-panel > header { align-items: flex-start; flex-direction: column; }
  .candidate-panel h3 { font-size: 21px; }
  .candidate-grid { gap: 7px; }
  .candidate-card { min-height: 103px; padding: 5px; border-width: 2px; border-radius: 15px; }
  .candidate-card img { height: 63px; }
  .candidate-card b { font-size: 10px; }
  .hint-button, .hide-button, .next-button { width: 100%; }
}

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