:root {
  color-scheme: light;
  --ink: #183f38;
  --muted: #65766d;
  --paper: #fffdf6;
  --cream: #f7f0dc;
  --line: #e1d4ae;
  --green: #3f936f;
  --green-dark: #267257;
  --coral: #ec765d;
  --gold: #e6a632;
  --shadow: 0 15px 34px rgba(63, 59, 39, 0.14);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: #f3efd9;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 16px 16px, rgba(255,255,255,.85) 0 2px, transparent 3px) 0 0 / 34px 34px,
    linear-gradient(145deg, #faf7e9, #eee7cc);
}

button { font: inherit; }

button:focus-visible {
  outline: 4px solid rgba(236, 118, 93, 0.38);
  outline-offset: 3px;
}

.app {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.paper,
.loading-card {
  border: 2px solid rgba(216, 197, 150, .76);
  border-radius: 28px;
  background: rgba(255, 253, 246, .96);
  box-shadow: var(--shadow);
}

.loading-card {
  display: grid;
  min-height: 360px;
  place-content: center;
  text-align: center;
}

.loading-card span { font-size: 64px; }
.loading-card p { font-size: 22px; font-weight: 900; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 17px;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 17px;
  color: #fff;
  background: linear-gradient(145deg, #58aa75, #31845e);
  box-shadow: 0 8px 0 rgba(40, 114, 88, .18);
  font-size: 27px;
  transition: transform 160ms ease;
}

.brand:hover .brand-mark { transform: translateY(-2px); }

.brand small,
.eyebrow {
  display: block;
  color: #986719;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.brand strong {
  display: block;
  overflow: hidden;
  font-size: clamp(18px, 2.3vw, 24px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions,
.hero-actions,
.game-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.icon-button,
.soft-button,
.primary-button,
.route-card,
.food-card,
.slot-card,
.atlas-card {
  min-height: 46px;
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.icon-button:hover,
.soft-button:hover,
.primary-button:hover,
.route-card:hover,
.food-card:hover,
.atlas-card:hover { transform: translateY(-2px); }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 48px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--paper);
  font-weight: 900;
}

.primary-button,
.soft-button {
  padding: 13px 20px;
  border-radius: 16px;
  font-weight: 900;
}

.primary-button {
  color: #fff;
  background: var(--coral);
  box-shadow: 0 7px 0 #c9533f;
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #c9533f;
}

.soft-button {
  border: 2px solid var(--line);
  color: var(--ink);
  background: #fffaf0;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .9fr);
  min-height: 390px;
  overflow: hidden;
  padding: 38px;
}

.hero::after {
  position: absolute;
  right: -80px;
  bottom: -210px;
  width: 600px;
  height: 500px;
  border-radius: 50%;
  background: #dfefd3;
  content: "";
}

.hero-copy {
  position: relative;
  z-index: 2;
  align-self: center;
}

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

h1 {
  margin-bottom: 15px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 6vw, 68px);
  line-height: .98;
}

.hero-copy > p {
  max-width: 630px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.48;
}

.hero-chain {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  min-height: 290px;
}

.hero-chain img {
  width: 100%;
  height: 205px;
  object-fit: contain;
  filter: drop-shadow(0 13px 9px rgba(43, 64, 44, .18));
}

.hero-chain img:nth-of-type(1) { grid-column: 1 / 2; }
.hero-chain img:nth-of-type(2) { grid-column: 3 / 4; }
.hero-chain img:nth-of-type(3) { grid-column: 5 / 6; }

.hero-arrow {
  display: grid;
  place-items: center;
  color: var(--coral);
  font-size: 38px;
  font-weight: 900;
}

.nature-note {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  align-items: center;
  gap: 17px;
  margin: 18px 0;
  padding: 16px 21px;
}

.nature-note span {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 22px;
  background: #e8f0d4;
  font-size: 38px;
}

.nature-note p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 30px 4px 14px;
}

.section-head h2 {
  margin: 3px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(29px, 4vw, 43px);
}

.progress-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 900;
}

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

.route-card {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  padding: 22px;
  border: 2px solid rgba(255,255,255,.7);
  border-radius: 25px;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 11px 20px rgba(53, 67, 44, .12);
}

.route-card::after {
  position: absolute;
  right: -45px;
  bottom: -65px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,.34);
  content: "";
}

