/* ============================================================
 * game_action_whack.css
 * 打地鼠 · 答对挥锤主题动作特效
 * 纯 CSS + emoji，无外部依赖。
 * 仅新增样式，不修改任何已有文件。
 * 层级：网格=5 | 玩家=15 | 锤子=20 | 拖影=19 | 粉尘=23
 *       星粒=24 | 冲击星=25 | 眩晕=26
 * ============================================================ */

/* ---------- 1. 网格约束到画面上方 75%，给玩家/锤子留底部空间 ---------- */
#gamePlay .theme-whack .whack-grid {
  top: 3% !important;
  right: 0 !important;
  bottom: auto !important;
  left: 0 !important;
  height: 72% !important;
  padding: 2% 5% !important;
  gap: 3% 2% !important;
}

/* 专属动作期间保持地鼠可见，避免通用 target-hit 动画提前缩没 */
#gamePlay .theme-whack .whack-mole.target-hit {
  animation: none !important;
  opacity: 1 !important;
}

/* ---------- 2. 底部卡通主体 ---------- */
#gamePlay .theme-whack .whack-player {
  position: absolute;
  bottom: 1.5%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 玩家脚下阴影 */
#gamePlay .theme-whack .whack-player::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 58px;
  height: 14px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.28), transparent 70%);
  border-radius: 50%;
  z-index: -1;
}

#gamePlay .theme-whack .whack-player-body {
  font-size: 50px;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  transform-origin: 50% 100%;
  animation: whack-player-breathe 2.4s ease-in-out infinite;
}

@keyframes whack-player-breathe {
  0%, 100% { transform: scaleY(1) scaleX(1); }
  50%      { transform: scaleY(1.03) scaleX(0.98); }
}

/* 挥锤时主体动作 */
#gamePlay .theme-whack .whack-player.swinging .whack-player-body {
  animation: whack-player-swing 0.7s ease-out;
}

@keyframes whack-player-swing {
  0%   { transform: rotate(0deg) translateY(0); }
  12%  { transform: rotate(-10deg) translateY(-5px); }
  55%  { transform: rotate(12deg) translateY(3px); }
  75%  { transform: rotate(-3deg) translateY(-1px); }
  100% { transform: rotate(0deg) translateY(0); }
}

/* ---------- 3. 锤子（独立运动 DOM） ---------- */
#gamePlay .theme-whack .whack-hammer {
  position: absolute;
  font-size: 42px;
  line-height: 1;
  z-index: 20;
  pointer-events: none;
  transform-origin: 50% 75%;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
  will-change: transform, left, top;
}

/* 锤子拖影 */
#gamePlay .theme-whack .whack-hammer-trail {
  position: absolute;
  font-size: 38px;
  line-height: 1;
  pointer-events: none;
  z-index: 19;
  transform-origin: 50% 75%;
  animation: whack-trail-fade 0.32s ease-out forwards;
}

@keyframes whack-trail-fade {
  0% {
    opacity: 0.5;
    transform: rotate(var(--trail-rot, 0deg)) scale(0.9);
  }
  100% {
    opacity: 0;
    transform: rotate(var(--trail-rot, 0deg)) scale(0.35) translateY(12px);
  }
}

/* ---------- 4. 命中冲击星 ---------- */
#gamePlay .theme-whack .whack-impact {
  position: absolute;
  font-size: 52px;
  line-height: 1;
  pointer-events: none;
  z-index: 25;
  animation: whack-impact-burst 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes whack-impact-burst {
  0%   { transform: scale(0) rotate(-30deg); opacity: 1; }
  45%  { transform: scale(1.5) rotate(15deg); opacity: 1; }
  100% { transform: scale(0.7) rotate(-10deg); opacity: 0; }
}

/* ---------- 5. 星粒飞散 ---------- */
#gamePlay .theme-whack .whack-star {
  position: absolute;
  line-height: 1;
  pointer-events: none;
  z-index: 24;
  animation: whack-star-fly 0.6s ease-out forwards;
}

@keyframes whack-star-fly {
  0% {
    transform: translate(0, 0) scale(0) rotate(0deg);
    opacity: 0;
  }
  15% {
    transform: translate(0, 0) scale(1.3) rotate(40deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0.2) rotate(180deg);
    opacity: 0;
  }
}

