/* 移动端样式优化 */
@media (max-width: 768px) {
    /* 返回主页按钮只显示图标 */
    .back-btn span {
        display: none;
    }

    .test-intro {
        margin-top: 80px; /* 确保与顶部栏有足够间距 */
    }
    
    #testIntro {
        position: relative;
        top: 0; /* 重置位置，不覆盖顶部栏 */
    }

    /* 调整返回按钮样式 */
    .back-btn {
        padding: 8px;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 调整页面标题样式 */
    .page-title h1 {
        font-size: 16px;
    }
    
    /* 确保标题图标与页面图标一致 */
    .page-title i {
        font-size: 20px;
    }
    
    /* 调整问题导航按钮，防止底部被裁切 */
    .question-navigation {
        padding-bottom: 30px;
        margin-top: -20px !important; /* 或者 -10px，如果想紧贴问题卡片 */
    }
    
    .nav-btn {
        width: 50px;
        height: 50px;
    }
    
    /* 移动端内嵌禁用状态样式 */
    .nav-btn.disabled-embedded {
        opacity: 0.15 !important; /* 使用和上一题按钮相同的透明度 */
        cursor: not-allowed;
        background: rgba(30, 30, 40, 0.3) !important;
        border: 2px solid rgba(255, 255, 255, 0.05) !important;
        color: rgba(255, 255, 255, 0.2) !important;
        transform: scale(0.85) !important; /* 使用和上一题按钮相同的缩放 */
        box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3) !important;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        pointer-events: none; /* 完全禁用点击事件 */
    }
    
    /* 确保下一题按钮禁用状态和上一题按钮完全一致 */
    .next-btn.disabled-embedded {
        opacity: 0.15 !important;
        background: rgba(30, 30, 40, 0.3) !important;
        border: 2px solid rgba(255, 255, 255, 0.05) !important;
        color: rgba(255, 255, 255, 0.2) !important;
        transform: scale(0.85) !important;
        box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    }
    
    /* 紫色提交按钮样式 - 最后一题专用 */
    .next-btn.purple-submit-btn {
        background: linear-gradient(135deg, #8b5cf6 0%, #a876e8 100%) !important;
        color: white !important;
        border: 2px solid rgba(139, 92, 246, 0.3) !important;
        box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4) !important;
    }
    
    /* 确保submit-btn和purple-submit-btn同时存在时也应用紫色样式 */
    .next-btn.submit-btn.purple-submit-btn {
        background: linear-gradient(135deg, #8b5cf6 0%, #a876e8 100%) !important;
        color: white !important;
        border: 2px solid rgba(139, 92, 246, 0.3) !important;
        box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4) !important;
    }
    
    .next-btn.purple-submit-btn:hover:not(:disabled) {
        transform: scale(1.1) !important;
        box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6) !important;
    }
    
    .next-btn.purple-submit-btn i {
        font-size: 24px !important;
        color: white !important;
    }
    
    /* 调整问题卡片样式 */
        .question-container {
            order: 2;
            display: flex;
            flex-direction: column;
            margin: 0 !important; /* 移除左右边距，占满屏幕宽度 */
            margin-top: 200px !important; /* 增加上边距，避免遮挡音乐按钮 */
            height: calc(100vh - 200px);
            min-height: 400px;
            box-sizing: border-box;
            flex: 1;
            position: relative;
            width: 100%; /* 使用100%宽度确保占满容器 */
            overflow: hidden; /* 防止内容溢出 */
            padding: 0; /* 移除内边距 */
        }
        
        /* 题目头部容器：包含题目编号和音乐按钮 */
        .question-header-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 15px;
            margin-bottom: 10px;
            flex-shrink: 0;
        }
        
        /* 题目文案容器 */
        .question-text-container {
            padding: 0 15px;
            margin-bottom: 20px;
            flex-shrink: 0;
            max-height: calc(100vh - 300px);
            overflow-y: auto;
        }
        
        /* 选项按钮容器 */
        .question-options-container {
            width: 100%;
            height: 180px;
            margin-bottom: 10px;
            padding: 0 5px;
            position: relative;
            flex-shrink: 0;
            position: absolute;
            bottom: 80px;
            left: 0;
            right: 0;
        }
        
        /* 导航按钮容器 */
        .question-navigation-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px;
            flex-shrink: 0;
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
        }

    .question-card {
        padding: 20px 15px;
        box-sizing: border-box;
        width: 100%;
        margin: 0;
        transform: translateY(-10px);
        overflow: hidden;
    }
    
    
    .test-progress {
        padding: 8px 15px;
    }
    
    .progress-text {
        font-size: 12px;
        padding: 4px 10px;
    }
    
    /* 测试前页面移动端适配 */
    .test-intro {
    padding: 8px 6px 15px;
    min-height: auto;
}
    
    .intro-header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .intro-icon {
        width: 60px;
        height: 60px;
    }
    
    .intro-icon i {
        font-size: 30px;
    }
    
    .intro-title h2 {
        font-size: 22px;
    }
    
    .intro-subtitle {
        font-size: 14px;
    }
    

    
    /* 移动端按钮容器样式 */
    .intro-button-container {
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 20px 0;
        padding: 15px 0;
        width: 100%;
    }
    
    /* 移动端分割线样式 */
    .intro-divider-top,
    .intro-divider-bottom {
        margin: 8px 0;
        opacity: 0.6;
    }
    
    /* 调整测试信息标签为水平排列 */
    .test-info-compact {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 5px;
        margin-bottom: 15px;
        overflow-x: auto;
        padding-bottom: 5px;
    }

    .info-pill {
        padding: 3px 8px;
        font-size: 10px;
        justify-content: center;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* 调整标题图标与顶部栏间距 */
    .page-title {
        margin-top: 0;
    }

    /* 调整移动端进度条与顶部栏间距 */
    .test-stage-container {
            display: flex;
            flex-direction: column;
            gap: 16px;
            margin-top: -2px; /* 整体上移50px */
            width: 100%;
            max-width: 800px;
        }

        .test-progress-container {
            order: 1;
            padding: 12px 16px;
            background: rgba(40, 40, 50, 0.9);
            border-radius: 12px;
            margin: -30px 16px 0 16px;
            margin-top: -65px !important; /* 如果你仍想整体上移 */
        }


        /* 确保body.loaded不会遮挡进度框 */
        body.loaded {
            z-index: 1;
            position: relative;
        }
    
    .test-questions {
    margin-top: 0; /* 移除负边距，防止影响测试前页面布局 */
    padding-top: 0;
    min-height: auto; /* 移除固定高度限制 */
    height: auto; /* 移除固定高度限制 */
    margin-bottom: 0; /* 移除底部外边距 */
    padding-bottom: 20px; /* 添加底部内边距 */
    box-sizing: border-box; /* 确保高度计算包含边框和内边距 */
    display: flex;
    flex-direction: column;
}

.dimensions-compact {
    margin: 12px 0 15px;
}
    
    .dimension-row {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 10px;
    }
    
    .dimension-pill {
        padding: 8px 15px;
        font-size: 13px;
        justify-content: center;
    }
    
    .tips-compact {
    margin: 12px 0;
    padding: 0 8px;
}
    
    .tip-item {
        font-size: 13px;
        padding: 8px 0;
    }
    
    .disclaimer {
        font-size: 12px;
        padding: 0 10px;
    }
    
    /* 移动端选项按钮布局 - 2x2网格 */
    .question-options-container .option-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr;
        gap: 4px;
        width: calc(100% - 32px); /* 减去左右边距 */
        max-width: none; /* 移除90%限制 */
        margin: 0 auto;
        position: relative; /* 改为相对定位 */
        top: auto;
        left: auto;
        transform: none; /* 移除transform */
        height: 240px;
        min-height: 240px;
        max-height: 240px;
        box-sizing: border-box;
        overflow: visible; /* 确保内容不被裁切 */
    }
    
    .question-options-container .option-grid .option-btn {
        min-height: 110px !important;
        max-height: 120px !important;
        padding: 16px 20px !important;
        flex: 1;
        width: 100%;
        height: auto;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        margin: 0;
        border-radius: 8px;
        gap: 8px;
        overflow: hidden;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .question-options-container .option-grid .option-btn .option-emoji {
        font-size: 26px !important;
        margin-bottom: 8px;
    }
    
    .question-options-container .option-grid .option-btn .option-text {
        font-size: 16px !important;
        line-height: 1.5;
        font-weight: 500;
    }
    
    /* 题目文本样式 */
    .question-text {
        margin-bottom: 25px;
        padding: 0 10px;
        min-height: 60px;
        max-height: 120px;
        overflow-y: auto;
    }
    
    /* 移动端简介统计布局优化 - 水平排列 */
    .intro-stats {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        margin: 16px 0;
    }
    
    .stat-item {
        flex: 1;
        text-align: center;
        min-width: 0;
    }
    
    .stat-number {
        font-size: 20px;
        font-weight: 700;
        color: var(--primary-color);
        margin-bottom: 2px;
    }
    
    .stat-label {
        font-size: 11px;
        color: var(--text-secondary);
        margin-top: 0;
        line-height: 1.2;
    }
}

