/* 基础布局 */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: Arial, sans-serif;
    background: #000;
    color: #fff;
}

/* UI 覆盖层 */
.ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000; /* 🔧 恢复原值，User Corner已移出此层级 */
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.ui-overlay > * {
    pointer-events: auto;
}

/* 内容包装器 */
.content-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    z-index: 1001;
    transition: transform 0.3s ease;
}

/* 当侧边栏打开时，内容向右移动 */
.sidebar-open .content-wrapper {
    transform: translateX(300px);
}

/* 标题样式 */
.main-title {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 2.2em;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
    position: absolute;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    text-align: center;
    margin: 0;
    padding: 0 20px;
    box-sizing: border-box;
    letter-spacing: 2px;
}

.subtitle {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 1.4em;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    margin: 0;
    padding: 0 20px;
    box-sizing: border-box;
    letter-spacing: 1px;
}

/* 输入区域样式 */
.input-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 1001;
    pointer-events: auto;
}

#question-input {
    width: 100%;
    min-height: 100px;
    padding: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 18px;
    resize: vertical;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    box-sizing: border-box;
    position: relative;
    z-index: 1001;
    pointer-events: auto !important;
}

#question-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

/* 🎯 命运抉择牌阵的AB选项输入框样式 */
.choice-options-container {
    width: 100%;
    margin-top: 8px;
    display: flex;
    gap: 12px;
    animation: fadeInUp 0.4s ease;
    position: relative; /* 🔧 确保z-index生效 */
    z-index: 1; /* 🔧 设置较低的z-index，确保不会覆盖卡牌 */
    pointer-events: auto; /* 🔧 默认启用点击事件 */
}

.choice-option-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.choice-option-label {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.choice-option-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 14px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.choice-option-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.choice-option-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 开始按钮样式 */
.start-button, .button {
    padding: 15px 40px;
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(45, 45, 45, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin-top: 20px;
    position: relative;
    z-index: 1001;
    pointer-events: auto !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.start-button:hover, .button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
    background: rgba(55, 55, 55, 0.9);
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.95);
}

.start-button:active, .button:active {
    transform: translateY(1px);
}

/* 部分样式 */
.section {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    text-align: center;
    position: relative;
    z-index: 101;
}

.section.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.section h2 {
    color: #ffffff;
    font-size: 1.8em;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

#questionSection {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    pointer-events: auto;
}

/* 动画层样式 */
.animation-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#p5-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

#three-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: auto;
}

#three-container canvas {
    pointer-events: auto !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main-title {
        font-size: 1.8em;
        top: 10%;
    }

    .subtitle {
        font-size: 1.2em;
        top: 22%;
    }

    .input-container {
        width: 95%;
        max-width: 700px;
    }

    #question-input {
        height: 70px;
        min-height: 70px;
        font-size: 1.1em;
    }

    .choice-options-container {
        gap: 8px;
        margin-top: 6px;
    }

    .choice-option-input {
        padding: 8px 10px;
        font-size: 13px;
    }

    .choice-option-label {
        font-size: 12px;
    }

    .start-button {
        padding: 12px 30px;
        font-size: 1.1em;
    }
    
    /* 🎯 手机端调整"请选择x张牌"的位置（往下移） */
    #drawSection h2 {
        margin-top: 80px; /* 增加顶部间距，避免和按钮重合 */
    }
    
    /* 🎯 手机端隐藏"您的占卜结果" */
    #resultSection h2 {
        display: none !important;
    }
}

@media (max-width: 540px) {
    .main-title {
        font-size: 1.6em;
        top: 10%; /* 🔧 与768px保持一致，防止标题向上跳动 */
    }
    
    .input-container {
        top: 49%; /* 🔧 在540px-480px之间稍微调整，平滑过渡 */
    }
}

@media (max-width: 480px) {
    .main-title {
        font-size: 1.5em;
        top: 10%; /* 🔧 保持与768px和540px一致，防止标题向上移动过多 */
    }

    .subtitle {
        font-size: 1.1em;
        top: 20%;
    }

    .input-container {
        width: 95%;
        max-width: none;
        padding: 0 10px;
        top: 48%; /* 🔧 在移动端稍微往上移动，避免视觉上显得过于靠下 */
    }

    #question-input {
        height: 70px;
        font-size: 1em;
    }

    .start-button {
        padding: 10px 25px;
        font-size: 1em;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

#shuffleSection h2 {
    color: #ffffff;
    font-size: 1.8em;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    /* animation: pulse 2s infinite; */
    transition: opacity 0.3s ease;
}

/* 洗牌部分样式 */
#shuffleSection {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    text-align: center;
    z-index: 1001;
}

#shuffleSection.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transform: translateY(0);
}

#shuffleSection .button-container {
    position: fixed;
    bottom: 25%;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1002;
}

#finish-shuffle-button {
    padding: 15px 40px;
    font-size: 1.3em;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(45, 45, 45, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    display: none;
    opacity: 0;
    transform: translateY(20px);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#finish-shuffle-button.visible {
    display: inline-block;
    opacity: 1;
    transform: translateY(0);
}

