/**
 * ============================================================
 * 单词竞技场 - 增强游戏动画特效 v2.0
   ============================================================
 */

/* ============================================================
   页面入场动画
   ============================================================ */
@keyframes pageEnterGame {
    0% { opacity: 0; transform: scale(0.95) translateY(20px); filter: blur(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

.page-enter-game {
    animation: pageEnterGame 0.6s var(--ease-out-expo) both;
}

/* ============================================================
   卡片入场 - 3D 翻转
   ============================================================ */
@keyframes cardFlipIn {
    0% { opacity: 0; transform: perspective(1000px) rotateY(90deg) scale(0.8); }
    100% { opacity: 1; transform: perspective(1000px) rotateY(0) scale(1); }
}

.card-flip-in {
    animation: cardFlipIn 0.6s var(--ease-out-expo) both;
}

/* ============================================================
   从下方弹入
   ============================================================ */
@keyframes bounceUp {
    0% { opacity: 0; transform: translateY(40px) scale(0.8); }
    50% { opacity: 1; transform: translateY(-10px) scale(1.05); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.bounce-up {
    animation: bounceUp 0.6s var(--ease-spring) both;
}

/* ============================================================
   震动 (错误反馈)
   ============================================================ */
@keyframes shakeX {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

.shake-x {
    animation: shakeX 0.4s ease;
}

/* ============================================================
   爆炸/粒子扩散
   ============================================================ */
@keyframes explodeOut {
    0% { transform: scale(0); opacity: 1; }
    100% { transform: scale(2.5); opacity: 0; }
}

.explode-out {
    animation: explodeOut 0.5s var(--ease-out-quart) forwards;
}

/* ============================================================
   光波脉冲
   ============================================================ */
@keyframes pulseWave {
    0% { transform: scale(0.8); opacity: 0.8; box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.6); }
    100% { transform: scale(1.2); opacity: 0; box-shadow: 0 0 0 20px rgba(108, 92, 231, 0); }
}

.pulse-wave {
    animation: pulseWave 1.2s ease-out infinite;
}

/* ============================================================
   文字打字机效果
   ============================================================ */
@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blinkCaret {
    50% { border-color: transparent; }
}

.typewriter {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--accent);
    animation: typewriter 2s steps(40) forwards, blinkCaret 0.8s infinite;
}

/* ============================================================
   闪光/高亮
   ============================================================ */
@keyframes flashHighlight {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(255, 215, 0, 0.2); }
}

.flash-highlight {
    animation: flashHighlight 0.6s ease;
}

/* ============================================================
   升级光环
   ============================================================ */
@keyframes levelUpAura {
    0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.8), 0 0 0 0 rgba(255, 215, 0, 0.4); }
    100% { box-shadow: 0 0 40px 20px rgba(255, 215, 0, 0), 0 0 80px 40px rgba(255, 215, 0, 0); }
}

.level-up-aura {
    animation: levelUpAura 1.5s ease-out;
}

/* ============================================================
   静态光环背景
   ============================================================ */
.rotate-glow::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(135deg, transparent, var(--primary), transparent, var(--accent), transparent);
    z-index: -1;
    opacity: 0.5;
}

/* ============================================================
   答对/答错颜色闪烁
   ============================================================ */
@keyframes correctFlash {
    0% { background-color: transparent; border-color: var(--border); }
    30% { background-color: rgba(46, 213, 115, 0.2); border-color: var(--success); }
    100% { background-color: transparent; border-color: var(--border); }
}

.correct-flash { animation: correctFlash 0.6s ease; }

@keyframes wrongFlash {
    0% { background-color: transparent; border-color: var(--border); }
    30% { background-color: rgba(255, 71, 87, 0.2); border-color: var(--danger); }
    100% { background-color: transparent; border-color: var(--border); }
}

.wrong-flash { animation: wrongFlash 0.6s ease; }

/* ============================================================
   进度条充能动画
   ============================================================ */
@keyframes chargeUp {
    0% { width: 0%; }
    100% { width: var(--charge-target, 100%); }
}

.charge-up { animation: chargeUp 1s var(--ease-out-quart) forwards; }

/* ============================================================
   数字跳动
   ============================================================ */
@keyframes numberPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); color: var(--gold); }
    100% { transform: scale(1); }
}

.number-pop { animation: numberPop 0.4s var(--ease-spring); }

/* ============================================================
   呼吸光效 (重要提示)
   ============================================================ */
@keyframes breathe {
    0%, 100% { box-shadow: 0 0 10px rgba(108, 92, 231, 0.2); }
    50% { box-shadow: 0 0 25px rgba(108, 92, 231, 0.5); }
}

.breathe { animation: breathe 2s ease-in-out infinite; }

/* ============================================================
   品质发光
   ============================================================ */
