/* ============================================================
   因數分數魔法城堡 — 動畫
   開啟「動態效果減弱」或系統設定 prefers-reduced-motion 時一律關閉。
   ============================================================ */
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes pop-in {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.7); }
  14% { opacity: 1; transform: translate(-50%, 0) scale(1.06); }
  24% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, 14px) scale(0.95); }
}
@keyframes float-up {
  0% { opacity: 0; transform: translateY(10px) scale(0.8); }
  15% { opacity: 1; transform: translateY(0) scale(1.1); }
  100% { opacity: 0; transform: translateY(-70px) scale(1); }
}
@keyframes star-pop {
  0% { transform: scale(0) rotate(-40deg); }
  70% { transform: scale(1.25) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes step-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}
@keyframes glow-good { 0% { box-shadow: 0 0 0 0 rgba(62, 224, 169, 0.9); } 100% { box-shadow: 0 0 0 26px rgba(62, 224, 169, 0); } }
@keyframes glow-bad { 0% { box-shadow: 0 0 0 0 rgba(255, 111, 134, 0.8); } 100% { box-shadow: 0 0 0 22px rgba(255, 111, 134, 0); } }
@keyframes hit { 0%, 100% { transform: scale(1); } 30% { transform: scale(0.82) rotate(-8deg); filter: brightness(2); } 60% { transform: scale(1.05) rotate(5deg); } }
@keyframes strike { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-14px) scale(1.12); } 60% { transform: translateX(8px); } }
@keyframes heart-break { 0% { transform: scale(1); } 40% { transform: scale(1.5) rotate(-12deg); } 100% { transform: scale(1); } }
@keyframes lock-shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes combo-pulse { 0% { transform: scale(0.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes confetti-fall {
  0% { transform: translate3d(0, -12vh, 0) rotate(0); opacity: 1; }
  100% { transform: translate3d(var(--dx, 0), 112vh, 0) rotate(var(--rot, 720deg)); opacity: 0.9; }
}
@keyframes low-time { 0%, 100% { filter: none; } 50% { filter: brightness(1.5); } }

.is-shake { animation: shake 0.45s ease; }
.is-glow-good { animation: glow-good 0.7s ease-out; }
.is-glow-bad { animation: glow-bad 0.6s ease-out; }
.is-hit { animation: hit 0.5s ease; }
.is-strike { animation: strike 0.5s ease; }
.is-lock-shake { animation: lock-shake 0.4s ease 2; }
.hearts .breaking { animation: heart-break 0.5s ease; }
.combo__badge.is-new { animation: combo-pulse 0.4s ease; }
.timerbar.is-low .timerbar__fill { animation: low-time 0.6s ease infinite; }

.confetti {
  position: absolute;
  top: 0;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  animation: confetti-fall var(--dur, 3s) linear forwards;
  animation-delay: var(--delay, 0s);
}

/* 減弱動態：使用者設定或系統偏好 */
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  animation-delay: 0s !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
html.reduce-motion .confetti { display: none; }
html.reduce-motion .feedback.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }
@media (prefers-reduced-motion: reduce) {
  html:not(.motion-ok) *, html:not(.motion-ok) *::before, html:not(.motion-ok) *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.001ms !important;
  }
  html:not(.motion-ok) .confetti { display: none; }
  html:not(.motion-ok) .feedback.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
