:root {
  --ink: #24463a;
  --muted: #65766e;
  --paper: #fffdf7;
  --line: #ded7c9;
  --green: #3f8c68;
  --green-dark: #2f6f54;
  --green-soft: #e3f2e7;
  --gold: #e4ac3f;
  --gold-soft: #fff3c7;
  --orange: #d27643;
  --orange-soft: #ffeadc;
  --shadow: 0 15px 38px rgba(58, 68, 54, .13);
}

* { box-sizing: border-box; }
html { min-width: 320px; color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at 8% 12%, rgba(255,221,118,.34), transparent 28%), radial-gradient(circle at 93% 10%, rgba(162,222,183,.35), transparent 29%), #f8f2df; font-family: "Trebuchet MS", Arial, sans-serif; }
button { color: inherit; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 4px solid rgba(234,177,57,.5); outline-offset: 3px; }
button:disabled { cursor: default; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.03; }

.app { width: min(1120px, calc(100% - 32px)); margin: 24px auto 0; }
.game-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 15px; padding: 12px 15px; border: 1px solid rgba(173,154,106,.22); border-radius: 24px; background: linear-gradient(120deg, rgba(255,250,230,.96), rgba(223,243,223,.95)); box-shadow: 0 8px 23px rgba(72,85,60,.1); }
.game-brand { display: flex; min-width: 0; align-items: center; gap: 12px; }
.game-brand > span:last-child { display: grid; min-width: 0; }
.game-brand strong { overflow: hidden; font-size: 21px; text-overflow: ellipsis; white-space: nowrap; }
.game-brand small { margin-top: 3px; color: var(--muted); }
.game-icon { display: grid; width: 58px; height: 58px; flex: 0 0 auto; place-items: center; border-radius: 18px; color: #fff6d2; background: linear-gradient(145deg, #d79a3b, #9e6a2e); box-shadow: 0 8px 14px rgba(137,86,37,.24); transform: rotate(-2deg); }
.game-icon svg { width: 42px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.age-pill { flex: 0 0 auto; padding: 10px 14px; border: 2px solid #ead6a2; border-radius: 999px; color: #765f2d; background: #fff8dc; font-weight: 900; }

.screen { display: none; padding: 30px; overflow: hidden; border: 1px solid rgba(171,155,116,.28); border-radius: 34px; background: rgba(255,253,247,.96); box-shadow: var(--shadow); }
.screen.is-active { display: block; }
.home-screen.is-active, .result-screen.is-active { display: grid; grid-template-columns: minmax(0, .82fr) minmax(470px, 1.18fr); align-items: center; gap: 25px; }
.eyebrow { margin-bottom: 8px; color: #a36e32; font-size: 12px; font-weight: 1000; letter-spacing: .15em; }
.hero-copy h1 { max-width: 520px; margin-bottom: 16px; font-size: clamp(42px, 5.6vw, 68px); letter-spacing: -.035em; }
.hero-copy > p:not(.eyebrow) { max-width: 510px; margin-bottom: 19px; color: var(--muted); font-size: 19px; line-height: 1.45; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.hero-facts span { padding: 8px 11px; border-radius: 999px; color: #3c6653; background: #e6f1e5; font-size: 13px; font-weight: 900; }
.primary-button, .secondary-button, .route-button, .hide-button, .next-button { min-height: 54px; padding: 13px 20px; border: 0; border-radius: 17px; color: white; background: linear-gradient(145deg, #4b9b72, #347c5a); box-shadow: 0 8px 17px rgba(45,111,79,.2); font-weight: 1000; cursor: pointer; }
.primary-button:hover, .route-button:hover, .hide-button:hover, .next-button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.secondary-button { border: 2px solid #4d8d6d; color: #356d52; background: white; box-shadow: none; }
.hero-copy .primary-button { min-width: 235px; }
.hero-board { min-height: 385px; }
.how-strip { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding-top: 1px; }
.how-strip article { display: flex; min-height: 88px; align-items: center; gap: 12px; padding: 14px; border: 1px solid #e2dac9; border-radius: 19px; background: linear-gradient(145deg, #fffdf8, #f6f1e5); }
.how-strip article > b { display: grid; width: 39px; height: 39px; flex: 0 0 auto; place-items: center; border-radius: 13px; color: #fff7d7; background: #b97f37; }
.how-strip article span { display: grid; gap: 3px; }
.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 h2 { margin-bottom: 0; font-size: clamp(32px, 4vw, 46px); }
.section-title > p { margin: 0 0 4px; color: var(--muted); 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: 230px; overflow: hidden; background: var(--route-soft); }
.route-preview .pair-stage { position: absolute; inset: 0; min-height: 0; padding: 13px; border: 0; border-radius: 0; }
.route-preview .pair-grid { gap: 6px; }
.route-preview .pair-card { min-height: 170px; grid-template-rows: 65px 12px 65px; padding: 7px 5px; border-radius: 16px; }
.route-preview .animal-image { height: 61px; }
.route-preview .gift-place { min-height: 61px; }
.route-preview .gift-image { height: 52px; }
.route-preview .pair-name, .route-preview .gift-name { display: none; }
.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: 298px; flex: 1; flex-direction: column; padding: 17px; }
.route-copy h3 { margin-bottom: 10px; font-size: 25px; }
.route-copy > p:not(.eyebrow) { min-height: 79px; margin-bottom: 15px; color: var(--muted); line-height: 1.38; }
.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)); }
.text-button { margin-top: 18px; padding: 10px 2px; border: 0; color: #4c7462; background: transparent; font-weight: 900; cursor: pointer; }

.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; cursor: pointer; }
.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.45fr) minmax(300px, .55fr); gap: 20px; align-items: start; }
.pair-stage-card { min-width: 0; padding: 12px; border: 1px solid #dcd3c2; border-radius: 27px; background: linear-gradient(150deg, #e6dfd1, #fffaf0); }
.pair-stage { position: relative; min-height: 390px; overflow: hidden; padding: 20px; border: 7px solid white; border-radius: 22px; background-color: #dcebd9; background-image: linear-gradient(rgba(250,246,226,.63), rgba(241,236,212,.72)), var(--board-image); background-position: center; background-size: cover; }
.pair-stage::before { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% 20%, rgba(255,255,255,.52), transparent 48%), linear-gradient(180deg, rgba(255,255,255,.08), rgba(72,83,53,.12)); content: ""; }
.pair-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(var(--pair-count), minmax(0, 1fr)); gap: 10px; align-items: stretch; }
.pair-card { position: relative; display: grid; min-width: 0; min-height: 320px; grid-template-rows: auto minmax(112px, 1fr) 18px minmax(105px, 1fr); align-items: center; padding: 12px 9px 10px; border: 3px solid rgba(255,255,255,.94); border-radius: 22px; background: rgba(255,252,239,.92); box-shadow: 0 10px 20px rgba(51,58,41,.16); transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.pair-card.is-active { border-color: #f4c13e; background: rgba(255,248,206,.97); box-shadow: 0 0 0 6px rgba(248,194,56,.32), 0 12px 24px rgba(87,66,24,.2); animation: pair-pulse 1.35s ease-in-out infinite; }
.pair-card.is-correct { border-color: #64aa7b; background: rgba(237,250,238,.97); box-shadow: 0 0 0 4px rgba(79,157,102,.2), 0 10px 20px rgba(47,86,56,.16); }
.pair-card.is-correct::after { position: absolute; z-index: 4; top: 8px; right: 8px; display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; color: white; background: #4f9b6a; content: "✓"; font-weight: 1000; }
.pair-name, .gift-name { overflow: hidden; font-weight: 1000; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.pair-name { width: 100%; color: #2d5544; font-size: clamp(12px, 1.1vw, 15px); }
.animal-image { width: 100%; height: 112px; object-fit: contain; filter: drop-shadow(0 6px 5px rgba(48,57,41,.16)); }
.pair-ribbon { position: relative; display: block; width: 72%; height: 5px; justify-self: center; border-radius: 999px; background: repeating-linear-gradient(90deg, #df9854 0 9px, #f8d982 9px 17px); }
.pair-ribbon::after { position: absolute; top: 50%; left: 50%; width: 13px; height: 13px; border: 3px solid #fff4cf; border-radius: 50%; background: #d98649; content: ""; transform: translate(-50%, -50%); }
.gift-place { display: grid; min-width: 0; min-height: 105px; place-items: center; align-self: stretch; padding: 4px; border: 2px solid rgba(211,177,100,.38); border-radius: 16px; background: rgba(255,255,255,.78); }
.gift-place.is-empty { border: 3px dashed #cdbf9d; color: #86775c; background: repeating-linear-gradient(135deg, rgba(255,255,255,.8) 0 10px, rgba(238,231,211,.8) 10px 20px); font-size: 12px; font-weight: 900; line-height: 1.2; text-align: center; }
.pair-card.is-active .gift-place.is-empty { border-style: solid; border-color: #d99116; color: #775513; background: #fff6c9; box-shadow: inset 0 0 0 4px rgba(255,255,255,.68), 0 0 0 5px rgba(241,177,39,.25); }
.gift-image { width: 100%; height: 85px; object-fit: contain; filter: drop-shadow(0 5px 5px rgba(54,57,37,.15)); }
.gift-name { width: 100%; margin-top: -3px; color: #604d32; font-size: 12px; }
.stage-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; }
.pair-progress { display: flex; align-items: center; gap: 8px; min-height: 58px; margin: 13px 0 15px; padding: 10px; border-radius: 16px; background: #f3eee4; }
.pair-dot { 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; }
.pair-dot.is-current { border-style: solid; border-color: #e6b94b; color: #755b1f; background: #fff2b8; box-shadow: 0 0 0 4px rgba(230,185,75,.16); }
.pair-dot.is-correct { border-style: solid; border-color: #61a878; color: white; background: #58a171; }
.feedback { display: grid; gap: 4px; min-height: 116px; 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; font-weight: 900; cursor: pointer; }
.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(var(--candidate-count), minmax(0, 1fr)); gap: 11px; }
.candidate-card { position: relative; display: grid; min-width: 0; min-height: 154px; place-items: center; padding: 8px; border: 3px solid #ddd5c8; border-radius: 19px; background: white; box-shadow: 0 7px 14px rgba(58,66,51,.1); cursor: pointer; transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.candidate-card:hover:not(:disabled) { border-color: #b99754; transform: translateY(-2px); }
.candidate-card img { width: 100%; height: 105px; object-fit: contain; }
.candidate-card b { overflow: hidden; max-width: 100%; font-size: 14px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.candidate-card.is-wrong { border-color: #d97649; background: #fff0e7; animation: card-wiggle .22s ease; }
.candidate-card.is-hint { border-color: #e6b53e; background: #fff7d4; box-shadow: 0 0 0 5px rgba(230,181,62,.22); }
.candidate-card.is-used { opacity: .68; border-color: #71aa82; background: #edf7ee; }
.candidate-card.is-used::after { position: absolute; top: 7px; right: 7px; display: grid; width: 25px; height: 25px; place-items: center; border-radius: 50%; color: white; background: #4c9a68; content: "✓"; font-weight: 1000; }

.result-board { min-height: 420px; }
.result-copy h2 { margin-bottom: 16px; font-size: clamp(37px, 5vw, 57px); }
.result-copy > p:not(.eyebrow) { color: var(--muted); font-size: 18px; line-height: 1.45; }
.result-facts { display: flex; gap: 9px; margin: 20px 0; }
.result-facts span { padding: 10px 13px; border-radius: 15px; color: #3d6854; background: var(--green-soft); font-weight: 900; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@keyframes card-wiggle { 33% { transform: translateX(-5px); } 66% { transform: translateX(5px); } }
@keyframes pair-pulse { 50% { box-shadow: 0 0 0 9px rgba(248,194,56,.37), 0 14px 27px rgba(87,66,24,.23); transform: translateY(-2px); } }

@media (max-width: 1050px) {
  .memory-board { grid-template-columns: 1fr; }
  .guide-card { display: grid; grid-template-columns: minmax(0, .85fr) minmax(300px, 1.15fr); gap: 0 14px; }
  .guide-card .eyebrow, .guide-card h3, .pair-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: 860px) {
  .home-screen.is-active, .result-screen.is-active { grid-template-columns: 1fr; }
  .hero-board, .result-board { width: min(100%, 690px); justify-self: center; }
}

@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; }
  .game-icon svg { width: 35px; }
  .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: 190px; }
  .route-copy { min-height: 338px; }
  .section-title { align-items: flex-start; flex-direction: column; }
  .candidate-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
  .route-grid { grid-template-columns: 1fr; }
  .route-preview { min-height: 250px; }
  .route-copy { min-height: 270px; }
  .route-copy > p:not(.eyebrow) { min-height: 0; }
  .guide-card { display: block; }
  .feedback { min-height: 84px; }
  .pair-stage { min-height: 0; padding: 12px; }
  .pair-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pair-grid[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pair-grid[data-count="5"] .pair-card:last-child { grid-column: 1 / -1; width: calc(50% - 5px); justify-self: center; }
  .pair-card { min-height: 222px; grid-template-rows: auto 75px 15px 82px; padding: 8px 5px 7px; border-radius: 17px; }
  .pair-grid[data-count="3"] .pair-card { min-height: 205px; grid-template-rows: auto 67px 13px 75px; }
  .animal-image { height: 75px; }
  .gift-place { min-height: 82px; }
  .gift-image { height: 62px; }
  .pair-name { font-size: 12px; }
  .gift-name { font-size: 10px; }
  .pair-ribbon { height: 4px; }
  .result-board { min-height: 0; }
}

@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; }
  .pair-stage-card { padding: 7px; border-radius: 20px; }
  .pair-stage { border-width: 5px; border-radius: 18px; }
  .pair-grid { gap: 7px; }
  .pair-grid[data-count="3"] { gap: 5px; }
  .pair-grid[data-count="3"] .pair-card { min-height: 190px; padding-inline: 3px; }
  .stage-note { font-size: 12px; }
  .guide-card { padding: 14px; border-radius: 20px; }
  .guide-card h3 { font-size: 23px; }
  .pair-progress { gap: 5px; min-height: 54px; padding: 8px; }
  .pair-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: 112px; padding: 5px; border-width: 2px; border-radius: 15px; }
  .candidate-card img { height: 76px; }
  .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; }
}
