/* Ink Green Theme Variables - Light Version */
:root {
    --primary-purple: #0c3b2e; /* 墨绿色 - 主色调 */
    --secondary-purple: #1d5746; /* 浅墨绿 */
    --accent-gold: #d4af37;
    --text-main: #0c3b2e; /* 墨绿色文字 */
    --bg-main: #ffffff; /* 白色背景 */
    --bg-card: #f8f9fa; /* 卡片背景 */
}

/* Global Styles */
body {
    background-color: var(--bg-main) !important;
    background: var(--bg-main) !important;
    color: var(--text-main) !important;
}

/* Modal Content Override */
.modal-content {
    background: #ffffff;
    border: 2px solid var(--primary-purple);
    color: var(--text-main);
}

/* 输入框样式适配 */
#questionInput {
    color: var(--primary-purple) !important;
    border-color: var(--primary-purple) !important;
}

#questionInput::placeholder {
    color: rgba(12, 59, 46, 0.5) !important;
}

#questionInput:focus {
    box-shadow: 0 0 0 0.25rem rgba(12, 59, 46, 0.25);
}

/* 按钮样式重写 - 墨绿色风格 */
.btn-warning {
    background: var(--primary-purple) !important;
    border-color: var(--primary-purple) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 6px rgba(12, 59, 46, 0.3) !important;
}

.btn-warning:hover {
    background: var(--secondary-purple) !important;
    border-color: var(--secondary-purple) !important;
}

/* 性别选择按钮适配 */
.btn-outline-warning {
    color: var(--primary-purple) !important;
    border-color: var(--primary-purple) !important;
}

.btn-outline-warning:hover {
    background-color: var(--primary-purple) !important;
    color: #ffffff !important;
}

.btn-check:checked + .btn-outline-warning {
    background-color: var(--primary-purple) !important;
    border-color: var(--primary-purple) !important;
    color: #ffffff !important;
}

/* 文字颜色覆盖 */
.text-warning {
    color: var(--primary-purple) !important;
}

/* Custom CSS - 配合Bootstrap使用 */

/* 全局禁止水平滚动 */
html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
    position: relative; /* 确保定位参考 */
}

/* 确保主容器也不会溢出 */
.flex-fill {
    max-width: 100vw;
    overflow-x: hidden;
}

/* 输入框 placeholder 样式 */
#questionInput::placeholder {
    color: rgba(12, 59, 46, 0.5) !important;
}

#questionInput:focus {
    box-shadow: 0 0 0 0.25rem rgba(212, 175, 55, 0.25);
}

/* 移动端调整控件布局 */
@media (max-width: 767px) {
    #userControls {
        flex-direction: column;
        align-items: stretch !important;
        transform: scale(0.9); /* 整体缩小控件 */
        transform-origin: top center;
        margin-bottom: 2rem !important; /* 补偿缩放后的间距 */
    }
    
    .control-group {
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .btn-group {
        width: 100%;
    }
    
    .btn-group .btn {
        flex: 1;
    }
    
    #questionInput {
        text-align: center;
    }
    
    button[onclick="startDivination"] {
        width: 100%;
    }
}

/* 结果弹窗 - Bootstrap Modal 样式优化 - 统一版本 */
.modal-content {
    max-height: 90vh;
    overflow-y: hidden; /* 防止出现滚动条 */
}

/* 弹窗图片容器通用样式 */
.modal-img-container {
    width: 100%;
    background-color: rgba(0,0,0,0.02);
}

/* 弹窗图片通用样式 */
#resultImage {
    object-fit: contain;
    border-radius: 8px;
    width: 100%;
    height: 100%;
    /* transition: transform 0.3s ease; 移除互动效果 */
}

/* 桌面设备弹窗优化 - 左右布局 */
@media (min-width: 992px) { /* lg breakpoint */
    .modal-dialog {
        max-width: 900px; /* 加宽以适应左右布局 */
        margin: 2rem auto;
    }
    
    .modal-content {
        max-height: 85vh;
        min-height: 500px; /* 保证最小高度 */
    }

    /* 图片容器占左半边 */
    .modal-img-container {
        width: 50%;
        height: auto;
        min-height: 100%;
        border-right: 1px solid rgba(212, 175, 55, 0.2); /* 金色分割线 */
    }

    #resultImage {
        max-height: 75vh;
        padding: 20px;
    }
    
    /* 移除悬停放大效果
    #resultImage:hover {
        transform: scale(1.05);
    }
    */
}

/* 移动端和平板设备 - 上下布局 */
@media (max-width: 991px) {
    #resultImage {
        width: auto;
        height: auto;
        max-width: 90%;
        max-height: 90%;
        object-fit: contain;
        padding: 0;
    }
    
    .modal-img-container {
        padding: 0;
        flex: 1 1 auto; /* 让图片区域占据主要空间 */
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 50%; /* 保证图片区域至少占一半高度 */
        width: 100%;
        overflow: hidden;
    }

    .modal-body {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }

    /* 调整内容区域紧凑度 */
    .modal-body > .flex-fill {
        flex: 0 0 auto !important; /* 不伸缩，由内容决定高度 */
        max-height: none; /* 移除最大高度限制 */
        padding: 5px 15px !important;
        /* 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: 92vw;
        margin: 1rem auto;
    }
    
    .modal-content {
        max-height: 82vh;
    }

    /* 移动端标题优化 */
    h1.display-1 {
        font-size: 2.5rem;
    }
}

/* 卡片容器样式 - 简化动画适配 */
#cardDisplay {
    overflow: visible !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) {
    #userControls {
        transform: scale(0.95); /* 桌面端稍微缩小 */
    }

    .card {
        width: 150px; /* 原160px */
        min-height: 225px; /* 原240px */
        padding: 0.9rem;
        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 */