/* ==================== MDUI 2 Material Design 3 主题配置 ==================== */
:root {
    /* 主色调 */
    --md-sys-color-primary: #6750a4;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #eaddff;
    --md-sys-color-on-primary-container: #21005d;

    /* 次要色 */
    --md-sys-color-secondary: #625b71;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #e8def8;
    --md-sys-color-on-secondary-container: #1d192b;

    /* 第三色 */
    --md-sys-color-tertiary: #7d5260;
    --md-sys-color-on-tertiary: #ffffff;
    --md-sys-color-tertiary-container: #ffd8e4;
    --md-sys-color-on-tertiary-container: #31111d;

    /* 表面色 */
    --md-sys-color-surface: #fef7ff;
    --md-sys-color-on-surface: #1d1b20;
    --md-sys-color-surface-variant: #e7e0ec;
    --md-sys-color-on-surface-variant: #49454f;
    --md-sys-color-surface-container: #f3edf7;
    --md-sys-color-surface-container-low: #f7f2fa;
    --md-sys-color-surface-container-high: #ece6f0;

    /* 状态色 */
    --md-sys-color-success: #34a853;
    --md-sys-color-on-success: #ffffff;
    --md-sys-color-error: #ba1a1a;
    --md-sys-color-on-error: #ffffff;
    --md-sys-color-warning: #f9ab00;

    /* Elevation (阴影) */
    --md-sys-elevation-level0: none;
    --md-sys-elevation-level1: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
    --md-sys-elevation-level2: 0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
    --md-sys-elevation-level3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
    --md-sys-elevation-level4: 0px 6px 10px 4px rgba(0, 0, 0, 0.15), 0px 2px 3px 0px rgba(0, 0, 0, 0.3);

    /* 圆角 */
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-full: 9999px;
}

/* ==================== 暗色主题 ==================== */
.dark-mode {
    /* 主色调（暗色） */
    --md-sys-color-primary: #d0bcff;
    --md-sys-color-on-primary: #381e72;
    --md-sys-color-primary-container: #4f378b;
    --md-sys-color-on-primary-container: #eaddff;

    /* 次要色（暗色） */
    --md-sys-color-secondary: #ccc2dc;
    --md-sys-color-on-secondary: #332d41;
    --md-sys-color-secondary-container: #4a4458;
    --md-sys-color-on-secondary-container: #e8def8;

    /* 第三色（暗色） */
    --md-sys-color-tertiary: #efb8c8;
    --md-sys-color-on-tertiary: #492532;
    --md-sys-color-tertiary-container: #633b48;
    --md-sys-color-on-tertiary-container: #ffd8e4;

    /* 表面色（暗色） */
    --md-sys-color-surface: #141218;
    --md-sys-color-on-surface: #e6e1e5;
    --md-sys-color-surface-variant: #49454f;
    --md-sys-color-on-surface-variant: #cac4d0;
    --md-sys-color-surface-container: #1d1b20;
    --md-sys-color-surface-container-low: #211f26;
    --md-sys-color-surface-container-high: #2b2930;

    /* 状态色（暗色调整） */
    --md-sys-color-success: #81c995;
    --md-sys-color-error: #ffb4ab;
    --md-sys-color-warning: #fcd34d;

    /* Elevation (暗色模式阴影) */
    --md-sys-elevation-level0: none;
    --md-sys-elevation-level1: 0px 1px 3px 1px rgba(0, 0, 0, 0.3), 0px 1px 2px 0px rgba(0, 0, 0, 0.5);
    --md-sys-elevation-level2: 0px 2px 6px 2px rgba(0, 0, 0, 0.3), 0px 1px 2px 0px rgba(0, 0, 0, 0.5);
    --md-sys-elevation-level3: 0px 4px 8px 3px rgba(0, 0, 0, 0.3), 0px 1px 3px 0px rgba(0, 0, 0, 0.5);
    --md-sys-elevation-level4: 0px 6px 10px 4px rgba(0, 0, 0, 0.3), 0px 2px 3px 0px rgba(0, 0, 0, 0.5);
}

