/* ===== CSS变量 ===== */
:root {
    --primary: #6C5CE7;
    --primary-light: #A29BFE;
    --primary-dark: #5849C4;
    --success: #34C759;
    --success-light: #A8F0BA;
    --danger: #FF3B30;
    --danger-light: #FF9F9A;
    --warning: #FF9500;
    --bg: #F2F2F7;
    --card-bg: #FFFFFF;
    --text: #1C1C1E;
    --text-light: #8E8E93;
    --text-lighter: #C7C7CC;
    --border: #E5E5EA;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-full: 9999px;
    --transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);

    /* iOS 安全区域 */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* 深色模式 */
[data-theme="dark"] {
    --bg: #1A1A2E;
    --card-bg: #16213E;
    --text: #EAEAEA;
    --text-light: #B8B8B8;
    --text-lighter: #6B6B6B;
    --border: #2D3A4F;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* ===== 基础样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    height: -webkit-fill-available;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* 禁止选择文本 */
    -webkit-user-select: none;
    user-select: none;
    /* iOS 全屏时的顶部安全区域 */
    padding-top: var(--safe-top);
}

/* 允许输入框选择文本 */
input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

#app {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: calc(100vh - var(--safe-top));
    position: relative;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

/* iOS 风格按钮按下效果 */
button:active, .menu-btn:active, .choice-btn:active {
    transform: scale(0.97);
    opacity: 0.9;
}

/* ===== 页面切换 ===== */
.page {
    display: none;
    padding: 20px;
    padding-bottom: 40px;
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

/* ===== 用户选择页 ===== */
.user-select-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 20px;
}

.user-select-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.user-select-subtitle {
    color: var(--text-light);
    margin-bottom: 30px;
}

.user-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    max-width: 400px;
}

.user-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 30px;
    background: var(--card-bg);
    border: 3px solid transparent;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    min-width: 120px;
}

.user-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-light);
    box-shadow: var(--shadow-lg);
}

.user-card:active {
    transform: scale(0.98);
}

.user-card .avatar {
    font-size: 3.5rem;
    margin-bottom: 10px;
}

.user-card .name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.user-card .user-stats {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 5px;
}

.user-card .delete-user {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--danger);
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
}

.user-card {
    position: relative;
}

.user-card:hover .delete-user {
    opacity: 1;
}

.add-user-section {
    margin-bottom: 20px;
}

.add-user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    background: var(--card-bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
}

.add-user-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.add-icon {
    font-size: 1.5rem;
    font-weight: 300;
}

.new-user-form {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 320px;
    width: 100%;
}

.new-user-form.hidden {
    display: none;
}

.user-name-input {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 15px;
    color: var(--text);
    background: var(--bg);
}

.user-name-input:focus {
    outline: none;
    border-color: var(--primary);
}

.avatar-picker {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.avatar-option {
    font-size: 2rem;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.avatar-option:hover {
    background: var(--bg);
}

.avatar-option.selected {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.1);
}

.form-buttons {
    display: flex;
    gap: 10px;
}

.form-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.form-btn.cancel {
    background: var(--border);
    color: var(--text-light);
}

.form-btn.confirm {
    background: var(--primary);
    color: white;
}

.form-btn:hover {
    opacity: 0.9;
}

/* ===== 首页用户徽章 ===== */
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--card-bg);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow);
    cursor: pointer;
    margin-bottom: 15px;
    transition: var(--transition);
}

.user-badge:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

.user-badge .user-avatar {
    font-size: 1.5rem;
}

.user-badge .user-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.user-badge .switch-hint {
    font-size: 0.7rem;
    color: var(--text-lighter);
    margin-left: 5px;
}

/* ===== 首页 ===== */
.home-header {
    text-align: center;
    padding: 30px 0 20px;
}

.home-header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-light);
    font-size: 1rem;
}

/* 统计栏 */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 15px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-icon {
    font-size: 1.2rem;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-light);
    white-space: nowrap;
}

