/* =========================================================
   植物守家园 · mobile-first lawn defense
   ========================================================= */
* { box-sizing: border-box; }
:root {
  --orange: #FF8A3D;
  --orange-deep: #E96A1E;
  --cream: #FFF4D6;
  --wood: #7A441C;
  --wood-dark: #4B2610;
  --wood-light: #C08A4A;
  --leaf: #5FA82B;
  --leaf-dark: #2C5A16;
  --ink: #3A2412;
  --shadow: 0 4px 0 #4A2610;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #091705;
}
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
img { -webkit-user-drag: none; user-select: none; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 1em; height: 1em; display: block; fill: currentColor; }

.app-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(90% 60% at 50% 8%, rgba(120, 200, 90, .22), transparent 60%),
    radial-gradient(80% 70% at 50% 100%, rgba(255, 138, 61, .10), transparent 55%),
    #091705;
}

.game {
  position: relative;
  width: min(100vw, 480px);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, #77D5F6 0%, #A7E8FA 12%, #D4F4E0 24%, #8ACB50 38%, #6DB936 52%, #5FA82B 100%);
  isolation: isolate;
}
.game::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 0;
  left: 0;
  right: 0;
  height: 210px;
  background: url("img/sky.jpg") center top / cover no-repeat;
  opacity: .92;
  pointer-events: none;
}
.game::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: 112px;
  right: 8%;
  width: 88px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .65);
  box-shadow: -34px 8px 0 -6px rgba(255, 255, 255, .5), 26px 6px 0 -10px rgba(255, 255, 255, .45);
  filter: blur(.3px);
  opacity: .7;
  pointer-events: none;
}

/* ============ 顶部种子栏 ============ */
.topbar {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: calc(10px + var(--safe-top)) 10px 4px;
}
.sun-bank {
  position: relative;
  flex: 0 0 58px;
  height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  border-radius: 13px;
  border: 3px solid #7B4415;
  background: linear-gradient(180deg, #FFE894 0%, #FFC84E 40%, #EF9F22 72%, #D67D12 100%);
  box-shadow: inset 0 2px 0 #FFF6C8, inset 0 -4px 8px rgba(155, 80, 0, .35), 0 4px 0 #4A2610, 0 8px 14px rgba(20, 50, 10, .3);
}
.sun-bank::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 9px;
  border: 1px dashed rgba(120, 64, 10, .28);
  pointer-events: none;
}
.sun-bank__icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(120, 60, 0, .25));
  animation: sunPulse 3.2s ease-in-out infinite;
}
.sun-bank__num {
  font-size: 19px;
  line-height: 1;
  font-weight: 900;
  color: #4B2A0C;
  letter-spacing: .3px;
  text-shadow: 0 1px 0 #FFEDB0;
  transition: transform .15s;
}
.sun-bank__num.is-pop { animation: numPop .32s ease-out; }
.seed-rail {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}
.seed-card {
  position: relative;
  height: 88px;
  min-width: 0;
  padding: 3px 2px 2px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 11px;
  border: 3px solid #7B4415;
  background: linear-gradient(180deg, #FFF9E4 0%, #F8E8BC 52%, #E8CA8B 100%);
  box-shadow: inset 0 2px 0 #FFFCF0, inset 0 -3px 6px rgba(150, 100, 40, .22), 0 4px 0 #4A2610, 0 7px 12px rgba(20, 50, 10, .28);
  transition: transform .12s ease, box-shadow .12s ease, filter .15s ease;
  touch-action: manipulation;
}
.seed-card::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 7px;
  border: 1px dashed rgba(122, 68, 28, .22);
  pointer-events: none;
}
.seed-card__thumb {
  position: relative;
  width: 100%;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
}
.seed-card__thumb img {
  max-width: 94%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(60, 34, 4, .22));
  transition: transform .15s;
}
.seed-card__name {
  display: block;
  font-size: 9.5px;
  line-height: 1;
  font-weight: 800;
  color: #5B3615;
  white-space: nowrap;
  letter-spacing: -.3px;
  margin-top: 1px;
}
.seed-card__cost {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  color: #4B2A0C;
}
.seed-card__cost img { width: 12px; height: 12px; object-fit: contain; }
.seed-card__cd {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: conic-gradient(rgba(24, 38, 14, .66) calc(var(--cd, 0) * 1turn), transparent 0);
  transition: opacity .15s;
  pointer-events: none;
}
.seed-card.is-cooling .seed-card__cd { opacity: 1; }
.seed-card.is-selected {
  transform: translateY(-4px);
  border-color: #FFE14A;
  box-shadow: 0 0 0 2px #FFF8B8, 0 6px 0 #4A2610, 0 0 24px rgba(255, 224, 74, .8);
}
.seed-card.is-selected .seed-card__thumb img { transform: scale(1.08); }
.seed-card.is-poor { filter: grayscale(.6) brightness(.8); }
.seed-card.is-nope { animation: cardNope .24s ease-in-out; }
.seed-card:active {
  transform: translateY(2px) scale(.97);
  box-shadow: 0 2px 0 #4A2610;
}

