:root {
  --ink: #173f39;
  --muted: #5d746f;
  --paper: #fffaf0;
  --cream: #f7eedc;
  --green: #31745f;
  --green-dark: #245a4c;
  --gold: #e6ad4c;
  --coral: #c86f57;
  --line: rgba(35, 87, 73, 0.14);
  --shadow: 0 20px 48px rgba(51, 65, 50, 0.13);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html,
body {
  margin: 0;
  overflow-x: hidden;
}

body {
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(236, 192, 101, 0.18), transparent 25rem),
    radial-gradient(circle at 92% 30%, rgba(91, 154, 126, 0.14), transparent 28rem),
    #f7f2e8;
  font-family: "Segoe UI", Arial, sans-serif;
}

button { font: inherit; }

button:focus-visible {
  outline: 4px solid rgba(66, 132, 111, 0.28);
  outline-offset: 3px;
}

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

.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 12px 18px;
  border: 1px solid rgba(54, 107, 90, 0.12);
  border-radius: 22px;
  background: rgba(255, 252, 245, 0.82);
  box-shadow: 0 10px 24px rgba(49, 72, 60, 0.07);
  backdrop-filter: blur(10px);
}

.game-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.game-brand > span:last-child { display: grid; gap: 2px; }
.game-brand strong { font-size: 20px; line-height: 1.12; }
.game-brand small { color: var(--muted); font-size: 13px; }

.game-icon {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #e6f1e6, #f9e8bc);
  box-shadow: inset 0 0 0 1px rgba(49, 116, 95, 0.12);
}

