:root {
  --green-50: #EAF3DE;
  --green-200: #97C459;
  --green-400: #639922;
  --green-800: #27500A;
  --wood: #C9965A;
  --wood-dark: #8B5A2B;
  --wood-deep: #6B3E18;
  --cream: #FFF6DE;
  --ink: #3A2A18;
  --line: #E8D9B8;
  --sky-top: #BFE7FF;
  --sky-bot: #E7F7C9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #1d3a18;
  color: var(--ink);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100%;
  display: grid;
  place-items: center;
}

.phone {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 500px;
  height: 844px;
  overflow: hidden;
  transform-origin: center center;
  background: linear-gradient(180deg, #c5ebff 0%, #b8ea72 26%, #8edc4a 100%);
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
}

.sky { position: absolute; inset: 0 0 55% 0; pointer-events: none; }
.sun {
  position: absolute; top: 86px; right: 28px; width: 54px; height: 54px;
  border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6c4, #ffd15a 55%, #f5b431);
  box-shadow: 0 0 28px #ffe08a;
}
.cloud {
  position: absolute; background: #fff; border-radius: 40px;
  box-shadow: 14px 8px 0 #fff, 28px 4px 0 #fff;
  opacity: .92; animation: drift 22s linear infinite;
}
.c1 { width: 52px; height: 22px; top: 108px; left: -40px; animation-duration: 28s; }
.c2 { width: 40px; height: 18px; top: 148px; left: -80px; animation-duration: 36s; animation-delay: -10s; }
.c3 { width: 46px; height: 20px; top: 128px; left: -20px; animation-duration: 32s; animation-delay: -18s; }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(520px); } }

