:root {
  --cream: #FFF7E6;
  --cream-2: #FFEFD0;
  --brown: #5B3A1A;
  --brown-soft: #8A6A45;
  --green: #6DBE3F;
  --green-deep: #4E8E20;
  --orange: #FF8A3D;
  --orange-deep: #D96A17;
  --gold: #FFC94A;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background:
    radial-gradient(120% 80% at 50% 18%, #3d5a27 0%, #1a2710 62%, #0b1206 100%);
  color: var(--brown);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.game {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #9ECF6A;
  box-shadow: 0 0 70px rgba(0, 0, 0, 0.45);
}

/* ---------- 场景 ---------- */

.world {
  position: absolute;
  left: 0;
  top: 0;
  width: 1536px;
  height: 1024px;
  transform-origin: 0 0;
  transform: translate3d(-495px, 0, 0) scale(0.99);
  opacity: 0;
  transition: opacity 0.28s ease;
  will-change: transform;
}

.game.ready .world {
  opacity: 1;
}

.scene {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.game::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    radial-gradient(120% 92% at 50% 42%, rgba(255, 255, 255, 0) 52%, rgba(20, 34, 10, 0.2) 100%);
}

/* ---------- 菜地热点 ---------- */

.plot {
  position: absolute;
  z-index: 2;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  color: var(--brown);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, filter 0.08s ease;
}

.plot:active {
  transform: scale(0.97);
  filter: brightness(1.04);
}

.plot:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.95);
  outline-offset: 2px;
  border-radius: 26px;
}

.plot-scrim {
  position: absolute;
  inset: -4px;
  border-radius: 28px;
  background:
    radial-gradient(ellipse at 50% 60%, rgba(43, 26, 11, 0.72) 0%, rgba(43, 26, 11, 0.44) 55%, rgba(43, 26, 11, 0.08) 82%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.plot.empty .plot-scrim {
  opacity: 1;
}

.plot.empty::after {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: 1;
  border: 3px dashed rgba(255, 246, 220, 0.62);
  border-radius: 24px;
  pointer-events: none;
}

.plot-glow {
  position: absolute;
  inset: -28px;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle, rgba(255, 214, 100, 0.78) 0%, rgba(255, 190, 56, 0.26) 46%, rgba(255, 190, 56, 0) 72%);
  opacity: 0;
}

.plot.ready .plot-glow {
  opacity: 1;
  animation: glowPulse 1.45s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { transform: scale(0.9); opacity: 0.55; }
  50% { transform: scale(1.08); opacity: 0.95; }
}

.plot-icon {
  position: absolute;
  left: 50%;
  top: 37%;
  width: 70px;
  height: 70px;
  margin: -35px 0 0 -35px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 249, 235, 0.94);
  background: #fff;
  box-shadow: 0 6px 16px rgba(28, 30, 8, 0.32);
  z-index: 2;
  opacity: 0;
  transform: scale(0.55);
  transition: opacity 0.16s ease, transform 0.16s ease;
  pointer-events: none;
}

.plot-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.plot.empty .plot-icon,
.plot.ready .plot-icon {
  opacity: 1;
  transform: scale(1);
}

.plot.empty .plot-icon {
  animation: seedBob 2.1s ease-in-out infinite;
}

.plot.ready .plot-icon {
  animation: readyBob 1.1s ease-in-out infinite;
}

@keyframes seedBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.025); }
}

@keyframes readyBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.05); }
}

.plot-badge {
  position: absolute;
  left: 50%;
  bottom: -5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateX(-50%);
  padding: 6px 16px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  background: linear-gradient(180deg, #93D64F, #67B52D);
  box-shadow: 0 4px 0 rgba(78, 142, 32, 0.55), 0 7px 14px rgba(26, 48, 8, 0.28);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  z-index: 3;
}

.plot.growing .plot-badge {
  background: linear-gradient(180deg, #FFFEF7, #FFEDC4);
  border-color: #fff;
  box-shadow: 0 4px 0 rgba(187, 150, 91, 0.4), 0 7px 14px rgba(26, 48, 8, 0.2);
  color: #7A5A2B;
  text-shadow: none;
}

.plot.ready .plot-badge {
  background: linear-gradient(180deg, #FFDA6A, #FF9E2A);
  border-color: #FFF5D7;
  box-shadow: 0 4px 0 var(--orange-deep), 0 7px 16px rgba(150, 80, 0, 0.34);
  color: #5A3200;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.plot-bar {
  position: absolute;
  left: 50%;
  bottom: 40px;
  width: 114px;
  height: 9px;
  margin-left: -57px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(57, 36, 14, 0.46);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.32), 0 0 0 2px rgba(255, 255, 255, 0.3);
  opacity: 0;
  z-index: 2;
}

.plot.growing .plot-bar {
  opacity: 1;
}

.plot-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #B8E96E, #59B72A);
  transition: width 0.16s linear;
}

.plot.just-ready {
  animation: readyPop 0.5s ease;
}

@keyframes readyPop {
  0% { transform: scale(1); }
  42% { transform: scale(1.07); }
  100% { transform: scale(1); }
}

/* ---------- 顶部状态 ---------- */

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 14px 0;
  pointer-events: none;
}