#finish-shuffle-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
    background: rgba(55, 55, 55, 0.9);
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.95);
}

#finish-shuffle-button:active {
    transform: translateY(1px);
}

#shuffleSection.button-visible h2 {
    opacity: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
    }
}

/* 翻转阶段样式 - 使用和 drawSection 相同的定位方式 */
#flipSection {
    /* 继承 .section 的基本样式，不使用居中定位 */
    pointer-events: none;
    z-index: 1001;
}

#flipSection.active {
    opacity: 1;
    transform: translateY(0);
}

#flipSection h2 {
    color: #ffffff;
    font-size: 1.8em;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    /* 🎯 手机端和 drawSection 保持一致 */
}

@media (max-width: 768px) {
    /* 🎯 手机端调整"点击卡牌查看结果"的位置（和"请选择x张牌"一致） */
    #flipSection h2 {
        margin-top: 80px; /* 和 drawSection 保持一致 */
    }
}

#flipSection p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.2em;
    margin: 0;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* 🔧 新增：卡牌名称显示样式 */
.card-name-display {
    position: fixed;
    z-index: 1003;
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    text-align: center;
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
    pointer-events: none;
    max-width: 90%; /* 🔧 限制最大宽度 */
}

.card-name-display.show {
    opacity: 1 !important;
    transform: translate(-50%, -50%) !important;
}

/* 🎯 英文语言：缩小卡牌名称字号 */
html[lang="en"] .card-name-display {
    font-size: 13px; /* 从 18px 缩小到 13px（共5号） */
}

/* 🎯 卡牌名称内部的正逆位信息样式 */
.card-orientation {
    display: block;
    font-size: 0.85em;
    font-weight: normal;
    margin-top: 4px;
    opacity: 0.9;
}

html[lang="en"] .card-orientation {
    font-size: 0.8em; /* 相对于已缩小的基础字号 */
}

/* 🔧 修复：卡牌信息显示样式 */
.card-info-display {
    position: fixed;
    z-index: 1002;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    color: white;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
    width: 280px;
    max-width: 90vw;
    box-sizing: border-box;
}

.card-info-display.show {
    opacity: 1 !important;
    transform: translateX(-50%) translateY(0) !important;
}

.card-info-content {
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.card-info-display .card-meaning {
    margin: 0;
    font-size: 1em;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* 🎯 英文语言：缩小卡牌信息框字号 */
html[lang="en"] .card-info-display {
    font-size: 0.85em; /* 缩小基础字号 */
}

html[lang="en"] .card-info-display .card-meaning {
    font-size: 0.95em; /* 相对于已缩小的基础字号 */
}

/* 响应式设计 - 卡牌名称显示 */
@media (max-width: 768px) {
    .card-name-display {
        font-size: 14px; /* 从16px缩小到14px */
    }
    
    .card-info-display {
        width: 180px; /* 从250px缩小到180px，避免重叠 */
        padding: 10px 12px; /* 减小内边距 */
        font-size: 0.8em; /* 从0.9em缩小到0.8em */
    }
    
    .card-info-display .card-meaning {
        font-size: 0.85em; /* 从0.9em缩小到0.85em */
        line-height: 1.3; /* 减小行高 */
    }
}

@media (max-width: 480px) {
    .card-name-display {
        font-size: 12px; /* 从14px进一步缩小到12px */
    }
    
    .card-info-display {
        width: 160px; /* 从220px进一步缩小到160px */
        padding: 8px 10px; /* 进一步减小内边距 */
        font-size: 0.75em; /* 从0.85em进一步缩小到0.75em */
    }
    
    .card-info-display .card-meaning {
        font-size: 0.8em; /* 保持0.8em */
        line-height: 1.3; /* 从1.4减小到1.3 */
    }
}

/* AI解读按钮样式 */
.ai-interpretation-button.show {
    opacity: 1 !important;
    transform: translateX(-50%) translateY(0) !important;
}

.ai-interpretation-button:hover {
    transform: translateX(-50%) translateY(-5px) !important;
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.6) !important;
}

.ai-interpretation-button:active {
    transform: translateX(-50%) translateY(-2px) !important;
}

/* AI解读内容样式 */
.ai-interpretation-content {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
    margin-top: 20px;
}

.ai-interpretation-content.show {
    opacity: 1;
    transform: translateY(0);
}

.interpretation-subtitle {
    color: #667eea;
    font-size: 1.2em;
    font-weight: bold;
    margin: 20px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.3);
}

.interpretation-paragraph {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    margin: 15px 0;
    text-align: justify;
    text-justify: inter-ideograph;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .ai-interpretation-button {
        bottom: 20px !important;
        padding: 12px 24px !important;
        font-size: 14px !important;
    }
    
    .interpretation-subtitle {
        font-size: 1.1em;
    }
    
    .interpretation-paragraph {
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    .ai-interpretation-button {
        bottom: 15px !important;
        padding: 10px 20px !important;
        font-size: 13px !important;
    }
    
    .interpretation-subtitle {
        font-size: 1em;
    }
    
    .interpretation-paragraph {
        font-size: 0.85em;
    }
}