@keyframes qualityGlow {
    0%, 100% { box-shadow: 0 0 5px var(--glow-color, rgba(108, 92, 231, 0.3)); }
    50% { box-shadow: 0 0 20px var(--glow-color, rgba(108, 92, 231, 0.6)); }
}

.quality-glow { animation: qualityGlow 2s ease-in-out infinite; }

/* ============================================================
   滚动淡入 (增强版)
   ============================================================ */
.reveal-game {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
    transition: opacity 0.6s var(--ease-out-expo), transform 0.6s var(--ease-out-expo);
}

.reveal-game.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ============================================================
   3D 卡片悬浮 (鼠标跟随)
   ============================================================ */
.card-3d {
    transform-style: preserve-3d;
    transition: transform 0.2s var(--ease-out-quart);
}

.card-3d .card-3d-inner {
    transform: translateZ(30px);
    transform-style: preserve-3d;
}

/* ============================================================
   粒子飞散
   ============================================================ */
.particle-burst {
    position: absolute;
    pointer-events: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: particleBurst 0.8s var(--ease-out-quart) forwards;
}

@keyframes particleBurst {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--px, 50px), var(--py, -50px)) scale(0); opacity: 0; }
}

/* ============================================================
   VS 对战动画
   ============================================================ */
@keyframes vsClash {
    0% { transform: scale(0) rotate(-90deg); opacity: 0; }
    50% { transform: scale(1.5) rotate(0deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.vs-clash { animation: vsClash 0.6s var(--ease-spring) both; }

/* ============================================================
   匹配成功连线
   ============================================================ */
@keyframes matchConnect {
    0% { transform: scaleX(0); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: scaleX(1); opacity: 1; }
}

.match-connect { animation: matchConnect 0.4s var(--ease-out-quart) both; }

/* ============================================================
   倒计时圈
   ============================================================ */
@keyframes countdownRing {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: var(--ring-circum, 283); }
}

.countdown-ring {
    animation: countdownRing var(--countdown-duration, 10s) linear forwards;
}

/* ============================================================
   滑入 (左右)
   ============================================================ */
@keyframes slideInLeftGame {
    0% { opacity: 0; transform: translateX(-40px); }
    100% { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRightGame {
    0% { opacity: 0; transform: translateX(40px); }
    100% { opacity: 1; transform: translateX(0); }
}

.slide-in-left { animation: slideInLeftGame 0.5s var(--ease-out-quart) both; }
.slide-in-right { animation: slideInRightGame 0.5s var(--ease-out-quart) both; }

/* ============================================================
   闪烁提醒
   ============================================================ */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.blink { animation: blink 1s infinite; }

/* ============================================================
   奖励雨
   ============================================================ */
@keyframes rewardRain {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

.reward-rain-item {
    position: fixed;
    font-size: 24px;
    pointer-events: none;
    z-index: 450;
    animation: rewardRain 3s linear forwards;
}

/* ============================================================
   文字渐变动画
   ============================================================ */
@keyframes textGradientFlow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.text-gradient-flow {
    background: linear-gradient(90deg, var(--primary-light), var(--accent), var(--gold), var(--primary-light));
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textGradientFlow 3s linear infinite;
}

/* ============================================================
   按钮按下波纹
   ============================================================ */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple .ripple-wave {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: rippleExpand 0.6s ease-out;
    pointer-events: none;
}

@keyframes rippleExpand {
    to { transform: scale(4); opacity: 0; }
}

/* ============================================================
   战斗 HP 条减少动画
   ============================================================ */
@keyframes hpDeplete {
    0% { width: var(--hp-from, 100%); }
    100% { width: var(--hp-to, 0%); }
}

.hp-deplete { animation: hpDeplete 0.5s var(--ease-out-quart) forwards; }

/* ============================================================
   回合切换横幅
   ============================================================ */
@keyframes bannerSlide {
    0% { transform: translateX(-100%) scale(0.8); opacity: 0; }
    20% { transform: translateX(0) scale(1); opacity: 1; }
    80% { transform: translateX(0) scale(1); opacity: 1; }
    100% { transform: translateX(100%) scale(0.8); opacity: 0; }
}

.banner-slide { animation: bannerSlide 1.5s var(--ease-out-expo) both; }

/* ============================================================
   卡片选中高亮
   ============================================================ */
@keyframes selectGlow {
    0% { box-shadow: 0 0 0 0 rgba(0, 206, 201, 0); border-color: var(--border); }
    50% { box-shadow: 0 0 20px 4px rgba(0, 206, 201, 0.4); border-color: var(--accent); }
    100% { box-shadow: 0 0 0 0 rgba(0, 206, 201, 0); border-color: var(--border); }
}

.select-glow { animation: selectGlow 0.8s ease; }

/* ============================================================
   懒加载/骨架屏脉冲
   ============================================================ */
@keyframes skeletonPulse {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton-game {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: skeletonPulse 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ============================================================
   减少动画
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