/* 暗色模式下的卡片和面板样式调整 */
.dark-mode .card,
.dark-mode .settings-panel {
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.dark-mode .option-item {
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* 暗色模式下的主题选择器选项样式 */
.dark-mode .theme-select option {
    background-color: #1d1b20;
    color: #e6e1e5;
}

/* 暗色模式下的反馈框样式调整 */
.dark-mode .feedback.correct {
    background: rgba(129, 201, 149, 0.15);
}

.dark-mode .feedback.incorrect {
    background: rgba(255, 180, 171, 0.15);
}

.dark-mode .feedback.correct .feedback-header {
    color: #81c995;
}

.dark-mode .feedback.incorrect .feedback-header {
    color: #ffb4ab;
}

/* 暗色模式下的徽章样式调整 */
.dark-mode .badge.single {
    background: #4f378b;
    color: #eaddff;
}

.dark-mode .badge.multiple {
    background: #633b48;
    color: #ffd8e4;
}

.dark-mode .badge.truefalse {
    background: #7d5260;
    color: #efb8c8;
}

/* 暗色模式下的选项样式调整 */
.dark-mode .option-text {
    color: var(--md-sys-color-on-surface);
}

.dark-mode .option-item.selected .option-text {
    color: var(--md-sys-color-on-primary-container);
}

.dark-mode .option-item.correct .option-text {
    color: var(--md-sys-color-on-surface);
}

.dark-mode .option-item.incorrect .option-text {
    color: var(--md-sys-color-on-surface);
}

.dark-mode .option-item.correct {
    background: rgba(129, 201, 149, 0.2);
    border-color: var(--md-sys-color-success);
}

.dark-mode .option-item.incorrect {
    background: rgba(255, 180, 171, 0.2);
    border-color: var(--md-sys-color-error);
}

/* 暗色模式下的选项单选按钮样式 */
.dark-mode .option-radio {
    border-color: var(--md-sys-color-on-surface-variant);
}

.dark-mode .option-item.selected .option-radio {
    border-color: var(--md-sys-color-primary);
}

.dark-mode .option-item.selected .option-radio::after {
    background: var(--md-sys-color-primary);
}

/* 暗色模式下的禁用选项样式 */
.dark-mode .option-item.disabled {
    opacity: 0.6;
}

/* 暗色模式下的悬停状态 */
.dark-mode .option-item:hover {
    border-color: var(--md-sys-color-primary);
}

.dark-mode .option-item:hover .option-text {
    color: var(--md-sys-color-on-surface);
}

/* 暗色模式下的题目标题 */
.dark-mode .quiz-header h2 {
    color: var(--md-sys-color-on-surface);
}

.dark-mode h2#questionTitle {
    color: var(--md-sys-color-on-surface);
}

/* 暗色模式下的答题卡图例标签 */
.dark-mode .legend-label {
    color: var(--md-sys-color-on-surface);
}

/* 暗色模式下的答题卡项目 */
.dark-mode .answer-sheet-item {
    color: var(--md-sys-color-on-surface);
    border-color: var(--md-sys-color-surface-variant);
}

.dark-mode .answer-sheet-item.current {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-color: var(--md-sys-color-primary);
}

.dark-mode .answer-sheet-item.correct {
    background: var(--md-sys-color-success);
    color: var(--md-sys-color-on-success);
    border-color: var(--md-sys-color-success);
}

.dark-mode .answer-sheet-item.incorrect {
    background: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    border-color: var(--md-sys-color-error);
}

.dark-mode .answer-sheet-item.unanswered {
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    border-color: var(--md-sys-color-surface-variant);
}

/* 暗色模式下的答题卡统计文字 */
.dark-mode .answer-sheet-stats span {
    color: var(--md-sys-color-on-surface);
}

/* 暗色模式下的其他标题文字 */
.dark-mode .section-title {
    color: var(--md-sys-color-on-surface);
}

.dark-mode .answer-sheet-header h3 {
    color: var(--md-sys-color-on-surface);
}

.dark-mode .settings-header h2 {
    color: var(--md-sys-color-on-surface);
}

/* 暗色模式下的统计文字 */
.dark-mode .stat-card .label {
    color: var(--md-sys-color-on-surface-variant);
}

.dark-mode .stat-card .value {
    color: var(--md-sys-color-primary);
}

/* 暗色模式下的进度文字 */
.dark-mode .quiz-progress {
    color: var(--md-sys-color-secondary);
}

.dark-mode .quiz-progress span {
    color: var(--md-sys-color-on-surface);
}

/* 暗色模式下的按钮文字 */
.dark-mode .btn {
    color: var(--md-sys-color-on-surface);
}

.dark-mode .btn-primary {
    color: var(--md-sys-color-on-primary);
}

.dark-mode .btn-secondary {
    color: var(--md-sys-color-on-secondary-container);
}

/* 暗色模式下的 footer */
.dark-mode .footer {
    color: var(--md-sys-color-on-surface-variant);
}

.dark-mode .footer p {
    color: var(--md-sys-color-on-surface-variant);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', 'Noto Sans SC', sans-serif;
    background-color: var(--md-sys-color-surface-container-low);
    background-image:
        radial-gradient(at 40% 20%, var(--md-sys-color-primary-container) 0px, transparent 50%),
        radial-gradient(at 80% 0%, var(--md-sys-color-secondary-container) 0px, transparent 50%),
        radial-gradient(at 0% 50%, var(--md-sys-color-tertiary-container) 0px, transparent 50%),
        radial-gradient(at 80% 50%, var(--md-sys-color-primary-container) 0px, transparent 50%),
        radial-gradient(at 0% 100%, var(--md-sys-color-secondary-container) 0px, transparent 50%),
        radial-gradient(at 80% 100%, var(--md-sys-color-tertiary-container) 0px, transparent 50%);
    background-attachment: fixed;
    background-size: 100% 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: background-color 0.3s ease;
}

.container {
    max-width: 900px;
    width: 100%;
    animation: fadeIn 0.4s ease-out;
}

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

.header {
    text-align: center;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 24px;
    padding: 24px;
    background: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: var(--md-sys-elevation-level2);
    position: relative;
}

.header h1 {
    font-size: 2.25rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--md-sys-color-primary);
}

