:root {
  --bg: #f6eedf;
  --bg-2: #efe3cc;
  --card: #fffaf1;
  --ink: #3b2a22;
  --ink-soft: #7a6355;
  --cap: #d9483b;
  --cap-dark: #b8362b;
  --stem: #f7e9d3;
  --moss: #6f8f4e;
  --moss-dark: #4f6b36;
  --soil: #8a5a3b;
  --soil-dark: #6b4029;
  --soil-wet: #5a3422;
  --wood: #b98252;
  --wood-dark: #8e5c34;
  --gold: #e9b23a;
  --shadow: rgba(59, 42, 34, 0.12);
  --line: rgba(59, 42, 34, 0.12);
  --display: "Fraunces", Georgia, serif;
  --body: "Nunito", system-ui, sans-serif;
  --hand: "Caveat", cursive;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- ambient spores ---------- */
.spores { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.spore {
  position: absolute; bottom: -10px;
  border-radius: 50%;
  background: #e9c98f;
  opacity: 0;
  animation: float linear infinite;
}
@keyframes float {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: .7; }
  90% { opacity: .5; }
  100% { transform: translate(var(--drift), -110vh); opacity: 0; }
}

/* ---------- click sprouts ---------- */
#sprouts { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.sprout {
  position: absolute;
  width: 34px; height: 34px;
  margin: -30px 0 0 -17px;
  transform-origin: 50% 100%;
  animation: sprout 1.6s cubic-bezier(.3,1.6,.5,1) forwards;
}
@keyframes sprout {
  0% { transform: scale(0) rotate(-10deg); opacity: 1; }
  25% { transform: scale(1.1) rotate(4deg); }
  40% { transform: scale(1) rotate(0); }
  80% { opacity: 1; }
  100% { transform: scale(1) translateY(-14px); opacity: 0; }
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 48px 16px 120px;
  background: radial-gradient(ellipse at 50% 0%, #fff6e6 0%, var(--bg) 60%);
  z-index: 1;
}
.kicker { font-family: var(--hand); font-size: 28px; color: var(--ink-soft); }
h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(44px, 11vw, 112px);
  line-height: .95;
  letter-spacing: -0.03em;
}
h1 span { color: var(--cap); }
h1 em { font-style: italic; font-weight: 400; color: var(--moss); font-size: .5em; letter-spacing: 0; }
.sub { margin-top: 12px; color: var(--ink-soft); font-family: var(--hand); font-size: 30px; font-weight: 700; }

.big-shroom {
  position: relative;
  width: min(280px, 70vw);
  margin-top: 76px;
  animation: bob 4s ease-in-out infinite;
}
.hero-svg { width: 100%; display: block; overflow: visible; }
.big-shroom .cap, .big-shroom .stem { transform-origin: 100px 190px; transition: transform .25s cubic-bezier(.3,1.8,.5,1); }
.big-shroom:hover .cap { transform: rotate(-3deg); }
.big-shroom.squish .cap { transform: scale(1.08, .88); }
.big-shroom.squish .stem { transform: scale(1.06, .9); }
.big-shroom .blush { opacity: .55; transition: opacity .3s; }
.big-shroom.squish .blush { opacity: 1; }
.eye { animation: blink 5s infinite; transform-box: fill-box; transform-origin: center; }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.bubble {
  position: absolute;
  top: -14px; left: 50%;
  translate: -50% -100%;
  white-space: nowrap;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 18px;
  padding: 6px 16px;
  font-family: var(--hand);
  font-size: 24px;
  font-weight: 700;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .2s cubic-bezier(.3,1.8,.5,1);
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -9px;
  width: 14px; height: 14px; background: var(--card);
  border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
}
.bubble.pop { transform: scale(1.12); }

.scroll-hint {
  margin-top: 36px;
  font-family: var(--hand); font-size: 24px;
  text-decoration: none; color: var(--ink-soft);
  animation: nudge 2s ease-in-out infinite;
}
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

.grass {
  position: absolute; left: 0; right: 0; bottom: 0; height: 70px;
  background:
    radial-gradient(circle at 20px 52px, var(--moss) 20px, transparent 21px) 0 0 / 36px 70px repeat-x,
    linear-gradient(transparent 45px, var(--moss) 45px);
}