/* 菜单网格 */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 12px;
    background: var(--card-bg);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    /* iOS 风格：微妙的内阴影 */
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.08),
        0 4px 12px rgba(0, 0, 0, 0.05);
}

.menu-btn:hover {
    transform: translateY(-1px);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.1),
        0 8px 24px rgba(0, 0, 0, 0.08);
}

.menu-btn:active {
    transform: scale(0.98);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.1);
}

.menu-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.menu-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}

.menu-desc {
    font-size: 0.75rem;
    color: var(--text-light);
}

.times-btn {
    background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
}

[data-theme="dark"] .times-btn {
    background: linear-gradient(135deg, #1A237E, #283593);
}

.wrong-book-btn {
    background: linear-gradient(135deg, #FFF5E6, #FFE8CC);
}

[data-theme="dark"] .wrong-book-btn {
    background: linear-gradient(135deg, #3D2E1F, #4A3728);
}

.learn-btn {
    background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
}

[data-theme="dark"] .learn-btn {
    background: linear-gradient(135deg, #1E3D1F, #2E4D2F);
}

/* 页脚 */
.home-footer {
    text-align: center;
}

.quick-start-btn {
    width: 100%;
    padding: 18px;
    margin-bottom: 15px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.quick-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.link-btn {
    padding: 10px 20px;
    background: transparent;
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-light);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.link-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ===== 页面头部 ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 16px;
    position: sticky;
    top: 0;
    /* iOS 毛玻璃效果 */
    background: rgba(242, 242, 247, 0.85);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    z-index: 100;
    margin: 0 -20px;
    padding-left: 20px;
    padding-right: 20px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .page-header {
    background: rgba(26, 26, 46, 0.85);
    border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
}

.page-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.back-btn {
    padding: 8px 16px;
    background: var(--card-bg);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.back-btn:hover {
    background: var(--primary-light);
    color: white;
}

.header-spacer {
    width: 80px;
}

.practice-stats {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

/* ===== 难度选择器 ===== */
.difficulty-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.diff-btn {
    padding: 8px 16px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.diff-btn:hover {
    border-color: var(--primary-light);
}

.diff-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ===== 计时条 ===== */
.timer-bar {
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-full);
    margin-bottom: 20px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s;
}

.timer-bar.active {
    opacity: 1;
}

.timer-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
    border-radius: var(--radius-full);
    transition: width 0.1s linear;
    width: 100%;
}

/* ===== 题目区域 ===== */
.question-area {
    position: relative;
    margin-bottom: 30px;
}

.question-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 20px;
    text-align: center;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.question-card.correct {
    background: var(--success-light);
    animation: pulse 0.3s ease;
}

.question-card.wrong {
    background: var(--danger-light);
    animation: shake 0.4s ease;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.question-text {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
}

/* 连胜指示器 */
.streak-indicator {
    position: absolute;
    top: -10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #FF6B6B, #FF8E53);
    border-radius: var(--radius-full);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    opacity: 0;
    transform: scale(0.8);
    transition: var(--transition);
}

.streak-indicator.active {
    opacity: 1;
    transform: scale(1);
}

.streak-fire {
    font-size: 1.2rem;
}

/* ===== 答案区域 ===== */
.answer-area {
    margin-bottom: 20px;
}

.choices {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.choice-btn {
    padding: 18px;
    background: var(--card-bg);
    border: none;
    border-radius: var(--radius);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    /* iOS 风格阴影 */
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.04);
}

.choice-num {
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 0.7rem;
    color: var(--text-lighter);
    font-weight: 500;
}

.choice-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.choice-btn:active {
    transform: scale(0.98);
}

.choice-btn.correct {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.choice-btn.wrong {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.choice-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 填空题模式 */
.input-mode {
    display: flex;
    gap: 12px;
}

.input-mode.hidden {
    display: none;
}

.answer-input {
    flex: 1;
    padding: 18px 20px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    color: var(--text);
    transition: var(--transition);
}

.answer-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1);
}

.submit-btn {
    padding: 18px 30px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.submit-btn:hover {
    background: var(--primary-dark);
}

.submit-btn:active {
    transform: scale(0.98);
}

/* ===== 反馈 ===== */
.feedback {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 1000;
}

.feedback.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.feedback-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 25px;
    background: var(--card-bg);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    font-size: 1.1rem;
    font-weight: 600;
}

.feedback.correct .feedback-content {
    background: var(--success);
    color: white;
}

.feedback.wrong .feedback-content {
    background: var(--danger);
    color: white;
}

.feedback-icon {
    font-size: 1.3rem;
}

/* ===== 每日挑战 ===== */
.daily-timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.daily-progress {
    margin-bottom: 20px;
}

.progress-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.progress-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-lighter);
    transition: var(--transition);
}

.progress-dot.current {
    background: var(--primary);
    color: white;
    transform: scale(1.2);
}

.progress-dot.correct {
    background: var(--success);
    color: white;
}

.progress-dot.wrong {
    background: var(--danger);
    color: white;
}

.start-daily-btn {
    width: 100%;
    padding: 25px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    border-radius: var(--radius);
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.start-daily-btn:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

/* ===== 结果页 ===== */
#result-page {
    display: none;
    padding: 40px 20px;
}

#result-page.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-content {
    text-align: center;
    width: 100%;
}

.result-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.result-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}

.result-encourage {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 25px;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
}

.result-stat {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.result-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.result-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

.result-accuracy {
    margin-bottom: 40px;
}

.accuracy-bar {
    height: 12px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 10px;
}

.accuracy-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--success-light));
    border-radius: var(--radius-full);
    transition: width 1s ease;
}

.accuracy-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-btn {
    padding: 18px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}

.result-btn:hover {
    border-color: var(--primary);
}

.result-btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.result-btn.primary:hover {
    background: var(--primary-dark);
}

/* ===== 错题本 ===== */
.clear-wrong-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.clear-wrong-btn:hover {
    background: var(--danger);
    color: white;
}

.wrong-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 80px;
}

