* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at center, #1f3b18 0%, #0d1a0a 100%);
  color: #fff;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 保持与第一版原作背景图 (1376x768) 完全一致的 16:9 画布比例 */
#game-app {
  width: min(1320px, 98vw, calc(95vh * 1376 / 768));
  aspect-ratio: 1376 / 768;
  background: #2b4c1b;
  border: 5px solid #4a2c11;
  border-radius: 16px;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.78), inset 0 2px 0 rgba(255, 255, 255, 0.25);
  position: relative;
  overflow: hidden;
}

/* ================= 顶部 PvZ 1 经典木质传送带仪表盘 ================= */
#top-bar {
  position: absolute;
  top: 6px;
  left: 19.5%;
  right: 1.5%;
  height: 104px;
  background: linear-gradient(180deg, #945d2c 0%, #6e411b 55%, #4d2c10 100%);
  border: 4px solid #361d08;
  border-radius: 14px;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  gap: 12px;
  z-index: 30;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6), inset 0 2px 1px rgba(255, 230, 180, 0.35);
}

.hud-left {
  width: 215px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.level-badge {
  background: linear-gradient(180deg, #42250e 0%, #291607 100%);
  border: 2px solid #c28d53;
  color: #ffea9f;
  font-weight: 900;
  font-size: 14px;
  padding: 5px 8px;
  border-radius: 8px;
  text-align: center;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-row {
  display: flex;
  gap: 5px;
  justify-content: space-between;
}

.stat-pill {
  flex: 1;
  background: rgba(24, 12, 4, 0.78);
  border: 2px solid #9e6b36;
  border-radius: 8px;
  padding: 3px 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-weight: 900;
  font-size: 13px;
  color: #fff6db;
}

/* 传送带轨道 */
#conveyor-wrapper {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.conveyor-label {
  font-size: 12px;
  color: #fff2c6;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  gap: 8px;
}

.conveyor-label b {
  color: #ffe14d;
}

#conveyor-track {
  height: 68px;
  background: linear-gradient(180deg, #1b1e21 0%, #343a40 50%, #16191b 100%);
  border: 3px solid #5c646d;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 6px 12px rgba(0, 0, 0, 0.9);
}

.conveyor-rollers {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 26px,
    rgba(255, 255, 255, 0.1) 26px,
    rgba(255, 255, 255, 0.1) 30px
  );
  animation: beltScroll 1.5s linear infinite;
}

@keyframes beltScroll {
  from { background-position-x: 30px; }
  to { background-position-x: 0px; }
}

#conveyor-items {
  position: relative;
  width: 100%;
  height: 100%;
}

/* 传送带上的卡牌与阳光球容器 */
.belt-item {
  position: absolute;
  top: 3px;
  width: 58px;
  height: 56px;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, filter 0.12s ease;
  touch-action: none;
  z-index: 5;
}

.belt-item:hover {
  transform: scale(1.1) translateY(-2px);
  filter: brightness(1.1);
  z-index: 12;
}

.belt-item.dragging-source {
  opacity: 0.3;
  transform: scale(0.9);
}

