/* ============================================================
   拼音豌豆园 —— 声母豌豆 + 韵母向日葵 → 拼读音节 → 打僵尸
   ============================================================ */

.pz {
  --cw: 11.1%;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #14301f;
  color: #f4f9ea;
  overflow: hidden;
}

.pz-field { min-height: 260px; }

/* ---------------- 顶部种子栏 ---------------- */

.pz-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px clamp(8px, 2vw, 22px) 8px;
  background: linear-gradient(180deg, #6b4a24, #4a3216);
  border-bottom: 3px solid #d9a75a;
  box-shadow: 0 6px 16px #0b1d1233;
}

.seed-group { display: grid; gap: 4px; min-width: 0; }
.seed-group__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: .08em;
  color: #ffe6ac;
  white-space: nowrap;
  overflow: hidden;
}
.seed-group__title span { font-size: 10.5px; font-weight: 700; color: #ffe6ac99; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; }
.seed-group__title i { flex: 1; height: 1px; min-width: 8px; background: #ffffff33; }
.seed-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }

.seed-card {
  position: relative;
  flex: 0 0 auto;
  width: clamp(46px, 5vw, 62px);
  border-radius: 10px;
  border: 2px solid #ffffff26;
  background: linear-gradient(180deg, #fdf6e2, #e7dcc0);
  color: #2b2417;
  cursor: pointer;
  padding: 4px 2px 3px;
  display: grid;
  justify-items: center;
  gap: 1px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.seed-card:hover { transform: translateY(-2px); }
.seed-card[aria-pressed="true"] {
  border-color: #ffd257;
  box-shadow: 0 0 0 3px #ffd25766, 0 8px 16px #00000033;
}
.seed-card--poor { opacity: .48; cursor: not-allowed; }
.seed-card svg { width: 100%; height: auto; max-height: 30px; }
.seed-card b { font-size: 15px; line-height: 1; letter-spacing: .02em; }
.seed-card small { font-size: 9.5px; color: #7d6c4b; font-weight: 800; }

/* 声调选择 */
.tone-picker { display: flex; gap: 3px; margin-top: 2px; }
.tone-btn {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 1px solid #00000022;
  background: #fffdf4;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  color: #5b4a2c;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.tone-btn[aria-pressed="true"] { background: #e0574f; color: #fff; border-color: #b93a33; }

.sun-counter {
  display: grid;
  justify-items: center;
  align-content: center;
  min-width: 74px;
  padding: 6px 12px;
  border-radius: 12px;
  background: #fff8db;
  color: #6a4a0d;
  box-shadow: inset 0 -3px 0 #d9a75a;
}
.sun-counter strong { font-size: 20px; line-height: 1; }
.sun-counter span { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; }

/* ---------------- 草地 ---------------- */

.pz-field {
  position: relative;
  /* 右侧留出 60px 给工具条，避免僵尸走到边上被按钮盖住 */
  margin: 0 60px 0 clamp(6px, 1.4vw, 16px);
  border-radius: 14px;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, #79b74f 0 11.1%, #6fae47 11.1% 22.2%),
    #6fae47;
  box-shadow: inset 0 0 0 3px #4e7d33, inset 0 0 60px #2f5220aa;
}

.pz-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(5, 1fr);
}
.pz-cell {
  border: 1px solid #4f8a3a55;
  background: none;
  cursor: pointer;
  transition: background .12s ease;
}
.pz-cell:nth-child(odd) { background: #ffffff08; }
.pz-cell:hover { background: #ffffff26; }
.pz-cell[data-armed="1"]:hover { background: #ffd25733; }

/* 左侧小车（最后防线） */
.pz-mowers {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6%;
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  pointer-events: none;
}
.mower {
  align-self: center;
  justify-self: center;
  width: 78%;
  aspect-ratio: 1.4;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #d64c3f, #a83328);
  box-shadow: 0 3px 0 #7a1f16, 0 0 0 2px #00000022;
  position: relative;
  transition: transform .2s ease, opacity .2s ease;
}
.mower::before {
  content: '';
  position: absolute;
  left: 12%; right: 12%; top: -6px;
  height: 8px;
  border-radius: 4px;
  background: #e9e4d4;
}
.mower[data-used="1"] { opacity: .2; transform: translateX(-30px); }

/* 植物 / 僵尸 / 弹体 通用定位 */
.pz-layer { position: absolute; inset: 0; pointer-events: none; }

.plant {
  position: absolute;
  width: 9.4%;
  aspect-ratio: 1;
  transform: translate(-50%, -58%);
  pointer-events: auto;
  cursor: pointer;
  filter: drop-shadow(0 4px 4px #1d3a1c55);
}
.plant svg { width: 100%; height: 100%; }
.plant--pairing::after {
  content: '';
  position: absolute;
  inset: -12%;
  border-radius: 50%;
  border: 2px dashed #ffe08a;
  animation: pairSpin 6s linear infinite;
  opacity: .85;
}
@keyframes pairSpin { to { transform: rotate(360deg); } }

.plant__hint {
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 99px;
  background: #15340fcc;
  color: #ffe9a8;
  white-space: nowrap;
}

/* 植物血量：被僵尸啃的时候才出现 */
.plant__hp {
  position: absolute;
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
  width: 62%;
  height: 4px;
  border-radius: 99px;
  background: #0d251199;
  overflow: hidden;
  opacity: 0;
  transition: opacity .15s ease;
}
.plant__hp i { display: block; height: 100%; background: linear-gradient(90deg, #9be07a, #ffe066); }
.plant--hit .plant__hp { opacity: 1; }
.plant--hit svg { animation: plantBite .3s ease-in-out infinite; }
@keyframes plantBite {
  0%, 100% { transform: translateX(0) rotate(0); }
  50% { transform: translateX(-2px) rotate(-2deg); }
}
.plant--dying { animation: plantDying .45s ease forwards; }
@keyframes plantDying {
  0% { opacity: 1; transform: translate(-50%, -58%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(.5) rotate(24deg); }
}

.zombie {
  position: absolute;
  width: 8.6%;
  transform: translate(-50%, -50%);
  transition: opacity .2s ease;
}
.zombie__body { position: relative; animation: zombieBob 1.1s ease-in-out infinite; }
@keyframes zombieBob {
  0%, 100% { transform: translateY(0) rotate(-1.2deg); }
  50% { transform: translateY(-3px) rotate(1.2deg); }
}
.zombie__body svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 3px 3px #00000055); }
.zombie__sign {
  position: absolute;
  left: 50%;
  top: -44%;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 6px;
  background: linear-gradient(180deg, #f6d38a, #d9a75a);
  border: 2px solid #8a5a2b;
  color: #4a2f12;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
  box-shadow: 0 3px 0 #8a5a2b;
}
.zombie__sign::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 4px;
  height: 9px;
  margin-left: -2px;
  background: #8a5a2b;
}
.zombie__sign small { display: block; font-size: 9px; font-weight: 800; opacity: .8; letter-spacing: .04em; }
.zombie__hp {
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  width: 74%;
  height: 4px;
  border-radius: 99px;
  background: #0d251199;
  overflow: hidden;
}
.zombie__hp i { display: block; height: 100%; background: linear-gradient(90deg, #9be07a, #ffe066); }
.zombie--hit { animation: zombieHit .3s ease; }
@keyframes zombieHit {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.6) saturate(1.4); }
}

/* 啃植物的时候身体前倾、啃得更快 */
.zombie--eating .zombie__body { animation: zombieChew .42s ease-in-out infinite; }
@keyframes zombieChew {
  0%, 100% { transform: translateY(0) rotate(-3deg) translateX(-2px); }
  50% { transform: translateY(-2px) rotate(2deg) translateX(1px); }
}

/* 音节弹 / 豌豆弹 */
.shot {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 4;
}
.shot--syllable {
  display: grid;
  justify-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff6d2, #ffcf6a);
  border: 2px solid #b8842c;
  color: #4a2f12;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 0 18px #ffe08acc, 0 4px 8px #00000033;
}
.shot--pea {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d9ff9e, #6cc23f);
  box-shadow: 0 0 10px #9be07a99;
}

/* 命中特效 */
.pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 17px;
  font-weight: 900;
  color: #eaffd0;
  text-shadow: 0 2px 0 #2d5a1f, 0 0 14px #9be07a;
  pointer-events: none;
  animation: popUp .9s ease-out forwards;
  white-space: nowrap;
}
@keyframes popUp {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
  25% { opacity: 1; transform: translate(-50%, -80%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

/* ---------------- 拼读面板 ---------------- */

.pair-panel {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: 14%;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 24px));
  padding: 14px 18px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffdf2, #fdf1cf);
  border: 3px solid #f2c14e;
  box-shadow: 0 20px 44px #0b1d1299;
  color: #3d2b12;
  text-align: center;
}
.pair-panel[hidden] { display: none; }
.pair-panel__kicker {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 99px;
  background: #f2c14e;
  color: #5b3d0b;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: .06em;
}
.pair-panel__formula {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 6px;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 900;
}
.pair-panel__formula .pill {
  padding: 2px 12px;
  border-radius: 10px;
  background: #fff;
  border: 2px solid #d9c9a0;
  color: #2b6b46;
  font-size: inherit;
}
.pair-panel__formula .pill--tone { color: #b1502f; }
.pair-panel__formula .arrow { color: #b8842c; }
.pair-panel__result {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 14px;
  border-radius: 10px;
  background: #ffe9a8;
  border: 2px solid #d9a75a;
}
.pair-panel__result b { font-size: clamp(24px, 3.4vw, 34px); }
.pair-panel__result i { font-style: normal; font-size: clamp(22px, 3vw, 30px); color: #6b3f12; }
.pair-panel__tip { font-size: 13px; color: #7a5c2c; margin: 4px 0 12px; }
.pair-panel__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------------- 右侧工具 ---------------- */

.pz-tools {
  position: fixed;
  right: 6px;
  top: 120px;
  z-index: 25;
  display: grid;
  gap: 6px;
}
.tool {
  width: 46px;
  min-height: 44px;
  border-radius: 12px;
  border: 2px solid #ffffff26;
  background: #2b4b2fdd;
  color: #eaf7dd;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 1px;
  padding: 4px 2px;
  backdrop-filter: blur(4px);
  transition: background .12s ease, transform .12s ease;
}
.tool:hover { background: #3a6340ee; transform: translateX(-2px); }
.tool[aria-pressed="true"] { background: #d9a75a; color: #3d2b12; border-color: #ffe6ac; }
.tool i { font-style: normal; font-size: 15px; }

/* ---------------- 底部：进度 + 汉字收集 ---------------- */

.pz-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px clamp(10px, 2vw, 22px) max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #2b4b2f, #17301d);
  border-top: 3px solid #d9a75a;
}
.progress-track {
  position: relative;
  width: clamp(120px, 18vw, 210px);
  height: 12px;
  border-radius: 99px;
  background: #0d2511;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px #ffffff1f;
}
.progress-track i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #9be07a, #ffe066);
  transition: width .4s ease;
}
.pz-foot__count { font-size: 12.5px; font-weight: 900; color: #cfe6b8; white-space: nowrap; }
.pz-foot__level {
  font-size: 12px;
  font-weight: 800;
  color: #0f2a17;
  background: #cfe6b8;
  border-radius: 99px;
  padding: 2px 10px;
  white-space: nowrap;
}

/* 关卡选择 */
.level-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 4px;
}
.level-tile {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid #e2d3ab;
  background: linear-gradient(180deg, #fffdf2, #f2e6c8);
  color: #3d2b12;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: grid;
  place-items: center;
  position: relative;
  transition: transform .12s ease, box-shadow .12s ease;
}
.level-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 16px #00000026; }
.level-tile[data-state="done"] { background: linear-gradient(180deg, #b6e08a, #7fbf5e); border-color: #4f8a3a; color: #1f3d16; }
.level-tile[data-state="current"] { border-color: #e0574f; box-shadow: 0 0 0 3px #e0574f55; }
.level-tile[data-state="locked"] { opacity: .45; cursor: not-allowed; }
.level-tile small { position: absolute; bottom: 3px; font-size: 8.5px; font-weight: 700; opacity: .7; }

.collected { display: flex; align-items: center; gap: 6px; margin-left: auto; overflow-x: auto; }
.collected__title { font-size: 11px; font-weight: 800; color: #9dbb8c; white-space: nowrap; }
.tile {
  flex: 0 0 auto;
  min-width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(180deg, #f6d38a, #d9a75a);
  border: 2px solid #8a5a2b;
  color: #4a2f12;
  font-size: 17px;
  font-weight: 900;
  display: grid;
  place-items: center;
  animation: tileIn .4s cubic-bezier(.2, 1.5, .5, 1) both;
}
.tile--empty { background: #ffffff14; border: 2px dashed #ffffff33; color: #ffffff44; }
@keyframes tileIn { from { transform: scale(.4); opacity: 0 } to { transform: scale(1); opacity: 1 } }

/* ---------------- 覆盖层 ---------------- */

.pz-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: #0b1d12cc;
  backdrop-filter: blur(4px);
  padding: 20px;
}
/* 关卡面板要能盖在开场卡上面 */
#levelOverlay { z-index: 70; }
.pz-overlay[hidden] { display: none; }
.pz-card {
  width: min(520px, 100%);
  border-radius: 22px;
  background: linear-gradient(180deg, #fffdf2, #f6ecd2);
  color: #33240f;
  padding: 24px;
  text-align: center;
  box-shadow: 0 30px 70px #00000073, 0 0 0 4px #f2c14e55;
}
.pz-card h1 { font-size: clamp(22px, 2.8vw, 30px); color: #1f4b2c; }
.pz-card p { font-size: 13.5px; color: #6b5a3c; line-height: 1.85; margin: 8px 0 0; }
.pz-card__rules { text-align: left; display: grid; gap: 6px; margin: 14px 0 4px; font-size: 13px; color: #4b3d24; }
.pz-card__rules b { color: #b1502f; }
.pz-card__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

@media (max-width: 860px) {
  .pz-bar { grid-template-columns: minmax(0, 1fr); }
  .sun-counter { grid-row: 1; justify-self: end; }
  .pz-tools { top: auto; bottom: 64px; right: 6px; grid-auto-flow: column; }
  .tool { width: 40px; min-height: 40px; font-size: 9.5px; }
  .zombie__sign { font-size: 12px; }
  .collected { display: none; }
}
