/* ==================== 全局 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  touch-action: manipulation;
  -ms-touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'PingFang SC', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  overflow: hidden;
  background: #7ec8e3;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.screen { display: none; width: 100vw; height: 100vh; position: fixed; top: 0; left: 0; }
.screen.active { display: flex; }

/* ==================== 开始界面 ==================== */
.start-bg {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #7ec8e3 0%, #b8e6ff 40%, #ffc0cb 60%, #ff9ec6 100%);
}

.start-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; gap: 20px;
}

.start-icon { font-size: 5rem; animation: bounce 1.5s infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

.start-content h1 {
  font-size: 2.8rem; color: #fff;
  text-shadow: 3px 3px 0 #ff69b4, 6px 6px 0 rgba(0,0,0,0.1);
  letter-spacing: 4px;
}

.start-content p { font-size: 1rem; color: rgba(255,255,255,0.85); }

.btn-candy {
  background: linear-gradient(180deg, #ff7eb3, #ff3d8b);
  color: #fff; border: none; border-radius: 50px;
  padding: 16px 60px; font-size: 1.3rem; font-weight: bold;
  cursor: pointer; letter-spacing: 3px;
  box-shadow: 0 6px 0 #c4246a, 0 10px 20px rgba(0,0,0,0.15);
  transition: transform 0.1s;
}
.btn-candy:active { transform: translateY(3px); box-shadow: 0 3px 0 #c4246a; }

/* ==================== 游戏画布 ==================== */
#game-canvas {
  width: 100vw; height: 100vh;
  display: block; position: absolute; top: 0; left: 0;
}

/* ==================== 顶部 HUD ==================== */
.hud-top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  z-index: 10; pointer-events: none;
}

.hud-top > * { pointer-events: auto; }

.map-info {
  background: rgba(255,255,255,0.92); border-radius: 20px;
  padding: 8px 16px; min-width: 160px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.1);
}

#map-name {
  font-size: 0.85rem; font-weight: bold; color: #555;
  display: block; text-align: center; margin-bottom: 4px;
}

.progress-bar {
  height: 18px; background: #e0e0e0; border-radius: 9px;
  position: relative; overflow: hidden;
}

.progress-fill {
  height: 100%; border-radius: 9px;
  background: linear-gradient(90deg, #a855f7, #ec4899);
  width: 0%; transition: width 0.5s ease;
}

#progress-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: bold; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.hud-right { display: flex; flex-direction: column; gap: 6px; }

.currency-item {
  background: rgba(255,255,255,0.92); border-radius: 16px;
  padding: 6px 14px; display: flex; align-items: center; gap: 6px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.1);
  font-size: 0.95rem; font-weight: bold; color: #333;
}

.coin-icon, .gem-icon { font-size: 1.1rem; }

/* ==================== 层数信息 ==================== */
.layer-info {
  position: fixed; left: 16px; top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.92); border-radius: 16px;
  padding: 12px 16px; z-index: 10;
  box-shadow: 0 3px 12px rgba(0,0,0,0.1);
  text-align: center;
}

.layer-title {
  font-size: 1.1rem; font-weight: bold; color: #e91e63;
  margin-bottom: 4px;
}

