/* ========== 固定红包样式 ========== */
.fixed-red-packet {
    position: fixed !important;
    left: 15px !important;
    top: 80px !important;
    width: 50px !important;
    height: 60px !important;
    z-index: 999999 !important;
    background: url('../img/red-packet.gif') center center/contain no-repeat !important;
    cursor: pointer !important;
    animation: none !important;
    -webkit-animation: none !important;
    transform: scale(1) !important;
    transition: all 0.3s ease !important;
}

.fixed-red-packet:hover {
    transform: scale(1) !important;
}

.fixed-red-packet:active {
    transform: scale(1) !important;
}

.fixed-red-packet.hidden {
    opacity: 0 !important;
    transform: translateX(-50px) !important;
    pointer-events: none !important;
}

/* 强制禁用固定红包的动画，不影响弹窗 */
.fixed-red-packet {
    animation: none !important;
    -webkit-animation: none !important;
    animation-name: none !important;
    -webkit-animation-name: none !important;
}

/* 红包区域整体优化 */
.fixed-red-packet,
.red-packet-tip {
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* 确保红包和文字在一个视觉组合中 */
.red-packet-tip {
    white-space: nowrap !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
}

/* ========== 红包弹窗样式 ========== */
.red-packet-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.7) !important;
    z-index: 999998 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.red-packet-modal {
    background: #d32f2f !important;
    background: linear-gradient(135deg, #d32f2f 0%, #f44336 50%, #ff5722 100%) !important;
    border-radius: 16px !important;
    width: 300px !important;
    max-width: 90vw !important;
    padding: 25px 20px !important;
    text-align: center !important;
    color: white !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
    z-index: 999999 !important;
}

/* 弹窗显示动画 */
@keyframes redPacketShow {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    70% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* ========== 弹窗内容样式 ========== */
.red-packet-header {
    position: relative !important;
    margin-bottom: 15px !important;
}

.red-packet-close {
    position: absolute !important;
    top: -5px !important;
    right: -5px !important;
    width: 24px !important;
    height: 24px !important;
    background: rgba(255, 255, 255, 0.2) !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.2s ease !important;
}

.red-packet-close:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

.red-packet-close::before,
.red-packet-close::after {
    content: '' !important;
    position: absolute !important;
    width: 12px !important;
    height: 2px !important;
    background: white !important;
    border-radius: 1px !important;
}

.red-packet-close::before {
    transform: rotate(45deg) !important;
}

.red-packet-close::after {
    transform: rotate(-45deg) !important;
}

.red-packet-avatar {
    margin-bottom: 10px !important;
}

.red-packet-avatar img {
    width: 50px !important;
    height: 50px !important;
    border-radius: 50% !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    background: white !important;
    padding: 2px !important;
}

.red-packet-title {
    font-size: 18px !important;
    font-weight: bold !important;
    margin-bottom: 5px !important;
    color: #fff !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3) !important;
}

.red-packet-subtitle {
    font-size: 14px !important;
    color: rgba(255, 255, 255, 0.9) !important;
    margin-bottom: 20px !important;
}

.red-packet-amount {
    font-size: 32px !important;
    font-weight: bold !important;
    color: #ffeb3b !important;
    margin: 15px 0 !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3) !important;
    animation: none !important;
}

/* 金额闪烁动画 */
@keyframes amountBlink {
    0% { 
        color: #ffeb3b;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 8px rgba(255, 235, 59, 0.6);
    }
    100% { 
        color: #fff176;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 12px rgba(255, 235, 59, 0.9);
    }
}

.red-packet-footer {
    font-size: 12px !important;
    color: rgba(255, 255, 255, 0.8) !important;
    margin-top: 15px !important;
    line-height: 1.4 !important;
}

/* ========== 移动端适配 ========== */
@media (max-width: 480px) {
    .red-packet-modal {
        width: 280px !important;
        padding: 20px 15px !important;
    }
    
    .red-packet-title {
        font-size: 16px !important;
    }
    
    .red-packet-amount {
        font-size: 28px !important;
    }
    
    .fixed-red-packet {
        left: 12px !important;
        width: 42px !important;
        height: 50px !important;
    }
}

/* ========== 确保样式优先级 ========== */
html .red-packet-overlay,
body .red-packet-overlay {
    display: block !important;
    visibility: visible !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

html .red-packet-modal,
body .red-packet-modal {
    display: block !important;
    visibility: visible !important;
}

/* 防止其他样式干扰 */
.red-packet-overlay * {
    box-sizing: border-box !important;
}

.red-packet-modal * {
    box-sizing: border-box !important;
}

/* ========== 红包提示文字样式 ========== */
.red-packet-tip {
    position: fixed !important;
    left: 40px !important;
    top: 148px !important;
    width: 60px !important;
    font-size: 10px !important;
    color: #ff4500 !important;
    text-align: center !important;
    font-weight: bold !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3) !important;
    z-index: 999999 !important;
    animation: none !important;
    transition: opacity 0.3s ease !important;
    transform: translateX(-50%) !important;
    line-height: 1.2 !important;
    letter-spacing: 0.5px !important;
}

/* 提示文字闪烁动画 */
@keyframes tipBlink {
    0%, 50% {
        opacity: 1;
        color: #ff4500;
    }
    25%, 75% {
        opacity: 0.6;
        color: #ff6b35;
    }
}

/* 提示文字隐藏状态 */
.red-packet-tip.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* 移动端适配 */
@media (max-width: 480px) {
    .red-packet-tip {
        font-size: 9px !important;
        top: 138px !important;
        left: 33px !important;
        width: 50px !important;
    }
}

/* ========== 淡入动画效果 ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== 闪光效果 ========== */
.red-packet-modal:hover::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 1s ease-in-out;
    z-index: 2;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* ========== 红包加载动画 ========== */
.red-packet-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
}

