/* === 页面入场动画 === */
@keyframes floatInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

.page-enter {
    animation: floatInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* === 格子点击动画 === */
@keyframes cellClickCorrect {
    0% { transform: scale(1); }
    30% { transform: scale(0.88); }
    60% { transform: scale(1.02); }
    100% { transform: scale(0.92); }
}

@keyframes cellShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.cell.clicked {
    animation: cellClickCorrect 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.cell.error {
    animation: cellShake 0.5s ease;
}

/* === 当前目标脉冲 === */
@keyframes pulseSoft {
    0%, 100% { 
        box-shadow: 0 0 0 3px rgba(216, 208, 164, 0.3); 
    }
    50% { 
        box-shadow: 0 0 0 6px rgba(216, 208, 164, 0.5),
                    0 0 30px rgba(216, 208, 164, 0.2); 
    }
}

.cell.current {
    animation: pulseSoft 2s ease-in-out infinite;
}

/* === 数字翻转 === */
@keyframes digitFlip {
    0% { transform: rotateX(0deg); opacity: 1; }
    50% { transform: rotateX(-90deg); opacity: 0; }
    51% { transform: rotateX(90deg); opacity: 0; }
    100% { transform: rotateX(0deg); opacity: 1; }
}

.timer-digit {
    display: inline-block;
    font-family: var(--font-mono);
    font-weight: 200;
    animation: digitFlip 0.3s ease-in-out;
}

/* === 光晕扩散 === */
@keyframes haloFade {
    from { 
        opacity: 1; 
        transform: scale(0.8); 
    }
    to { 
        opacity: 0; 
        transform: scale(1.5); 
    }
}

.cell.clicked::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: inherit;
    background: radial-gradient(circle, rgba(212,164,184,0.3), transparent 70%);
    animation: haloFade 0.5s ease-out forwards;
}

/* === 弹窗弹性入场 === */
@keyframes modalEnter {
    0% { 
        opacity: 0; 
        transform: scale(0.9) translateY(20px); 
    }
    70% { 
        transform: scale(1.01) translateY(-1px); 
    }
    100% { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
}

.modal-enter {
    animation: modalEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* === 倒计时脉冲 === */
@keyframes countdownPulse {
    0%, 100% { 
        transform: scale(1); 
        opacity: 1; 
    }
    50% { 
        transform: scale(1.1); 
        opacity: 0.8; 
    }
}

.countdown-number {
    animation: countdownPulse 1s ease-in-out infinite;
}

/* === 高亮脉冲（视觉观察模式）=== */
@keyframes highlightPulse {
    0%, 100% {
        background: linear-gradient(135deg, #D4A4B8 0%, #8C5A6C 100%);
        transform: scale(1.02);
        box-shadow: 0 0 20px rgba(212, 164, 184, 0.4);
    }
    50% {
        background: linear-gradient(135deg, #D4A4B8 0%, #C0A88C 100%);
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(212, 164, 184, 0.6);
    }
}

.cell.highlighted {
    animation: highlightPulse 2s ease-in-out infinite;
    border-color: var(--primary-300);
    z-index: 10;
}

/* === 格子隐藏/显示（盲打模式）=== */
@keyframes revealNumber {
    from { 
        opacity: 0; 
        transform: scale(0.8); 
        filter: blur(4px); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
        filter: blur(0); 
    }
}

.cell.revealed {
    animation: revealNumber 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cell.hidden {
    background: var(--neutral-50);
    border: 2px dashed var(--neutral-200);
    color: var(--neutral-400);
    font-size: 2rem;
}

.cell.hidden::before {
    content: '?';
    font-family: var(--font-display);
}

.cell.semi-blind {
    opacity: 0.3;
    color: var(--neutral-400);
}

/* === GPU加速优化 === */
.cell {
    transform: translateZ(0);
    backface-visibility: hidden;
}

.stat-card {
    transform: translateZ(0);
}

/* === 进度条动画 === */
@keyframes progressBar {
    from { width: 0%; }
    to { width: 100%; }
}

.progress-bar {
    transition: width 1s linear, background-color 0.3s ease;
}

/* === 错误提示浮动动画 === */
@keyframes errorTooltip {
    0% { 
        opacity: 1; 
        transform: translateX(-50%) translateY(0); 
    }
    70% { 
        opacity: 1; 
    }
    100% { 
        opacity: 0; 
        transform: translateX(-50%) translateY(-10px); 
    }
}

.error-tooltip {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-700);
    color: white;
    font-family: var(--font-display);
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    z-index: 10;
    animation: errorTooltip 1s ease forwards;
}

/* === 按钮微光效果 === */
.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

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

@media (max-width: 576px) {
    .cell {
        transition-duration: 0.15s;
    }
    
    .btn-primary:hover {
        transform: none;
    }
}