/* ---------- 6. 粉尘 ---------- */
#gamePlay .theme-whack .whack-dust {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(190, 160, 110, 0.75), rgba(160, 120, 70, 0));
  pointer-events: none;
  z-index: 23;
  animation: whack-dust-burst 0.5s ease-out forwards;
}

@keyframes whack-dust-burst {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0.75;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0.15);
    opacity: 0;
  }
}

/* ---------- 7. 眩晕小星 ---------- */
#gamePlay .theme-whack .whack-dizzy {
  position: absolute;
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
  z-index: 26;
  animation: whack-dizzy-fly 0.7s ease-out forwards;
}

@keyframes whack-dizzy-fly {
  0% {
    transform: translate(0, 0) scale(0) rotate(0deg);
    opacity: 0;
  }
  20% {
    transform: translate(0, -8px) scale(1) rotate(90deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0.5) rotate(270deg);
    opacity: 0;
  }
}

/* ---------- 8. 屏幕震动 ---------- */
#gamePlay .theme-whack.whack-shaking {
  animation: whack-screen-shake 0.32s ease;
}

@keyframes whack-screen-shake {
  0%, 100% { transform: translate(0, 0); }
  15%      { transform: translate(-5px, 3px); }
  30%      { transform: translate(5px, -3px); }
  45%      { transform: translate(-4px, 2px); }
  60%      { transform: translate(4px, -2px); }
  75%      { transform: translate(-2px, 1px); }
  90%      { transform: translate(2px, -1px); }
}

/* ---------- 9. 击中地鼠：命中表情弹出 + 压扁 ---------- */
#gamePlay .theme-whack .whack-mole .mole-emoji.mole-hit-emoji {
  display: inline-block !important;
  font-size: 38px !important;
  line-height: 1;
  animation: whack-hit-emoji-pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes whack-hit-emoji-pop {
  0%   { transform: scale(0) rotate(-180deg); opacity: 0; }
  35%  { transform: scale(1.35) rotate(10deg); opacity: 1; }
  60%  { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: scale(0.85) rotate(8deg); opacity: 0.6; }
}

/* whacked 状态在主题内保持半可见，让击中表情能看到 */
#gamePlay .theme-whack .whack-mole.target-hit.whacked {
  opacity: 0.55 !important;
  transform: translateY(-6px) scale(0.65) rotate(-10deg) !important;
  transition: all 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* 地鼠身体额外压扁 */
#gamePlay .theme-whack .whack-mole.target-hit .mole-body {
  animation: whack-mole-squash 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes whack-mole-squash {
  0%   { transform: scaleY(1) scaleX(1); }
  30%  { transform: scaleY(0.25) scaleX(1.45); }
  55%  { transform: scaleY(1.1) scaleX(0.92); }
  100% { transform: scaleY(0.5) scaleX(1.15); opacity: 0.4; }
}

/* ---------- 10. 命中闪光环 ---------- */
#gamePlay .theme-whack .whack-flash-ring {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid rgba(255, 230, 100, 0.8);
  pointer-events: none;
  z-index: 22;
  animation: whack-flash-expand 0.45s ease-out forwards;
}

@keyframes whack-flash-expand {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0.9;
    border-width: 5px;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.8);
    opacity: 0;
    border-width: 1px;
  }
}

/* ---------- 11. reduced-motion 降级 ---------- */
@media (prefers-reduced-motion: reduce) {
  #gamePlay .theme-whack .whack-player-body,
  #gamePlay .theme-whack .whack-player.swinging .whack-player-body {
    animation: none !important;
  }
  #gamePlay .theme-whack.whack-shaking {
    animation: none !important;
  }
  #gamePlay .theme-whack .whack-mole.target-hit .mole-body,
  #gamePlay .theme-whack .whack-mole .mole-emoji.mole-hit-emoji {
    animation: none !important;
    opacity: 0.3 !important;
  }
  #gamePlay .theme-whack .whack-hammer-trail,
  #gamePlay .theme-whack .whack-dust,
  #gamePlay .theme-whack .whack-star,
  #gamePlay .theme-whack .whack-dizzy,
  #gamePlay .theme-whack .whack-flash-ring {
    display: none !important;
  }
  #gamePlay .theme-whack .whack-impact {
    animation-duration: 0.2s !important;
  }
}