/* 修复上一题按钮被裁切的问题 - 仅移动端 */
@media (max-width: 768px) {
    .question-navigation {
        position: relative;
        padding-bottom: 20px;
    }

    #prevBtn,
    #nextBtn {
        position: relative;
        bottom: 0;
        margin-top: 10px;
    }
    
    /* 统一移动端导航按钮样式 */
    #nextBtn {
        background: rgba(30, 30, 40, 0.8) !important;
        border: 2px solid rgba(255, 255, 255, 0.1) !important;
        color: var(--text-color) !important;
    }
    
    /* 移动端选项按钮移除左侧紫色竖线 */
    .option-btn::before {
        display: none !important;
    }
}

/* 针对高屏幕移动端的优化 - 不影响小屏幕 */
@media (max-width: 768px) and (min-height: 700px) {
    /* 移动端选项按钮布局 - 2x2网格 */
    .question-options-container .option-grid {
        position: relative; /* 改为相对定位 */
        top: auto;
        left: auto;
        transform: none; /* 移除transform */
        margin-top: 20px; /* 使用margin代替position定位 */
    }
    
    /* 题目文本样式 */
    .question-text {
        margin-bottom: 40px !important;
    }
    
    /* 调整问题容器高度分配 */
    .question-container {
        height: calc(100vh - 200px);
    }
    
    /* 调整选项容器位置 */
    .question-options-container {
        bottom: 120px;
    }
}