/* 原作风牛皮纸植物种子包 (Seed Packet) */
.pvz-seed-packet {
  width: 54px;
  height: 54px;
  background: linear-gradient(180deg, #e7c996 0%, #c89d5c 100%);
  border: 2.5px solid #3d250b;
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.packet-top-bar {
  font-size: 9px;
  font-weight: 900;
  color: #3d2206;
  text-align: center;
  line-height: 1;
}

.packet-art-window {
  flex: 1;
  background: linear-gradient(180deg, #a9def9 0%, #76c893 70%, #52b788 100%);
  border: 1.5px solid #4a2e0f;
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.mini-sprout-svg {
  width: 38px;
  height: 28px;
  opacity: 0.45;
  position: absolute;
  bottom: -2px;
}

.packet-initial-text {
  position: relative;
  z-index: 2;
  font-size: 21px;
  font-weight: 900;
  color: #102a02;
  text-shadow: 0 0 4px #fff, 0 0 6px #fff;
  font-family: "Comic Sans MS", "Chalkboard SE", "PingFang SC", sans-serif;
}

.packet-bottom-bar {
  background: #f4e2ba;
  border-top: 1.5px solid #593814;
  font-size: 10px;
  font-weight: 900;
  color: #2b1803;
  text-align: center;
  line-height: 1.1;
  border-radius: 0 0 3px 3px;
}

/* 原作风立体旋转太阳球 (Sun Orb) */
.pvz-sun-orb {
  width: 58px;
  height: 58px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.8));
}

.sun-svg {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.sun-rays-spin {
  transform-origin: 40px 40px;
  animation: spinSun 9s linear infinite;
}

@keyframes spinSun {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.sun-label-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sun-final-text {
  font-size: 19px;
  font-weight: 900;
  color: #3d1300;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
  font-family: "Arial Rounded MT Bold", "PingFang SC", sans-serif;
}

/* 右侧工具栏：铁铲与控制按钮 */
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#shovel-slot {
  width: 58px;
  height: 64px;
  background: radial-gradient(circle, #5e3b1e 0%, #301c0b 100%);
  border: 3px solid #b5834c;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.75);
}

.draggable-shovel {
  width: 48px;
  height: 54px;
  background: linear-gradient(180deg, #fff5d6 0%, #d4b483 100%);
  border: 2px solid #4a2e0f;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: #3d2206;
  font-weight: 900;
  touch-action: none;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.45);
}

.shovel-svg {
  width: 32px;
  height: 32px;
}

.shovel-sub {
  font-size: 10px;
  margin-top: -2px;
}

.control-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ui-btn {
  background: linear-gradient(180deg, #ffe17d 0%, #d99b26 100%);
  border: 2px solid #4a2b06;
  border-radius: 7px;
  padding: 2.5px 9px;
  font-size: 12px;
  font-weight: 900;
  color: #2e1902;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

.ui-btn:hover {
  filter: brightness(1.08);
}

/* ================= 拼读觉醒浮动横幅 ================= */
#spell-toast {
  position: absolute;
  top: 116px;
  left: 55%;
  transform: translateX(-50%);
  background: rgba(20, 52, 12, 0.94);
  border: 3px solid #ffe066;
  border-radius: 16px;
  padding: 7px 22px;
  z-index: 45;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  animation: popIn 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
  from { transform: translateX(-50%) scale(0.6); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

.spell-formula {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 900;
}

.part-ini {
  color: #9bf6ff;
  background: rgba(255, 255, 255, 0.14);
  padding: 1px 9px;
  border-radius: 8px;
}

.part-fin {
  color: #ffd166;
  background: rgba(255, 255, 255, 0.14);
  padding: 1px 9px;
  border-radius: 8px;
}

.part-full {
  color: #80ed99;
  font-size: 26px;
}

.part-char {
  background: #ef233c;
  color: #fff;
  padding: 1px 10px;
  border-radius: 9px;
  font-size: 24px;
  box-shadow: 0 3px 0 #9b0f22;
}

.spell-phrase {
  font-size: 13px;
  color: #e9f5db;
  margin-top: 2px;
}

.spell-rule {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 800;
  color: #ffe066;
  background: rgba(255, 215, 0, 0.2);
  padding: 2px 8px;
  border-radius: 6px;
}

/* ================= 主战场：贴合第一版原作手绘背景图 ================= */
#battlefield {
  position: absolute;
  inset: 0;
  background: url("assets/bg_classic.jpg") center / 100% 100% no-repeat;
  overflow: hidden;
}

/* 左侧石板路 5 辆除草小推车（严格对齐背景图左侧石板坐标） */
#mower-lane {
  position: absolute;
  left: 19.6%;
  top: 25.1%;
  width: 8.6%;
  height: 65.1%;
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  z-index: 8;
}

.mower-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.mower-car {
  width: 92px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}

.mower-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 5行 x 6列 草坪网格（1:1 严格对齐背景图中的 5x6 手绘棋盘草坪） */
#lawn-grid {
  position: absolute;
  left: 28.3%;
  top: 25.1%;
  width: 54.4%;
  height: 65.1%;
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  grid-template-columns: repeat(6, 1fr);
  z-index: 6;
}

.lawn-cell {
  position: relative;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.14s ease, box-shadow 0.14s ease;
  border-radius: 6px;
}

/* 拖拽声母卡时的可种植高亮 */
.lawn-cell.drop-ready-initial {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42);
  background: rgba(180, 255, 100, 0.08);
}

/* 拖拽韵母太阳时，已种下的声母幼苗格子发光 */
.lawn-cell.seedling-highlight {
  box-shadow: inset 0 0 18px rgba(255, 225, 53, 0.85), inset 0 0 0 3px #ffd000;
  background: rgba(255, 230, 80, 0.18);
}

.lawn-cell.drop-hover {
  background-color: rgba(170, 255, 95, 0.38) !important;
  box-shadow: inset 0 0 0 4px #fffb96 !important;
}

/* ================= 原作风植物精灵（幼苗 & 豌豆射手） ================= */
.plant-unit {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 7;
  pointer-events: none;
}

.pvz-plant-wrap {
  width: 96%;
  height: 96%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.plant-svg {
  width: 88%;
  height: 86%;
  overflow: visible;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.35));
}

.plant-head-bob {
  transform-origin: 55px 62px;
  animation: headBob 1.5s ease-in-out infinite;
}

.peashooter-head-anim {
  transform-origin: 52px 58px;
  animation: shooterRecoil 0.32s ease-in-out infinite alternate;
}

@keyframes headBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(-3deg); }
}