/* ============ 草坪战场 ============ */
.stage {
  position: relative;
  z-index: 5;
  flex: 1 1 auto;
  min-height: 0;
  margin: clamp(12px, 2.8vh, 28px) 8px 0;
  display: flex;
  border-radius: 18px;
  border: 3px solid #5A3113;
  overflow: hidden;
  background: #63AF2C;
  box-shadow:
    inset 0 0 0 2px rgba(255, 222, 160, .35),
    inset 0 14px 24px rgba(255, 255, 255, .12),
    0 7px 0 rgba(40, 22, 8, .3),
    0 18px 30px rgba(8, 30, 3, .42);
}
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  border-radius: 15px;
  box-shadow: inset 0 0 26px rgba(14, 52, 5, .35), inset 0 -18px 30px rgba(14, 52, 5, .22);
}

/* 房子 */
.house {
  position: relative;
  flex: 0 0 76px;
  z-index: 8;
  overflow: hidden;
  border-right: 3px solid #4A2610;
  background: url("img/house.jpg") 34% center / cover no-repeat;
}
.house::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(30, 12, 2, .18) 0%, transparent 22%, transparent 72%, rgba(30, 12, 2, .3) 100%);
}
.house::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 10px;
  background: linear-gradient(90deg, transparent, rgba(40, 20, 6, .4));
  pointer-events: none;
}
.house__lamp {
  position: absolute;
  top: 21%;
  left: 50%;
  width: 20px;
  height: 26px;
  transform: translateX(-50%);
  border-radius: 9px 9px 6px 6px;
  background: radial-gradient(circle at 50% 38%, #FFF8C8 0 15%, #FFD75A 38%, rgba(255, 190, 50, .16) 70%);
  box-shadow: 0 0 18px rgba(255, 220, 100, .55);
  opacity: .9;
}
.house__tag {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 2px solid #5A3113;
  background: linear-gradient(#F2D18C, #C98E43);
  box-shadow: 0 2px 0 #3B1D08;
  color: #6B3B12;
  font-size: 13px;
  font-weight: 900;
}
.house__tag span { transform: translateY(-1px); }

.lawn-wrap { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; background: #5FA82B; }
.lawn { position: absolute; inset: 0; overflow: hidden; }
.lawn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("img/grass.jpg") center / cover no-repeat;
  opacity: .55;
  filter: saturate(1.08) brightness(1.04);
  transform: scale(1.05);
}
.lawn::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(18, 62, 6, .28) 0%, transparent 8%, transparent 92%, rgba(18, 62, 6, .2) 100%);
  pointer-events: none;
}
.fence {
  position: absolute;
  z-index: 12;
  top: 0;
  left: 0;
  right: 0;
  height: 34px;
  background: url("img/fence.png") center top / 100% 100% no-repeat;
  filter: drop-shadow(0 3px 2px rgba(20, 50, 10, .34));
  pointer-events: none;
}
.fence::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7px;
  background: linear-gradient(180deg, transparent, rgba(34, 88, 14, .42));
}
.path {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7%;
  min-height: 26px;
  border-top: 3px solid #8A6B3D;
  background:
    repeating-linear-gradient(115deg, rgba(120, 90, 45, .18) 0 2px, transparent 2px 26px),
    repeating-linear-gradient(25deg, rgba(120, 90, 45, .12) 0 2px, transparent 2px 34px),
    linear-gradient(180deg, #D9C18C 0%, #BCA06B 60%, #9D814D 100%);
  box-shadow: inset 0 5px 8px rgba(255, 246, 210, .35), inset 0 -6px 10px rgba(70, 50, 20, .25);
  pointer-events: none;
}
.path::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 8%;
  right: 8%;
  height: 1px;
  background: rgba(255, 248, 215, .45);
}
.path__hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(70, 48, 20, .34);
  color: rgba(255, 249, 222, .9);
  font-size: 9px;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: .6px;
  white-space: nowrap;
  text-shadow: 0 1px 1px rgba(40, 24, 8, .4);
}
.cell:focus { outline: none; }
body.is-planting .lawn { cursor: crosshair; }