.header p {
    font-size: 1rem;
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.9;
}

.card {
    background: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-sys-elevation-level2);
    padding: 24px;
    margin-bottom: 16px;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--md-sys-elevation-level3);
}

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

.auth-status {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--md-sys-color-primary-container);
    border-radius: var(--md-sys-shape-corner-medium);
    margin-bottom: 16px;
}

.auth-status .icon {
    font-size: 24px;
    color: var(--md-sys-color-primary);
}

.auth-status .icon.success {
    color: var(--md-sys-color-success);
}

.auth-status .icon.error {
    color: var(--md-sys-color-error);
}

.auth-info h3 {
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--md-sys-color-on-primary-container);
    font-weight: 500;
}

.auth-info .key {
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--md-sys-color-primary);
    letter-spacing: 1.5px;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--md-sys-color-surface-container);
}

.quiz-progress {
    display: flex;
    gap: 20px;
    font-size: 1rem;
    color: var(--md-sys-color-secondary);
}

.quiz-progress span {
    font-weight: 500;
}

.answer-sheet-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--md-sys-elevation-level1);
}

.answer-sheet-toggle:hover {
    background: color-mix(in srgb, var(--md-sys-color-primary) 90%, black);
    box-shadow: var(--md-sys-elevation-level2);
}

.answer-sheet-toggle:active {
    background: color-mix(in srgb, var(--md-sys-color-primary) 80%, black);
}