.wrong-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    gap: 12px;
}

.wrong-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wrong-question {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.delete-wrong-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--border);
    color: var(--text-light);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.delete-wrong-btn:hover {
    background: var(--danger);
    color: white;
}

.wrong-answer {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.wrong-your {
    font-size: 0.85rem;
    color: var(--danger);
    text-decoration: line-through;
}

.wrong-correct {
    font-size: 1rem;
    font-weight: 600;
    color: var(--success);
}

.wrong-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.wrong-empty.hidden {
    display: none;
}

.empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 15px;
}

.wrong-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

.wrong-actions.hidden {
    display: none;
}

.practice-wrong-btn {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    display: block;
    padding: 18px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.practice-wrong-btn:hover {
    background: var(--primary-dark);
}

/* ===== 学习页 ===== */
.learn-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 15px;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}

.learn-tab {
    flex-shrink: 0;
    padding: 10px 18px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
}

.learn-tab:hover {
    border-color: var(--primary-light);
}

.learn-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.learn-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.learn-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.learn-card-title {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 10px;
}

.learn-card-content {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.learn-item {
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.start-practice-btn {
    width: 100%;
    padding: 18px;
    margin-top: 20px;
    background: linear-gradient(135deg, var(--success), var(--success-light));
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.start-practice-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.start-practice-btn:active {
    transform: scale(0.98);
}

/* ===== 设置页 ===== */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 40px;
}

.setting-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.setting-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.setting-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.setting-opt {
    padding: 10px 18px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
}

.setting-opt:hover {
    border-color: var(--primary-light);
}

.setting-opt.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.settings-footer {
    text-align: center;
}

.reset-btn {
    padding: 12px 24px;
    background: transparent;
    border: 2px solid var(--danger);
    border-radius: var(--radius-full);
    color: var(--danger);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 20px;
}

.reset-btn:hover {
    background: var(--danger);
    color: white;
}

.version {
    font-size: 0.8rem;
    color: var(--text-lighter);
}

/* ===== 成就页 ===== */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.achievement-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 10px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.achievement-card.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.achievement-card.unlocked {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.1), rgba(162, 155, 254, 0.1));
    border: 2px solid var(--primary-light);
}

