:root {
  --ink: #164b42;
  --muted: #667a77;
  --paper: #fffdf8;
  --cream: #f5ecd6;
  --line: #e4cfaa;
  --green: #4c9a70;
  --green-dark: #2e7d59;
  --coral: #e7745e;
  --blue: #4e98aa;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html { min-width: 0; background: #f4f0e3; }
body { margin: 0; min-width: 0; overflow-x: hidden; background: radial-gradient(circle at 16px 16px, rgba(190,151,88,.12) 1px, transparent 1.5px) 0 0 / 24px 24px, linear-gradient(135deg, #edf4e8, #f4eedf); }
button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 4px solid rgba(231,116,94,.35); outline-offset: 3px; }

.app { width: min(1120px, calc(100% - 32px)); margin: 32px auto 44px; background: var(--paper); border: 1px solid var(--line); border-radius: 34px; box-shadow: 0 24px 55px rgba(69,72,45,.14); overflow: hidden; }
.game-bar { min-height: 90px; padding: 18px 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); }
.game-brand { min-width: 0; display: inline-flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; border-radius: 18px; }
.game-brand:hover strong { color: var(--green-dark); }
.game-icon { width: 56px; height: 56px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 18px; background: #f3dfad; color: #806a43; }
.game-icon svg { width: 43px; height: 38px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.game-brand > span:last-child { min-width: 0; display: grid; gap: 3px; }
.game-brand strong { font-size: 25px; line-height: 1.05; }
.game-brand small { color: var(--muted); font-size: 14px; }
.age-pill, .counter { flex: 0 0 auto; padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-weight: 800; }

.screen { display: none; }
.screen.is-active { display: block; }
.home-screen { position: relative; display: none; grid-template-columns: 1.05fr 1fr; overflow: hidden; background: linear-gradient(111deg, #fff5df 0 55%, #e3f0dc 55%); }
.home-screen.is-active { display: grid; }
.hero-copy { padding: 50px 26px 28px 48px; align-self: center; }
.eyebrow { margin: 0 0 8px; color: var(--green-dark); font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0 0 20px; max-width: 590px; font-size: clamp(38px, 4.6vw, 57px); line-height: 1.05; letter-spacing: -.035em; }
.hero-copy > p:not(.eyebrow) { margin: 0; max-width: 575px; color: var(--muted); font-size: 21px; line-height: 1.5; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0; }
.hero-facts span { padding: 9px 15px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.82); font-weight: 800; }
.primary-button, .secondary-button, .check-button, .hint-button, .restart-button, .next-button { min-height: 54px; padding: 0 22px; border: 0; border-radius: 17px; cursor: pointer; font-weight: 900; }
.primary-button, .check-button, .next-button { color: #fff; background: var(--green); box-shadow: 0 7px 0 var(--green-dark); }
.primary-button:hover, .check-button:hover:not(:disabled), .next-button:hover { filter: brightness(1.05); transform: translateY(-1px); }
.check-button:disabled { cursor: not-allowed; opacity: .45; box-shadow: none; }
.secondary-button, .restart-button { color: var(--ink); border: 2px solid #9cc6af; background: #fff; }
.hero-scene { padding: 48px 46px 30px 22px; display: grid; place-items: center; }
.hero-scene img { width: 100%; aspect-ratio: 3/2; object-fit: cover; border-radius: 30px; box-shadow: 0 18px 30px rgba(44,77,59,.18); }
.how-strip { grid-column: 1/-1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 0 48px 36px; }
.how-strip article { min-height: 114px; display: flex; align-items: center; gap: 16px; padding: 20px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.95); }
.how-strip b, .riddle-number { width: 56px; height: 56px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 18px; color: #fff; background: var(--coral); box-shadow: 0 6px 0 #c95d49; font-size: 23px; }
.how-strip span { display: grid; gap: 4px; }
.how-strip strong { font-size: 17px; }
.how-strip small { color: var(--muted); font-size: 14px; line-height: 1.35; }

.routes-screen, .play-screen { padding: 38px 42px 46px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.section-title h2, .task-head h2 { margin: 0; font-size: clamp(34px, 4vw, 46px); line-height: 1.08; }
.section-title > p { color: var(--muted); font-weight: 800; }
.route-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.route-card { min-width: 0; display: flex; flex-direction: column; padding: 14px; border: 1px solid var(--line); border-radius: 26px; background: #fff; box-shadow: 0 14px 24px rgba(86,77,45,.09); }
.route-art { height: 170px; display: grid; place-items: center; overflow: hidden; border-radius: 20px; background: linear-gradient(135deg, #eef5e4, #f7ead2); }
.route-art img { width: 76%; height: 82%; object-fit: contain; }
.route-card > p { margin: 16px 0 6px; color: var(--route-color); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.route-card h3 { margin: 0; font-size: 24px; }
.route-card > span { flex: 1 1 auto; min-height: 78px; margin: 14px 0; color: var(--muted); font-size: 16px; line-height: 1.45; }
.route-meta { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); }
.route-progress { height: 8px; overflow: hidden; border-radius: 999px; background: #e9e5d9; }
.route-progress i { display: block; height: 100%; border-radius: inherit; background: var(--route-color); }
.route-card button { min-height: 54px; margin-top: 16px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border: 0; border-radius: 17px; color: #fff; background: var(--route-color); cursor: pointer; font-weight: 900; }
.back-link { margin-top: 24px; padding: 10px 6px; border: 0; background: transparent; color: var(--green-dark); cursor: pointer; font-weight: 900; }

.task-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; }
.round-button { width: 50px; height: 50px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: #fff; cursor: pointer; font-size: 23px; }
.progress-line { height: 8px; margin: 22px 0; overflow: hidden; border-radius: 999px; background: #e9e5d9; }
.progress-line i { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .25s ease; }
.letter-board { padding: 22px; border: 1px solid var(--line); border-radius: 26px; background: linear-gradient(135deg, #f9f0db, #eef6e9); }
.letter-board > header, .final-panel > header { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.letter-board h3, .final-panel h3 { margin: 0; font-size: 25px; }
.letter-board header > span, .final-panel header > span { color: var(--muted); font-weight: 800; }
.letter-slots { max-width: 620px; margin: 20px auto 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.letter-slot { min-height: 95px; display: grid; place-items: center; align-content: center; gap: 4px; border: 2px dashed #cfb988; border-radius: 20px; background: rgba(255,255,255,.72); color: #9f8a60; }
.letter-slot b { font-size: 38px; line-height: 1; }
.letter-slot small { font-weight: 800; }
.letter-slot.is-open { border-style: solid; border-color: #84bf98; color: var(--ink); background: #e4f2df; box-shadow: inset 0 -5px 0 #c6dfc0; }

.riddle-panel, .final-panel { margin-top: 16px; padding: 22px; border: 1px solid var(--line); border-radius: 26px; background: #fff; }
.riddle-copy { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.riddle-copy h3 { margin: 0; font-size: 24px; line-height: 1.35; }
.candidate-grid, .final-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.candidate-card { min-width: 0; min-height: 205px; padding: 14px; display: grid; place-items: center; align-content: center; gap: 7px; border: 2px solid #e3d4b8; border-radius: 22px; color: var(--ink); background: #fff; cursor: pointer; }
.candidate-card:hover:not(:disabled) { border-color: #88bda0; background: #f3faf1; transform: translateY(-2px); }
.candidate-picture { width: 100%; height: 118px; display: grid; place-items: center; overflow: hidden; border-radius: 16px; background: linear-gradient(145deg, #f5f7ea, #f8ecd6); }
.candidate-picture img { width: 88%; height: 88%; object-fit: contain; }
.candidate-card strong { font-size: 19px; }
.candidate-card small { color: var(--muted); }
.candidate-card.is-selected { border-color: #e9b94f; background: #fff8df; box-shadow: 0 0 0 5px rgba(233,185,79,.2); }
.candidate-card.is-eliminated { opacity: .33; filter: grayscale(.5); cursor: default; }
.candidate-card.is-correct { border-color: #63a77c; background: #e7f4e2; box-shadow: inset 0 -5px 0 #bcdcb8; }
.check-button { display: block; min-width: 250px; margin: 18px auto 5px; }

.control-card { margin-top: 16px; padding: 18px 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; align-items: center; border: 1px solid var(--line); border-radius: 24px; background: #f9f5eb; }
.feedback { min-width: 0; display: grid; gap: 5px; padding-left: 16px; border-left: 5px solid #b7c5b8; }
.feedback b { font-size: 18px; }
.feedback span { color: var(--muted); line-height: 1.4; }
.feedback[data-tone="error"] { border-color: var(--coral); }
.feedback[data-tone="hint"] { border-color: #e0aa3e; }
.feedback[data-tone="success"] { border-color: var(--green); }
.actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 10px; }
.hint-button { color: #735514; background: #ffe49c; box-shadow: 0 5px 0 #d7b35b; }
.restart-button { min-height: 50px; padding: 0 16px; }
.next-button { min-height: 50px; box-shadow: 0 5px 0 var(--green-dark); }
.task-tabs { grid-column: 1/-1; display: flex; justify-content: center; gap: 8px; }
.task-tabs button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: var(--ink); cursor: pointer; font-weight: 900; }
.task-tabs button.is-active { color: #fff; border-color: var(--coral); background: var(--coral); }
.task-tabs button.is-done { color: #fff; border-color: var(--green); background: var(--green); }

.result-screen { padding: 54px 42px; grid-template-columns: .92fr 1.08fr; gap: 38px; align-items: center; }
.result-screen.is-active { display: grid; }
.result-scene { position: relative; min-height: 380px; display: grid; place-items: center; overflow: hidden; border-radius: 28px; background: linear-gradient(#dff0d4 0 68%, #d3bb8f 68%); }
.result-sun { position: absolute; top: 28px; right: 32px; width: 84px; height: 84px; border: 16px solid rgba(248,207,92,.22); border-radius: 50%; background: #f8cf5c; }
.result-scene > img:not(.reward-art) { position: absolute; left: 8%; bottom: 12%; width: 48%; height: 55%; object-fit: contain; }
.result-scene .reward-art { position: absolute; right: 8%; bottom: 12%; width: 42%; height: 42%; object-fit: contain; }
.result-screen h2 { margin: 0 0 22px; font-size: clamp(38px, 5vw, 56px); line-height: 1.02; }
.result-screen > div:last-child > p:not(.eyebrow) { color: var(--muted); font-size: 18px; line-height: 1.5; }
.result-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.secondary-button { min-height: 54px; }

@media (max-width: 900px) {
  .home-screen, .result-screen.is-active { grid-template-columns: 1fr; }
  .home-screen { background: linear-gradient(#fff5df 0 52%, #e3f0dc 52%); }
  .hero-copy { padding: 38px 34px 18px; }
  .hero-scene { padding: 20px 34px; }
  .hero-scene img { max-width: 640px; }
  .how-strip { padding: 10px 34px 34px; }
  .routes-screen, .play-screen { padding: 32px 28px 38px; }
  .control-card { grid-template-columns: 1fr; }
  .actions { justify-content: start; }
  .result-screen { padding: 36px 28px; }
  .result-scene { min-height: 330px; }
}

@media (max-width: 700px) {
  .app { width: min(100% - 16px, 1120px); margin: 10px auto 26px; border-radius: 25px; }
  .game-bar { min-height: 76px; padding: 13px 16px; }
  .game-icon { width: 48px; height: 48px; border-radius: 15px; }
  .game-brand strong { font-size: 19px; }
  .game-brand small { display: none; }
  .age-pill { display: none; }
  .hero-copy { padding: 30px 18px 14px; }
  h1 { font-size: 37px; }
  .hero-copy > p:not(.eyebrow) { font-size: 17px; }
  .hero-scene { padding: 18px; }
  .how-strip { grid-template-columns: 1fr; padding: 4px 18px 26px; }
  .how-strip article { min-height: 88px; }
  .routes-screen, .play-screen { padding: 26px 16px 32px; }
  .section-title { align-items: start; flex-direction: column; gap: 8px; }
  .section-title h2, .task-head h2 { font-size: 32px; }
  .route-grid { grid-template-columns: 1fr; }
  .route-card > span { min-height: 0; }
  .task-head { grid-template-columns: auto 1fr; }
  .task-head .counter { grid-column: 2; justify-self: start; padding: 7px 12px; }
  .letter-board { padding: 17px 14px; }
  .letter-board > header, .final-panel > header { align-items: start; flex-direction: column; gap: 8px; }
  .letter-slots { gap: 7px; }
  .letter-slot { min-height: 80px; border-radius: 16px; }
  .letter-slot b { font-size: 31px; }
  .letter-slot small { font-size: 11px; }
  .riddle-panel, .final-panel { padding: 16px 12px; }
  .riddle-copy { align-items: start; }
  .riddle-copy h3 { font-size: 21px; }
  .candidate-grid, .final-grid { gap: 7px; }
  .candidate-card { min-height: 170px; padding: 8px 5px; border-radius: 17px; }
  .candidate-picture { height: 96px; }
  .candidate-card strong { font-size: 15px; }
  .candidate-card small { font-size: 12px; }
  .check-button { width: 100%; min-width: 0; }
  .control-card { padding: 16px 13px; }
  .actions > button { flex: 1 1 150px; }
  .result-screen { padding: 28px 16px; }
  .result-scene { min-height: 290px; }
}

@media (max-width: 420px) {
  .game-brand { gap: 9px; }
  .game-brand strong { font-size: 17px; }
  .game-icon { width: 46px; height: 46px; }
  h1 { font-size: 33px; }
  .hero-facts span { padding: 8px 11px; font-size: 13px; }
  .routes-screen, .play-screen { padding-left: 12px; padding-right: 12px; }
  .riddle-copy { gap: 11px; }
  .riddle-number { width: 48px; height: 48px; }
  .candidate-card strong { font-size: 14px; }
  .candidate-picture { height: 88px; }
  .task-tabs button { width: 39px; height: 39px; }
}

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