:root {
  --ink: #24463a;
  --muted: #66766e;
  --paper: #fffdf7;
  --line: #ded5c4;
  --green: #4c946d;
  --green-dark: #347452;
  --green-soft: #e4f2e7;
  --gold: #dfa83f;
  --gold-soft: #fff3c9;
  --orange-soft: #ffeadf;
  --shadow: 0 15px 38px rgba(58, 68, 54, .13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at 9% 7%, rgba(255, 215, 96, .3), transparent 27%), radial-gradient(circle at 92% 15%, rgba(155, 214, 178, .35), transparent 29%), #f8f1dd; 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(232, 177, 58, .55); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.06; }

.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, .97), rgba(222, 243, 222, .96)); 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: #fff2c8; background: linear-gradient(145deg, #8670b0, #5d4b8d); box-shadow: 0 8px 14px rgba(87, 68, 133, .25); transform: rotate(-2deg); }
.game-icon svg { width: 43px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.7; }
.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, .97); box-shadow: var(--shadow); }
.screen.is-active { display: block; }
.home-screen.is-active, .result-screen.is-active { display: grid; grid-template-columns: minmax(0, .86fr) minmax(470px, 1.14fr); align-items: center; gap: 25px; }
.eyebrow { margin-bottom: 8px; color: #9a6935; font-size: 12px; font-weight: 1000; letter-spacing: .15em; }
.hero-copy h1 { max-width: 510px; margin-bottom: 16px; font-size: clamp(42px, 5vw, 61px); 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, var(--green), var(--green-dark)); 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: 392px; }
.how-strip { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding-top: 2px; }
.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: #9a6d40; }
.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; }