/* ---------- farm ---------- */
.farm {
  position: relative; z-index: 1;
  background: var(--moss);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.06) 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,.06) 2px, transparent 3px);
  background-size: 34px 34px, 46px 46px;
  color: #fff8ee;
  padding: 40px 16px 96px;
}
.farm-head { max-width: 620px; margin: 0 auto 28px; text-align: center; }
h2 {
  font-family: var(--display);
  font-size: clamp(34px, 6vw, 52px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
.farm-head p { opacity: .9; }

.hud {
  max-width: 720px; margin: 0 auto 14px;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center;
}
.stat, .shop-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 99px;
  padding: 6px 14px;
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.coin {
  display: inline-block; flex: none;
  width: .95em; height: .95em;
  vertical-align: -0.12em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a3 0 18%, #f2c14e 40%, #d39a24 100%);
  box-shadow: inset 0 0 0 1.5px #a8731a, inset 0 0 0 3.5px #f6cf63;
}
.stat small { font-weight: 600; color: var(--ink-soft); }
.stat b.bump { animation: bump .35s ease; display: inline-block; }
@keyframes bump { 50% { transform: scale(1.35); } }
.shop-btn { background: var(--gold); transition: transform .12s, box-shadow .12s; }
.shop-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.seedbag {
  max-width: 720px; margin: 0 auto 18px;
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.seed {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px 4px 6px;
  border-radius: 14px;
  background: rgba(255,248,238,.18);
  border: 2px solid transparent;
  color: #fff8ee;
  font-weight: 700; font-size: 14px;
  transition: background .15s, border-color .15s;
}
.seed svg { width: 30px; height: 30px; }
.seed[aria-checked="true"] { background: var(--card); color: var(--ink); border-color: var(--ink); }
.seed.locked { opacity: .45; }

.bed-wrap {
  max-width: 520px; margin: 0 auto;
  background: var(--wood);
  border: 3px solid var(--ink);
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 8px 0 var(--wood-dark), 0 8px 0 3px var(--ink);
}
.bed {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), 1fr);
  gap: 8px;
}
.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  background:
    repeating-linear-gradient(0deg, transparent 0 9px, rgba(0,0,0,.1) 9px 11px),
    var(--soil);
  box-shadow: inset 0 -5px 0 var(--soil-dark);
}
.tile.wet {
  background:
    repeating-linear-gradient(0deg, transparent 0 9px, rgba(0,0,0,.15) 9px 11px),
    var(--soil-wet);
}
.tile:hover { filter: brightness(1.08); }
.tile:active { transform: scale(.96); }

.plant {
  position: absolute; left: 8%; right: 8%; bottom: 10%;
  height: 84%;
  transform-origin: 50% 100%;
  pointer-events: none;
}
.plant svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.plant.s1 { transform: scale(.42); }
.plant.s2 { transform: scale(.7); }
.plant.s3 { transform: scale(1); animation: ready 1.6s ease-in-out infinite; }
.plant.grew { animation: pop .5s cubic-bezier(.3,1.8,.5,1); }
.plant.s3.grew { animation: pop .5s cubic-bezier(.3,1.8,.5,1), ready 1.6s ease-in-out .5s infinite; }
.plant.glow svg { filter: drop-shadow(0 0 6px var(--glow)); }
@keyframes pop { 0% { scale: .6; } 100% { scale: 1; } }
@keyframes ready { 0%, 100% { rotate: -3deg; } 50% { rotate: 3deg; } }