.route-card h3 {
  position: relative;
  z-index: 1;
  margin: 7px 0;
  font-size: 24px;
}

.route-card p {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #385e53;
  line-height: 1.42;
}

.route-progress {
  position: absolute;
  right: 16px;
  bottom: 15px;
  z-index: 2;
  display: grid;
  min-width: 60px;
  height: 40px;
  padding: 0 11px;
  place-items: center;
  border-radius: 14px;
  background: rgba(255,255,255,.86);
  font-weight: 900;
}

.route-card.is-complete::before {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 2;
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  content: "✓";
  font-weight: 900;
}

.game-shell { overflow: hidden; }

.game-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: 25px 28px 17px;
}

.game-head h1 {
  margin: 4px 0 7px;
  font-size: clamp(32px, 5vw, 51px);
}

.game-head p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.step-counter {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 14px;
  color: var(--green-dark);
  background: #e8f1df;
  font-weight: 900;
}

.progress-track {
  height: 12px;
  margin: 0 28px 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8dfc8;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #86bd70);
}

.chain-area {
  padding: 20px 28px 26px;
  background: linear-gradient(180deg, #f9f5e7, #eff0d8);
}

.chain-instruction {
  margin-bottom: 15px;
  text-align: center;
  font-weight: 900;
}

.chain-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.slot-card {
  position: relative;
  display: grid;
  width: min(220px, 25vw);
  min-width: 0;
  min-height: 232px;
  padding: 12px;
  place-items: center;
  border: 3px dashed #cdbf96;
  border-radius: 24px;
  color: var(--muted);
  background: rgba(255,255,255,.62);
  text-align: center;
}

.slot-card.is-filled {
  border-style: solid;
  border-color: #a8c68c;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 10px 22px rgba(52, 67, 45, .11);
}

.slot-card.is-wrong { border-color: #e47e69; background: #fff0e9; }
.slot-card.is-correct { border-color: #51a478; background: #e9f5e6; }

.slot-card img {
  width: 100%;
  height: 155px;
  object-fit: contain;
}

.slot-card strong {
  display: block;
  line-height: 1.15;
}

.slot-number {
  position: absolute;
  top: 10px;
  left: 10px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}

.slot-placeholder {
  display: grid;
  gap: 10px;
  place-items: center;
}

.slot-placeholder span { font-size: 40px; opacity: .65; }

.chain-arrow {
  flex: 0 0 auto;
  color: var(--coral);
  font-size: 36px;
  font-weight: 900;
}

.bank-section {
  padding: 25px 28px;
  border-top: 2px dashed var(--line);
}

.bank-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.bank-head h2 { margin: 0; font-size: 23px; }
.bank-head span { color: var(--muted); font-size: 14px; }

.food-bank {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 11px;
}

.food-card {
  min-width: 0;
  min-height: 174px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 19px;
  color: var(--ink);
  background: #fffaf0;
  box-shadow: 0 7px 12px rgba(58, 62, 42, .08);
  font-weight: 900;
}

.food-card img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: contain;
}

.food-card.is-used {
  cursor: default;
  filter: grayscale(.7);
  opacity: .35;
  transform: none;
}

.feedback-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 18px 28px 24px;
  border-top: 2px dashed var(--line);
  background: #fffdf6;
}

.feedback {
  min-height: 58px;
  padding: 13px 16px;
  border-radius: 16px;
  color: var(--muted);
  background: #f4efdf;
  line-height: 1.4;
}

.feedback.is-error { color: #8c3f31; background: #fff0e9; }
.feedback.is-hint { color: #725316; background: #fff6d9; }
.feedback.is-success { color: #205f43; background: #e5f3e5; }

.success-chain {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 15px 0;
}

.success-chip {
  display: grid;
  width: 120px;
  min-height: 134px;
  padding: 7px;
  place-items: center;
  border: 2px solid #b8cf9f;
  border-radius: 18px;
  background: #fbfff5;
  text-align: center;
  font-weight: 900;
}

.success-chip img { width: 92px; height: 92px; object-fit: contain; }

.result-card,
.atlas {
  padding: clamp(22px, 4vw, 42px);
}

.result-card { text-align: center; }
.result-card h1 { margin: 7px auto 13px; }
.result-card p { color: var(--muted); font-size: 18px; }

.stars {
  color: var(--gold);
  font-size: 54px;
  letter-spacing: 8px;
}

.result-scene {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  justify-content: center;
  align-items: center;
  min-height: 190px;
  margin: 15px 0;
}

.result-scene img {
  width: 175px;
  height: 175px;
  object-fit: contain;
  filter: drop-shadow(0 12px 9px rgba(43, 62, 43, .16));
}

.result-actions { justify-content: center; }

.atlas-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.atlas-card {
  position: relative;
  min-height: 217px;
  overflow: hidden;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  background: #fffaf0;
  text-align: center;
}

.atlas-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 145px;
}

.atlas-preview img {
  width: 52%;
  height: 120px;
  margin: 0 -8px;
  object-fit: contain;
}

.atlas-card strong { display: block; line-height: 1.2; }
.atlas-card small { display: block; margin-top: 5px; color: var(--muted); }

.atlas-card.is-locked {
  cursor: default;
  filter: grayscale(1);
  opacity: .55;
}

.atlas-card.is-locked .atlas-preview { opacity: .18; }

.lock-mark {
  position: absolute;
  inset: 63px 0 auto;
  z-index: 2;
  font-size: 38px;
}

@media (max-width: 940px) {
  .hero { grid-template-columns: 1fr; }
  .hero-chain { min-height: 250px; }
  .routes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .route-card:last-child { grid-column: 1 / -1; }
  .food-bank { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .atlas-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .app { width: min(100% - 20px, 1120px); padding-top: 12px; }
  .brand small,
  .button-label { display: none; }
  .hero { padding: 24px 20px; }
  .hero-chain { min-height: 220px; }
  .nature-note { grid-template-columns: 62px minmax(0, 1fr); padding: 13px; }
  .nature-note span { width: 58px; height: 58px; font-size: 30px; }
  .routes { grid-template-columns: 1fr; }
  .route-card:last-child { grid-column: auto; }
  .section-head { align-items: flex-start; }
  .game-head { display: block; padding: 21px 18px 14px; }
  .step-counter { display: inline-flex; margin-top: 10px; }
  .progress-track { margin-inline: 18px; }
  .chain-area { padding: 18px; }
  .chain-track { flex-direction: column; }
  .slot-card { width: min(100%, 310px); min-height: 190px; }
  .slot-card img { height: 120px; }
  .chain-arrow { transform: rotate(90deg); line-height: .7; }
  .bank-section { padding: 21px 18px; }
  .food-bank { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .food-card { min-height: 158px; }
  .food-card img { height: 105px; }
  .feedback-row { grid-template-columns: 1fr; padding: 17px 18px 22px; }
  .feedback-row .game-actions { width: 100%; }
  .feedback-row .game-actions button { flex: 1; }
  .atlas-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-scene { gap: 0; }
  .result-scene img { width: 110px; height: 130px; }
}

@media (max-width: 390px) {
  .app { width: min(100% - 14px, 1120px); }
  .topbar { gap: 7px; }
  .icon-button { padding: 9px 11px; }
  .hero-chain { min-height: 190px; }
  .hero-chain img { height: 145px; }
  .hero-arrow { font-size: 28px; }
  .section-head { display: block; }
  .progress-label { display: block; margin-top: 7px; }
  .bank-head { display: block; }
  .bank-head span { display: block; margin-top: 5px; }
  .food-card { padding: 7px; }
  .success-chain { gap: 4px; }
  .success-chip { width: 88px; min-height: 115px; font-size: 13px; }
  .success-chip img { width: 72px; height: 72px; }
}

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