:root {
  --orange: #FF8A3D;
  --orange-deep: #E96F22;
  --orange-soft: #FFB77F;
  --orange-pale: #FFE8D2;
  --cream: #FFFBF0;
  --cream-2: #FFF4DE;
  --cream-3: #F8EED6;
  --ink: #4A3527;
  --ink-2: #7C5D48;
  --ink-3: #A88A72;
  --green: #7FC160;
  --green-deep: #5EA344;
  --sky: #81C9D0;
  --field: #87CCA2;
  --field-deep: #8ACC7F;
  --soil-a: #A27B65;
  --soil-b: #886250;
  --soil-c: #74503F;
  --shadow-card: 0 12px 30px rgba(64, 40, 18, .14), 0 2px 6px rgba(64, 40, 18, .08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(120% 55% at 10% 0%, rgba(255, 255, 255, .34), transparent 62%),
    linear-gradient(180deg, #81C9D0 0%, #83CAC9 20%, #85CBB8 38%, #87CCA2 56%, #8ACC7F 100%);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.game {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶部金币条 ---------- */

.hud {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
}

.hud-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 14px 0 8px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, .72);
  background: rgba(255, 251, 240, .88);
  box-shadow: 0 5px 16px rgba(42, 92, 83, .16), inset 0 1px 0 rgba(255, 255, 255, .95);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--ink);
  will-change: transform;
}

.coin-pill {
  padding-right: 12px;
}

.coin-face {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid #FFF3C4;
  background: radial-gradient(circle at 34% 28%, #FFE894 0%, #FFC63F 58%, #F3A117 100%);
  box-shadow: inset 0 -2px 0 rgba(176, 100, 0, .3), inset 0 2px 0 rgba(255, 255, 255, .6), 0 2px 5px rgba(150, 90, 0, .26);
  color: #8A5200;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.coin-num {
  min-width: 34px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .2px;
  font-variant-numeric: tabular-nums;
  color: #5A3B1F;
}

.coin-unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  margin-left: -2px;
}

.basket-pill {
  padding: 0 13px 0 11px;
  background: rgba(255, 246, 227, .9);
}

.basket-icon {
  width: 21px;
  height: 21px;
  color: var(--orange-deep);
}

.basket-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.basket-num {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #5A3B1F;
}

.basket-unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  margin-left: -1px;
}

.bump {
  animation: bump .38s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes bump {
  0% { transform: scale(1); }
  38% { transform: scale(1.09); }
  100% { transform: scale(1); }
}

/* ---------- 成品农场画面 + 可点菜地 ---------- */

.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 0;
  flex: none;
  padding-top: 79.2308%;
  overflow: hidden;
  background: #81C9D0;
  isolation: isolate;
}

.stage.no-art {
  background:
    radial-gradient(120% 90% at 78% 4%, rgba(255, 249, 224, .8), transparent 50%),
    linear-gradient(180deg, #8FD8D2 0%, #9AD7B7 46%, #8ACC7F 100%);
}

.stage-art {
  position: absolute;
  left: 0;
  top: -58.2524%;
  width: 100%;
  height: auto;
  max-width: none;
  display: block;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.plots {
  position: absolute;
  left: 43.5897%;
  top: 21.0356%;
  width: 49.7436%;
  height: 57.9288%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 5.5866% 5.1546%;
  z-index: 2;
}

.plot {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1.5px solid rgba(255, 255, 255, .22);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 240, 218, .16) 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 76% 64%, rgba(255, 240, 218, .13) 0 1px, transparent 1.6px),
    radial-gradient(circle at 46% 84%, rgba(45, 22, 10, .16) 0 1.4px, transparent 2px),
    radial-gradient(110% 80% at 26% 16%, rgba(255, 255, 255, .16), transparent 62%),
    radial-gradient(90% 95% at 78% 90%, rgba(58, 30, 16, .22), transparent 66%),
    linear-gradient(158deg, var(--soil-a) 0%, var(--soil-b) 58%, var(--soil-c) 100%);
  box-shadow:
    inset 0 3px 5px rgba(255, 236, 210, .16),
    inset 0 -8px 12px rgba(58, 28, 14, .22),
    0 3px 6px rgba(54, 30, 16, .22);
  transition: transform .13s ease, box-shadow .2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.plot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, .08), transparent 36%);
  pointer-events: none;
}