.quilt-scene { position: relative; display: grid; min-height: 392px; overflow: hidden; place-items: center; padding: 25px 34px; border: 7px solid white; border-radius: 27px; background: radial-gradient(circle at 16% 18%, rgba(255,255,255,.65), transparent 20%), linear-gradient(160deg, rgba(250, 235, 201, .96), rgba(221, 205, 169, .94)); box-shadow: inset 0 0 0 2px rgba(147, 110, 67, .14), 0 13px 24px rgba(70, 63, 43, .16); }
.quilt-scene::before { position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(90deg, transparent 0 52px, rgba(132, 98, 53, .055) 52px 54px); content: ""; transform: skewX(-3deg); }
.sewing-basket { position: absolute; z-index: 1; right: 18px; bottom: 13px; width: 80px; height: 48px; border: 5px solid rgba(118, 77, 38, .42); border-radius: 12px 12px 24px 24px; background: repeating-linear-gradient(0deg, #c28a4f 0 7px, #d5a364 7px 13px); opacity: .78; transform: rotate(3deg); }
.sewing-basket::before { position: absolute; left: 13px; bottom: 38px; width: 45px; height: 28px; border: 5px solid rgba(118, 77, 38, .42); border-bottom: 0; border-radius: 28px 28px 0 0; content: ""; }
.sewing-basket i { position: absolute; top: -13px; width: 24px; height: 24px; border-radius: 50%; background: #8ba477; box-shadow: inset -5px -5px rgba(72, 101, 71, .18); }
.sewing-basket i:nth-child(1) { left: 8px; }
.sewing-basket i:nth-child(2) { left: 28px; top: -18px; background: #d67e64; }
.sewing-basket i:nth-child(3) { right: 5px; background: #7e9fc0; }
.quilt { position: relative; z-index: 2; display: grid; width: min(91%, 620px); grid-template-rows: repeat(var(--row-count), minmax(0, 1fr)); overflow: hidden; border: 10px solid #f4e6c8; border-radius: 22px; background: #f8ead0; box-shadow: 0 15px 26px rgba(71, 55, 37, .24), inset 0 0 0 3px #b99b6e; transform: rotate(-1deg); }
.quilt-row { min-height: clamp(54px, 6.6vw, 75px); border-bottom: 3px dashed rgba(255, 247, 222, .82); }
.quilt-row:last-child { border-bottom: 0; }
.pattern-strip { position: relative; display: grid; width: 100%; height: 100%; min-height: inherit; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; overflow: hidden; color: var(--strip-ink); background: var(--strip-bg); }
.pattern-strip::after { position: absolute; inset: 4px; pointer-events: none; border: 2px dashed rgba(255,255,255,.62); content: ""; }
.motif { display: grid; min-width: 0; place-items: center; border-right: 2px dashed rgba(255,255,255,.52); }
.motif:last-of-type { border-right: 0; }
.motif svg { width: clamp(38px, 5.4vw, 58px); height: clamp(38px, 5.4vw, 58px); filter: drop-shadow(0 2px 0 rgba(255,255,255,.28)); }
.quilt-row.is-covered { position: relative; min-height: clamp(54px, 6.6vw, 75px); background: #eadfc8; }
.strip-cover { display: grid; width: 100%; height: 100%; grid-template-columns: repeat(3, 1fr); place-items: center; color: #8b795d; background: repeating-linear-gradient(135deg, rgba(255,251,238,.95) 0 14px, rgba(225,215,194,.95) 14px 28px); }
.strip-cover span { display: grid; width: 38px; height: 38px; grid-column: 2; place-items: center; border: 2px solid #c7b899; border-radius: 12px; background: #fff8e8; font-weight: 1000; }
.strip-cover i { display: none; }
.quilt-row.is-current { z-index: 4; border: 4px solid #d79f24; background: #fff2bb; box-shadow: inset 0 0 0 5px #fff8d8, 0 0 0 7px rgba(232, 179, 55, .52), 0 6px 18px rgba(103, 76, 20, .3); transform: scale(1.025); }
.quilt-row.is-current .strip-cover { color: #6d531d; background: repeating-linear-gradient(135deg, #fff8d8 0 14px, #f6df94 14px 28px); }
.quilt-row.is-future { opacity: .74; }

.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 .quilt-scene { position: absolute; inset: 0; min-height: 0; padding: 16px 12px; border: 0; border-radius: 0; }
.route-preview .sewing-basket { display: none; }
.route-preview .quilt { width: 88%; border-width: 7px; border-radius: 15px; }
.route-preview .quilt-row { min-height: 31px; border-bottom-width: 2px; }
.route-preview .motif svg { width: 28px; height: 28px; }
.route-preview .pattern-strip::after { inset: 2px; border-width: 1px; }
.route-count { position: absolute; z-index: 9; top: 12px; right: 12px; display: grid; width: 54px; height: 54px; place-items: center; border: 4px solid rgba(255, 255, 255, .92); border-radius: 17px; color: white; background: var(--route-accent); font-size: 20px; font-weight: 1000; box-shadow: 0 5px 12px rgba(48, 61, 48, .16); transform: rotate(3deg); }
.route-copy { display: flex; min-height: 305px; flex: 1; flex-direction: column; padding: 17px; }
.route-copy h3 { margin-bottom: 10px; font-size: 25px; }
.route-copy > p:not(.eyebrow) { min-height: 98px; 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: 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; }
.quilt-stage-card { min-width: 0; padding: 12px; border: 1px solid #dcd3c2; border-radius: 27px; background: linear-gradient(150deg, #e8e0d0, #fffaf0); }
.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; }
.row-progress { display: flex; align-items: center; gap: 8px; min-height: 58px; margin: 13px 0 15px; padding: 10px; border-radius: 16px; background: #f3eee4; }
.row-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; }
.row-dot.is-current { border-style: solid; border-color: #e1a827; color: #684e12; background: #ffefac; box-shadow: 0 0 0 4px rgba(230, 185, 75, .2); }
.row-dot.is-found { 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, #9a76b6, #6e548e); box-shadow: 0 8px 17px rgba(91, 67, 121, .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-columns), minmax(0, 1fr)); gap: 10px; }
.candidate-strip { min-width: 0; min-height: 104px; padding: 8px; border: 3px solid #d8d0c1; border-radius: 18px; 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-strip:hover { border-color: #9d7eac; transform: translateY(-2px); }
.candidate-strip > .pattern-strip { min-height: 82px; border-radius: 11px; }
.candidate-strip .motif svg { width: clamp(29px, 4vw, 46px); height: clamp(29px, 4vw, 46px); }
.candidate-strip.is-wrong { border-color: #d97649; background: #fff0e7; animation: strip-wiggle .22s ease; }
.candidate-strip.is-hint { border-color: #e2ad2e; background: #fff7d4; box-shadow: 0 0 0 5px rgba(230, 181, 62, .25); }

.result-board { min-height: 420px; }
.result-board .quilt-scene { 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 strip-wiggle { 33% { transform: translateX(-5px); } 66% { transform: translateX(5px); } }

@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, .row-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%, 700px); 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-copy { min-height: 338px; }
  .section-title { align-items: flex-start; flex-direction: column; }
  .candidate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
  .route-grid { grid-template-columns: 1fr; }
  .route-preview { min-height: 260px; }
  .route-preview .quilt { width: min(84%, 470px); }
  .route-preview .quilt-row { min-height: 36px; }
  .route-copy { min-height: 275px; }
  .route-copy > p:not(.eyebrow) { min-height: 0; }
  .guide-card { display: block; }
  .feedback { min-height: 84px; }
  .quilt-scene { min-height: 320px; padding: 17px 14px; }
  .quilt { width: 94%; border-width: 7px; }
  .quilt-row, .quilt-row.is-covered { min-height: clamp(49px, 14vw, 64px); }
  .motif svg { width: clamp(34px, 11vw, 52px); height: clamp(34px, 11vw, 52px); }
  .candidate-grid { grid-template-columns: 1fr; }
  .candidate-strip { min-height: 96px; }
  .candidate-strip > .pattern-strip { min-height: 76px; }
  .candidate-strip .motif svg { width: 45px; height: 45px; }
  .result-board, .result-board .quilt-scene { 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; }
  .quilt-stage-card { padding: 7px; border-radius: 20px; }
  .quilt-scene { min-height: 292px; border-width: 5px; border-radius: 18px; }
  .quilt { width: 96%; border-width: 6px; border-radius: 15px; }
  .quilt-row, .quilt-row.is-covered { min-height: 48px; }
  .quilt-row.is-current { border-width: 3px; box-shadow: inset 0 0 0 3px #fff8d8, 0 0 0 5px rgba(232, 179, 55, .55); transform: scale(1.01); }
  .motif svg { width: 36px; height: 36px; }
  .pattern-strip::after { inset: 2px; border-width: 1px; }
  .sewing-basket { display: none; }
  .stage-note { font-size: 12px; }
  .guide-card { padding: 14px; border-radius: 20px; }
  .guide-card h3 { font-size: 23px; }
  .row-progress { gap: 5px; min-height: 54px; padding: 8px; }
  .row-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: 22px; }
  .candidate-grid { gap: 7px; }
  .candidate-strip { min-height: 90px; padding: 6px; border-radius: 15px; }
  .candidate-strip > .pattern-strip { min-height: 72px; }
  .candidate-strip .motif svg { width: 43px; height: 43px; }
  .result-facts { flex-wrap: wrap; }
}

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