@keyframes shooterRecoil {
  from { transform: translateX(-2px) scale(0.98, 1.02); }
  to { transform: translateX(3px) scale(1.04, 0.97); }
}

.pvz-pinyin-tag {
  position: absolute;
  top: -8px;
  z-index: 9;
  font-weight: 900;
  font-size: 14px;
  padding: 1px 8px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
}

.tag-seedling {
  background: rgba(24, 52, 10, 0.92);
  border: 2px solid #a8f558;
  color: #fff;
}

.tag-seedling .q-mark {
  color: #ffd166;
}

.tag-awakened {
  background: linear-gradient(90deg, #ff9900, #e84800);
  border: 2px solid #fff3b0;
  color: #fff;
  font-size: 15px;
}

.seedling-chest-badge {
  position: absolute;
  bottom: 18px;
  background: rgba(255, 252, 225, 0.92);
  border: 2px solid #255208;
  color: #163803;
  font-weight: 900;
  font-size: 15px;
  padding: 0 6px;
  border-radius: 8px;
  line-height: 1.15;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

/* 拼读错误时的摇晃反馈 */
.shake-error {
  animation: shakeAnim 0.4s ease;
}

@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px) rotate(-5deg); }
  40% { transform: translateX(8px) rotate(5deg); }
  60% { transform: translateX(-6px) rotate(-3deg); }
  80% { transform: translateX(6px) rotate(3deg); }
}

/* ================= 实体层：原作风僵尸、木牌汉字、豌豆能量弹 ================= */
#entity-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
}

.zombie-unit {
  position: absolute;
  width: 102px;
  height: 126px;
  transform: translate(-50%, -58%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.08s;
}

.zombie-unit.hit-flash {
  filter: brightness(1.85) drop-shadow(0 0 12px #fff);
}

.pvz-zombie-wrap {
  width: 100%;
  height: 100%;
  position: relative;
}

.zombie-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.5));
}

.zombie-head-bob {
  transform-origin: 54px 55px;
  animation: zHeadWalk 0.85s ease-in-out infinite alternate;
}

.zombie-legs-anim {
  transform-origin: 55px 110px;
  animation: zLegsWalk 0.85s ease-in-out infinite alternate;
}

@keyframes zHeadWalk {
  from { transform: rotate(-4deg) translateY(0px); }
  to { transform: rotate(3deg) translateY(3px); }
}

@keyframes zLegsWalk {
  from { transform: skewX(-4deg); }
  to { transform: skewX(4deg); }
}