.spore-dot {
  position: absolute; left: 50%; bottom: 26%;
  width: 18px; height: 10px; translate: -50% 0;
  border-radius: 50% 50% 40% 40%;
  background: var(--soil-dark);
  box-shadow: 0 -3px 0 rgba(255,255,255,.12);
}
.spore-dot::after {
  content: ""; position: absolute; left: 50%; top: -6px; translate: -50% 0;
  width: 6px; height: 6px; border-radius: 50%; background: var(--c, #fff8ee);
}

.need {
  position: absolute; top: -6px; right: -6px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 50%;
  font-size: 13px;
  z-index: 2;
  animation: nudge 1.4s ease-in-out infinite;
  pointer-events: none;
}
.need.harvest { background: var(--gold); }

.bar {
  position: absolute; left: 14%; right: 14%; bottom: 6%;
  height: 5px; border-radius: 9px;
  background: rgba(0,0,0,.3);
  overflow: hidden;
  pointer-events: none;
}
.bar i { display: block; height: 100%; background: #9fd0ff; border-radius: 9px; }

.coin-float {
  position: absolute; left: 50%; top: 10%;
  translate: -50% 0;
  font-weight: 800; color: #fff8ee;
  text-shadow: 0 2px 0 var(--ink);
  pointer-events: none;
  animation: rise 1s ease-out forwards;
  z-index: 3;
  white-space: nowrap;
}
@keyframes rise { to { transform: translateY(-46px); opacity: 0; } }

.howto {
  max-width: 620px; margin: 26px auto 0;
  text-align: center; font-size: 14px; opacity: .85;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 20px;
  translate: -50% 0;
  width: min(460px, calc(100vw - 32px));
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 20px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 18px 22px;
  text-align: center;
  z-index: 60;
  cursor: pointer;
  animation: toastIn .35s cubic-bezier(.3,1.6,.5,1);
}
@keyframes toastIn { from { transform: translateY(30px); opacity: 0; } }
.toast-top { font-family: var(--hand); font-size: 22px; font-weight: 700; color: var(--cap); line-height: 1.1; }
.toast-text { font-family: var(--display); font-size: 18px; line-height: 1.35; margin-top: 4px; }

/* ---------- shop modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(59, 42, 34, .45);
  display: grid; place-items: center;
  padding: 16px;
}
.modal-card {
  width: min(460px, 100%);
  max-height: calc(100svh - 32px);
  overflow: auto;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 22px;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 22px;
  animation: toastIn .3s cubic-bezier(.3,1.6,.5,1);
}
.modal-top { display: flex; justify-content: space-between; align-items: center; }
h3 { font-family: var(--display); font-size: 28px; }
.close { font-size: 20px; width: 36px; height: 36px; border-radius: 50%; }
.close:hover { background: var(--bg-2); }
.modal-coins { color: var(--ink-soft); margin-bottom: 14px; }
.shop-list { display: grid; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 14px;
}
.item-icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; font-size: 28px; }
.item-icon svg { width: 100%; height: 100%; }
.item-info { flex: 1; line-height: 1.3; }
.item-info b { display: block; }
.item-info small { color: var(--ink-soft); }
.buy {
  flex: none;
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--gold);
  border: 2px solid var(--ink);
  font-weight: 800; font-size: 14px;
}
.buy:disabled { background: var(--bg-2); color: var(--ink-soft); border-color: var(--line); cursor: not-allowed; }
.buy.owned { background: var(--moss); color: #fff8ee; border-color: var(--moss-dark); }
.book-btn { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.book-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.book-list { display: grid; gap: 18px; }
.book-type { display: flex; align-items: center; gap: 6px; font-weight: 800; margin-bottom: 6px; }
.book-type svg { width: 26px; height: 26px; }
.book-group { display: grid; gap: 8px; }
.mem {
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff3c9;
  line-height: 1.4;
}
.mem p { font-size: 15px; margin-top: 2px; }
.mem.locked { background: var(--bg-2); color: var(--ink-soft); }
.mem-photo { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; }
.mem-title { display: block; font-size: 22px; margin-bottom: 4px; }
.reset { margin-top: 18px; font-size: 13px; color: var(--ink-soft); text-decoration: underline; }

footer {
  position: relative; z-index: 1;
  background: var(--ink); color: #e9dcc6;
  text-align: center; padding: 28px 16px; font-size: 14px;
}

@media (max-width: 560px) {
  .bed { gap: 6px; }
  .bed-wrap { padding: 8px; border-radius: 16px; }
  .need { width: 22px; height: 22px; font-size: 11px; top: -4px; right: -4px; }
  .seed { font-size: 13px; }
  .hud { gap: 6px; }
  .stat, .shop-btn { padding: 4px 10px; font-size: 15px; gap: 4px; box-shadow: 2px 2px 0 var(--ink); }
}

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