.field {
  position: absolute;
  z-index: 4;
  top: 28px;
  left: 0;
  right: 0;
  bottom: 7%;
  background:
    repeating-linear-gradient(0deg,
      rgba(255, 255, 255, .045) 0,
      rgba(255, 255, 255, .045) 20%,
      rgba(18, 62, 6, .09) 20%,
      rgba(18, 62, 6, .09) 40%);
}
.cells {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(5, 1fr);
}
.cell {
  position: relative;
  border-right: 1px solid rgba(255, 255, 255, .13);
  border-bottom: 1px solid rgba(255, 255, 255, .13);
  transition: background .16s;
}
.cell:nth-child(4n) { border-right: 0; }
.cell:nth-child(n+17) { border-bottom: 0; }
.cell::after {
  content: "";
  position: absolute;
  inset: 8% 7%;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: border-color .15s, background .15s, transform .15s;
  transform: scale(.94);
}
body.is-planting .cell::after {
  border-color: rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .04);
}
body.is-planting .cell.is-valid::after {
  border-color: rgba(255, 244, 158, .72);
  background: rgba(255, 244, 158, .13);
  box-shadow: inset 0 0 18px rgba(255, 245, 160, .2);
}
body.is-planting .cell.is-valid:active::after {
  background: rgba(255, 244, 158, .34);
  transform: scale(.88);
}
body.is-planting .cell.is-filled::after { border-color: rgba(255, 120, 80, .22); }

.layer { position: absolute; inset: 0; pointer-events: none; }
.layer--plants { z-index: 6; }
.layer--zombies { z-index: 8; }
.layer--peas { z-index: 9; }
.layer--suns { z-index: 10; }
.layer--fx { z-index: 14; }

/* 植物 */
.plant {
  position: absolute;
  width: 25%;
  max-width: 78px;
  transform: translate(-50%, -50%);
  transform-origin: 50% 82%;
  pointer-events: none;
  will-change: transform;
  animation: plantPop .3s cubic-bezier(.34, 1.56, .64, 1);
}
.plant img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 5px 3px rgba(18, 48, 4, .34));
  transition: transform .08s ease;
}
.plant.is-shooting img { transform: translateX(3px) scale(1.03); }
.plant[data-type="peashooter"] { width: 26%; }
.plant[data-type="wallnut"] { width: 24%; }
.plant[data-type="potato"] { width: 28%; }
.plant__hp {
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: -5px;
  height: 4px;
  border-radius: 3px;
  background: rgba(20, 30, 10, .55);
  overflow: hidden;
  opacity: 0;
  transition: opacity .18s;
}
.plant__hp i { display: block; height: 100%; width: 100%; border-radius: 3px; background: linear-gradient(90deg, #9BE34A, #D7FF85); transition: width .18s; }
.plant.is-damaged .plant__hp { opacity: 1; }
.plant.is-hurt img { filter: brightness(1.2) saturate(.8) drop-shadow(0 5px 3px rgba(18, 48, 4, .34)); }
.plant.is-eaten { animation: plantShake .22s linear infinite; }
.plant.is-dying { opacity: 0; transform: translate(-50%, -50%) scale(.7) rotate(-8deg); transition: .3s; }
.plant.is-armed::after {
  content: "";
  position: absolute;
  inset: 10% 8% -4%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 240, 120, .7);
  animation: armedPulse 1.2s ease-in-out infinite;
}

/* 僵尸 */
.zombie {
  position: absolute;
  width: 24%;
  max-width: 76px;
  transform: translate(-50%, -55%);
  will-change: left;
  pointer-events: none;
}
.z-bob {
  transform-origin: 50% 88%;
  animation: zWalk .64s ease-in-out infinite alternate;
}
.z-bob img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 4px rgba(16, 40, 6, .38));
}
.zombie.is-eating .z-bob { animation: zEat .22s ease-in-out infinite alternate; }
.zombie.is-hit .z-bob img { filter: brightness(1.9) saturate(.35) drop-shadow(0 4px 3px rgba(16, 40, 6, .3)); }
.zombie.is-dead {
  opacity: 0;
  transform: translate(-50%, -48%) rotate(12deg) scale(.86);
  transition: opacity .42s, transform .42s;
}
.z-hp {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -3px;
  height: 4px;
  border-radius: 3px;
  background: rgba(20, 26, 8, .55);
  overflow: hidden;
  opacity: 0;
  transition: opacity .15s;
}
.z-hp i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #FF8A3D, #FFD05A); transition: width .18s; }
.zombie.is-damaged .z-hp { opacity: 1; }