.layer-depth { font-size: 0.8rem; color: #888; }

/* ==================== 角色头顶背包条 ==================== */
.backpack-bar {
  position: fixed; z-index: 10; pointer-events: none;
  display: none; flex-direction: column; align-items: center; gap: 2px;
}

#bp-text { font-size: 0.65rem; font-weight: bold; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }

.bp-fill-wrap {
  width: 60px; height: 6px; background: rgba(0,0,0,0.3);
  border-radius: 3px; overflow: hidden;
}

.bp-fill {
  height: 100%; background: linear-gradient(90deg, #76ff03, #00e676);
  border-radius: 3px; width: 0%; transition: width 0.3s;
}

/* ==================== 右侧按钮 ==================== */
.side-buttons {
  position: fixed; right: 16px; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 12px;
  z-index: 10;
}

.side-btn {
  width: 56px; height: 56px; border-radius: 50%;
  border: 3px solid #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: transform 0.15s;
}
.side-btn:active { transform: scale(0.9); }
.side-btn span { font-size: 1.3rem; }
.side-btn small { font-size: 0.55rem; color: #fff; font-weight: bold; }

.speed-btn { background: linear-gradient(135deg, #42a5f5, #1565c0); }
.speed-btn.active { background: linear-gradient(135deg, #ffd54f, #ff8f00); animation: pulse 0.8s infinite; }

.auto-btn { background: linear-gradient(135deg, #66bb6a, #2e7d32); }
.auto-btn.active { background: linear-gradient(135deg, #76ff03, #00c853); animation: pulse 0.8s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,213,79,0.5); }
  50% { box-shadow: 0 0 0 10px rgba(255,213,79,0); }
}

/* ==================== 底部建筑按钮（已移除，改为3D场景） ==================== */
.bottom-hint {
  position: fixed; bottom: 0; left: 0; right: 0;
  text-align: center; padding: 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 10; pointer-events: none;
  font-size: 0.75rem; color: rgba(255,255,255,0.8);
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.1));
}

/* ==================== 商店面板 ==================== */
.shop-panel {
  position: fixed; bottom: -100vh; left: 50%;
  transform: translateX(-50%);
  width: 320px; max-width: 90vw;
  max-height: 70vh;
  background: rgba(255,255,255,0.97);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
  z-index: 200;
  transition: bottom 0.3s ease;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.shop-panel.show { bottom: 0; }

.shop-panel-content {
  padding: 16px 20px 24px;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; flex: 1;
}

.shop-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  background: linear-gradient(135deg, #ff7eb3, #ff3d8b);
  color: #fff;
}
.shop-panel-header h3 { margin: 0; font-size: 1.1rem; }
.shop-panel-close-btn {
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.3); color: #fff; font-size: 1rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

.shop-desc {
  font-size: 0.85rem; color: #555; margin: 0; line-height: 1.5;
}
.shop-info {
  font-size: 0.8rem; color: #888; margin: 0;
}
.shop-lock-info {
  font-size: 0.9rem; color: #e91e63; font-weight: bold; margin: 0;
}

.shop-action-btn {
  width: 100%; padding: 12px 16px; border: none; border-radius: 12px;
  color: #fff; font-size: 0.95rem; font-weight: bold;
  cursor: pointer; transition: transform 0.1s;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}
.shop-action-btn:active { transform: scale(0.96); }
.shop-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.sell-color { background: linear-gradient(135deg, #66bb6a, #388e3c); }
.hire-color { background: linear-gradient(135deg, #ffa726, #e65100); }
.upgrade-color { background: linear-gradient(135deg, #78909c, #455a64); }
.expand-color { background: linear-gradient(135deg, #a1887f, #5d4037); }
.unlock-color { background: linear-gradient(135deg, #ce93d8, #7b1fa2); }
.speed-color { background: linear-gradient(135deg, #42a5f5, #1565c0); }
.auto-color { background: linear-gradient(135deg, #66bb6a, #2e7d32); }
.pet-color { background: linear-gradient(135deg, #ff8a65, #d84315); }
.petbag-color { background: linear-gradient(135deg, #ffab91, #e64a19); }
.bath-color { background: linear-gradient(135deg, #4fc3f7, #0288d1); }
.prestige-color { background: linear-gradient(135deg, #ffd54f, #f9a825); }
.synthesis-color { background: linear-gradient(135deg, #b388ff, #7c4dff); }
.achieve-color { background: linear-gradient(135deg, #ff8a65, #ff5722); }

/* ==================== 洗澡buff信息 ==================== */
.bath-buff-info {
  position: fixed; left: 16px; bottom: 60px;
  background: rgba(255,255,255,0.92); border-radius: 12px;
  padding: 6px 12px; z-index: 10;
  font-size: 0.8rem; font-weight: bold; color: #0288d1;
  box-shadow: 0 3px 12px rgba(0,0,0,0.1);
  animation: bathGlow 2s ease-in-out infinite;
}
@keyframes bathGlow {
  0%, 100% { box-shadow: 0 3px 12px rgba(2,136,209,0.15); }
  50% { box-shadow: 0 3px 20px rgba(2,136,209,0.4); }
}

/* ==================== 浮动提示 ==================== */
.float-tip {
  position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.8); color: #fff; padding: 14px 28px;
  border-radius: 14px; font-size: 1rem; font-weight: bold;
  pointer-events: none; opacity: 0; transition: opacity 0.3s;
  z-index: 100; text-align: center;
}
.float-tip.show { opacity: 1; }

/* ==================== 金币飞出效果 ==================== */
#fly-container { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

.fly-coin {
  position: absolute; font-size: 1.2rem; font-weight: bold;
  color: #ffd700; pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
  animation: flyCoin 1s ease-out forwards;
}

@keyframes flyCoin {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-70px) scale(1.4); }
}

.fly-gem {
  position: absolute; pointer-events: none;
  animation: flyGem 0.8s ease-out forwards;
}

@keyframes flyGem {
  0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0.5) rotate(360deg); }
}

/* ==================== 限时挑战计时器 ==================== */
.challenge-timer {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 80; font-size: 2rem; font-weight: bold;
  background: rgba(0,0,0,0.7); color: #4caf50;
  padding: 8px 24px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  text-shadow: 0 0 10px currentColor;
  animation: challengePulse 1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes challengePulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.05); }
}

/* ==================== 音效控制按钮 ==================== */
.sound-buttons {
  position: fixed; left: 10px; bottom: 16px; z-index: 50;
  display: flex; flex-direction: column; gap: 6px;
}
.sound-btn {
  width: 44px; height: 44px; border-radius: 12px; border: none;
  background: rgba(255,255,255,0.85);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
  padding: 2px;
}
.sound-btn span { font-size: 1.1rem; line-height: 1; }
.sound-btn small { font-size: 0.55rem; color: #555; margin-top: 1px; }
.sound-btn:active { transform: scale(0.9); }
.sound-btn.off {
  background: rgba(200,200,200,0.7);
  opacity: 0.6;
}
.sound-btn.off small { color: #999; text-decoration: line-through; }

/* ==================== 响应式 ==================== */
@media (max-width: 600px) {
  .building-btn { padding: 6px 4px; max-width: 68px; }
  .building-icon { font-size: 1.2rem; }
  .building-name { font-size: 0.58rem; }

  /* 顶部HUD缩小 */
  .map-info { min-width: 100px; padding: 5px 10px; border-radius: 14px; }
  #map-name { font-size: 0.7rem; margin-bottom: 2px; }
  .progress-bar { height: 14px; }
  #progress-text { font-size: 0.6rem; }
  .currency-item { padding: 4px 10px; font-size: 0.8rem; border-radius: 12px; }
  .coin-icon, .gem-icon { font-size: 0.9rem; }

  /* 层数信息缩小并移到左上角偏下 */
  .layer-info { padding: 6px 10px; border-radius: 12px; left: 10px; }
  .layer-title { font-size: 0.85rem; margin-bottom: 2px; }
  .layer-depth { font-size: 0.65rem; }

  /* 右侧按钮缩小 */
  .side-btn { width: 42px; height: 42px; border-width: 2px; }
  .side-btn span { font-size: 1rem; }
  .side-btn small { font-size: 0.45rem; }
  .side-buttons { right: 8px; gap: 8px; }

  /* 音效按钮缩小 */
  .sound-btn { width: 34px; height: 34px; border-radius: 10px; }
  .sound-btn span { font-size: 0.9rem; }
  .sound-btn small { font-size: 0.45rem; }
  .sound-buttons { left: 6px; bottom: 36px; gap: 4px; }

  /* 底部提示缩小 */
  .bottom-hint { font-size: 0.6rem; padding: 6px; }

  /* 宠物加成信息缩小 */
  .pet-active-info { font-size: 0.65rem; padding: 4px 8px; left: 8px; bottom: 80px; }
  .bath-buff-info { font-size: 0.65rem; padding: 4px 8px; left: 8px; bottom: 44px; }
}

/* ==================== 宠物加成信息 ==================== */
.pet-active-info {
  position: fixed; left: 16px; bottom: 100px;
  background: rgba(255,255,255,0.92); border-radius: 12px;
  padding: 6px 12px; z-index: 10;
  font-size: 0.8rem; font-weight: bold; color: #e91e63;
  box-shadow: 0 3px 12px rgba(0,0,0,0.1);
  animation: petInfoGlow 2s ease-in-out infinite;
}
@keyframes petInfoGlow {
  0%, 100% { box-shadow: 0 3px 12px rgba(233,30,99,0.15); }
  50% { box-shadow: 0 3px 20px rgba(233,30,99,0.35); }
}

.petbag-btn { background: linear-gradient(135deg, #ff8a65, #e64a19); }

/* ==================== 宠物袋面板 ==================== */
.pet-bag-panel {
  position: fixed; right: -320px; top: 0; bottom: 0;
  width: 300px; max-width: 80vw;
  background: rgba(255,255,255,0.97); z-index: 200;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  transition: right 0.3s ease;
  display: flex; flex-direction: column;
  border-radius: 16px 0 0 16px;
}
.pet-bag-panel.show { right: 0; }

.pet-bag-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid #eee;
}
.pet-bag-header h3 { font-size: 1.1rem; color: #333; margin: 0; }
.pet-bag-close {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: #f5f5f5; font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.pet-list {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}

.pet-empty {
  text-align: center; color: #999; padding: 40px 0; font-size: 0.9rem;
}

.pet-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: 12px;
  background: #f8f8f8; transition: background 0.2s;
}
.pet-item.active {
  background: linear-gradient(135deg, #fff3e0, #ffe0b2);
  border: 2px solid #ff9800;
}

.pet-item-emoji { font-size: 2rem; }
.pet-item-info { flex: 1; }
.pet-item-name { font-size: 0.9rem; font-weight: bold; color: #333; }
.pet-item-rarity { font-size: 0.75rem; font-weight: bold; }
.pet-item-bonus { font-size: 0.7rem; color: #e91e63; margin-top: 2px; }

.pet-item-action { flex-shrink: 0; }
.pet-active-tag {
  font-size: 0.7rem; color: #ff9800; font-weight: bold;
  background: rgba(255,152,0,0.1); padding: 4px 8px; border-radius: 8px;
}
.pet-use-btn {
  font-size: 0.7rem; color: #fff; font-weight: bold;
  background: linear-gradient(135deg, #42a5f5, #1565c0);
  border: none; padding: 6px 12px; border-radius: 8px; cursor: pointer;
}

/* ==================== 开蛋结果弹窗 ==================== */
.egg-result-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center;
}
.egg-result-overlay.show { display: flex; }

.egg-result-card {
  background: #fff; border-radius: 20px;
  padding: 30px 40px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: eggCardPop 0.4s ease;
  max-width: 85vw;
}
@keyframes eggCardPop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.egg-crack-anim {
  font-size: 3rem;
  animation: eggCrack 0.6s ease forwards;
}
@keyframes eggCrack {
  0% { transform: scale(1) rotate(0); opacity: 1; }
  50% { transform: scale(1.3) rotate(15deg); opacity: 0.8; }
  100% { transform: scale(0) rotate(-30deg); opacity: 0; }
}

.egg-result-emoji {
  font-size: 4rem; margin: 10px 0;
  animation: petReveal 0.5s 0.3s ease both;
}
@keyframes petReveal {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.egg-result-name {
  font-size: 1.4rem; font-weight: bold; color: #333; margin: 8px 0 4px;
}
.egg-result-rarity {
  font-size: 1rem; font-weight: bold; margin-bottom: 4px;
}
.egg-result-bonus {
  font-size: 0.9rem; color: #e91e63; margin-bottom: 16px;
}

.egg-result-btn {
  background: linear-gradient(180deg, #ff7eb3, #ff3d8b);
  color: #fff; border: none; border-radius: 30px;
  padding: 12px 40px; font-size: 1rem; font-weight: bold;
  cursor: pointer; box-shadow: 0 4px 0 #c4246a;
  transition: transform 0.1s;
}
.egg-result-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #c4246a; }
