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

html, body {
  height: 100%;
  background: #16210f radial-gradient(ellipse at 50% 30%, #2c3f1d 0%, #16210f 70%);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#stage {
  width: 966px;
  position: relative;
  transform-origin: center center;
}

/* ---------- 顶部栏 ---------- */
#topbar {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(#9c7a46, #6d4f28);
  border: 3px solid #4a3416;
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .18);
}

#sunbox {
  width: 76px;
  border-radius: 10px;
  background: linear-gradient(#f3e6bb, #d8c48c);
  border: 2px solid #6b5322;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .15);
}

.sun-icon {
  font-size: 26px;
  line-height: 1;
  color: #f9a825;
  text-shadow: 0 0 8px #ffd54f;
}

#sunCount {
  font-size: 20px;
  font-weight: 800;
  color: #4a3416;
  line-height: 1.2;
}

#packets {
  display: grid;
  grid-template-columns: repeat(6, max-content);
  gap: 5px;
  align-content: center;
}

.packet {
  position: relative;
  width: 58px;
  height: 78px;
  border-radius: 9px;
  background: linear-gradient(#efe0ac, #c9b377);
  border: 2px solid #59421f;
  cursor: pointer;
  overflow: hidden;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, .5), 0 2px 3px rgba(0, 0, 0, .35);
  transition: transform .08s;
}

.packet:hover { transform: translateY(-2px); }

.packet canvas { display: block; margin: 2px auto 0; }

.packet .cost {
  position: absolute;
  bottom: 1px;
  left: 0; right: 0;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: #3d2c10;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}

.packet .cd {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 25, .62);
  transform-origin: top center;
  transform: scaleY(0);
  pointer-events: none;
}

.packet.disabled { filter: grayscale(.75) brightness(.82); cursor: not-allowed; }

.packet.selected {
  outline: 3px solid #ffe14d;
  outline-offset: -1px;
  box-shadow: 0 0 14px #ffe14d, inset 0 2px 3px rgba(255, 255, 255, .5);
}

.packet.shake { animation: pshake .3s; }
@keyframes pshake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

#shovelBtn {
  align-self: center;
  width: 52px;
  height: 60px;
  border-radius: 9px;
  border: 2px solid #59421f;
  background: linear-gradient(#cbb98a, #a58a54);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 3px rgba(0, 0, 0, .35);
}

#shovelBtn.selected {
  outline: 3px solid #ffe14d;
  box-shadow: 0 0 14px #ffe14d;
  background: linear-gradient(#e0cf9d, #b89a62);
}

/* ---------- 进度条 ---------- */
#progressWrap {
  flex: 1;
  align-self: center;
  padding: 0 6px;
}

#progLabel {
  font-size: 12px;
  color: #f5e9c8;
  text-align: center;
  letter-spacing: 2px;
  text-shadow: 0 1px 0 #4a3416;
  margin-bottom: 4px;
}

#prog {
  position: relative;
  height: 18px;
  border-radius: 10px;
  background: #3c2c12;
  border: 2px solid #241a08;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .5);
}

#progFill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0%;
  border-radius: 8px;
  background: linear-gradient(#7ec850, #4e8f2c);
  transition: width .5s linear;
}

.prog-flag {
  position: absolute;
  top: -16px;
  transform: translateX(-50%);
  font-size: 14px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .6));
}

#progZombie {
  position: absolute;
  top: -9px;
  left: 0;
  transform: translateX(-50%);
  font-size: 24px;
  line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .6));
  transition: left .5s linear;
}

/* ---------- 控制按钮 ---------- */
#ctrlBtns { display: flex; gap: 6px; align-self: center; }

#ctrlBtns button {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  border: 2px solid #4a3416;
  background: linear-gradient(#e8d9a8, #c1a86e);
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 3px rgba(0, 0, 0, .35);
}

#ctrlBtns button:active { transform: translateY(2px); }

/* ---------- 画布 ---------- */
#lawn {
  display: block;
  border: 3px solid #4a3416;
  border-radius: 0 0 14px 14px;
  background: #5a8f3c;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
  cursor: crosshair;
}

/* ---------- 遮罩与界面 ---------- */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 14, 4, .62);
  border-radius: 14px;
  backdrop-filter: blur(2px);
  z-index: 10;
}

#overlay.hidden { display: none; }

.screen {
  text-align: center;
  background: linear-gradient(#243a15, #17260c);
  border: 3px solid #59421f;
  border-radius: 18px;
  padding: 34px 52px 38px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .12);
  max-width: 640px;
}

.gtitle {
  font-size: 54px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #9cdc4f;
  text-shadow: 0 3px 0 #2c4d12, 0 7px 18px rgba(0, 0, 0, .65);
  margin-bottom: 6px;
}

.gsub {
  font-size: 17px;
  color: #cfe8a9;
  margin-bottom: 20px;
  letter-spacing: 2px;
}

.howto {
  text-align: left;
  display: inline-block;
  font-size: 15px;
  line-height: 1.9;
  color: #e6f2d2;
  margin-bottom: 22px;
}

.howto b { color: #ffe14d; }

.btn {
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 4px;
  padding: 12px 46px;
  border-radius: 12px;
  background: linear-gradient(#9ccc50, #5d8f2a);
  color: #fff;
  border: 3px solid #33691e;
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .3);
  box-shadow: 0 5px 0 #2e5b17, 0 8px 16px rgba(0, 0, 0, .4);
}

.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #2e5b17; }

.big-emoji { font-size: 64px; margin-bottom: 8px; }

.endtitle {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 10px;
}

.endtitle.win { color: #ffd54f; text-shadow: 0 3px 0 #7a5800, 0 6px 16px rgba(0, 0, 0, .6); }
.endtitle.lose { color: #ef5350; text-shadow: 0 3px 0 #5c0f0d, 0 6px 16px rgba(0, 0, 0, .6); }

.endsub { font-size: 16px; color: #cfe8a9; margin-bottom: 24px; line-height: 1.8; }

/* ---------- 无限阳光开关 ---------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .16);
  padding: 10px 16px;
  border-radius: 10px;
  margin: 4px 0 20px;
  color: #e6f2d2;
  font-size: 15px;
  text-align: left;
}

.switch {
  position: relative;
  width: 48px;
  height: 25px;
  flex: 0 0 48px;
  display: inline-block;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch i {
  position: absolute;
  inset: 0;
  background: #57593f;
  border-radius: 13px;
  transition: .18s;
  cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .45);
}

.switch i::before {
  content: '';
  position: absolute;
  width: 19px;
  height: 19px;
  left: 3px;
  top: 3px;
  background: #e8e4d0;
  border-radius: 50%;
  transition: .18s;
}

.switch input:checked + i { background: #7cb342; }
.switch input:checked + i::before { transform: translateX(23px); }