.plot:active {
  transform: scale(.93);
}

.plot:focus-visible {
  outline: 2px solid #FFF0C4;
  outline-offset: 2px;
}

/* 空地 */
.plot--empty::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1.5px dashed rgba(255, 237, 211, .34);
  border-radius: 9px;
  pointer-events: none;
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: rgba(255, 240, 216, .92);
  pointer-events: none;
}

.empty-plus {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 240, 216, .62);
  background: rgba(255, 255, 255, .09);
}

.empty-plus .mp-icon {
  width: 12px;
  height: 12px;
  color: rgba(255, 244, 226, .95);
}

.empty-text {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255, 242, 220, .82);
  text-shadow: 0 1px 1px rgba(50, 24, 10, .3);
}

.plot--empty {
  animation: emptyBreathe 3.2s ease-in-out infinite;
}

@keyframes emptyBreathe {
  0%, 100% { box-shadow: inset 0 3px 5px rgba(255, 236, 210, .16), inset 0 -8px 12px rgba(58, 28, 14, .22), 0 3px 6px rgba(54, 30, 16, .22); }
  50% { box-shadow: inset 0 3px 5px rgba(255, 236, 210, .2), inset 0 -8px 12px rgba(58, 28, 14, .22), 0 3px 10px rgba(255, 180, 86, .34); }
}

/* 生长中 */
.plant-sprout {
  position: absolute;
  left: 50%;
  bottom: 10%;
  width: 56%;
  height: 56%;
  transform: translateX(-50%) scale(var(--sprout-scale, .76));
  transform-origin: 50% 100%;
  opacity: var(--sprout-alpha, 1);
  display: grid;
  place-items: center;
  pointer-events: none;
}

.plant-crop {
  position: absolute;
  left: 50%;
  bottom: 9%;
  width: 82%;
  height: 82%;
  transform: translateX(-50%) scale(var(--crop-scale, .46));
  transform-origin: 50% 100%;
  opacity: var(--crop-alpha, 0);
  display: grid;
  place-items: center;
  filter: drop-shadow(0 3px 2px rgba(46, 22, 10, .22));
  pointer-events: none;
}

.plant-sprout svg,
.plant-crop svg,
.log-chip svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.grow-bar {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 5px;
  height: 4px;
  border-radius: 3px;
  background: rgba(38, 18, 8, .32);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, .2);
  overflow: hidden;
  pointer-events: none;
}

.grow-bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #FFD86B, var(--orange));
  box-shadow: 0 0 4px rgba(255, 190, 90, .6);
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
}

/* 成熟 */
.plot--ready {
  border-color: rgba(255, 236, 174, .9);
  animation: readyPulse 2.1s ease-in-out infinite;
}

@keyframes readyPulse {
  0%, 100% {
    box-shadow:
      inset 0 3px 5px rgba(255, 236, 210, .18),
      inset 0 -8px 12px rgba(58, 28, 14, .2),
      0 0 0 1.5px rgba(255, 199, 80, .85),
      0 0 12px rgba(255, 190, 60, .42),
      0 3px 7px rgba(54, 30, 16, .25);
  }
  50% {
    box-shadow:
      inset 0 3px 5px rgba(255, 236, 210, .22),
      inset 0 -8px 12px rgba(58, 28, 14, .2),
      0 0 0 2px rgba(255, 213, 111, 1),
      0 0 20px rgba(255, 190, 60, .7),
      0 3px 7px rgba(54, 30, 16, .25);
  }
}

.plot--ready .plant-crop {
  animation: cropBounce 1.5s ease-in-out infinite;
  transform: translateX(-50%) scale(1);
  opacity: 1;
}