.achievement-card-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.achievement-card-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.achievement-card-desc {
    font-size: 0.7rem;
    color: var(--text-light);
}

@media (max-width: 400px) {
    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== 成就弹窗 ===== */
.achievement-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.achievement-popup.show {
    opacity: 1;
    visibility: visible;
}

.achievement-popup.hidden {
    display: none;
}

.achievement-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    transform: scale(0.8);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.achievement-popup.show .achievement-content {
    transform: scale(1);
    animation: achievementPop 0.5s ease;
}

@keyframes achievementPop {
    0% { transform: scale(0.5); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

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

.achievement-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
}

.achievement-desc {
    color: var(--text-light);
}

/* ===== 特效层 ===== */
.effects-layer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 3000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100%) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* 星星爆炸效果 */
.star-burst {
    position: absolute;
    font-size: 1.5rem;
    animation: star-burst 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes star-burst {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(0) rotate(360deg);
        opacity: 0;
    }
}

/* 答对时的放大闪烁效果 */
@keyframes correct-pop {
    0% { transform: scale(1); }
    30% { transform: scale(1.08); }
    60% { transform: scale(0.98); }
    100% { transform: scale(1); }
}

.question-card.correct {
    animation: correct-pop 0.4s ease;
}

/* 答错时的摇晃效果增强 */
@keyframes wrong-shake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    15% { transform: translateX(-12px) rotate(-2deg); }
    30% { transform: translateX(10px) rotate(2deg); }
    45% { transform: translateX(-8px) rotate(-1deg); }
    60% { transform: translateX(6px) rotate(1deg); }
    75% { transform: translateX(-4px) rotate(0deg); }
}

.question-card.wrong {
    animation: wrong-shake 0.5s ease;
}

/* 连胜火焰动画 */
@keyframes flame {
    0%, 100% { transform: scale(1) rotate(-3deg); }
    25% { transform: scale(1.1) rotate(3deg); }
    50% { transform: scale(1.05) rotate(-2deg); }
    75% { transform: scale(1.15) rotate(2deg); }
}

.streak-indicator.active .streak-fire {
    animation: flame 0.3s ease infinite;
}

/* 连胜数字跳动 */
@keyframes number-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.streak-num.pop {
    animation: number-pop 0.3s ease;
}

/* 选项按钮hover波纹效果 */
.choice-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(108, 92, 231, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.choice-btn:active::after {
    width: 200%;
    height: 200%;
}

/* 正确选项的闪光效果 */
@keyframes correct-glow {
    0% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.4); }
    50% { box-shadow: 0 0 20px 10px rgba(52, 199, 89, 0.2); }
    100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}

.choice-btn.correct {
    animation: correct-glow 0.6s ease;
}

/* 分数飘浮效果 */
@keyframes score-float {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    50% {
        opacity: 1;
        transform: translateY(-30px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0.8);
    }
}

/* 结果页数字滚动效果 */
@keyframes count-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-value {
    animation: count-up 0.5s ease backwards;
}

.result-stat:nth-child(1) .result-value { animation-delay: 0.1s; }
.result-stat:nth-child(2) .result-value { animation-delay: 0.2s; }
.result-stat:nth-child(3) .result-value { animation-delay: 0.3s; }

/* 结果页正确率条动画 */
@keyframes fill-bar {
    from { width: 0; }
}

.accuracy-fill {
    animation: fill-bar 1s ease-out 0.5s backwards;
}