.loading-animation {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.loading-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ffeb3b;
    animation: loadingBounce 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.loading-text {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
    animation: pulse 1.5s infinite ease-in-out;
}

/* 加载动画关键帧 */
@keyframes loadingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* ========== 金额动画 ========== */
.red-packet-amount-container {
    position: relative;
    margin: 20px 0;
    min-height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.red-packet-amount {
    font-size: 36px !important;
    font-weight: bold !important;
    color: #ffeb3b !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 235, 59, 0.8) !important;
    position: relative;
    z-index: 10;
}

/* 金额出现动画 */
@keyframes amountAppear {
    0% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
        filter: blur(10px);
    }
    50% {
        transform: scale(1.2) rotate(90deg);
        opacity: 0.8;
        filter: blur(5px);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
        filter: blur(0);
    }
}

/* 金额脉冲动画 */
@keyframes amountPulse {
    0% {
        transform: scale(1);
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 235, 59, 0.8);
    }
    50% {
        transform: scale(1.05);
        text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.4), 0 0 30px rgba(255, 235, 59, 1);
    }
    100% {
        transform: scale(1);
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 235, 59, 0.8);
    }
}

/* ========== 彩纸效果 ========== */
.red-packet-confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 5;
}

.confetti-piece {
    position: absolute;
    pointer-events: none;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(400px) rotate(720deg);
        opacity: 0;
    }
}

/* ========== 提示文字动画效果 ========== */
@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    40%, 43% {
        transform: translateX(-50%) translateY(-10px);
    }
    70% {
        transform: translateX(-50%) translateY(-5px);
    }
    90% {
        transform: translateX(-50%) translateY(-2px);
    }
}

@keyframes swing {
    0% {
        transform: translateX(-50%) rotate(0deg);
    }
    20% {
        transform: translateX(-50%) rotate(15deg);
    }
    40% {
        transform: translateX(-50%) rotate(-10deg);
    }
    60% {
        transform: translateX(-50%) rotate(5deg);
    }
    80% {
        transform: translateX(-50%) rotate(-5deg);
    }
    100% {
        transform: translateX(-50%) rotate(0deg);
    }
}

