/* 自定义CSS - 配合Bootstrap使用 */

/* Bootstrap Modal 样式优化 - 统一版本 */
.modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

/* 桌面设备弹窗优化 */
@media (min-width: 1025px) {
    .modal-dialog {
        max-width: 800px;
        margin: 1.75rem auto;
    }
    
    .modal-content {
        max-height: 85vh;
    }
}

/* 平板设备弹窗优化 */
@media (min-width: 768px) and (max-width: 1024px) {
    .modal-dialog {
        max-width: 85vw;
        margin: 1rem auto;
    }
    
    .modal-content {
        max-height: 85vh;
    }
    
    /* 平板横屏模式优化 */
    @media (orientation: landscape) {
        .modal-dialog {
            max-width: 75vw;
        }
        
        .modal-content {
            max-height: 80vh;
        }
    }
    
    /* 平板竖屏模式优化 */
    @media (orientation: portrait) {
        .modal-dialog {
            max-width: 90vw;
        }
        
        .modal-content {
            max-height: 85vh;
        }
    }
}

/* 移动设备弹窗优化 */
@media (max-width: 767px) {
    .modal-dialog {
        max-width: 95vw;
        margin: 0.5rem auto;
    }
    
    .modal-content {
        max-height: 90vh;
    }
}

/* 卡片容器样式 - 简化动画适配 */
#cardDisplay {
    overflow: hidden !important;
    position: relative !important;
    padding: 40px 20px !important;
    margin: 15px 0 !important;
    min-height: 300px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 响应式调整容器 */
/* 平板设备专用优化 */
@media (min-width: 768px) and (max-width: 1024px) {
    #cardDisplay {
        padding: 45px 25px !important;
        min-height: 320px !important;
    }
    
    /* 平板横屏模式 */
    @media (orientation: landscape) {
        #cardDisplay {
            padding: 35px 40px !important;
            min-height: 280px !important;
        }
    }
    
    /* 平板竖屏模式 */
    @media (orientation: portrait) {
        #cardDisplay {
            padding: 50px 20px !important;
            min-height: 350px !important;
        }
    }
}

/* 大屏设备 */
@media (min-width: 1025px) {
    #cardDisplay {
        padding: 60px 40px !important;
        min-height: 400px !important;
    }
}