/* 针对小屏幕设备的优化 - iPhone SE 375x667等设备 */
@media (max-width: 375px) {
    /* 修复进度框右侧超出屏幕 */
    .test-stage-container {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 8px !important;
        box-sizing: border-box !important;
    }
    
    .test-progress-container {
        margin: -65px 8px 0 8px !important;
        margin-top: -65px !important;
        padding: 8px !important;
        box-sizing: border-box !important;
    }
    
    /* 修复做题框右侧超出屏幕 */
    .question-container {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        margin-top: 200px !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    .question-card {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        padding: 15px 8px !important;
        box-sizing: border-box !important;
        margin: 0 !important;
    }
    
    /* 修复导航按钮重叠问题 */
    .question-options-container {
        bottom: 100px !important;
        height: 160px !important;
    }
    
    .question-options-container .option-grid {
        height: 160px !important;
        min-height: 160px !important;
        max-height: 160px !important;
        width: calc(100% - 16px) !important;
        gap: 2px !important;
    }
    
    .question-options-container .option-grid .option-btn {
        min-height: 75px !important;
        max-height: 80px !important;
        padding: 8px 12px !important;
    }
    
    .question-options-container .option-grid .option-btn .option-emoji {
        font-size: 20px !important;
        margin-bottom: 4px;
    }
    
    .question-options-container .option-grid .option-btn .option-text {
        font-size: 14px !important;
        line-height: 1.3;
    }
    
    .question-navigation-container {
        padding: 8px !important;
        bottom: 0 !important;
    }
    
    .nav-btn {
        width: 40px !important;
        height: 40px !important;
    }
    
    /* 调整题目文本样式 */
    .question-text {
        margin-bottom: 15px !important;
        padding: 0 5px !important;
        font-size: 18px !important;
    }
}

/* 针对超高屏幕移动端的进一步优化 - 针对430*932等设备 */
@media (max-width: 768px) and (min-height: 900px) {
    /* 移动端选项按钮布局 - 2x2网格 */
    .question-options-container .option-grid {
        position: relative; /* 改为相对定位 */
        top: auto;
        left: auto;
        transform: none; /* 移除transform */
        margin-top: 30px; /* 使用margin代替position定位 */
    }
    
    /* 题目文本样式 */
    .question-text {
        margin-bottom: 60px !important;
        font-size: 20px !important;
        line-height: 1.6 !important;
        font-weight: 600 !important;
    }
    
    /* 调整问题容器高度分配 */
    .question-container {
        height: calc(100vh - 220px);
    }
    
    /* 调整选项容器位置 */
    .question-options-container {
        bottom: 140px;
    }
}

/* 结算页面移动端适配 */
@media (max-width: 768px) {
    /* 结算页面容器 */
    .test-results {
        padding: 20px 16px;
        min-height: 100vh;
    }
    
    /* 结果卡片通用样式 */
    .result-card {
        margin-bottom: 20px;
        padding: 20px 16px;
        border-radius: 12px;
    }
    
    /* 操作按钮容器 - 移动端优化 */
    .personality-actions {
        display: flex;
        flex-direction: row;
        gap: 12px;
        margin: 20px 0;
        padding: 0;
        /* 移除可能的分割线或边框 */
        border: none !important;
        border-top: none !important;
        border-bottom: none !important;
        border-left: none !important;
        border-right: none !important;
        outline: none !important;
        box-shadow: none !important;
        /* 水平居中 */
        justify-content: center;
    }
    
    /* 为personality-section添加包裹框样式 */
    .personality-section {
        background: rgba(255, 255, 255, 0.04) !important;
        backdrop-filter: blur(10px) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-radius: 12px !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
    }
    
    /* 为result-card.personality-section添加包裹框样式 */
    .result-card.personality-section {
        background: rgba(255, 255, 255, 0.04) !important;
        backdrop-filter: blur(10px) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-radius: 12px !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
    }
    
    /* 为result-card添加悬停效果 - 紫色外发光 */
    .result-card:hover {
        background: rgba(255, 255, 255, 0.08) !important;
        transform: translateY(-4px) !important;
        box-shadow: 0 8px 24px rgba(187, 134, 252, 0.15) !important;
        border-color: rgba(187, 134, 252, 0.2) !important;
        transition: all 0.3s ease !important;
    }
    
    /* 确保性格描述模块与其他卡片宽度一致 */
    .test-results .result-card.personality-section {
        margin: 0 0 20px 0 !important;
        padding: 20px 8px !important;
    }
    
    /* 操作按钮样式 */
    .personality-actions .action-btn {
        width: auto;
        min-width: 120px;
        max-width: 160px;
        margin: 0;
        padding: 14px 20px;
        font-size: 16px;
        min-height: 48px;
        border-radius: 10px;
        box-shadow: 0 4px 12px rgba(187, 134, 252, 0.3);
        /* 移除所有可能的分割线或边框 */
        border: none !important;
        border-top: none !important;
        border-bottom: none !important;
        border-left: none !important;
        border-right: none !important;
        outline: none !important;
    }
    
    /* 性格描述部分 */
    .personality-section {
        padding: 0;
        margin-bottom: 0;
    }
    
    .personality-header {
        margin-bottom: 16px;
    }
    
    .personality-header .card-title {
        font-size: 18px;
        margin-bottom: 8px;
    }
    
    .personality-header .card-title i {
        font-size: 20px;
    }
    
    #personalityDescription {
        font-size: 15px;
        line-height: 1.6;
        color: var(--text-secondary);
    }
    
    /* 结果行布局 - 改为垂直堆叠 */
    .result-row {
        flex-direction: column;
        gap: 20px;
    }
    
    /* 雷达图容器 */
    .chart-container {
        height: 300px;
        padding: 15px;
        margin-bottom: 20px;
    }
    
    /* 雷达图图例 */
    .chart-legend {
        flex-direction: column;
        gap: 12px;
        align-items: center;
    }
    
    .chart-legend-item {
        font-size: 14px;
    }
    
    /* 核心特质部分 */
    .core-traits-section {
        margin-top: 1rem;
        padding-top: 1rem;
    }
    
    .core-traits-section h4 {
        font-size: 15px;
        margin-bottom: 0.6rem;
    }
    
    .core-traits-section .tags {
        gap: 6px;
    }
    
    .core-traits-section .tag {
        padding: 4px 10px;
        font-size: 12px;
    }
    
    /* 人物关系模块 */
    .people-relationship {
        gap: 16px;
    }
    
    .similar-people {
        padding: 16px;
    }
    
    .similar-people h4 {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .similar-people p {
        font-size: 14px;
        line-height: 1.5;
    }
    
    /* 职业方向部分 */
    .people-relationship .career-section {
        margin-top: 1rem;
        padding-top: 1rem;
    }
    
    .people-relationship .career-section h4 {
        font-size: 15px;
        margin-bottom: 0.6rem;
    }
    
    .people-relationship .career-section .tags {
        gap: 6px;
    }
    
    .people-relationship .career-section .tag {
        padding: 4px 10px;
        font-size: 12px;
    }
    
    /* 维度分析和特征分析卡片 */
    #resultDimensions,
    #resultCharacteristics,
    #growthSuggestionsCard {
        padding: 20px 16px;
        margin-bottom: 20px;
    }
    
    /* 成长建议卡片 */
    .growth-cards {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .growth-card {
        padding: 16px;
    }
    
    .growth-card h4 {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .growth-card p {
        font-size: 14px;
        line-height: 1.5;
    }
    
    /* 卡片标题通用样式 */
    .card-title {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .card-title i {
        font-size: 18px;
    }
    
    /* 标签通用样式 */
    .tags {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .tag {
        padding: 4px 10px;
        font-size: 12px;
        border-radius: 16px;
    }
    
    /* 确保移动端滚动流畅 */
    .test-results {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* 修复移动端右侧裁切问题 */
        padding: 20px 16px !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }
    
    /* 修复result-row右侧裁切问题 */
    .result-row {
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        padding: 0 8px !important;
        margin: 0 !important;
    }
    
    /* 修复result-card右侧裁切问题 */
    .result-card {
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        padding: 20px 16px !important;
        margin: 0 0 20px 0 !important;
        overflow: hidden !important;
    }
    
    /* 修复chart-container右侧裁切问题 */
    .chart-container {
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        padding: 15px !important;
        margin: 0 0 20px 0 !important;
        overflow: hidden !important;
    }
    
    /* 修复people-relationship右侧裁切问题 */
    .people-relationship {
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }
    
    /* 移动端结果头部样式（如果显示的话） */
    .result-header {
        margin-bottom: 30px;
    }
    
    .result-type {
        font-size: 36px;
    }
    
    .result-title {
        font-size: 24px;
        margin-bottom: 12px;
    }
    
    .result-subtitle {
        font-size: 16px;
    }
    
    /* 移动端分享图模态框样式 */
    .share-modal {
        padding: 20px;
    }
    
    .share-modal-content {
        max-width: 95%;
        max-height: 95%;
    }
    
    .share-modal-header {
        padding: 16px 20px;
    }
    
    .share-modal-header h3 {
        font-size: 18px;
    }
    
    .share-modal-body {
        padding: 16px 20px;
        max-height: 60vh;
    }
    
    .share-image-container img {
        max-height: 50vh;
    }
    
    .share-modal-footer {
        padding: 16px 20px;
        flex-direction: column;
        gap: 12px;
    }
    
    .share-action-btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
        font-size: 16px;
    }
    
    .share-action-btn i {
        font-size: 18px;
    }
}

