/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.container {
    width: 100%;
    max-width: 900px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* 页面切换 */
.page {
    display: none;
    padding: 40px;
    animation: fadeIn 0.5s;
}

.page.active {
    display: block;
}

/* 测试页面布局优化 - 移除与JS冲突的样式 */

.test-header {
    flex-shrink: 0;
}

.test-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.test-footer {
    flex-shrink: 0;
    padding-top: 10px;
}

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

/* 标题样式 */
h1 {
    font-size: 2.5em;
    color: #333;
    text-align: center;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.8em;
    color: #333;
    text-align: center;
    margin-bottom: 20px;
}

h3 {
    font-size: 1.3em;
    color: #555;
    margin-bottom: 15px;
}

/* 描述文字 */
.description {
    text-align: center;
    color: #666;
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 30px;
}

/* 特性列表 */
.features {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
}

.features ul {
    list-style: none;
}

.features li {
    padding: 10px 0;
    color: #555;
    font-size: 1.05em;
}

/* 按钮样式 */
.btn-primary {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 30px auto 0;
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* 说明页面 */
.instructions {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.instructions p, .instructions li {
    color: #555;
    line-height: 1.8;
    margin-bottom: 15px;
}

.instructions ol, .instructions ul {
    margin-left: 20px;
}

.instructions strong {
    color: #333;
}

/* 进度条 */
.progress-bar {
    width: 100%;
    height: 30px;
    background: #f0f0f0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 30px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #333;
    font-weight: bold;
}

/* 测试说明 */
.test-instruction {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
    font-size: 1.05em;
}

/* 单词网格 */
.word-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    /* 修复底部单词被遮挡 */
    padding-bottom: 20px;
    scroll-padding-bottom: 20px;
    /* 优化滚动性能 */
    will-change: scroll-position;
    -webkit-overflow-scrolling: touch;
}

.word-item {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px 15px;
    transition: all 0.2s ease;
}

.word-item:hover {
    background: #e8e9ea;
}

.word-item input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.2);
    cursor: pointer;
}

.word-item label {
    cursor: pointer;
    font-size: 1em;
    color: #333;
    display: inline-block;
    width: calc(100% - 25px);
    word-break: break-word;
    line-height: 1.3;
}

.word-item input[type="checkbox"]:checked + label {
    color: #667eea;
    font-weight: bold;
}

/* 结果页面 */
.result-container {
    text-align: center;
}