.game-icon svg { width: 36px; height: 36px; }
.icon-tile { fill: #fff9ec; stroke: #34735f; stroke-width: 2.4; }
.icon-leaf { fill: #e5ab4b; stroke: #8c6930; stroke-width: 1.6; }

.age-pill {
  flex: 0 0 auto;
  padding: 8px 14px;
  color: #fff;
  border-radius: 999px;
  background: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.screen {
  display: none;
  animation: screen-in 0.32s ease both;
}

.screen.is-active { display: block; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.home-screen {
  position: relative;
  overflow: hidden;
  min-height: 580px;
  padding: 62px 56px 32px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background:
    linear-gradient(105deg, rgba(255, 252, 242, 0.98) 0 48%, rgba(229, 241, 229, 0.86) 48% 100%),
    var(--paper);
  box-shadow: var(--shadow);
}

.home-screen::before {
  content: "";
  position: absolute;
  right: -70px;
  bottom: -160px;
  width: 650px;
  height: 360px;
  border-radius: 50%;
  background: #b7cc96;
  opacity: 0.72;
}

.hero-copy {
  position: relative;
  z-index: 3;
  width: min(50%, 500px);
}

.eyebrow {
  margin: 0 0 8px;
  color: #7a6a42;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1 {
  margin-bottom: 18px;
  font-size: clamp(38px, 5.3vw, 67px);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.hero-copy > p:not(.eyebrow) {
  max-width: 480px;
  margin-bottom: 24px;
  color: #49635e;
  font-size: 18px;
  line-height: 1.58;
}

.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.hero-facts span {
  padding: 7px 11px;
  border: 1px solid rgba(49, 116, 95, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 750;
}

.primary-button,
.secondary-button,
.check-button,
.hint-button,
.next-button {
  min-height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 850;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.primary-button,
.next-button {
  color: #fff;
  background: linear-gradient(145deg, #367c66, #285f50);
  box-shadow: 0 11px 22px rgba(38, 95, 78, 0.22);
}

.primary-button:hover,
.next-button:hover,
.check-button:hover,
.hint-button:hover,
.secondary-button:hover { transform: translateY(-2px); filter: saturate(1.06); }

.hero-scene {
  position: absolute;
  z-index: 2;
  top: 34px;
  right: 22px;
  width: 47%;
  height: 430px;
}

.hero-sky {
  position: absolute;
  top: 28px;
  right: 35px;
  width: 210px;
}

.hero-sky img { display: block; width: 100%; }
.hero-sun { position: absolute; top: 5px; left: 32px; width: 106px; }
.hero-basket { position: absolute; right: 42px; bottom: 15px; width: 190px; filter: drop-shadow(0 12px 9px rgba(50, 65, 48, 0.18)); }
.hero-leaf { position: absolute; right: 22px; bottom: 20px; width: 82px; transform: rotate(16deg); }

.hero-letters {
  position: absolute;
  left: 12px;
  bottom: 94px;
  display: flex;
  gap: 7px;
  padding: 13px;
  border-radius: 19px;
  background: rgba(104, 76, 42, 0.72);
  box-shadow: 0 14px 26px rgba(58, 63, 41, 0.18);
  transform: rotate(-3deg);
}

.hero-letters span {
  display: grid;
  width: 54px;
  height: 58px;
  place-items: center;
  border: 2px solid #e8c87d;
  border-radius: 13px;
  background: #fff7e3;
  color: #295e50;
  font-size: 27px;
  font-weight: 900;
  box-shadow: 0 5px 0 #d2b278;
}

.hero-letters span:nth-child(2) { transform: translateY(-7px); }
.hero-letters span:nth-child(3) { transform: translateY(6px); }

.how-strip {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 50px;
}

.how-strip article {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 13px 15px;
  border: 1px solid rgba(50, 103, 85, 0.13);
  border-radius: 18px;
  background: rgba(255, 252, 245, 0.89);
  box-shadow: 0 8px 20px rgba(49, 69, 57, 0.07);
}

.how-strip article > b {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: var(--green);
}

.how-strip article span { display: grid; gap: 3px; }
.how-strip strong { font-size: 14px; }
.how-strip small { color: var(--muted); line-height: 1.3; }

.routes-screen,
.play-screen {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: rgba(255, 251, 243, 0.96);
  box-shadow: var(--shadow);
}

.section-title,
.task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.section-title h2,
.task-head h2,
.result-copy h2 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.section-title > p {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.route-card {
  display: flex;
  min-width: 0;
  min-height: 410px;
  flex-direction: column;
  padding: 17px;
  border: 1px solid color-mix(in srgb, var(--accent) 23%, transparent);
  border-radius: 24px;
  background: linear-gradient(160deg, #fffdf7, var(--soft));
  box-shadow: 0 12px 26px rgba(48, 69, 57, 0.08);
}

.route-preview {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 4px;
  height: 145px;
  padding: 14px;
  overflow: hidden;
  border-radius: 19px;
  background: linear-gradient(180deg, rgba(255,255,255,.72), rgba(255,255,255,.24));
}

.route-preview span {
  display: grid;
  width: 31%;
  height: 105px;
  place-items: center;
}

.route-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 7px 6px rgba(44, 60, 48, 0.14));
}

.route-preview span:nth-child(2) { transform: translateY(-12px); }
.route-copy { min-height: 119px; padding: 19px 5px 8px; }
.route-copy h3 { margin-bottom: 7px; font-size: 23px; line-height: 1.08; }
.route-copy > p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.42; }

.route-progress { display: flex; align-items: center; gap: 10px; margin: auto 4px 14px; }
.route-progress > span { height: 9px; flex: 1; overflow: hidden; border-radius: 999px; background: rgba(33, 81, 67, 0.11); }
.route-progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.route-progress b { flex: 0 0 auto; color: var(--accent); font-size: 12px; }

.route-card > button {
  display: flex;
  min-height: 49px;
  align-items: center;
  justify-content: space-between;
  padding: 0 17px;
  border: 0;
  border-radius: 15px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 850;
}

.text-button {
  margin-top: 22px;
  padding: 9px 0;
  border: 0;
  color: var(--green-dark);
  background: none;
  cursor: pointer;
  font-weight: 800;
}

.task-head { justify-content: flex-start; margin-bottom: 14px; }
.task-head > div { flex: 1; }

.round-button {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-size: 22px;
  font-weight: 900;
}

.counter {
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--green-dark);
  background: #e8f1eb;
  font-weight: 850;
}

.task-progress { height: 8px; margin-bottom: 19px; overflow: hidden; border-radius: 999px; background: #e5e7dd; }
.task-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width .25s ease; }

.crossword-workspace {
  display: grid;
  grid-template-columns: minmax(420px, 0.93fr) minmax(0, 1.07fr);
  gap: 17px;
  align-items: stretch;
}

.grid-card,
.word-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fffdf8;
  box-shadow: 0 10px 24px rgba(48, 66, 55, 0.07);
}

.grid-card { padding: 18px; }
.grid-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.grid-heading span { color: #79673e; font-size: 12px; font-weight: 900; letter-spacing: .13em; }
.grid-heading small { color: var(--muted); text-align: right; }

.crossword-grid-wrap {
  display: grid;
  align-items: center;
  justify-content: center;
  min-height: 370px;
  padding: 14px;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(rgba(255,255,255,.48), rgba(255,255,255,.48)),
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(70, 110, 89, .06) 24px),
    #edf1e5;
}

.crossword-grid {
  --cell-size: min(42px, calc((100vw - 112px) / var(--cols)));
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  grid-template-rows: repeat(var(--rows), var(--cell-size));
  gap: 3px;
}

.crossword-cell,
.crossword-gap {
  position: relative;
  width: var(--cell-size);
  height: var(--cell-size);
}

.crossword-cell {
  display: grid;
  place-items: center;
  border: 2px solid #b6b195;
  border-radius: 8px;
  color: var(--ink);
  background: #fffaf0;
  font-size: clamp(14px, 2vw, 21px);
  font-weight: 900;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.crossword-cell.is-active { border-color: #d29b40; background: #fff1c9; transform: translateY(-1px); }
.crossword-cell.is-filled { border-color: #4c8a71; background: #dff0e4; }
.crossword-cell.is-locked-active { box-shadow: inset 0 0 0 3px #fff, 0 0 0 2px rgba(61, 125, 100, .25); }
.cell-number { position: absolute; top: 2px; left: 4px; color: #77664b; font-size: 8px; line-height: 1; }

.clue-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 13px;
}

.clue-tab {
  display: flex;
  min-width: 0;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: #f7f4e9;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clue-tab.is-active { color: #fff; border-color: var(--green); background: var(--green); }
.clue-tab.is-solved { color: var(--green-dark); border-color: rgba(49,116,95,.2); background: #e1efe5; }
.clue-tab:disabled { cursor: default; opacity: 1; }

.word-card { display: flex; flex-direction: column; overflow: hidden; }
.clue-banner { display: grid; grid-template-columns: 145px 1fr; gap: 16px; align-items: center; min-height: 183px; padding: 18px; background: linear-gradient(125deg, #f1f6e9, #fffaf1); }
.clue-picture { display: grid; height: 145px; place-items: center; border-radius: 20px; background: rgba(255,255,255,.77); box-shadow: inset 0 0 0 1px rgba(50,100,83,.09); }
.clue-picture img { width: 91%; height: 91%; object-fit: contain; filter: drop-shadow(0 8px 6px rgba(45,60,48,.13)); }
.clue-copy h3 { margin-bottom: 8px; font-size: 24px; }
.clue-copy > p:last-child { margin-bottom: 0; color: #48635d; font-size: 15px; line-height: 1.48; }

.swap-area { display: flex; flex: 1; flex-direction: column; padding: 21px; }
.swap-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.swap-heading h3 { margin-bottom: 0; font-size: 22px; }
.swap-heading > span { color: var(--muted); font-size: 12px; text-align: right; }

.letter-board {
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, .7vw, 8px);
  margin: 19px 0;
  padding: 11px;
  border-radius: 18px;
  background: #786247;
  box-shadow: inset 0 4px 12px rgba(45,35,25,.18);
}

.letter-tile {
  position: relative;
  display: grid;
  width: clamp(38px, 5vw, 54px);
  height: clamp(48px, 6vw, 62px);
  flex: 0 1 54px;
  place-items: center;
  border: 2px solid #efd598;
  border-radius: 12px;
  color: var(--ink);
  background: linear-gradient(145deg, #fffdf5, #f7e9c8);
  box-shadow: 0 6px 0 #b99a63, 0 9px 12px rgba(39,31,24,.18);
  cursor: pointer;
  font-size: clamp(20px, 3vw, 29px);
  font-weight: 950;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
}

.letter-tile:hover:not(:disabled) { transform: translateY(-3px); }
.letter-tile.is-selected { color: #fff; border-color: #f6d473; background: #c66e54; box-shadow: 0 6px 0 #874736, 0 0 0 4px rgba(240,190,86,.35); transform: translateY(-5px); }
.letter-tile.is-locked { color: #fff; border-color: #84b698; background: #4b876f; box-shadow: 0 6px 0 #2f624f; cursor: default; }
.letter-tile.is-locked::after { content: "✓"; position: absolute; top: -8px; right: -7px; display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; background: #2d654f; color: #fff; font-size: 11px; }
.letter-tile.is-wrong { animation: soft-wrong .42s ease; border-color: #d77761; background: #ffe2d8; }

@keyframes soft-wrong {
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

.feedback {
  display: grid;
  gap: 3px;
  min-height: 66px;
  padding: 12px 15px;
  border-left: 5px solid #d8b05b;
  border-radius: 13px;
  background: #fff4d8;
}

.feedback b { font-size: 14px; }
.feedback span { color: #536a65; font-size: 13px; line-height: 1.36; }
.feedback[data-tone="success"] { border-left-color: #3b8166; background: #e4f2e7; }
.feedback[data-tone="error"] { border-left-color: #c86f57; background: #fde8e1; }
.feedback[data-tone="hint"] { border-left-color: #607fa8; background: #e8eef8; }

.word-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 14px; }
.check-button { color: #fff; background: #b96a51; box-shadow: 0 8px 17px rgba(154,84,62,.18); }
.hint-button { color: #33546e; background: #e5edf6; box-shadow: inset 0 0 0 1px rgba(62,98,126,.15); }
.next-button { grid-column: 1 / -1; }
.word-actions button[hidden] { display: none; }

.result-screen {
  display: none;
  grid-template-columns: 0.92fr 1.08fr;
  min-height: 515px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: #fffaf0;
  box-shadow: var(--shadow);
}

.result-screen.is-active { display: grid; }
.result-scene { position: relative; min-height: 420px; background: linear-gradient(160deg, #dcecdf, #f4dfaa); }
.result-scene::before { content: ""; position: absolute; inset: 12% 13%; border-radius: 50%; background: rgba(255,255,255,.47); }
.result-object { position: absolute; width: 42%; height: 42%; object-fit: contain; filter: drop-shadow(0 12px 9px rgba(44,60,48,.15)); }
.result-object:nth-child(1) { left: 11%; top: 16%; }
.result-object:nth-child(2) { right: 8%; top: 26%; }
.result-object:nth-child(3) { left: 29%; bottom: 5%; }
.result-copy { display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 6vw, 70px); }
.result-copy > p:not(.eyebrow) { margin: 18px 0 22px; color: var(--muted); font-size: 18px; line-height: 1.55; }
.result-facts { display: flex; gap: 11px; margin-bottom: 28px; }
.result-facts span { padding: 9px 13px; border-radius: 12px; color: var(--green-dark); background: #e6efe6; font-weight: 750; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.secondary-button { color: var(--green-dark); background: #e8eee5; }

@media (max-width: 900px) {
  .home-screen { min-height: 690px; padding: 45px 34px 28px; }
  .hero-copy { width: 60%; }
  .hero-scene { top: 65px; right: 0; width: 43%; }
  .hero-letters span { width: 45px; }
  .how-strip { margin-top: 90px; }
  .crossword-workspace { grid-template-columns: 1fr; }
  .grid-card { order: 2; }
  .word-card { order: 1; }
  .crossword-grid-wrap { min-height: 350px; }
  .crossword-grid { --cell-size: min(46px, calc((100vw - 120px) / var(--cols))); }
}

@media (max-width: 760px) {
  .app { width: min(1120px, calc(100% - 20px)); margin-top: 14px; }
  .game-head { padding: 10px 12px; border-radius: 18px; }
  .game-brand strong { font-size: 17px; }
  .game-brand small { display: none; }
  .game-icon { width: 42px; height: 42px; }
  .age-pill { padding: 7px 10px; font-size: 12px; }
  .home-screen { min-height: 0; padding: 34px 24px 24px; border-radius: 25px; background: linear-gradient(180deg, #fffaf0 0 54%, #e6f0e4 54%); }
  .hero-copy { width: 100%; }
  h1 { font-size: clamp(39px, 11vw, 55px); }
  .hero-copy > p:not(.eyebrow) { font-size: 16px; }
  .hero-scene { position: relative; top: auto; right: auto; width: 100%; height: 285px; margin-top: 10px; }
  .hero-sky { width: 155px; }
  .hero-sun { width: 82px; }
  .hero-basket { right: 6%; width: 145px; }
  .hero-letters { left: 4%; bottom: 82px; }
  .hero-letters span { width: 39px; height: 46px; font-size: 22px; }
  .how-strip { grid-template-columns: 1fr; margin-top: 5px; }
  .routes-screen,
  .play-screen { padding: 20px 15px; border-radius: 25px; }
  .section-title { align-items: flex-start; }
  .section-title > p { max-width: 100px; text-align: right; }
  .route-grid { grid-template-columns: 1fr; }
  .route-card { min-height: 355px; }
  .route-copy { min-height: 100px; }
  .task-head h2 { font-size: 27px; }
  .crossword-grid-wrap { min-height: 300px; padding: 8px; }
  .crossword-grid { --cell-size: min(40px, calc((100vw - 74px) / var(--cols))); gap: 2px; }
  .crossword-cell { border-width: 1.5px; border-radius: 6px; }
  .clue-banner { grid-template-columns: 105px 1fr; min-height: 155px; padding: 14px; }
  .clue-picture { height: 112px; }
  .clue-copy h3 { font-size: 20px; }
  .clue-copy > p:last-child { font-size: 13px; }
  .swap-area { padding: 16px 12px; }
  .swap-heading { align-items: start; }
  .letter-board { gap: 4px; padding: 9px 5px; }
  .letter-tile { width: auto; min-width: 0; height: 51px; flex-basis: 48px; font-size: 21px; border-radius: 10px; }
  .word-actions { grid-template-columns: 1fr; }
  .next-button { grid-column: auto; }
  .result-screen.is-active { grid-template-columns: 1fr; }
  .result-scene { min-height: 270px; }
  .result-copy { padding: 30px 24px; }
}

@media (max-width: 430px) {
  .game-brand strong { font-size: 15px; }
  .age-pill { font-size: 11px; }
  .home-screen { padding-inline: 19px; }
  .hero-facts span { font-size: 11px; }
  .section-title { display: block; }
  .section-title > p { max-width: none; margin-top: 8px; text-align: left; }
  .task-head { gap: 9px; }
  .task-head h2 { font-size: 23px; }
  .round-button { width: 42px; height: 42px; }
  .counter { padding-inline: 9px; font-size: 12px; }
  .clue-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clue-banner { grid-template-columns: 82px 1fr; gap: 10px; }
  .clue-picture { height: 93px; border-radius: 15px; }
  .clue-copy > p:last-child { line-height: 1.35; }
  .swap-heading > span { display: none; }
  .letter-board { min-height: 72px; }
  .letter-tile { height: 48px; font-size: 19px; box-shadow: 0 4px 0 #b99a63; }
  .letter-tile.is-locked { box-shadow: 0 4px 0 #2f624f; }
  .grid-heading { display: block; }
  .grid-heading small { display: block; margin-top: 4px; text-align: left; }
}

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