/* 豌豆 */
.pea {
  position: absolute;
  width: 15px;
  height: 15px;
  transform: translate(-50%, -50%);
  animation: peaSpin .7s linear infinite;
}
.pea img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 0 5px rgba(190, 255, 70, .9)); }

/* 阳光 */
.sun-token {
  position: absolute;
  width: 17%;
  max-width: 50px;
  min-width: 40px;
  transform: translate(-50%, -50%);
  padding: 0;
  pointer-events: auto;
  cursor: pointer;
  z-index: 10;
  animation: sunFloat 2.4s ease-in-out infinite;
  transition: opacity .35s, transform .35s;
  touch-action: manipulation;
}
.sun-token::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 245, 150, .26), transparent 70%);
}
.sun-token img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 0 11px rgba(255, 224, 80, .95)) drop-shadow(0 3px 2px rgba(100, 60, 0, .2));
  animation: sunSpin 9s linear infinite;
}
.sun-token.is-leaving { opacity: 0; transform: translate(-50%, -50%) scale(.45); }
.sun-token:active { transform: translate(-50%, -50%) scale(.88); }

/* 特效 */
.fx-text {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: 900;
  color: #FFF8CB;
  text-shadow: 0 2px 0 #3B6C12, 0 3px 6px rgba(0, 0, 0, .35);
  pointer-events: none;
  animation: fxFloat .85s ease-out forwards;
  white-space: nowrap;
}
.fx-ring {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid #FFD84A;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: fxRing .5s ease-out forwards;
}
.fx-ring--boom { border-color: #FF7B32; box-shadow: 0 0 20px #FFB23D; }
.fx-dirt {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7A4A1E;
  pointer-events: none;
  animation: dirtFly .5s ease-out forwards;
}
.ghost {
  position: absolute;
  z-index: 16;
  width: 25%;
  max-width: 78px;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
}
.ghost img { width: 100%; height: auto; filter: drop-shadow(0 0 8px rgba(255, 246, 170, .8)); }
.ghost.is-on { opacity: .68; }

.damage-flash {
  position: absolute;
  inset: 0;
  z-index: 18;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 12% 50%, rgba(255, 40, 20, .65), rgba(255, 40, 20, .1) 45%, transparent 72%);
}
.damage-flash.is-on { animation: damageFlash .55s ease-out; }
.house.is-hit { animation: houseHit .42s ease-out; }
.fly-sun {
  position: fixed;
  left: 0;
  top: 0;
  width: 42px;
  height: 42px;
  z-index: 200;
  object-fit: contain;
  pointer-events: none;
  will-change: transform;
  transform-origin: 0 0;
  filter: drop-shadow(0 0 9px rgba(255, 228, 80, .9));
}