.hud::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: -1;
  height: calc(88px + var(--safe-top));
  pointer-events: none;
  background: linear-gradient(180deg, rgba(18, 38, 56, 0.24), rgba(18, 38, 56, 0));
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  pointer-events: auto;
}

.avatar {
  flex: none;
  width: 50px;
  height: 50px;
  overflow: hidden;
  border: 3px solid #FFF8E9;
  border-radius: 50%;
  background: #FFF8E9;
  box-shadow: 0 4px 14px rgba(26, 38, 12, 0.34);
}

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.06);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 13px 0 10px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  background: rgba(255, 249, 236, 0.95);
  box-shadow: 0 4px 14px rgba(26, 38, 12, 0.22);
  color: var(--brown);
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.pill .mp-icon {
  width: 20px;
  height: 20px;
  color: #B97A28;
}

.coin-pill {
  padding-left: 6px;
  padding-right: 15px;
  gap: 7px;
}

.coin-pill img {
  display: block;
  flex: none;
  width: 28px;
  height: 28px;
  margin-left: -3px;
  border-radius: 50%;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
}

.coin-pill.gain {
  animation: coinBump 0.45s ease;
}

@keyframes coinBump {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); }
  72% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* ---------- 底部操作台 ---------- */

.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  padding: 0;
}

.dock-inner {
  position: relative;
  overflow: hidden;
  padding: 10px 16px calc(12px + var(--safe-bottom));
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-bottom: 0;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(255, 251, 241, 0.985), #FFF3D9);
  box-shadow: 0 -12px 32px rgba(22, 38, 8, 0.3), inset 0 1px 0 #fff;
}

.dock-inner::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0) 42%);
}

.dock-hint {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 0 0 8px;
  color: #8B7051;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.dock-hint .mp-icon {
  width: 15px;
  height: 15px;
  color: #E08A28;
}

.actions {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 60px;
  padding: 0 10px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  font-family: inherit;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: manipulation;
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.08s ease, filter 0.08s ease;
}

.action::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 48%);
  pointer-events: none;
}

.action.plant {
  background: linear-gradient(180deg, #95D957, #64B42B);
  box-shadow: 0 5px 0 #4B8A1E, 0 9px 18px rgba(50, 90, 20, 0.28);
}

.action.harvest {
  background: linear-gradient(180deg, #FFC24B, #FF8A3D);
  box-shadow: 0 5px 0 var(--orange-deep), 0 9px 18px rgba(150, 80, 0, 0.26);
}

.action.harvest.is-idle {
  filter: saturate(0.72) brightness(0.97);
}

.action:active {
  transform: translateY(3px);
  filter: brightness(0.98);
}

.action.plant:active {
  box-shadow: 0 2px 0 #4B8A1E, 0 4px 8px rgba(50, 90, 20, 0.22);
}

.action.harvest:active {
  box-shadow: 0 2px 0 var(--orange-deep), 0 4px 8px rgba(150, 80, 0, 0.2);
}

.action-icon {
  flex: none;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.action-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.action-text {
  position: relative;
  z-index: 1;
}

.action-badge {
  position: absolute;
  top: -8px;
  right: -4px;
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--cream);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
  color: #B3600F;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.action-badge.show {
  display: flex;
  animation: badgePop 0.3s ease;
}

@keyframes badgePop {
  0% { transform: scale(0.55); }
  72% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* ---------- 提示与特效 ---------- */

.toast {
  position: absolute;
  left: 50%;
  top: 26%;
  z-index: 20;
  max-width: 84%;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(46, 33, 17, 0.93);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  color: #FFF7E6;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.toast.good {
  background: rgba(70, 120, 26, 0.95);
}

.toast.bad {
  background: rgba(150, 70, 20, 0.95);
}

.fx {
  position: absolute;
  inset: 0;
  z-index: 18;
  overflow: hidden;
  pointer-events: none;
}

.coin-fly {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  pointer-events: none;
  animation: coinFly 0.9s cubic-bezier(0.2, 0.72, 0.3, 1) forwards;
}

@keyframes coinFly {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
  14% { opacity: 1; transform: translate(0, -14px) scale(1.08); }
  62% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.34); }
}

.float-gain {
  position: absolute;
  font-size: 23px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #FFD75E;
  text-shadow: 0 2px 0 rgba(122, 64, 0, 0.65), 0 0 14px rgba(255, 190, 60, 0.7);
  pointer-events: none;
  animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  22% { opacity: 1; transform: translate(-50%, -65%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(0.95); }
}

.burst {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 3px solid rgba(255, 214, 94, 0.95);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: burst 0.58s ease-out forwards;
}

.burst.green {
  border-color: rgba(168, 224, 99, 0.95);
}

@keyframes burst {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(9); }
}

/* ---------- 小屏收敛 ---------- */

@media (max-height: 700px) {
  .avatar { width: 44px; height: 44px; }
  .action { height: 54px; font-size: 18px; }
  .dock-inner { padding: 8px 10px calc(10px + var(--safe-bottom)); }
  .dock-hint { margin-bottom: 6px; }
  .plot-badge { font-size: 19px; padding: 5px 15px; }
}

@media (min-width: 521px) {
  body { padding: 0; }
}
