:root {
  --ink: #244b43;
  --muted: #667b75;
  --paper: #fffdf7;
  --line: #ded5c3;
  --green: #4e9b78;
  --coral: #e37661;
  --gold: #d48b3d;
  --purple: #796ab1;
  --shadow: 0 18px 46px rgba(68, 79, 62, .13);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 8% 4%, #e2f0dd 0 10%, transparent 34%), linear-gradient(145deg, #f7f0e1, #eef2df);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}
button { font: inherit; color: inherit; }

.app {
  width: min(1120px, calc(100% - 32px));
  margin: 24px auto 36px;
}

.game-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 16px;
  border: 1px solid rgba(101, 121, 96, .2);
  border-radius: 24px;
  background: rgba(255, 253, 247, .88);
  box-shadow: 0 10px 30px rgba(69, 84, 64, .08);
}
.game-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 3px 7px;
  border-radius: 18px;
  color: inherit;
  text-decoration: none;
  transition: .2s ease;
}
.game-brand:hover { background: #edf5e9; }
.game-brand:focus-visible, button:focus-visible {
  outline: 4px solid rgba(212, 139, 61, .35);
  outline-offset: 3px;
}
.game-brand > span:last-child { display: grid; gap: 1px; }
.game-brand strong { font-size: 19px; }
.game-brand small { color: var(--muted); font-size: 13px; }
.game-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 17px;
  background: #dbead6;
  color: #3f7d61;
}
.game-icon svg {
  width: 44px;
  height: 36px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.game-icon circle { fill: currentColor; stroke: none; }
.age-pill, .counter {
  flex: 0 0 auto;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
  white-space: nowrap;
}

.screen { display: none; margin-top: 18px; }
.screen.is-active { display: block; }
.home-screen, .result-screen {
  position: relative;
  display: none;
  grid-template-columns: .9fr 1fr;
  gap: 38px;
  overflow: hidden;
  padding: 52px 56px 132px;
  border: 1px solid rgba(115, 126, 94, .22);
  border-radius: 34px;
  background: linear-gradient(100deg, #e6f0dd 0 46%, #fffaf0 46%);
  box-shadow: var(--shadow);
}
.home-screen.is-active, .result-screen.is-active { display: grid; }
.hero-scene { align-self: stretch; display: grid; place-items: center; min-width: 0; }
.hero-scene img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 28px;
  object-fit: cover;
  box-shadow: 0 14px 36px rgba(57, 75, 55, .16);
}
.hero-copy { align-self: center; min-width: 0; }
.eyebrow {
  margin: 0 0 8px;
  color: #8d6232;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .11em;
}
.hero-copy h1, .section-title h2, .task-head h2, .result-screen h2 { margin: 0; line-height: 1.05; }
.hero-copy h1 { max-width: 580px; font-size: clamp(38px, 5vw, 64px); letter-spacing: -.045em; }
.hero-copy > p:not(.eyebrow) { margin: 23px 0 22px; color: var(--muted); font-size: 20px; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 26px; }
.hero-facts span {
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .84);
  font-weight: 800;
}
.primary-button, .secondary-button, .check-button, .next-button {
  min-height: 54px;
  padding: 0 24px;
  border: 0;
  border-radius: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: .18s ease;
}
.primary-button, .check-button, .next-button { background: var(--green); color: #fff; box-shadow: 0 9px 20px rgba(78, 155, 120, .2); }
.primary-button:hover, .check-button:hover, .next-button:hover { background: #3d8565; transform: translateY(-1px); }
.secondary-button { border: 1px solid var(--line); background: #fff; }
.how-strip {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 247, .94);
}
.how-strip article {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 102px;
  padding: 18px 24px;
  border-right: 1px solid var(--line);
}
.how-strip article:last-child { border-right: 0; }
.how-strip b {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--coral);
  color: #fff;
  font-size: 20px;
}
.how-strip span { display: grid; min-width: 0; }
.how-strip strong { font-size: 16px; }
.how-strip small { color: var(--muted); }

.routes-screen, .play-screen {
  padding: 32px;
  border: 1px solid rgba(115, 126, 94, .22);
  border-radius: 32px;
  background: rgba(255, 253, 247, .95);
  box-shadow: var(--shadow);
}
.section-title, .task-head, .riddle-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-title h2, .task-head h2 { font-size: clamp(28px, 4vw, 44px); }
.section-title > p {
  margin: 0;
  padding: 9px 15px;
  border-radius: 999px;
  background: #edf4e6;
  font-weight: 800;
}
.route-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 28px; align-items: stretch; }
.route-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(69, 84, 64, .08);
}
.route-art { display: grid; place-items: center; height: 148px; background: color-mix(in srgb, var(--route) 13%, #fff); }
.route-art img { width: 112px; height: 112px; object-fit: contain; filter: drop-shadow(0 8px 8px rgba(44, 58, 42, .14)); }
.route-card > p { margin: 20px 22px 4px; color: var(--route); font-size: 12px; font-weight: 900; letter-spacing: .12em; }
.route-card h3 { margin: 0 22px 7px; font-size: 24px; line-height: 1.12; }
.route-card > span { min-height: 48px; margin: 0 22px; color: var(--muted); }
.route-meta { display: flex; justify-content: space-between; gap: 10px; margin: 18px 22px 8px; }
.route-meta small { color: var(--muted); }
.route-bar { height: 8px; margin: 0 22px 18px; overflow: hidden; border-radius: 999px; background: #eee9dd; }
.route-bar i { display: block; height: 100%; border-radius: inherit; background: var(--route); }
.route-card button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  margin-top: auto;
  padding: 0 22px;
  border: 0;
  border-top: 1px solid var(--line);
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}
.route-card button:hover { background: color-mix(in srgb, var(--route) 9%, #fff); }
.route-card button b { color: var(--route); font-size: 22px; }
.back-link { margin-top: 24px; padding: 10px 4px; border: 0; background: none; font-weight: 800; cursor: pointer; }

.task-head { justify-content: flex-start; }
.task-head > div { flex: 1; }
.round-button {
  display: grid;
  place-items: center;
  flex: 0 0 50px;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 23px;
  cursor: pointer;
}
.progress-line { height: 9px; margin: 18px 0 25px; overflow: hidden; border-radius: 999px; background: #eae5da; }
.progress-line i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--green)); transition: width .25s; }
.riddle-head { padding: 0 4px 16px; }
.riddle-head h3 { margin: 0; font-size: 25px; }
.riddle-head > span { padding: 8px 13px; border-radius: 12px; background: #f1ede3; font-weight: 800; }

.domino-stage {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: #fff;
}
.domino-stage > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.domino-stage > header div { display: grid; gap: 2px; }
.domino-stage > header b { font-size: 19px; }
.domino-stage > header span, .domino-stage > header small { color: var(--muted); }
.domino-chain {
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-height: 180px;
  margin: 18px 0;
  padding: 18px;
  border-radius: 21px;
  background: linear-gradient(155deg, #f7efe0, #edf3e3);
}
.chain-link {
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  align-self: center;
  height: 30px;
  margin: 0 -2px;
  border-radius: 50%;
  background: #d48b3d;
  color: #fff;
  font-weight: 900;
  z-index: 2;
}
.domino-card {
  position: relative;
  display: grid;
  grid-template-rows: 92px auto;
  place-items: center;
  flex: 1 1 130px;
  min-width: 0;
  max-width: 175px;
  min-height: 150px;
  padding: 10px 10px 12px;
  border: 2px solid #d6c9b3;
  border-bottom-width: 5px;
  border-radius: 17px;
  background: #fffaf0;
  box-shadow: 0 7px 16px rgba(69, 80, 60, .09);
}
button.domino-card { cursor: pointer; transition: .16s ease; }
button.domino-card:hover { border-color: var(--green); transform: translateY(-2px); }
.domino-card img { display: block; width: 86px; height: 86px; object-fit: contain; filter: drop-shadow(0 7px 7px rgba(45, 59, 43, .12)); }
.domino-card b { max-width: 100%; overflow-wrap: anywhere; text-align: center; font-size: 15px; letter-spacing: .035em; }
.edge {
  position: absolute;
  top: 9px;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  color: #fff;
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
  z-index: 1;
}
.edge-first { left: 8px; background: var(--green); }
.edge-last { right: 8px; background: var(--gold); }
.domino-card.is-start { border-color: var(--green); background: #edf7ee; }
.domino-card.is-start::after { content: "СТАРТ"; position: absolute; bottom: -13px; padding: 3px 9px; border-radius: 999px; background: var(--green); color: #fff; font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.domino-card.is-wrong { border-color: var(--coral); background: #fff0ec; animation: soft-shake .26s ease; }
.domino-card.is-guided { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(121, 106, 177, .17); }
.domino-card.is-empty { display: grid; grid-template-rows: auto auto; align-content: center; border-style: dashed; background: rgba(255, 255, 255, .48); color: #8d897f; box-shadow: none; }
.domino-card.is-empty span { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #e9e2d4; font-weight: 900; }
.domino-card.is-empty b { margin-top: 8px; font-size: 13px; }
@keyframes soft-shake { 50% { transform: translateX(4px); } }
.bank-panel { padding-top: 16px; border-top: 1px solid var(--line); }
.bank-panel > p { margin: 0 0 12px; color: var(--muted); font-weight: 700; }
.domino-bank { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.domino-bank .domino-card { width: 100%; max-width: none; min-height: 132px; grid-template-rows: 78px auto; }
.domino-bank .domino-card img { width: 72px; height: 72px; }
.bank-empty { grid-column: 1 / -1; padding: 17px; border-radius: 14px; background: #edf5e9; text-align: center; color: var(--muted); }

.control-card {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
}
.feedback {
  display: grid;
  gap: 2px;
  min-height: 60px;
  padding: 11px 14px;
  border-left: 5px solid #9eb6a8;
  border-radius: 12px;
  background: #f5f7f2;
}
.feedback b { font-size: 16px; }
.feedback span { color: var(--muted); }
.feedback[data-tone="error"] { border-color: var(--coral); background: #fff1ed; }
.feedback[data-tone="hint"] { border-color: var(--purple); background: #f3effb; }
.feedback[data-tone="good"], .feedback[data-tone="success"] { border-color: var(--green); background: #edf7ef; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.actions button { min-height: 46px; padding: 0 15px; border: 1px solid var(--line); border-radius: 13px; background: #fff; font-weight: 800; cursor: pointer; }
.actions button:disabled { opacity: .45; cursor: not-allowed; }
.actions .hint-button { color: #654f94; background: #f6f1ff; }
.actions .check-button, .actions .next-button { border: 0; background: var(--green); color: #fff; }
.task-tabs { grid-column: 1 / -1; display: flex; justify-content: center; gap: 8px; padding-top: 4px; }
.task-tabs button { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: #fff; font-weight: 900; cursor: pointer; }
.task-tabs button.is-active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 139, 61, .18); }
.task-tabs button.is-done { border-color: var(--green); background: var(--green); color: #fff; }

.result-screen { grid-template-columns: 1fr .85fr; align-items: center; padding-bottom: 54px; background: linear-gradient(100deg, #fffaf0 0 56%, #e6f0dd 56%); }
.result-screen h2 { font-size: clamp(34px, 4.5vw, 56px); }
.result-screen > div:first-child > p:not(.eyebrow) { color: var(--muted); font-size: 19px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.result-scene { position: relative; display: grid; place-items: center; min-height: 350px; }
.result-scene > span { position: absolute; width: 285px; height: 285px; border-radius: 50%; background: #f6eddd; }
.result-scene > img:not(.reward-art) { position: relative; width: 245px; height: 245px; object-fit: contain; filter: drop-shadow(0 12px 10px rgba(50, 65, 45, .16)); }
.result-scene .reward-art { position: absolute; right: 2%; bottom: 3%; width: 118px; height: 118px; object-fit: contain; filter: drop-shadow(0 9px 8px rgba(50, 65, 45, .16)); transform: rotate(5deg); }

@media (max-width: 920px) {
  .home-screen { grid-template-columns: 350px 1fr; padding: 42px 38px 132px; }
  .hero-copy h1 { font-size: 43px; }
  .route-grid { gap: 12px; }
  .route-card h3 { font-size: 20px; }
  .route-card > span { min-height: 64px; }
  .routes-screen, .play-screen { padding: 26px 22px; }
  .domino-stage { padding: 16px; }
  .domino-card { min-height: 140px; grid-template-rows: 82px auto; }
  .domino-card img { width: 76px; height: 76px; }
  .domino-card b { font-size: 13px; }
  .chain-link { flex-basis: 24px; width: 24px; height: 24px; font-size: 12px; }
  .control-card { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
}

@media (max-width: 760px) {
  .app { width: min(100% - 20px, 1120px); margin-top: 10px; }
  .game-bar { border-radius: 20px; }
  .age-pill { display: none; }
  .home-screen, .result-screen { grid-template-columns: 1fr; padding: 28px 24px 0; background: linear-gradient(180deg, #e6f0dd 0 38%, #fffaf0 38%); }
  .hero-scene { order: 2; }
  .hero-copy { order: 1; }
  .hero-copy h1 { font-size: 40px; }
  .hero-copy > p:not(.eyebrow) { margin: 17px 0; font-size: 17px; }
  .how-strip { position: static; grid-template-columns: 1fr; order: 3; margin: 26px -24px 0; }
  .how-strip article { min-height: 76px; padding: 13px 20px; border-top: 1px solid var(--line); border-right: 0; }
  .routes-screen, .play-screen { padding: 22px 18px; }
  .section-title { align-items: flex-start; }
  .section-title > p { font-size: 13px; }
  .route-grid { grid-template-columns: 1fr; }
  .route-card > span { min-height: auto; }
  .domino-stage > header { display: grid; }
  .domino-chain { display: grid; grid-template-columns: 1fr; gap: 7px; padding: 14px; }
  .chain-link { width: 30px; height: 30px; margin: -4px auto; transform: rotate(90deg); }
  .domino-chain .domino-card { display: grid; grid-template: "img word first last" 1fr / 82px 1fr 34px 34px; width: 100%; max-width: none; min-height: 96px; padding: 8px 10px; }
  .domino-chain .domino-card img { grid-area: img; width: 76px; height: 76px; }
  .domino-chain .domino-card b { grid-area: word; justify-self: start; padding-left: 9px; font-size: 16px; text-align: left; }
  .domino-chain .edge { position: static; }
  .domino-chain .edge-first { grid-area: first; }
  .domino-chain .edge-last { grid-area: last; }
  .domino-chain .domino-card.is-empty { display: grid; grid-template: none; place-items: center; min-height: 82px; }
  .domino-bank { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-screen { padding-bottom: 28px; }
  .result-screen > div:first-child { order: 1; }
  .result-scene { min-height: 300px; order: 2; }
}

@media (max-width: 470px) {
  .game-brand { gap: 8px; }
  .game-icon { width: 46px; height: 46px; }
  .game-icon svg { width: 37px; }
  .game-brand strong { font-size: 16px; }
  .game-brand small { font-size: 11px; }
  .hero-copy h1 { font-size: 34px; }
  .hero-facts span { padding: 7px 11px; font-size: 13px; }
  .primary-button { width: 100%; }
  .section-title, .riddle-head { display: grid; }
  .section-title > p, .riddle-head > span { justify-self: start; }
  .task-head { gap: 10px; }
  .task-head h2 { font-size: 28px; }
  .round-button { flex-basis: 44px; height: 44px; }
  .counter { padding: 7px 10px; font-size: 12px; }
  .riddle-head h3 { font-size: 22px; }
  .domino-bank .domino-card { min-height: 126px; }
  .domino-bank .domino-card b { font-size: 12px; }
  .actions { display: grid; grid-template-columns: repeat(2, 1fr); }
  .actions button { padding: 0 8px; }
  .actions .check-button, .actions .next-button { grid-column: 1 / -1; }
  .result-actions { display: grid; }
  .result-actions button { width: 100%; }
}