/* ============ 底部状态栏 ============ */
.hud {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 11px calc(11px + var(--safe-bottom));
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .035) 0 2px, transparent 2px 16px),
    linear-gradient(180deg, #64391A 0%, #4B2810 48%, #30190A 100%);
  border-top: 3px solid #8E5B2B;
  box-shadow: inset 0 2px 0 rgba(255, 218, 160, .22), 0 -8px 22px rgba(6, 18, 2, .32);
}
.wave-info { flex: 1 1 auto; min-width: 0; }
.wave-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  font-size: 10px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: .8px;
  color: #F1DEB1;
  white-space: nowrap;
}
.wave-label b { font-size: 14px; color: #FFD34D; letter-spacing: 0; }
.wave-label em { font-style: normal; color: #B49A6D; }
.wave-label__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9BE34A;
  box-shadow: 0 0 8px #9BE34A;
  animation: blink 1.4s ease-in-out infinite;
}
.wave-track {
  position: relative;
  height: 15px;
  border-radius: 8px;
  border: 2px solid #8B5A2A;
  background: #1A2410;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .5);
}
.wave-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 5px;
  background: linear-gradient(90deg, #69B72B 0%, #A5E64A 60%, #CFFB78 100%);
  box-shadow: 0 0 9px rgba(160, 240, 70, .45);
  transition: width .45s ease;
}
.wave-head {
  position: absolute;
  top: 50%;
  left: 0;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  background: url("img/zombie.png") center / contain no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .55));
  transition: left .45s ease;
  pointer-events: none;
}
.lives { flex: 0 0 auto; display: flex; gap: 0; padding: 0 1px; }
.heart {
  width: 18px;
  height: 18px;
  color: #FF6B4A;
  fill: currentColor;
  filter: drop-shadow(0 2px 0 #5A1D0E);
  transition: color .25s, transform .25s, opacity .25s;
}
.heart.is-lost { color: #66513E; filter: none; transform: scale(.82); opacity: .5; }
.round-btn {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid #C99557;
  background: linear-gradient(180deg, #FFF1C9 0%, #E9C37E 50%, #C8954F 100%);
  box-shadow: inset 0 1px 0 #FFF9E2, 0 3px 0 #231006;
  color: #4B2A0C;
  transition: transform .1s, box-shadow .1s, background .15s;
  touch-action: manipulation;
}
.round-btn .ic { width: 17px; height: 17px; }
.round-btn span { font-size: 13px; font-weight: 900; letter-spacing: -.4px; }
.round-btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 #FFF9E2, 0 1px 0 #231006; }
.round-btn.is-on {
  border-color: #FFE6A0;
  background: linear-gradient(180deg, #FFD87A 0%, #FFA63D 55%, #E97A22 100%);
  color: #6A2D06;
  box-shadow: inset 0 1px 0 #FFF1C9, 0 0 14px rgba(255, 160, 60, .6), 0 3px 0 #231006;
}

/* ============ 提示 / 横幅 ============ */
.banner {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  text-align: center;
  width: 100%;
  padding: 0 20px;
}
.banner__text {
  display: inline-block;
  padding: 9px 24px;
  border-radius: 14px;
  border: 3px solid #7A3D10;
  background: linear-gradient(180deg, #FFD56A 0%, #FF9A3D 55%, #E96A1E 100%);
  box-shadow: 0 5px 0 #4A2108, 0 12px 26px rgba(0, 0, 0, .38);
  color: #FFF9DC;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-shadow: 0 2px 0 #A64A11, 0 4px 8px rgba(0, 0, 0, .3);
  white-space: nowrap;
}
.banner.show { animation: bannerIn 1.5s ease-out both; }
.toast {
  position: absolute;
  z-index: 32;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translate(-50%, 14px);
  max-width: 86%;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 225, 160, .38);
  background: rgba(32, 22, 8, .88);
  color: #FFF4CE;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ 开始界面 ============ */
.intro {
  position: absolute;
  z-index: 60;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(180deg,
    rgba(8, 24, 5, .16) 0%,
    rgba(8, 24, 5, .04) 18%,
    rgba(8, 24, 5, .02) 34%,
    rgba(9, 26, 4, .48) 56%,
    rgba(10, 28, 5, .9) 76%,
    #0A1D06 100%);
  transition: opacity .45s ease, visibility .45s ease;
}
.intro.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.intro__grain {
  position: absolute;
  z-index: 1;
  inset: 0;
  background:
    radial-gradient(120% 76% at 50% 28%, transparent 42%, rgba(8, 20, 4, .42) 100%),
    radial-gradient(100% 50% at 50% 102%, rgba(30, 70, 18, .2), transparent 70%);
  pointer-events: none;
}
.level-pill {
  position: absolute;
  z-index: 4;
  top: calc(110px + var(--safe-top));
  left: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 9px;
  border-radius: 999px;
  border: 2px solid rgba(255, 241, 196, .5);
  background: rgba(24, 50, 12, .58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  color: #FFF3C9;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .6px;
}
.level-pill__leaf {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(#B6F064, #69B72B);
  color: #2E5B12;
  font-size: 11px;
  line-height: 1;
}
.level-pill__leaf .ic { width: 11px; height: 11px; filter: drop-shadow(0 1px 0 rgba(255,255,255,.25)); }
.intro__content {
  position: relative;
  z-index: 3;
  width: 100%;
  padding: 0 22px calc(22px + var(--safe-bottom));
}
.logo {
  margin: 0 0 9px;
  color: #FFF7DA;
  font-size: clamp(41px, 11.8vw, 55px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: 2.5px;
  text-shadow:
    0 3px 0 #6A3A12,
    0 6px 0 #3A1C07,
    0 12px 22px rgba(0, 0, 0, .55);
  animation: logoIn .7s cubic-bezier(.2, .8, .3, 1) both;
}
.logo span { color: #FFD44D; }
.tagline {
  margin: 0 0 14px;
  color: #DCEBCA;
  font-size: 13.5px;
  line-height: 1.65;
  letter-spacing: .2px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}
.feature-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 17px; }
.feature {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 9px;
  border-radius: 9px;
  border: 1px solid rgba(255, 243, 200, .24);
  background: rgba(255, 255, 255, .075);
  color: #F3E8C6;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
}
.feature .ic { width: 12px; height: 12px; color: #FFD44D; }
.start-btn {
  position: relative;
  width: 100%;
  height: 56px;
  overflow: hidden;
  border-radius: 18px;
  border: 3px solid #8F3F0E;
  background: linear-gradient(180deg, #FFB85C 0%, #FF8A3D 42%, #EA671A 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), 0 6px 0 #74320A, 0 14px 26px rgba(0, 0, 0, .35);
  color: #FFFDF2;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 2px 0 #A64A11, 0 3px 8px rgba(0, 0, 0, .25);
  transition: transform .1s, box-shadow .1s;
  touch-action: manipulation;
}
.start-btn__shine {
  position: absolute;
  top: -40%;
  left: -30%;
  width: 26%;
  height: 180%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: rotate(18deg);
  animation: buttonShine 3.2s ease-in-out infinite;
}
.start-btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), 0 2px 0 #74320A, 0 6px 12px rgba(0, 0, 0, .3); }
.intro-tip {
  margin: 11px 0 0;
  text-align: center;
  color: rgba(226, 239, 205, .62);
  font-size: 10.5px;
  letter-spacing: .4px;
}

/* ============ 弹窗 ============ */
.modal {
  position: absolute;
  z-index: 70;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 18, 4, .64);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.modal.is-open { opacity: 1; visibility: visible; }
.panel {
  position: relative;
  width: 100%;
  max-width: 326px;
  padding: 27px 20px 20px;
  border-radius: 22px;
  border: 3px solid #7A441C;
  background:
    radial-gradient(120% 80% at 50% 0%, #FFFDF0 0%, #FFF4D8 50%, #F3DFB2 100%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .8), 0 15px 0 rgba(58, 27, 8, .34), 0 28px 60px rgba(0, 0, 0, .5);
  text-align: center;
  transform: translateY(12px) scale(.96);
  transition: transform .28s cubic-bezier(.2, .9, .3, 1.2);
}
.modal.is-open .panel { transform: translateY(0) scale(1); }
.panel::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 16px;
  border: 2px dashed rgba(122, 68, 28, .22);
  pointer-events: none;
}
.panel__ribbon {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 18px;
  border-radius: 999px;
  border: 2px solid #8A4A14;
  background: linear-gradient(#FFD064, #F59A34);
  box-shadow: 0 3px 0 #5A2C0A;
  color: #5A2C0A;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2px;
  white-space: nowrap;
}
.panel__title {
  margin: 4px 0 7px;
  color: #3B6B18;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 2px 0 #E6F5C4;
}
.panel__desc {
  margin: 0 auto 18px;
  max-width: 230px;
  color: #8A6A46;
  font-size: 12px;
  line-height: 1.6;
}
.panel__btns { display: flex; flex-direction: column; gap: 9px; }
.big-btn {
  width: 100%;
  height: 48px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1.5px;
  transition: transform .1s, box-shadow .1s;
}
.big-btn--primary {
  border: 3px solid #8F3F0E;
  background: linear-gradient(180deg, #FFB85C 0%, #FF8A3D 45%, #EA671A 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), 0 4px 0 #74320A;
  color: #FFFDF2;
  text-shadow: 0 1px 0 #A64A11;
}
.big-btn--ghost {
  border: 2px solid #C9A46A;
  background: rgba(255, 255, 255, .5);
  color: #7A5A34;
  box-shadow: 0 3px 0 rgba(120, 80, 35, .22);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #74320A; }
.panel--result .result__badge {
  width: 62px;
  height: 62px;
  margin: -4px auto 8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid #5A8A28;
  background: radial-gradient(circle at 40% 30%, #E8FFB0, #8FD33E 60%, #5CA51F 100%);
  color: #FFFBE0;
  box-shadow: 0 5px 0 rgba(54, 92, 20, .4), 0 10px 20px rgba(0, 0, 0, .18);
  animation: badgeIn .6s cubic-bezier(.2, .9, .3, 1.5) both;
}
.panel--result .result__badge .ic { width: 30px; height: 30px; filter: drop-shadow(0 2px 0 rgba(40, 80, 10, .4)); }
.panel--lose .panel__title { color: #B9432A; text-shadow: 0 2px 0 #FFE1D2; }
.panel--lose .result__badge {
  border-color: #A4412A;
  background: radial-gradient(circle at 40% 30%, #FFC8A8, #E5734F 60%, #B43E25 100%);
  box-shadow: 0 5px 0 rgba(110, 40, 20, .4), 0 10px 20px rgba(0, 0, 0, .18);
}
.result__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0 0 18px;
  padding: 10px 4px;
  border-radius: 13px;
  border: 1px solid rgba(140, 100, 45, .2);
  background: rgba(255, 255, 255, .42);
}
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat b { font-size: 18px; line-height: 1; color: #4E3A1E; letter-spacing: .2px; }
.stat span { font-size: 9px; color: #9B7B52; letter-spacing: .5px; }

/* ============ 动效 ============ */
@keyframes sunPulse { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.08) rotate(8deg); } }
@keyframes numPop { 0% { transform: scale(1); } 45% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes plantPop { 0% { opacity: 0; transform: translate(-50%, -42%) scale(.55); } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes plantShake { 0%, 100% { transform: translate(-50%, -50%) rotate(-2deg); } 50% { transform: translate(-50%, -50%) rotate(2deg); } }
@keyframes armedPulse { 0%, 100% { opacity: .25; transform: scale(.94); } 50% { opacity: .8; transform: scale(1.02); } }
@keyframes zWalk { from { transform: rotate(-2.2deg) translateY(0); } to { transform: rotate(1.6deg) translateY(-2px); } }
@keyframes zEat { from { transform: rotate(-3.5deg) translateY(0) scaleY(.98); } to { transform: rotate(2.5deg) translateY(-1px) scaleY(1.02); } }
@keyframes peaSpin { from { transform: translate(-50%, -50%) rotate(0); } to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes sunFloat { 0%, 100% { margin-top: 0; } 50% { margin-top: -7px; } }
@keyframes sunSpin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes fxFloat { 0% { opacity: 0; margin-top: 4px; transform: translate(-50%, -50%) scale(.7); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 100% { opacity: 0; margin-top: -30px; transform: translate(-50%, -50%) scale(.9); } }
@keyframes fxRing { 0% { opacity: 1; transform: translate(-50%, -50%) scale(.4); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(2.6); } }
@keyframes dirtFly { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, -22px))) scale(.4); } }
@keyframes damageFlash { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes bannerIn { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.72); } 14% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); } 24% { transform: translate(-50%, -50%) scale(1); } 78% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -55%) scale(1); } }
@keyframes logoIn { 0% { opacity: 0; transform: translateY(14px) scale(.94); } 100% { opacity: 1; transform: none; } }
@keyframes buttonShine { 0%, 55% { left: -35%; } 85%, 100% { left: 125%; } }
@keyframes badgeIn { 0% { opacity: 0; transform: scale(.4) rotate(-20deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes cardNope {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
@keyframes houseHit {
  0%, 100% { transform: translateX(0); filter: none; }
  20% { transform: translateX(-4px); filter: brightness(1.5) sepia(.3); }
  50% { transform: translateX(3px); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px) rotate(-.4deg); }
  40% { transform: translateX(5px) rotate(.4deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.game.is-shaking { animation: shake .32s ease-in-out; }

/* ============ 小屏 / 大屏 ============ */
@media (max-height: 720px) {
  .plant { width: 21.5%; }
  .plant[data-type="peashooter"] { width: 22.5%; }
  .plant[data-type="wallnut"] { width: 20.5%; }
  .plant[data-type="potato"] { width: 24%; }
  .zombie { width: 21%; }
  .ghost { width: 21.5%; }
  .topbar { padding-top: calc(7px + var(--safe-top)); }
  .sun-bank, .seed-card { height: 80px; }
  .sun-bank { flex-basis: 54px; }
  .sun-bank__icon { width: 33px; height: 33px; }
  .sun-bank__num { font-size: 17px; }
  .seed-card__thumb { height: 39px; }
  .seed-card__name { font-size: 9px; }
  .seed-card__cost { font-size: 10px; }
  .stage { margin-top: 9px; }
  .hud { padding-top: 8px; padding-bottom: calc(8px + var(--safe-bottom)); }
  .logo { font-size: clamp(37px, 10.8vw, 48px); }
  .tagline { margin-bottom: 10px; font-size: 12.5px; }
  .feature-row { margin-bottom: 12px; }
  .start-btn { height: 52px; }
}
@media (max-height: 620px) {
  .sun-bank, .seed-card { height: 71px; }
  .seed-card__thumb { height: 32px; }
  .seed-card__name { display: none; }
  .seed-card__cost { margin-top: 1px; font-size: 10px; }
  .stage { margin-top: 6px; border-width: 2px; }
  .hud { gap: 5px; padding: 6px 8px calc(6px + var(--safe-bottom)); }
  .round-btn { flex-basis: 34px; width: 34px; height: 34px; }
  .round-btn .ic { width: 14px; height: 14px; }
  .heart { width: 15px; height: 15px; }
  .wave-label { margin-bottom: 3px; }
  .wave-track { height: 12px; }
  .wave-head { width: 25px; height: 25px; }
  .logo { font-size: 34px; }
  .tagline { font-size: 11.5px; }
  .feature-row { margin-bottom: 9px; }
  .start-btn { height: 47px; font-size: 17px; }
  .intro-tip { margin-top: 7px; }
  .level-pill { top: calc(92px + var(--safe-top)); padding: 5px 10px; font-size: 10px; }
}
@media (min-width: 560px) and (min-height: 760px) {
  .app-shell { padding: 14px 0; }
  .game {
    height: min(calc(100dvh - 28px), 940px);
    border-radius: 30px;
    border: 1px solid rgba(255, 227, 170, .24);
    box-shadow: 0 0 0 8px rgba(30, 60, 18, .55), 0 24px 70px rgba(0, 0, 0, .55);
  }
  .game::before { border-radius: 30px 30px 0 0; }
  .stage { border-radius: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .start-btn__shine, .sun-bank__icon, .sun-token, .sun-token img { animation: none; }
}