.vocabulary-size {
    background: linear-gradient(135deg, #f8f9fa 0%, #e8e9ea 100%);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
}

.size-number {
    font-size: 4em;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 20px 0;
}

.size-range {
    color: #666;
    font-size: 1.1em;
}

.level-description {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    color: #856404;
    font-size: 1.1em;
    line-height: 1.6;
}

/* 统计信息 */
.statistics {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    text-align: left;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-item span:first-child {
    color: #555;
}

.stat-item span:last-child {
    color: #333;
    font-weight: bold;
}

/* 对比信息 */
.comparison {
    background: #e8f4fd;
    border: 1px solid #b3d9f2;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    text-align: left;
}

.comparison ul {
    list-style: none;
}

.comparison li {
    padding: 8px 0;
    color: #555;
    position: relative;
    padding-left: 20px;
}

.comparison li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #667eea;
    font-weight: bold;
}

/* 词汇分布图表样式 */
.vocabulary-distribution {
    background: #f9f9ff;
    border: 1px solid #8b7cc4;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.distribution-chart {
    margin-top: 20px;
}

.chart-item {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.chart-label {
    width: 100px;
    font-size: 0.95em;
    color: #555;
}

.chart-bar {
    flex: 1;
    height: 24px;
    background: #e8e8f0;
    border-radius: 12px;
    margin: 0 15px;
    overflow: hidden;
    position: relative;
}

.chart-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 1s ease-out;
    position: relative;
}

.chart-fill.daily {
    background: linear-gradient(90deg, #4caf50, #66bb6a);
}

.chart-fill.academic {
    background: linear-gradient(90deg, #2196f3, #42a5f5);
}

.chart-fill.professional {
    background: linear-gradient(90deg, #ff9800, #ffa726);
}

.chart-fill.advanced {
    background: linear-gradient(90deg, #9c27b0, #ab47bc);
}

.chart-percent {
    width: 50px;
    text-align: right;
    font-weight: bold;
    color: #333;
    font-size: 0.95em;
}

/* 强弱项分析样式 */
.strength-weakness {
    background: #fff8f0;
    border: 1px solid #ff9800;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.analysis-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.strength-section h4 {
    color: #4caf50;
    margin-bottom: 15px;
}

.weakness-section h4 {
    color: #ff9800;
    margin-bottom: 15px;
}

.strength-section ul, .weakness-section ul {
    list-style: none;
    padding: 0;
}

.strength-section li, .weakness-section li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: #555;
    line-height: 1.5;
}

.strength-section li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #4caf50;
    font-weight: bold;
}

.weakness-section li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: #ff9800;
    font-weight: bold;
}

/* 个性化建议样式 */
.personalized-suggestions {
    background: #f0f8ff;
    border: 1px solid #4a90e2;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    text-align: left;
}

.suggestion-item {
    padding: 10px 0;
    border-bottom: 1px solid #d0e4f7;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item strong {
    color: #2c5282;
    display: inline-block;
    width: 140px;
}

.sub-info {
    color: #666;
    font-size: 0.9em;
    margin-left: 10px;
}

/* 详细统计样式 */
.detailed-stats {
    background: #fff9e6;
    border: 1px solid #f0ad4e;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    text-align: left;
}

.stat-tree {
    font-family: 'Courier New', monospace;
    background: #fffef9;
    padding: 15px;
    border-radius: 5px;
}

.stat-line {
    padding: 5px 0;
    color: #555;
}

.stat-line span {
    color: #333;
    font-weight: bold;
}

/* 次要按钮样式 */
.btn-secondary {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 10px auto 0;
    padding: 12px 25px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(108, 117, 125, 0.3);
}

/* 图表容器样式 */
.history-charts {
    margin-top: 30px;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 15px;
}

.history-charts h3 {
    color: #333;
    margin-bottom: 25px;
    font-size: 1.3rem;
}

.history-charts h4 {
    color: #666;
    margin: 20px 0 15px 0;
    font-size: 1.1rem;
}

.chart-container {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 25px;
    position: relative;
    height: 300px;
}

.chart-container canvas {
    max-height: 250px !important;
}

/* 统计卡片 */
.statistics-summary {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 25px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.stat-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: #777;
    margin-bottom: 8px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

/* 成就系统 */
.achievements {
    margin-top: 30px;
    padding: 20px;
    background: white;
    border-radius: 10px;
}

.achievement-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.achievement-card {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.achievement-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 10px;
}

.achievement-label {
    font-size: 0.85rem;
    color: #666;
    display: block;
    margin-bottom: 5px;
}

.achievement-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: #333;
}

.achievement-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

.achievement-item .achievement-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.achievement-info {
    flex-grow: 1;
}

.achievement-title {
    font-weight: bold;
    margin-bottom: 3px;
}

.achievement-desc {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 移动端几乎无边距 */
    body {
        padding: 5px;
    }

    .container {
        border-radius: 10px;
        min-height: calc(100vh - 10px);
        /* 确保容器占满屏幕 */
        display: flex;
        flex-direction: column;
    }

    .page {
        padding: 12px;
        /* 优化页面布局 */
        display: flex;
        flex-direction: column;
        flex: 1;
    }

    h1 {
        font-size: 1.8em;
        margin-bottom: 15px;
    }

    h2 {
        font-size: 1.3em;
        margin-bottom: 15px;
    }

    /* 修复单词网格在移动端的显示 */
    .word-grid {
        /* 移动端使用2列布局，更适合手机屏幕 */
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        /* 动态高度，确保所有内容可见 */
        max-height: none;
        height: 100%;
        /* 优化滚动体验 */
        -webkit-overflow-scrolling: touch;
        padding: 5px 2px 20px 2px;
        /* 确保内容不被遮挡 */
        margin-bottom: 0;
    }

    /* 测试内容区域占满剩余空间 */
    .test-content {
        flex: 1;
        min-height: 300px;
        overflow: hidden;
    }

    /* 优化单词卡片在移动端的显示 */
    .word-item {
        padding: 6px 8px;
        min-height: 40px; /* 符合移动端触摸标准 */
        display: flex;
        align-items: center;
        /* 添加触摸反馈 */
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.1);
        touch-action: manipulation;
    }

    /* 触摸时的视觉反馈 */
    .word-item:active {
        background: #e8e9ea;
        transform: scale(0.98);
    }

    .word-item label {
        font-size: 0.95em;
        /* 处理长单词：允许换行或省略号 */
        word-break: break-word;
        hyphens: auto;
        overflow: hidden;
        display: block;
        width: 100%;
    }

    .word-item input[type="checkbox"] {
        /* 增大复选框便于点击 */
        transform: scale(1.3);
        margin-right: 10px;
    }

    /* 进度条优化 */
    .progress-bar {
        height: 22px;
        margin-bottom: 12px;
    }

    .progress-text {
        font-size: 0.85em;
    }

    /* 按钮优化 */
    .btn-primary, .btn-secondary {
        /* 固定在底部区域 */
        margin: 10px auto 5px;
        padding: 12px 20px;
        font-size: 1em;
        /* 确保按钮不被键盘遮挡 */
        position: relative;
        z-index: 10;
    }

    /* 测试说明优化 */
    .test-instruction {
        font-size: 0.9em;
        margin-bottom: 10px;
        padding: 0 5px;
    }

    .size-number {
        font-size: 2.5em;
    }

    /* 统计信息优化 */
    .statistics, .comparison, .personalized-suggestions, .detailed-stats,
    .vocabulary-distribution, .strength-weakness {
        padding: 15px;
        margin-bottom: 20px;
        font-size: 0.95em;
    }

    /* 移动端强弱项分析改为单列 */
    .analysis-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* 移动端图表优化 */
    .history-charts {
        padding: 15px;
        margin-top: 20px;
    }

    .chart-container {
        height: 250px;
        padding: 15px;
    }

    .chart-container canvas {
        max-height: 200px !important;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .achievement-grid {
        grid-template-columns: 1fr;
    }

    .achievement-list {
        grid-template-columns: 1fr;
    }

    .achievement-item {
        padding: 12px;
    }

    /* 移动端词汇分布调整 */
    .chart-label {
        width: 70px;
        font-size: 0.85em;
    }

    .chart-bar {
        margin: 0 10px;
        height: 20px;
    }

    .chart-percent {
        width: 40px;
        font-size: 0.85em;
    }
}

/* 针对小屏幕手机的特殊优化 */
@media (max-width: 480px) {
    body {
        padding: 3px;
    }

    .page {
        padding: 8px;
    }

    h1 {
        font-size: 1.4em;
        margin-bottom: 10px;
    }

    h2 {
        font-size: 1.1em;
        margin-bottom: 10px;
    }

    /* 小屏幕保持2列但减小间距 */
    .word-grid {
        gap: 5px;
        padding: 5px 2px 20px 2px;
        max-height: calc(100vh - 200px);
    }

    .word-item {
        padding: 5px 6px;
        font-size: 0.9em;
        min-height: 38px;
    }

    .word-item input[type="checkbox"] {
        transform: scale(1.2);
        margin-right: 8px;
    }

    /* 更紧凑的按钮 */
    .btn-primary, .btn-secondary {
        padding: 12px 20px;
        font-size: 1em;
        max-width: 280px;
    }

    /* 特别小的屏幕用单列 */
    @media (max-width: 360px) {
        .word-grid {
            grid-template-columns: 1fr;
        }
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 500px) {
    .word-grid {
        max-height: calc(100vh - 180px);
        grid-template-columns: repeat(3, 1fr);
    }

    h2 {
        font-size: 1.1em;
        margin-bottom: 10px;
    }

    .progress-bar {
        height: 20px;
        margin-bottom: 15px;
    }
}

/* 滚动条样式 */
.word-grid::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.word-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.word-grid::-webkit-scrollbar-thumb {
    background: #999;
    border-radius: 10px;
}

.word-grid::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* 移动端隐藏滚动条但保持滚动功能 */
@media (max-width: 768px) {
    .word-grid::-webkit-scrollbar {
        width: 4px;
    }

    .word-grid::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
    }
}