.question-meta {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge.single {
    background: #e8def8;
    color: #21005d;
}

.badge.multiple {
    background: #ffe8d6;
    color: #3d1a00;
}

.badge.truefalse {
    background: #ffc9d9;
    color: #31111d;
}

.type-stats-bar {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 15px 20px;
    background: var(--md-sys-color-surface-container);
    border-radius: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.type-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.type-stat-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
}

.type-stat-badge.single {
    background: #1976d2;
}

.type-stat-badge.multiple {
    background: #f57c00;
}

.type-stat-badge.truefalse {
    background: #c2185b;
}

.type-stat-label {
    color: var(--md-sys-color-secondary);
    font-weight: 500;
}

.type-stat-count {
    font-weight: bold;
    color: var(--md-sys-color-primary);
    font-size: 1.1rem;
}

.question-content {
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 25px;
    font-weight: 400;
    white-space: pre-wrap;
    font-family: 'Roboto', 'Noto Sans SC', sans-serif;
}

.question-content pre,
.question-content code {
    font-family: 'Roboto Mono', 'Courier New', monospace;
    white-space: pre;
    background: var(--md-sys-color-surface-container);
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    line-height: 1.5;
    font-size: 0.95rem;
}

.question-content pre {
    margin: 12px 0;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-item {
    padding: 16px 20px;
    border: 2px solid var(--md-sys-color-surface-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--md-sys-color-surface);
}

.option-item:hover {
    border-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-primary-container);
    transform: translateX(4px);
}

.option-item.selected {
    border-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-primary-container);
}

.option-item.correct {
    border-color: var(--md-sys-color-success);
    background: #dcedc8;
}

.option-item.incorrect {
    border-color: var(--md-sys-color-error);
    background: #ffcdd2;
}

.option-item.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.option-radio {
    width: 20px;
    height: 20px;
    border: 2px solid var(--md-sys-color-on-surface-variant);
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s ease;
}

.option-item.selected .option-radio {
    border-color: var(--md-sys-color-primary);
}

.option-item.selected .option-radio::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: var(--md-sys-color-primary);
    border-radius: 50%;
    animation: radioIn 0.2s ease;
}

@keyframes radioIn {
    from {
        transform: translate(-50%, -50%) scale(0);
    }
    to {
        transform: translate(-50%, -50%) scale(1);
    }
}

.option-item.correct .option-radio {
    border-color: var(--md-sys-color-success);
}

.option-item.correct .option-radio::after {
    background: var(--md-sys-color-success);
}

.option-item.incorrect .option-radio {
    border-color: var(--md-sys-color-error);
}

.option-text {
    flex: 1;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--md-sys-color-on-surface);
}

.feedback {
    margin-top: 25px;
    padding: 20px;
    border-radius: 12px;
    display: none;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.feedback.show {
    display: block;
}

.feedback.correct {
    background: #dcedc8;
    border-left: 4px solid var(--md-sys-color-success);
}

.feedback.incorrect {
    background: #ffcdd2;
    border-left: 4px solid var(--md-sys-color-error);
}

.feedback-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 1.1rem;
}

.feedback.correct .feedback-header {
    color: #1b5e20;
}

.feedback.incorrect .feedback-header {
    color: #c62828;
}

.feedback-content {
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.6;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: var(--md-sys-elevation-level1);
}

.btn-primary:hover {
    background: color-mix(in srgb, var(--md-sys-color-primary) 90%, black);
    box-shadow: var(--md-sys-elevation-level2);
}

.btn-primary:active {
    background: color-mix(in srgb, var(--md-sys-color-primary) 80%, black);
}

.btn-primary:disabled {
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.btn-secondary:hover {
    background: color-mix(in srgb, var(--md-sys-color-secondary-container) 90%, black);
    box-shadow: var(--md-sys-elevation-level1);
}

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

.stat-card {
    background: var(--md-sys-color-surface-container);
    padding: 20px;
    border-radius: var(--md-sys-shape-corner-medium);
    text-align: center;
}

.stat-card .label {
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 10px;
    font-weight: 500;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--md-sys-color-primary);
}

.result-card {
    text-align: center;
    padding: 40px;
}

.result-card h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
}

.result-card .score {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--md-sys-color-primary);
    margin: 30px 0;
}