/* 卡片样式 - 响应式设计 */
.card {
    position: absolute;
    transform-origin: center center;
    width: 80px;
    height: auto;
    min-height: 120px;
    top: 0;
    left: 0;
    margin: 5px 0;
    padding: 0.5rem;
    z-index: 1;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: visible;
    border-radius: 10px;
    /* 参考reference.html的阴影效果 */
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    background: linear-gradient(135deg, #ffffff, #f8f8f8);
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* 3D变换支持 */
    transform-style: preserve-3d;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* 卡片悬停和触摸效果 */
.card:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.card:active {
    transform: translateY(0) scale(0.98);
    transition: all 0.1s ease;
}

/* 移动设备触摸优化 */
@media (hover: none) and (pointer: coarse) {
    .card:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }
    
    .card:active {
        transform: scale(0.95);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    }
}

/* 平板设备专用卡片尺寸 */
@media (min-width: 768px) and (max-width: 1024px) {
    .card {
        width: 110px;
        min-height: 165px;
        padding: 0.7rem;
        border-radius: 10px;
    }
    
    /* 平板横屏模式 - 卡片稍小 */
    @media (orientation: landscape) {
        .card {
            width: 100px;
            min-height: 150px;
            padding: 0.6rem;
        }
    }
    
    /* 平板竖屏模式 - 卡片稍大 */
    @media (orientation: portrait) {
        .card {
            width: 120px;
            min-height: 180px;
            padding: 0.75rem;
        }
    }
}

/* 桌面设备 */
@media (min-width: 1025px) {
    .card {
        width: 160px;
        min-height: 240px;
        padding: 1rem;
        border-radius: 12px;
    }
}

/* 大屏设备 */
@media (min-width: 1280px) {
    .card {
        width: 180px;
        min-height: 270px;
    }
}

/* 卡片图片 - 响应式 */
.card img {
    width: 100%;
    height: auto;
    max-height: 90px;
    min-height: 70px;
    object-fit: contain;
    margin: 0 auto;
    flex-shrink: 0;
    border-radius: 6px;
}

/* 平板设备图片尺寸 */
@media (min-width: 768px) and (max-width: 1024px) {
    .card img {
        max-height: 125px;
        min-height: 100px;
        border-radius: 8px;
    }
    
    /* 平板横屏模式 - 图片稍小 */
    @media (orientation: landscape) {
        .card img {
            max-height: 110px;
            min-height: 90px;
        }
    }
    
    /* 平板竖屏模式 - 图片稍大 */
    @media (orientation: portrait) {
        .card img {
            max-height: 140px;
            min-height: 110px;
        }
    }
}

/* 桌面设备图片 */
@media (min-width: 1025px) {
    .card img {
        max-height: 200px;
        min-height: 160px;
        border-radius: 10px;
    }
}

@media (min-width: 1280px) {
    .card img {
        max-height: 240px;
        min-height: 200px;
        border-radius: 12px;
    }
}

/* 卡片文字 - 响应式 */
.card h3 {
    color: #d4af37;
    margin: 0.25rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
}

/* 平板设备文字尺寸 */
@media (min-width: 768px) and (max-width: 1024px) {
    .card h3 {
        font-size: 0.9rem;
        margin: 0.3rem 0;
        line-height: 1.3;
    }
    
    /* 平板横屏模式 - 文字稍小 */
    @media (orientation: landscape) {
        .card h3 {
            font-size: 0.85rem;
            margin: 0.25rem 0;
        }
    }
    
    /* 平板竖屏模式 - 文字稍大 */
    @media (orientation: portrait) {
        .card h3 {
            font-size: 1rem;
            margin: 0.375rem 0;
        }
    }
}

/* 桌面设备文字 */
@media (min-width: 1025px) {
    .card h3 {
        font-size: 1.25rem;
        margin: 0.5rem 0;
    }
}

@media (min-width: 1280px) {
    .card h3 {
        font-size: 1.5rem;
    }
}

.card p {
    font-size: 0.625rem;
    line-height: 1.2;
    opacity: 0.8;
    margin: 0;
}

/* 平板设备段落文字 */
@media (min-width: 768px) and (max-width: 1024px) {
    .card p {
        font-size: 0.7rem;
        line-height: 1.3;
    }
    
    @media (orientation: landscape) {
        .card p {
            font-size: 0.65rem;
        }
    }
    
    @media (orientation: portrait) {
        .card p {
            font-size: 0.75rem;
        }
    }
}

/* 桌面设备段落文字 */
@media (min-width: 1025px) {
    .card p {
        font-size: 0.875rem;
    }
}

@media (min-width: 1280px) {
    .card p {
        font-size: 1rem;
    }
}

/* 结果卡片样式 */
.card.result-card {
    width: 200px;
    height: 300px;
    position: relative;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border: 2px solid #d4af37;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.card.result-card h3 {
    position: absolute;
    bottom: 60px;
    left: 10px;
    right: 10px;
    margin: 0;
    padding: 8px;
    background: rgba(255,255,255,0.9);
    border-radius: 4px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.card.result-card p {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    margin: 0;
    padding: 6px;
    background: rgba(255,255,255,0.8);
    border-radius: 4px;
    text-align: center;
    font-size: 12px;
    color: #666;
    line-height: 1.3;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bootstrap Modal 自定义样式已移除，现在使用Bootstrap 5原生模态框 */

/* 关于页面蒙层 */
.about-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.about-content {
    background: #1a1a1a;
    color: #e0e0e0;
    padding: 2rem;
    border-radius: 12px;
    max-width: 600px;
    position: relative;
    border: 2px solid #d4af37;
}

.qr-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-top: 1.5rem;
}

.qr-item img {
    width: 200px;
    height: auto;
    border: 2px solid #d4af37;
    border-radius: 8px;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 2rem;
    background: none;
    border: none;
    color: #d4af37;
    cursor: pointer;
}

/* 动画定义 - 基础版本（小屏设备） */
@keyframes fanSpread {
    0% { transform: rotate(0deg) translateY(0); }
    50% { transform: rotate(var(--rot)) translateY(-12px); }
    100% { transform: rotate(var(--rot)) translateY(-8px); }
}

@keyframes collectCards {
    0% { transform: rotate(var(--rot)) translateY(-8px); }
    100% { transform: rotate(0deg) translateY(0px); }
}

@keyframes reshuffleSpread {
    0% { transform: rotate(0deg) translateY(0px); }
    100% { transform: rotate(var(--rot)) translateY(-10px); }
}

@keyframes popOutCard {
    0% { 
        transform: rotate(var(--rot)) translateY(-10px) scale(1);
        opacity: 1;
        z-index: 1;
    }
    50% { 
        transform: rotate(0deg) translateY(-60px) scale(1.1);
        opacity: 1;
        z-index: 999;
    }
    100% { 
        transform: rotate(0deg) translateY(-50px) scale(1.2);
        opacity: 1;
        z-index: 999;
    }
}

@keyframes fadeOutOthers {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes flipCard {
    0% { 
        transform: rotate(0deg) translateY(-50px) scale(1.2) rotateY(0deg);
    }
    50% { 
        transform: rotate(0deg) translateY(-50px) scale(1.2) rotateY(90deg);
    }
    100% { 
        transform: rotate(0deg) translateY(-50px) scale(1.3) rotateY(0deg);
    }
}

@keyframes finalScale {
    0% { 
        transform: rotate(0deg) translateY(-50px) scale(1.3);
    }
    100% { 
        transform: rotate(0deg) translateY(-45px) scale(1.4);
    }
}

/* 平板设备动画优化 */
@media (min-width: 768px) {
    @keyframes fanSpread {
        0% { transform: rotate(0deg) translateY(0); }
        50% { transform: rotate(var(--rot)) translateY(-15px); }
        100% { transform: rotate(var(--rot)) translateY(-12px); }
    }
    
    @keyframes collectCards {
        0% { transform: rotate(var(--rot)) translateY(-12px); }
        100% { transform: rotate(0deg) translateY(0px); }
    }
    
    @keyframes reshuffleSpread {
        0% { transform: rotate(0deg) translateY(0px); }
        100% { transform: rotate(var(--rot)) translateY(-13px); }
    }
    
    @keyframes popOutCard {
        0% { 
            transform: rotate(var(--rot)) translateY(-13px) scale(1);
            opacity: 1;
            z-index: 1;
        }
        50% { 
            transform: rotate(0deg) translateY(-90px) scale(1.15);
            opacity: 1;
            z-index: 999;
        }
        100% { 
            transform: rotate(0deg) translateY(-75px) scale(1.25);
            opacity: 1;
            z-index: 999;
        }
    }
    
    @keyframes flipCard {
        0% { 
            transform: rotate(0deg) translateY(-75px) scale(1.25) rotateY(0deg);
        }
        50% { 
            transform: rotate(0deg) translateY(-75px) scale(1.25) rotateY(90deg);
        }
        100% { 
            transform: rotate(0deg) translateY(-75px) scale(1.4) rotateY(0deg);
        }
    }
    
    @keyframes finalScale {
        0% { 
            transform: rotate(0deg) translateY(-75px) scale(1.4);
        }
        100% { 
            transform: rotate(0deg) translateY(-65px) scale(1.6);
        }
    }
}

/* 桌面设备动画优化 */
@media (min-width: 1025px) {
    @keyframes fanSpread {
        0% { transform: rotate(0deg) translateY(0); }
        50% { transform: rotate(var(--rot)) translateY(-18px); }
        100% { transform: rotate(var(--rot)) translateY(-15px); }
    }
    
    @keyframes collectCards {
        0% { transform: rotate(var(--rot)) translateY(-15px); }
        100% { transform: rotate(0deg) translateY(0px); }
    }
    
    @keyframes reshuffleSpread {
        0% { transform: rotate(0deg) translateY(0px); }
        100% { transform: rotate(var(--rot)) translateY(-16px); }
    }
    
    @keyframes popOutCard {
        0% { 
            transform: rotate(var(--rot)) translateY(-16px) scale(1);
            opacity: 1;
            z-index: 1;
        }
        50% { 
            transform: rotate(0deg) translateY(-110px) scale(1.2);
            opacity: 1;
            z-index: 999;
        }
        100% { 
            transform: rotate(0deg) translateY(-90px) scale(1.3);
            opacity: 1;
            z-index: 999;
        }
    }
    
    @keyframes flipCard {
        0% { 
            transform: rotate(0deg) translateY(-90px) scale(1.3) rotateY(0deg);
        }
        50% { 
            transform: rotate(0deg) translateY(-90px) scale(1.3) rotateY(90deg);
        }
        100% { 
            transform: rotate(0deg) translateY(-90px) scale(1.5) rotateY(0deg);
        }
    }
    
    @keyframes finalScale {
        0% { 
            transform: rotate(0deg) translateY(-90px) scale(1.5);
        }
        100% { 
            transform: rotate(0deg) translateY(-75px) scale(1.7);
        }
    }
}

/* 大屏设备动画优化 */
@media (min-width: 1280px) {
    @keyframes popOutCard {
        0% { 
            transform: rotate(var(--rot)) translateY(-18px) scale(1);
            opacity: 1;
            z-index: 1;
        }
        50% { 
            transform: rotate(0deg) translateY(-120px) scale(1.2);
            opacity: 1;
            z-index: 999;
        }
        100% { 
            transform: rotate(0deg) translateY(-100px) scale(1.3);
            opacity: 1;
            z-index: 999;
        }
    }
    
    @keyframes flipCard {
        0% { 
            transform: rotate(0deg) translateY(-100px) scale(1.3) rotateY(0deg);
        }
        50% { 
            transform: rotate(0deg) translateY(-100px) scale(1.3) rotateY(90deg);
        }
        100% { 
            transform: rotate(0deg) translateY(-100px) scale(1.5) rotateY(0deg);
        }
    }
    
    @keyframes finalScale {
        0% { 
            transform: rotate(0deg) translateY(-100px) scale(1.5);
        }
        100% { 
            transform: rotate(0deg) translateY(-80px) scale(1.8);
        }
    }
}

/* 动画类 */
.card.init-animation {
    animation: fanSpread 1s ease-in-out forwards;
}

.card.collect-animation {
    animation: collectCards 0.8s ease-in-out forwards;
}

.card.reshuffle-animation {
    animation: reshuffleSpread 0.6s ease-out forwards;
}

.card.pop-out {
    animation: popOutCard 1s ease-out forwards;
    z-index: 999 !important;
}

.card.fade-out {
    animation: fadeOutOthers 0.5s ease-out forwards;
}

.card.flip-reveal {
    animation: flipCard 1.2s ease-in-out forwards;
    z-index: 999 !important;
}

.card.final-scale {
    animation: finalScale 0.8s ease-out forwards;
    z-index: 999 !important;
}

/* 初始化扇形排列 */
.card:nth-child(n) {
    transform: rotate(var(--rot)) translateY(-50px);
}

/* 性能优化 */
.card.init-animation,
.card.highlight,
.shuffling .card {
    will-change: transform;
}

/* 旧的result-modal样式已删除，现在完全使用Bootstrap Modal */