@keyframes cropBounce {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  50% { transform: translateX(-50%) translateY(-2.5px) scale(1.03); }
}

.ready-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid #FFF3D0;
  background: linear-gradient(180deg, #FFB24D, #FF7A2F);
  box-shadow: 0 2px 5px rgba(140, 60, 0, .36);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(150, 60, 0, .3);
  pointer-events: none;
  animation: badgeNudge 1.5s ease-in-out infinite;
}

@keyframes badgeNudge {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-1px) scale(1.06); }
}

.plot.is-harvested {
  animation: harvestPop .3s ease-out forwards;
  pointer-events: none;
}

@keyframes harvestPop {
  0% { transform: scale(1); filter: brightness(1); }
  45% { transform: scale(1.12); filter: brightness(1.25); }
  100% { transform: scale(.86); filter: brightness(.9); opacity: .45; }
}

.plot.shake {
  animation: shake .36s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-3px) rotate(-1.5deg); }
  48% { transform: translateX(3px) rotate(1.5deg); }
  72% { transform: translateX(-2px) rotate(-1deg); }
}

/* 提示条 */
.toast {
  position: absolute;
  left: 50%;
  bottom: 9px;
  z-index: 4;
  max-width: 82%;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(58, 38, 24, .86);
  box-shadow: 0 4px 14px rgba(40, 20, 8, .24);
  color: #FFF6E4;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 8px) scale(.96);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* ---------- 底部菜地面板 ---------- */

.sheet {
  position: relative;
  z-index: 5;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 24px 16px calc(16px + var(--safe-bottom));
  border-radius: 26px 26px 0 0;
  background:
    radial-gradient(120% 90% at 8% 0%, #FFFFFF 0%, rgba(255, 255, 255, 0) 46%),
    linear-gradient(180deg, #FFFCF3 0%, #FFF8E9 62%, #FFF3DE 100%);
  box-shadow: 0 -10px 30px rgba(48, 70, 34, .16), inset 0 1px 0 rgba(255, 255, 255, .9);
}

.sheet-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sheet-title h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: .3px;
  color: #4D3522;
}

.sheet-title p {
  margin: 3px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: .2px;
}

.ready-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px 0 9px;
  border-radius: 16px;
  border: 1px solid #F2DFBE;
  background: #FFF4DE;
  color: #9B7448;
  font-size: 12px;
  font-weight: 600;
  flex: none;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.ready-chip .mp-icon {
  width: 16px;
  height: 16px;
  color: #C08A4E;
}

.ready-chip b {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ready-chip.is-hot {
  border-color: #FFC98F;
  background: linear-gradient(180deg, #FFEBD6, #FFDDBB);
  color: #B85A16;
  box-shadow: 0 3px 10px rgba(255, 138, 61, .26);
}

.ready-chip.is-hot .mp-icon {
  color: var(--orange-deep);
}

/* 统计 */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 11px 6px 10px;
  border-radius: 16px;
  border: 1px solid #F3E4CB;
  background: linear-gradient(180deg, #FFFFFF, #FFF9EC);
  box-shadow: 0 4px 12px rgba(120, 84, 40, .08), inset 0 1px 0 #fff;
}

.stat b {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  color: #5A3B1F;
  font-variant-numeric: tabular-nums;
}

.stat span {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: .2px;
}

.stat-ready {
  border-color: #FFD9B4;
  background: linear-gradient(180deg, #FFF6EA, #FFEBD8);
}

.stat-ready b {
  color: var(--orange-deep);
}

/* 一键收菜 */
.harvest-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 26px;
  background: linear-gradient(180deg, #FFA85C 0%, var(--orange) 52%, #F0741F 100%);
  box-shadow: 0 8px 18px rgba(233, 111, 34, .34), inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -2px 0 rgba(180, 78, 12, .3);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .6px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
  text-shadow: 0 1px 2px rgba(160, 66, 8, .35);
}

.harvest-all .mp-icon {
  width: 22px;
  height: 22px;
  color: #fff;
}

.harvest-all:active {
  transform: scale(.97);
  box-shadow: 0 4px 10px rgba(233, 111, 34, .3), inset 0 1px 0 rgba(255, 255, 255, .4);
}

.harvest-all:disabled {
  background: linear-gradient(180deg, #F0E2CE, #E7D6BE);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 3px 8px rgba(120, 84, 40, .1);
  color: #A98D6E;
  text-shadow: none;
  cursor: default;
}

.harvest-all:disabled .mp-icon {
  color: #B79B7C;
}

.harvest-all.is-ready {
  animation: btnGlow 2s ease-in-out infinite;
}

@keyframes btnGlow {
  0%, 100% { box-shadow: 0 8px 18px rgba(233, 111, 34, .34), inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -2px 0 rgba(180, 78, 12, .3); }
  50% { box-shadow: 0 10px 24px rgba(255, 138, 61, .55), inset 0 1px 0 rgba(255, 255, 255, .6), inset 0 -2px 0 rgba(180, 78, 12, .3); }
}

/* 收成记录 */
.log {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 13px 14px 14px;
  border-radius: 18px;
  border: 1px solid #F1E2C8;
  background: linear-gradient(180deg, #FFFDF7, #FFF7E8);
  box-shadow: 0 5px 14px rgba(120, 84, 40, .07), inset 0 1px 0 #fff;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #5A3B1F;
}

.log-hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
}

.log-list {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  flex-wrap: wrap;
}

.log-empty {
  font-size: 12px;
  color: #B49B80;
}

.log-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 34px;
  padding: 0 9px 0 4px;
  border-radius: 17px;
  border: 1px solid #F3E2C6;
  background: #fff;
  box-shadow: 0 2px 6px rgba(120, 84, 40, .1);
  animation: chipIn .3s ease-out;
}

.log-chip svg {
  width: 26px;
  height: 26px;
}

.log-chip b {
  font-size: 12px;
  font-weight: 800;
  color: var(--orange-deep);
  font-variant-numeric: tabular-nums;
}

@keyframes chipIn {
  0% { transform: scale(.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* 底部提示 */
.tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: .2px;
}

.tip .mp-icon {
  width: 15px;
  height: 15px;
  color: #9FCB86;
}

/* ---------- 特效层 ---------- */

.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  overflow: hidden;
}

.fly-coin {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 1.5px solid #FFF3C4;
  background: radial-gradient(circle at 34% 28%, #FFE894 0%, #FFC63F 58%, #F3A117 100%);
  box-shadow: 0 2px 6px rgba(150, 90, 0, .3);
  animation: flyCoin .78s cubic-bezier(.4, .1, .5, 1) forwards;
}

@keyframes flyCoin {
  0% { transform: translate(0, 0) scale(.6); opacity: 0; }
  18% { transform: translate(var(--mx, 0), var(--my, -16px)) scale(1.1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.5); opacity: 0; }
}

.float-text {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 17px;
  font-weight: 800;
  color: #FFD86B;
  text-shadow: 0 2px 4px rgba(120, 60, 0, .5), 0 0 10px rgba(255, 190, 90, .6);
  animation: floatUp .95s ease-out forwards;
  pointer-events: none;
}

@keyframes floatUp {
  0% { transform: translate(-50%, -50%) scale(.7); opacity: 0; }
  25% { transform: translate(-50%, -70%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -150%) scale(1); opacity: 0; }
}

.puff {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: radial-gradient(circle, #FFF6E0, rgba(255, 236, 200, 0));
  animation: puffOut .6s ease-out forwards;
}

@keyframes puffOut {
  0% { transform: translate(0, 0) scale(.6); opacity: .9; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.5); opacity: 0; }
}

@media (max-width: 340px) {
  .sheet-title h2 { font-size: 19px; }
  .stat b { font-size: 18px; }
  .harvest-all { height: 48px; font-size: 15px; }
}