.loading-container {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid var(--md-sys-color-surface-variant);
    border-top: 4px solid var(--md-sys-color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 1rem;
    margin-top: 16px;
}

.shuffle-btn {
    background: var(--md-sys-color-tertiary);
    color: var(--md-sys-color-on-tertiary);
    border: none;
    padding: 12px 24px;
    border-radius: var(--md-sys-shape-corner-full);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    margin-top: 16px;
    box-shadow: var(--md-sys-elevation-level1);
}

.shuffle-btn:hover {
    background: color-mix(in srgb, var(--md-sys-color-tertiary) 90%, black);
    box-shadow: var(--md-sys-elevation-level2);
}

.shuffle-btn:active {
    background: color-mix(in srgb, var(--md-sys-color-tertiary) 80%, black);
}

.footer {
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 30px;
    opacity: 0.7;
    font-size: 0.875rem;
    padding: 16px;
    background: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-medium);
}

/* ==================== 设置面板样式 ==================== */
.settings-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--md-sys-shape-corner-full);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-primary);
}

.settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 350px;
    height: 100%;
    background: var(--md-sys-color-surface);
    box-shadow: var(--md-sys-elevation-level4);
    padding: 24px;
    transition: right 0.3s cubic-bezier(0.2, 0, 0, 1);
    z-index: 1000;
    overflow-y: auto;
}

.settings-panel.open {
    right: 0;
}

.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
}

.settings-overlay.open {
    opacity: 1;
    visibility: visible;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--md-sys-color-surface-variant);
}

.settings-header h2 {
    font-size: 1.5rem;
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
}

.settings-group {
    margin-bottom: 24px;
}

.settings-group-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--md-sys-color-surface-container);
}

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

.settings-item-info {
    flex: 1;
    padding-right: 16px;
}

.settings-item-label {
    font-size: 1rem;
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
}

.settings-item-description {
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 4px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--md-sys-color-surface-variant);
    transition: 0.3s;
    border-radius: 32px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: var(--md-sys-color-primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider:hover {
    opacity: 0.8;
}

/* ==================== 主题选择器样式 ==================== */
.theme-select {
    padding: 8px 12px;
    border: 2px solid var(--md-sys-color-surface-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    min-width: 120px;
}

.theme-select:hover {
    border-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-primary-container);
}

.theme-select:focus {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 3px var(--md-sys-color-primary-container);
}

.theme-select option {
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    padding: 8px;
}

/* ==================== 答题卡样式 ==================== */
.answer-sheet-card {
    max-height: 600px;
    overflow-y: auto;
}

.answer-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--md-sys-color-surface-variant);
}

.answer-sheet-header h3 {
    margin: 0;
    color: var(--md-sys-color-on-surface);
    font-size: 1.5rem;
    font-weight: 500;
}

.close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--md-sys-shape-corner-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    color: var(--md-sys-color-on-surface-variant);
}

.close-btn:hover {
    background: var(--md-sys-color-surface-container-high);
}

.answer-sheet-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
}

.legend-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--md-sys-color-surface-variant);
}

.legend-dot.current {
    background: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}

.legend-dot.unanswered {
    background: var(--md-sys-color-surface);
}

.legend-dot.correct {
    background: var(--md-sys-color-success);
    border-color: var(--md-sys-color-success);
}

.legend-dot.incorrect {
    background: var(--md-sys-color-error);
    border-color: var(--md-sys-color-error);
}

/* 答题卡主容器 - 使用 flex 布局而不是 grid */
#answerSheetGrid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ==================== 答题卡分组样式 ==================== */
.answer-sheet-section {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-medium);
    transition: box-shadow 0.2s ease;
}

.answer-sheet-section:hover {
    box-shadow: var(--md-sys-elevation-level1);
}

.answer-sheet-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--md-sys-color-surface-variant);
}

.section-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
}

.answer-sheet-section:nth-child(1) .section-title::before {
    background: #1976d2;
}

.answer-sheet-section:nth-child(2) .section-title::before {
    background: #f57c00;
}