@keyframes tada {
    0% {
        transform: translateX(-50%) scale(1);
    }
    10%, 20% {
        transform: translateX(-50%) scale(0.9) rotate(-3deg);
    }
    30%, 50%, 70%, 90% {
        transform: translateX(-50%) scale(1.1) rotate(3deg);
    }
    40%, 60%, 80% {
        transform: translateX(-50%) scale(1.1) rotate(-3deg);
    }
    100% {
        transform: translateX(-50%) scale(1) rotate(0);
    }
}

/* ========== 红包加载动画 ========== */
.red-packet-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
}

.loading-animation {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.loading-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ffeb3b;
    animation: loadingBounce 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.loading-text {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
    animation: pulse 1.5s infinite ease-in-out;
}

/* 加载动画关键帧 */
@keyframes loadingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* ========== 金额动画 ========== */
.red-packet-amount-container {
    position: relative;
    margin: 20px 0;
    min-height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.red-packet-amount {
    font-size: 36px !important;
    font-weight: bold !important;
    color: #ffeb3b !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 235, 59, 0.8) !important;
    position: relative;
    z-index: 10;
}

/* 金额出现动画 */
@keyframes amountAppear {
    0% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
        filter: blur(10px);
    }
    50% {
        transform: scale(1.2) rotate(90deg);
        opacity: 0.8;
        filter: blur(5px);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
        filter: blur(0);
    }
}

/* 金额脉冲动画 */
@keyframes amountPulse {
    0% {
        transform: scale(1);
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 235, 59, 0.8);
    }
    50% {
        transform: scale(1.05);
        text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.4), 0 0 30px rgba(255, 235, 59, 1);
    }
    100% {
        transform: scale(1);
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 235, 59, 0.8);
    }
}

/* ========== 彩纸效果 ========== */
.red-packet-confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 5;
}

.confetti-piece {
    position: absolute;
    pointer-events: none;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(400px) rotate(720deg);
        opacity: 0;
    }
}

/* ========== 光芒效果 ========== */
.red-packet-modal::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle at center,
        rgba(255, 235, 59, 0.3) 0%,
        rgba(255, 193, 7, 0.2) 30%,
        rgba(255, 152, 0, 0.1) 60%,
        transparent 100%
    );
    opacity: 0;
    z-index: 1;
    pointer-events: none;
    animation: rayBurst 3s ease-in-out 2s;
}

@keyframes rayBurst {
    0%, 100% {
        opacity: 0;
        transform: scale(0.8) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1) rotate(180deg);
    }
}

/* ========== 增强版弹窗背景 ========== */
.red-packet-modal {
    position: relative;
    overflow: hidden;
}

.red-packet-modal::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('../img/red-packet-pattern.png') repeat;
    opacity: 0.1;
    pointer-events: none;
    z-index: 1;
}

/* 确保内容在特效上层 */
.red-packet-header,
.red-packet-amount-container,
.red-packet-footer {
    position: relative;
    z-index: 10;
}

/* ========== 增强版按钮样式 ========== */
.red-packet-close {
    z-index: 20;
}

/* ========== 移动端动画优化 ========== */
@media (max-width: 480px) and (prefers-reduced-motion: no-preference) {
    .red-packet-modal {
        animation: redPacketShowMobile 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    }
    
    @keyframes redPacketShowMobile {
        0% {
            transform: translate(-50%, -50%) scale(0.3);
            opacity: 0;
        }
        70% {
            transform: translate(-50%, -50%) scale(1.1);
            opacity: 0.9;
        }
        100% {
            transform: translate(-50%, -50%) scale(1);
            opacity: 1;
        }
    }
}

/* ========== 性能优化 ========== */
@media (prefers-reduced-motion: reduce) {
    .red-packet-loading,
    .loading-animation,
    .loading-dot,
    .loading-text,
    .red-packet-amount,
    .confetti-piece,
    .red-packet-modal::before {
        animation: none !important;
    }
    
    .red-packet-amount {
        transform: none !important;
    }
}