/* 进度点完成动画 */
@keyframes dot-complete {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

.progress-dot.correct,
.progress-dot.wrong {
    animation: dot-complete 0.3s ease;
}

/* 菜单按钮入场动画 */
@keyframes menu-enter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.menu-btn {
    animation: menu-enter 0.4s ease backwards;
}

.menu-btn:nth-child(1) { animation-delay: 0.05s; }
.menu-btn:nth-child(2) { animation-delay: 0.1s; }
.menu-btn:nth-child(3) { animation-delay: 0.15s; }
.menu-btn:nth-child(4) { animation-delay: 0.2s; }
.menu-btn:nth-child(5) { animation-delay: 0.25s; }
.menu-btn:nth-child(6) { animation-delay: 0.3s; }
.menu-btn:nth-child(7) { animation-delay: 0.35s; }
.menu-btn:nth-child(8) { animation-delay: 0.4s; }
.menu-btn:nth-child(9) { animation-delay: 0.45s; }

/* 用户卡片入场动画 */
.user-card {
    animation: menu-enter 0.4s ease backwards;
}

.user-card:nth-child(1) { animation-delay: 0.1s; }
.user-card:nth-child(2) { animation-delay: 0.2s; }

/* 成就弹窗增强 */
@keyframes achievement-shine {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

.achievement-popup.show .achievement-icon {
    animation: bounce 0.6s ease, flame 0.5s ease infinite 0.6s;
}

/* 倒计时闪烁 */
@keyframes timer-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.timer-progress.warning {
    animation: timer-warning 0.5s ease infinite;
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
    .home-header h1 {
        font-size: 1.6rem;
    }

    .stats-bar {
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        padding: 12px 8px;
    }

    .stat-icon {
        font-size: 1rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .menu-grid {
        gap: 10px;
    }

    .menu-btn {
        padding: 15px 10px;
    }

    .menu-icon {
        font-size: 2rem;
    }

    .menu-title {
        font-size: 1rem;
    }

    .question-text {
        font-size: 1.6rem;
    }

    .choice-btn {
        padding: 16px;
        font-size: 1.1rem;
    }

    .result-value {
        font-size: 2rem;
    }

    .quick-start-btn {
        padding: 15px;
        font-size: 1rem;
    }

    .footer-links {
        gap: 10px;
    }

    .link-btn {
        padding: 8px 15px;
        font-size: 0.8rem;
    }
}

@media (min-width: 768px) {
    .menu-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .choices {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== 分数显示 ===== */
.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 4px;
    font-size: 0.85em;
}

.fraction .numerator {
    border-bottom: 2px solid currentColor;
    padding: 0 6px 2px;
    line-height: 1.2;
}

.fraction .denominator {
    padding: 2px 6px 0;
    line-height: 1.2;
}

/* 题目中的分数稍大 */
.question-text .fraction {
    font-size: 0.9em;
}

.question-text .fraction .numerator,
.question-text .fraction .denominator {
    padding: 0 8px;
    min-width: 24px;
    text-align: center;
}

/* 学习卡片中的分数 */
.learn-item .fraction {
    font-size: 0.8em;
}

/* 分数提示 */
.fraction-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 10px;
    font-weight: normal;
}

/* ===== 工具类 ===== */
.hidden {
    display: none !important;
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-lighter);
}

/* ===== 安全区域适配 ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .page {
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }

    .wrong-actions {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }

    .home-footer {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ===== iPad 横屏优化 ===== */
@media (min-width: 768px) and (orientation: landscape) {
    #app {
        max-width: 700px;
    }

    .menu-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .question-text {
        font-size: 2.5rem;
    }

    .choices {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== iPad 大屏优化 ===== */
@media (min-width: 1024px) {
    #app {
        max-width: 800px;
    }

    .home-header h1 {
        font-size: 2.5rem;
    }

    .menu-btn {
        padding: 24px 16px;
    }

    .menu-icon {
        font-size: 3rem;
    }

    .question-card {
        padding: 50px 30px;
        min-height: 180px;
    }

    .choice-btn {
        padding: 22px;
        font-size: 1.4rem;
    }
}

/* ===== iOS 独立模式（添加到主屏幕后）===== */
@media (display-mode: standalone) {
    body {
        /* 独立模式下额外的顶部空间 */
        padding-top: calc(var(--safe-top) + 10px);
    }

    .page-header {
        padding-top: 8px;
    }
}

/* ===== 减少动画（辅助功能）===== */
@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