.answer-sheet-section:nth-child(3) .section-title::before {
    background: #c2185b;
}

.section-stats {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
}

.section-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
}

.section-stat.correct {
    color: var(--md-sys-color-success);
}

.section-stat.incorrect {
    color: var(--md-sys-color-error);
}

/* section 内部的网格布局 */
.answer-sheet-section .answer-sheet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 10px;
    margin-bottom: 0;
}

.answer-sheet-item {
    width: 50px;
    height: 50px;
    border: 2px solid var(--md-sys-color-surface-variant);
    border-radius: var(--md-sys-shape-corner-small);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    background: var(--md-sys-color-surface);
    font-size: 0.95rem;
}

.answer-sheet-item:hover {
    transform: scale(1.1);
    box-shadow: var(--md-sys-elevation-level2);
}

.answer-sheet-item.current {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-color: var(--md-sys-color-primary);
}

.answer-sheet-item.correct {
    background: var(--md-sys-color-success);
    color: var(--md-sys-color-on-success);
    border-color: var(--md-sys-color-success);
}

.answer-sheet-item.incorrect {
    background: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    border-color: var(--md-sys-color-error);
}

.answer-sheet-stats {
    display: flex;
    justify-content: space-around;
    padding: 16px 20px;
    background: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-medium);
    font-size: 0.95rem;
}

.answer-sheet-stats span {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

@media (max-width: 600px) {
    .header h1 {
        font-size: 1.75rem;
    }

    .card {
        padding: 20px;
    }

    .quiz-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .button-group {
        flex-direction: column;
    }

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

    /* 答题卡移动端适配 */
    .answer-sheet-section {
        padding: 12px;
        margin-bottom: 16px;
    }

    .answer-sheet-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .section-stats {
        width: 100%;
        justify-content: space-between;
        font-size: 0.8rem;
    }

    /* section 内部的网格移动端适配 */
    .answer-sheet-section .answer-sheet-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
        gap: 8px;
    }

    .answer-sheet-item {
        width: 45px;
        height: 45px;
        font-size: 0.875rem;
    }
}

/* ==================== 解锁面板样式 ==================== */
.unlock-panel {
    text-align: center;
    padding: 20px;
}

.unlock-panel h3 {
    font-size: 1.5rem;
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
    margin-bottom: 16px;
}

.unlock-info {
    text-align: left;
    border-radius: var(--md-sys-shape-corner-medium);
    margin-bottom: 20px;
}

.unlock-info div {
    margin-bottom: 8px;
}

.unlock-info strong {
    color: var(--md-sys-color-on-surface);
    font-weight: 600;
}

.unlock-info span {
    color: var(--md-sys-color-on-surface-variant);
    font-family: 'Roboto Mono', 'Courier New', monospace;
}

.unlock-input-group {
    margin: 20px 0;
}

.unlock-input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid var(--md-sys-color-surface-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    font-size: 1.1rem;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    text-align: center;
    letter-spacing: 2px;
    font-weight: 600;
    transition: all 0.2s ease;
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
}

.unlock-input:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 3px var(--md-sys-color-primary-container);
}

.unlock-input::placeholder {
    font-family: 'Roboto', 'Noto Sans SC', sans-serif;
    letter-spacing: normal;
    font-weight: 400;
    text-transform: none;
    opacity: 0.5;
}

/* 错误提示样式 */
.unlock-input.error {
    border-color: var(--md-sys-color-error);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-error) 20%, transparent);
}

/* 成功提示样式 */
.unlock-input.success {
    border-color: var(--md-sys-color-success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-success) 20%, transparent);
}

/* 设备ID显示样式 */
#deviceKey {
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--md-sys-color-primary);
    letter-spacing: 1.5px;
}

/* 解锁反馈信息 */
#unlockFeedback {
    min-height: 24px;
    transition: all 0.3s ease;
}

#unlockFeedback span {
    display: block;
    padding: 8px 16px;
    border-radius: var(--md-sys-shape-corner-small);
    font-weight: 500;
}