/* 僵尸胸前双手举着的原作风木质汉字牌 */
.pvz-wood-signboard {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-54%);
  width: 66px;
  height: 52px;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(92, 54, 18, 0.12) 0px,
      rgba(92, 54, 18, 0.12) 6px,
      transparent 6px,
      transparent 13px
    ),
    linear-gradient(180deg, #f5d79c 0%, #d4a359 100%);
  border: 3px solid #4a2a0a;
  border-radius: 9px;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.6), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* 僵尸扶着木牌的两只绿手 */
.zombie-hand {
  position: absolute;
  top: 16px;
  width: 11px;
  height: 14px;
  background: #87986a;
  border: 2.2px solid #1f2916;
  border-radius: 50%;
  z-index: 2;
}

.zombie-hand.hand-left {
  left: -7px;
}

.zombie-hand.hand-right {
  right: -7px;
}

.sign-char {
  font-size: 29px;
  font-weight: 900;
  color: #291202;
  line-height: 1.05;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.sign-hint {
  font-size: 10px;
  font-weight: 900;
  color: #5c2f04;
  background: rgba(255, 255, 255, 0.55);
  padding: 0 5px;
  border-radius: 4px;
  margin-top: -1px;
}

/* 原作风立体高光豌豆子弹 */
.pea-bullet {
  position: absolute;
  width: 38px;
  height: 30px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 32% 28%, #ebff99 0%, #74eb21 55%, #248202 100%);
  border: 2.5px solid #123b01;
  border-radius: 50%;
  box-shadow: 0 0 12px #80ff00, 0 4px 6px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: #092400;
}

/* 击败僵尸后植物化作星星/金币退场飘字 */
.floating-effect {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: 17px;
  color: #ffe135;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.92), 0 0 3px #000;
  white-space: nowrap;
  animation: floatUpFade 1.2s ease-out forwards;
}

@keyframes floatUpFade {
  0% { transform: translate(-50%, -50%) scale(0.7); opacity: 1; }
  35% { transform: translate(-50%, -95%) scale(1.14); opacity: 1; }
  100% { transform: translate(-50%, -145%) scale(1); opacity: 0; }
}

/* ================= 底部提示与拖拽幽灵 ================= */
#bottom-tip {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: rgba(24, 43, 14, 0.88);
  border-top: 2px solid #588c3b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  color: #ecfadc;
  padding: 0 12px;
  z-index: 25;
}

#bottom-tip b {
  color: #ffe066;
  margin: 0 2px;
}

#drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  transform: translate(-50%, -50%) scale(1.16);
}

.hidden {
  display: none !important;
}

/* ================= 弹窗遮罩（选关 / 胜利 / 失败） ================= */
#modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 22, 7, 0.82);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  width: min(540px, 92%);
  background: linear-gradient(180deg, #6e4423 0%, #4a2c14 100%);
  border: 5px solid #c99451;
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
}

#modal-title {
  font-size: 28px;
  color: #ffe169;
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.65);
  margin-bottom: 8px;
}

#modal-desc {
  font-size: 15px;
  color: #f5e6cc;
  margin-bottom: 18px;
  line-height: 1.5;
}

.level-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.level-option {
  background: rgba(25, 14, 6, 0.68);
  border: 2px solid #966636;
  border-radius: 12px;
  padding: 11px 16px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}

.level-option:hover,
.level-option.active {
  background: rgba(74, 128, 40, 0.72);
  border-color: #ffe169;
  transform: translateX(4px);
}

.level-option .lv-title {
  font-size: 16px;
  font-weight: 800;
  color: #ffe8a3;
}

.level-option .lv-sub {
  font-size: 13px;
  color: #d8ccb8;
  margin-top: 3px;
}

.primary-btn {
  background: linear-gradient(180deg, #80ed51 0%, #3ca615 100%);
  border: 3px solid #e2ffcf;
  border-radius: 12px;
  padding: 10px 32px;
  font-size: 18px;
  font-weight: 900;
  color: #113602;
  cursor: pointer;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.45);
}

.primary-btn:hover {
  filter: brightness(1.08);
  transform: scale(1.03);
}