.hud {
  position: relative; z-index: 5;
  padding: calc(10px + env(safe-area-inset-top)) 12px 0;
}
.hud-wood {
  background: linear-gradient(#e6c48a, #c48a4a);
  border: 3px solid var(--wood-deep);
  border-radius: 18px;
  padding: 8px 10px 10px;
  box-shadow: inset 0 2px 0 #f8e2b4, 0 4px 0 var(--wood-deep);
}
.hud-row { display: flex; align-items: center; gap: 8px; }
.hud-bars { margin-top: 8px; }
.pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--cream);
  border: 2px solid var(--wood-deep);
  border-radius: 999px;
  padding: 3px 10px 3px 4px;
  min-width: 86px;
  box-shadow: inset 0 1px 0 #fff;
}
.pill b { font-size: 15px; }
.ico-coin, .ico-gem {
  width: 22px; height: 22px; border-radius: 50%; display: inline-block;
}
.ico-coin { background: radial-gradient(circle at 35% 30%, #ffe9a0, #e2b12a 60%, #b8860b); border: 2px solid #8a5a12; }
.ico-gem { background: radial-gradient(circle at 35% 30%, #d2fff4, #3ecf9f 60%, #0f8a68); transform: rotate(45deg); border-radius: 6px; border: 2px solid #0b5a46; }
.icon-btn {
  margin-left: auto; width: 34px; height: 34px; border-radius: 10px;
  border: 2px solid var(--wood-deep); background: var(--cream); font-size: 16px; cursor: pointer;
}
.bar-wrap { flex: 1; display: flex; align-items: center; gap: 4px; }
.bar {
  flex: 1; height: 12px; background: #efe3c4; border: 2px solid var(--wood-deep);
  border-radius: 999px; overflow: hidden;
}
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; transition: width .25s; }
.bar.xp i { background: linear-gradient(90deg, #8fd15a, #4ea72a); }
.bar.water i { background: linear-gradient(90deg, #7ad7ff, #2f9adf); }
.bar-ico { font-size: 12px; }
.bar-label { font-size: 11px; font-weight: 700; min-width: 36px; }
.speed-tag {
  display: inline-block; margin: 6px 0 0 4px;
  background: rgba(255,255,255,.7); color: var(--green-800);
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
}

.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#garden {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 86px;
  width: 100%;
  height: calc(100% - 86px);
  display: block;
  cursor: grab;
  touch-action: none;
}
.zoom-btns {
  position: absolute;
  right: 12px;
  bottom: 108px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.zoom-btns button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 3px solid var(--wood-deep);
  background: linear-gradient(#f0c56a, #e09a32);
  color: var(--wood-deep);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--wood-deep);
}
.zoom-btns button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--wood-deep); }
.float-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute; font-weight: 800; color: #fff8d8; text-shadow: 0 2px 0 #6b3e18;
  animation: rise 1s ease-out forwards; font-size: 16px;
}
@keyframes rise { to { transform: translateY(-48px); opacity: 0; } }

.plot-pop {
  position: absolute; z-index: 4; min-width: 132px;
  background: var(--cream); border: 3px solid var(--wood-deep); border-radius: 14px;
  padding: 8px 10px; box-shadow: 0 6px 0 var(--wood-deep); font-size: 12px; text-align: center;
}
.plot-pop b { display: block; font-size: 13px; margin-bottom: 2px; }
.plot-pop button {
  margin-top: 6px; width: 100%;
}

.dock {
  position: absolute; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 6; display: flex; justify-content: space-between; gap: 6px;
  background: linear-gradient(#e6c48a, #c48a4a);
  border: 3px solid var(--wood-deep); border-radius: 22px;
  padding: 8px 8px 6px; box-shadow: 0 5px 0 var(--wood-deep);
}
.dock-btn {
  flex: 1; border: 0; background: transparent; cursor: pointer; color: var(--wood-deep);
}
.dock-btn small { display: block; font-size: 11px; font-weight: 700; margin-top: 2px; }
.dock-btn.active .dock-ico, .dock-btn:active .dock-ico { transform: translateY(2px); }
.dock-ico {
  width: 46px; height: 46px; margin: 0 auto; border-radius: 50%;
  border: 3px solid var(--wood-deep); display: grid; place-items: center;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 3px 0 var(--wood-deep);
  transition: transform .1s;
}
.water-can { background: radial-gradient(circle at 30% 30%, #c9f0ff, #4aa7e8); }
.water-can::after { content: "💧"; font-size: 22px; }
.bag-yellow { background: radial-gradient(circle at 30% 30%, #ffe9a8, #f0b429); }
.bag-yellow::after { content: "🎒"; font-size: 20px; }
.store { background: radial-gradient(circle at 30% 30%, #ffd0c0, #e36a3a); }
.store::after { content: "🏪"; font-size: 20px; }
.book { background: radial-gradient(circle at 30% 30%, #d9f5c4, #6db33a); }
.book::after { content: "📖"; font-size: 20px; }
.friends { background: radial-gradient(circle at 30% 30%, #dcd6ff, #7b6adf); }
.friends::after { content: "👫"; font-size: 20px; }

.sheet {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(40, 24, 8, .35);
  display: grid; align-items: end;
}
.sheet[hidden] { display: none !important; }
.sheet-card {
  background: var(--cream);
  border: 4px solid var(--wood-deep);
  border-radius: 22px 22px 0 0;
  max-height: 72%;
  box-shadow: 0 -8px 0 rgba(107,62,24,.2);
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .4; } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px;
  background: linear-gradient(#e6c48a, #d2a56a);
  border-bottom: 3px solid var(--wood-deep);
  border-radius: 18px 18px 0 0;
}
.sheet-head h3 { font-size: 16px; }
.close {
  width: 32px; height: 32px; border-radius: 10px; border: 2px solid var(--wood-deep);
  background: #fff; font-size: 20px; cursor: pointer; line-height: 1;
}
.sheet-body { padding: 12px; overflow: auto; max-height: 52vh; }
.sheet-foot { padding: 0 12px 16px; }

.item {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  padding: 8px; margin-bottom: 8px;
}
.item .art {
  width: 52px; height: 52px; border-radius: 12px;
  background: #eaf6d4; display: grid; place-items: center; font-size: 28px;
}
.item .meta { flex: 1; }
.item .meta b { display: block; font-size: 14px; }
.item .meta span { font-size: 12px; color: #6b5a40; }
.wood-btn {
  border: 3px solid var(--wood-deep); background: linear-gradient(#f0c56a, #e09a32);
  color: var(--wood-deep); font-weight: 800; border-radius: 12px;
  padding: 8px 12px; cursor: pointer; box-shadow: 0 3px 0 var(--wood-deep);
}
.wood-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--wood-deep); }
.wood-btn.big { width: 70%; font-size: 18px; padding: 12px; }
.wood-btn:disabled { filter: grayscale(.4); opacity: .6; cursor: default; }

.seed-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seed-card {
  border: 2px solid var(--wood-deep); border-radius: 14px; background: #fff;
  padding: 10px 8px; text-align: center; cursor: pointer;
}
.seed-card .art { font-size: 32px; }
.seed-card b { display: block; font-size: 13px; }
.seed-card span { font-size: 12px; color: #6b5a40; }

.book-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.book-card {
  border: 2px solid var(--line); border-radius: 14px; background: #fff;
  padding: 12px 8px; text-align: center;
}
.book-card.locked { filter: grayscale(1); opacity: .55; }
.book-card .art { font-size: 36px; }
.coming { text-align: center; padding: 28px 16px 36px; }
.coming-art { font-size: 56px; }
.coming p { margin-top: 8px; }
.hint { font-size: 12px; color: #7a6a50; }

.toast {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  z-index: 30; background: rgba(42, 28, 12, .88); color: #fff8e6;
  padding: 8px 14px; border-radius: 12px; font-size: 13px; white-space: nowrap;
  animation: pop .2s ease;
}
.toast[hidden] { display: none !important; }
@keyframes pop { from { transform: translate(-50%, 8px); opacity: 0; } }

.boot, .guide {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(22, 40, 12, .45);
  display: grid; place-items: center;
}
.boot { background: linear-gradient(180deg, #bfe7ff, #c8e98a); }
.boot[hidden], .guide[hidden] { display: none !important; }
.boot-card, .guide-card {
  width: min(340px, 86vw); text-align: center;
  background: var(--cream); border: 4px solid var(--wood-deep); border-radius: 24px;
  padding: 28px 20px; box-shadow: 0 10px 0 var(--wood-deep);
}
.gate-card { padding-top: 18px; }
.boot-garden { font-size: 64px; animation: bounce 1.2s ease infinite; }
@keyframes bounce { 50% { transform: translateY(-8px); } }
.boot-card h1 { color: var(--green-800); font-size: 24px; margin: 6px 0 4px; }
.boot-card p, .guide-card p { color: #5d4a32; margin-bottom: 14px; }
.guide-card h2 { margin-bottom: 8px; font-size: 18px; }

.gate-cat { position: relative; height: 168px; margin-bottom: 4px; }
.cat-bubble {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  min-width: 196px; max-width: 92%;
  background: #fff; border: 3px solid var(--wood-deep); border-radius: 16px;
  padding: 8px 12px; font-size: 13px; font-weight: 700; color: var(--wood-deep);
  box-shadow: 0 3px 0 var(--wood-deep); z-index: 2;
}
.cat-bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -10px;
  border: 8px solid transparent; border-top-color: var(--wood-deep);
  transform: translateX(-50%);
}
.cat-figure {
  position: absolute; left: 50%; bottom: 4px; width: 132px; height: 118px;
  transform: translateX(-50%);
}
.cat-body {
  position: absolute; left: 18px; bottom: 18px; width: 96px; height: 72px;
  background: radial-gradient(circle at 35% 30%, #ffe9c8, #f4d19a 58%, #e8b56a);
  border: 3px solid #c4925a; border-radius: 48px 48px 40px 40px;
}
.cat-face {
  position: absolute; left: 28px; top: 18px; width: 76px; height: 62px;
  background: radial-gradient(circle at 40% 35%, #fff6e8, #f4d19a);
  border: 3px solid #c4925a; border-radius: 46% 46% 48% 48%;
  z-index: 1;
}
.cat-ear {
  position: absolute; top: 8px; width: 28px; height: 28px;
  background: #f4d19a; border: 3px solid #c4925a;
  border-radius: 8px 18px 4px 18px; transform: rotate(-18deg);
}
.cat-ear::after {
  content: ""; position: absolute; inset: 6px 6px 8px 8px;
  background: #ffc1c8; border-radius: 6px 12px 2px 12px;
}
.cat-ear.left { left: 26px; }
.cat-ear.right { right: 26px; transform: scaleX(-1) rotate(-18deg); }
.cat-eye {
  position: absolute; top: 22px; width: 8px; height: 10px;
  background: #2a1a10; border-radius: 50%;
  animation: blink 4.2s infinite;
}
.cat-eye.l { left: 18px; }
.cat-eye.r { right: 18px; }
@keyframes blink { 0%, 88%, 100% { transform: scaleY(1); } 92% { transform: scaleY(0.1); } }
.cat-blush {
  position: absolute; top: 34px; width: 12px; height: 7px;
  background: rgba(255, 140, 150, .45); border-radius: 50%;
}
.cat-blush.l { left: 8px; }
.cat-blush.r { right: 8px; }
.cat-nose {
  position: absolute; left: 50%; top: 34px; width: 10px; height: 7px;
  background: #e89aa8; border-radius: 50%; transform: translateX(-50%);
}
.cat-paw {
  position: absolute; bottom: 10px; width: 28px; height: 16px;
  background: #ffe9c8; border: 3px solid #c4925a; border-radius: 12px;
  z-index: 2;
}
.cat-paw.l { left: 28px; }
.cat-paw.r { right: 28px; }
.cat-tail {
  position: absolute; right: 2px; bottom: 38px; width: 42px; height: 14px;
  background: #f4d19a; border: 3px solid #c4925a; border-left: 0; border-radius: 0 20px 20px 0;
  transform-origin: left center;
  animation: wag 1.4s ease-in-out infinite;
}
@keyframes wag { 50% { transform: rotate(18deg); } }
.gate-cat.nope .cat-figure { animation: nope .45s ease; }
.gate-cat.nope .cat-bubble { background: #ffe4e4; }
@keyframes nope {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 8px)); }
  75% { transform: translateX(calc(-50% + 8px)); }
}
.gate-cat.ok .cat-bubble { background: #eaffd4; }
#gate-form { display: grid; gap: 10px; justify-items: center; }
#gate-code {
  width: 86%; height: 44px; border-radius: 14px; text-align: center;
  border: 3px solid var(--wood-deep); background: #fff;
  font-size: 16px; font-weight: 700; color: var(--ink); letter-spacing: 2px;
  outline: none;
}
#gate-code:focus { box-shadow: 0 0 0 3px rgba(99, 153, 34, .25); }
.gate-hint { display: block; margin-top: 12px; color: #8a7358; font-size: 11px; }

@media (max-width: 520px) {
  .phone { box-shadow: none; }
}
