/* ===== 全局变量与基础重置 ===== */
:root {
    --primary-color: #007acc;
    --secondary-color: #00a86b;
    --accent-color: #ff9900;
    --danger-color: #ff3333;
    --card-bg: rgba(255,255,255,0.9);
    --text-color: #333;
    --question-font-size: 20px;
    --option-font-size: 18px;
    --option-height: auto;
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: radial-gradient(ellipse at 20% 20%, rgba(173,216,230,0.4) 0%, transparent 50%), radial-gradient(ellipse at 80% 80%, rgba(255,182,193,0.3) 0%, transparent 50%), linear-gradient(135deg, #e6f7ff 0%, #f0f8ff 30%, #f5f5f5 70%);
    color: #333;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.5s ease;
    zoom: 1.25;
}

.hidden {
    display: none;
}

/* ===== 深色主题基础 ===== */
body.dark-theme {
    background: radial-gradient(ellipse at 20% 20%, rgba(42,74,150,0.3) 0%, transparent 50%), radial-gradient(ellipse at 80% 80%, rgba(120,40,140,0.2) 0%, transparent 50%), linear-gradient(135deg, #0f0c29 0%, #302b63 30%, #24243e 70%);
    color: white;
    --primary-color: #00e5ff;
    --secondary-color: #00e676;
    --accent-color: #ffcc00;
    --danger-color: #ff5252;
    --card-bg: rgba(255,255,255,0.08);
    --text-color: white;
}

/* ===== 顶部导航 ===== */
.top-nav {
    position: fixed;
    top: 30px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 15px 30px;
    background: transparent;
    z-index: 1000;
}

.path-display {
    display: none;
}

.path-segment {
    cursor: pointer;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
}

.path-segment:hover {
    color: var(--accent-color);
}

.path-separator {
    margin: 0 8px;
    color: #aaa;
}

.nav-buttons {
    display: flex;
    gap: 15px;
}

.nav-btn {
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    font-weight: bold;
    color: white;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
}

.nav-btn:hover {
    transform: none;
    box-shadow: 0 5px 15px rgba(0,122,204,0.4);
}

.back-btn {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
}

.back-btn:hover {
    box-shadow: 0 5px 15px rgba(255, 152, 0, 0.4) !important;
}

/* ===== 首页 ===== */
.home-page {
    text-align: center;
    padding: 10px 20px;
}

.hero {
    margin-bottom: 60px;
}

.hero h1 {
    font-size: 48px;
    margin-bottom: 20px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 2px 10px rgba(0,229,255,0.2);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 10px rgba(0,229,255,0.5); }
    to { text-shadow: 0 0 20px rgba(0,230,118,0.7); }
}

.hero p {
    font-size: 20px;
    color: #666;
    margin-bottom: 40px;
    letter-spacing: 1px;
}

body.dark-theme .hero p {
    color: #b0b0ff;
}

.grade-selection {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.grade-card {
    background: rgba(255,255,255,0.85);
    padding: 10px 10px;
    border-radius: 20px;
    width: 280px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(0,0,0,0.08);
    backdrop-filter: blur(10px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    -webkit-tap-highlight-color: transparent;
}

.grade-card:hover {
    background: rgba(255,255,255,0.95);
    box-shadow: 0 10px 30px rgba(0,122,204,0.18);
    border-color: var(--primary-color);
}

.grade-card:active {
    transform: scale(0.97);
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

.grade-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.grade-card h3 {
    margin: 15px 0;
    color: var(--primary-color);
    font-size: 28px;
}

.grade-card p {
    color: #666;
    font-size: 16px;
}

body.dark-theme .grade-card {
    background: var(--card-bg);
    color: var(--text-color);
}

/* ===== 章节选择页面 ===== */
.chapter-page {
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.page-header h2 {
    font-size: 36px;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.page-header p {
    color: #666;
    font-size: 18px;
}

body.dark-theme .page-header p {
    color: #b0b0ff;
}

.selection-level {
    margin-bottom: 50px;
}

.selection-level h3 {
    text-align: center;
    color: var(--secondary-color);
    margin-bottom: 25px;
    font-size: 24px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin: 0 auto;
    max-width: 1000px;
    width: 100%;
}

.options1-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, 200px);
    gap: 20px;
    margin: 0 auto;
    max-width: 1000px;
    width: 100%;
    justify-content: center;
}

.option-btn {
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 15px;
    padding: 25px 20px;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 18px;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    -webkit-tap-highlight-color: transparent;
}

.option-btn:hover {
    background: rgba(255,255,255,0.95);
    box-shadow: 0 10px 30px rgba(0,122,204,0.18);
    border-color: var(--primary-color);
}

.option-btn small {
    display: block;
    margin-top: 8px;
    font-size: 18px;
    color: inherit;
    font-weight: normal;
}

body.dark-theme .option-btn {
    background: rgba(255,255,255,0.08);
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

body.dark-theme .option-btn:hover {
    background: linear-gradient(135deg, rgba(0,229,255,0.25), rgba(0,230,118,0.25));
    border-color: rgba(0,229,255,0.6);
    box-shadow: 0 0 15px rgba(0,229,255,0.5);
    transform: none;
}

body.dark-theme .option-btn:active {
    transform: scale(0.97);
    box-shadow: inset 0 0 10px rgba(0,229,255,0.6), 0 0 8px rgba(0,229,255,0.4);
}

body.dark-theme .option-btn small {
    color: #ccc;
}

/* ===== 游戏主界面布局 ===== */
.game-container {
    width: 98%;
    max-width: 1300px;
    margin: 30px auto;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.timer-column {
    flex: 0 0 180px;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    box-sizing: border-box;
    position: sticky;
    top: 100px;
}

.game-column {
    flex: 2;
    background: var(--card-bg);
    padding: 25px;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.badges-column {
    flex: 0 0 200px;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    box-sizing: border-box;
    position: sticky;
    top: 100px;
}

body.dark-theme .timer-column,
body.dark-theme .game-column,
body.dark-theme .badges-column {
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

/* ===== 计时器与统计 ===== */
.timer-container {
    text-align: center;
    margin-bottom: 15px;
}

.timer-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    box-shadow: 0 8px 20px rgba(0,122,204,0.3);
}

.timer-inner {
    background: white;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

#timerText {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
}

#timerLabel {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

body.dark-theme .timer-inner {
    background: rgba(0,0,0,0.3);
}

body.dark-theme #timerLabel {
    color: #ccc;
}

.timer-column h3 {
    text-align: center;
    color: var(--accent-color);
    margin-bottom: 20px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 16px;
    background: rgba(0,0,0,0.05);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05);
}

body.dark-theme .stats {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

.fire {
    font-size: 20px;
    color: #ff5722;
    animation: pulse 0.6s infinite alternate;
    filter: drop-shadow(0 0 5px #ff5722);
}

@keyframes pulse {
    from { transform: scale(1); filter: drop-shadow(0 0 5px #ff5722); }
    to { transform: scale(1.2); filter: drop-shadow(0 0 8px #ff5722); }
}

.progress {
    height: 10px;
    background: rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid rgba(0,0,0,0.05);
}

#progressBar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--accent-color));
    border-radius: 8px;
    transition: 0.4s ease;
    position: relative;
    overflow: hidden;
}

#progressBar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== 题目与选项 ===== */

#question {
    font-size: var(--question-font-size);
    margin-bottom: 20px;
    line-height: 1.5;
    padding: 0 10px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    font-weight: normal;
    text-align: left;
}

.word-formula {
    font-family: 'Cambria Math', 'Times New Roman', serif;
}

.option-label {
    flex: 0 0 auto;
    margin-right: 2px;
}

.option-content {
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.option {
    background: rgba(255,255,255,0.95);
    margin: 10px 0;
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(0,0,0,0.05);
    font-size: var(--option-font-size);
    min-height: var(--option-height);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
}

.question-inline-image {
    max-height: 2.5em;
    width: auto;
    vertical-align: middle;
    display: inline-block;
    margin: 0 2px;
}

.option .inline-image {
    width: 120px; 
    height: auto;
    max-height: 120px;
    object-fit: contain; 
    vertical-align: middle;
    margin-right: 8px;
}

.review-option .inline-image {
    width: 120px;
    height: auto;
    max-height: 120px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 8px;
}

body.dark-theme .option {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.12);
}

.correct {
    background: linear-gradient(90deg, rgba(0,168,107,0.7), rgba(76,175,80,0.7)) !important;
    border-color: rgba(0,168,107,0.5) !important;
    box-shadow: 0 4px 15px rgba(0,230,118,0.01) !important;
}

.wrong {
    background: linear-gradient(90deg, rgba(255,51,51,0.7), rgba(255,64,129,0.7)) !important;
    border-color: rgba(255,51,51,0.5) !important;
    box-shadow: 0 4px 15px rgba(255,82,82,0.01) !important;
}

.rank {
    font-weight: bold;
    color: #ff9900;
    font-size: 18px;
}
/* ===== 分数渲染 ===== */
.frac {
    display: inline-block;
    vertical-align: middle;
    text-align: center;
}
.frac > span {
    display: block;
}
.frac > span:first-child {
    border-bottom: 1px solid currentColor;
}
/* ===== 根号渲染 ===== */
.sqrt {
    display: inline-block;
    white-space: nowrap;
    position: relative;
    vertical-align: middle;
    margin-right: 0.1em;
}
.sqrt .radicand {
    border-top: 1px solid currentColor;
    padding-left: 0.1em;
    padding-right: 0.05em;
    margin-left: 0.1em;
    white-space: nowrap;
}
.sqrt .index {
    font-size: 0.7em;
    vertical-align: super;
    margin-right: 0.1em;
}
/* ===== 加点字渲染 ===== */
.dot {
    text-decoration: underline dotted;
    text-underline-position: under;
}
/* ===== 徽章列 ===== */
.badges-column h3 {
    text-align: center;
    color: var(--accent-color);
    margin-bottom: 20px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.badges-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 150px;
}

.badge-item {
    background: rgba(255,255,255,0.7);
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(0,0,0,0.05);
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.5s ease forwards;
}

body.dark-theme .badge-item {
    border: 1px solid rgba(255,255,255,0.05);
}

.badge-item.active {
    background: linear-gradient(45deg, gold, var(--accent-color));
    color: black;
    font-weight: bold;
    box-shadow: 0 3px 8px rgba(255,204,0,0.3);
}

.badge-icon {
    font-size: 18px;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 结束页面 ===== */
.finish {
    width: 80%;
    max-width: 600px;
    margin: 10px auto;
    background: var(--card-bg);
    padding: 10px;
    border-radius: 25px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    text-align: center;
}

body.dark-theme .finish {
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.finish h2 {
    font-size: 36px;
    margin-bottom: 30px;
    background: linear-gradient(to right, var(--accent-color), #ff9800);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.finish-stats {
    background: rgba(0,0,0,0.05);
    border-radius: 15px;
    padding: 8px;
    margin: 25px 0;
    border: 1px solid rgba(0,0,0,0.1);
}

body.dark-theme .finish-stats {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    font-size: 18px;
}

body.dark-theme .stat-item {
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.stat-value {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 22px;
}

.finish-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

.finish-buttons button {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

#restartBtn {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 15px rgba(0,122,204,0.3);
}

#homeBtn {
    background: linear-gradient(45deg, #ff6b6b, #ffa726);
    color: white;
    box-shadow: 0 4px 15px rgba(255,107,107,0.3);
}

#reviewBtn {
    background: linear-gradient(45deg, #ff4757, #ff6b6b);
    color: white;
    box-shadow: 0 4px 15px rgba(255,107,107,0.3);
}

#prevBtn {
    background: linear-gradient(45deg, #ff4757, #ff6b6b);
    color: white;
    box-shadow: 0 4px 15px rgba(255,107,107,0.3);
}

#nextBtn {
    background: linear-gradient(45deg, #ff6b6b, #ffa726);
    color: white;
    box-shadow: 0 4px 15px rgba(255,107,107,0.3);
}

#prevBtn:disabled,
#nextBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== 排行榜 ===== */
.leaderboard {
    margin: 60px auto 40px;
    max-width: 800px;
    background: var(--card-bg);
    padding: 30px;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

body.dark-theme .leaderboard {
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.leaderboard h3 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--accent-color);
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

#leaderboard {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#leaderboard p {
    background: rgba(0,0,0,0.05);
    padding: 18px;
    border-radius: 12px;
    margin: 5px 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
    border: 1px solid rgba(0,0,0,0.05);
}

body.dark-theme #leaderboard p {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.05);
}

#leaderboard p:hover {
    background: rgba(0,0,0,0.08);
    transform: translateX(10px);
}

body.dark-theme #leaderboard p:hover {
    background: rgba(255,255,255,0.12);
}

#leaderboard p:nth-child(1) {
    color: #ff9900;
    font-weight: bold;
}

#leaderboard p:nth-child(2) {
    color: #c0c0c0;
}

#leaderboard p:nth-child(3) {
    color: #cd7f32;
}

/* ===== 设置页面 ===== */
.settings {
    width: 80%;
    max-width: 800px;
    margin: 10px auto 30px;
    background: var(--card-bg);
    padding: 30px;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
}

body.dark-theme .settings {
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
}

.settings h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary-color);
    font-size: 28px;
}

.setting-group {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

body.dark-theme .setting-group {
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.setting-group h3 {
    color: var(--secondary-color);
    margin-bottom: 15px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0;
    padding: 10px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
    transition: all 0.3s ease;
}

body.dark-theme .setting-item {
    background: rgba(255,255,255,0.05);
}

.setting-item:hover {
    background: rgba(0,0,0,0.05);
}

body.dark-theme .setting-item:hover {
    background: rgba(255,255,255,0.1);
}

.setting-label {
    flex: 1;
    font-size: 16px;
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.slider-range {
    width: 150px;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
    outline: none;
}

.slider-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

.select-box {
    padding: 8px 15px;
    border-radius: 8px;
    background: rgba(255,255,255,0.9);
    border: 1px solid #ddd;
    color: #333;
    font-size: 14px;
    min-width: 150px;
}

body.dark-theme .select-box {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,122,204,0.4);
}

.btn-secondary {
    background: rgba(0,0,0,0.1);
    color: #333;
    border: 1px solid rgba(0,0,0,0.2);
}

.btn-secondary:hover {
    background: rgba(0,0,0,0.15);
}

body.dark-theme .btn-secondary {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

body.dark-theme .btn-secondary:hover {
    background: rgba(255,255,255,0.2);
}

/* ===== 模态框 ===== */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.custom-modal.hidden {
    display: none;
}

.custom-modal-content {
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.4);
    animation: modalFadeIn 0.3s ease-out;
}

body.dark-theme .custom-modal-content {
    border: 1px solid rgba(255,255,255,0.1);
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.custom-modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.custom-modal-header h3 {
    color: var(--accent-color);
    font-size: 24px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.custom-modal-body {
    margin-bottom: 30px;
    text-align: center;
}

.custom-modal-body p {
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-color);
    margin: 0;
}

.custom-modal-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.custom-modal-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.custom-modal-btn.cancel-btn {
    background: rgba(0,0,0,0.1);
    color: #333;
    border: 1px solid rgba(0,0,0,0.2);
}

.custom-modal-btn.cancel-btn:hover {
    background: rgba(0,0,0,0.15);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

body.dark-theme .custom-modal-btn.cancel-btn {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

body.dark-theme .custom-modal-btn.cancel-btn:hover {
    background: rgba(255,255,255,0.2);
}

.custom-modal-btn.ok-btn {
    background: linear-gradient(45deg, #ff6b6b, #ff5252);
    color: white;
    box-shadow: 0 4px 15px rgba(255,107,107,0.3);
}

.custom-modal-btn.ok-btn:hover {
    background: linear-gradient(45deg, #ff5252, #ff3333);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255,107,107,0.4);
}

/* ===== 复习页面 ===== */
.review-container {
    max-width: 800px;
    margin: 10px auto 10px auto;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    min-height: auto;
}

body.dark-theme .review-container {
    background: var(--card-bg);
}

.review-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--danger-color);
}

.review-header h2 {
    font-size: 28px;
    color: var(--danger-color);
    margin: 0;
}

.review-counter {
    text-align: center;
    color: #666;
    font-size: 16px;
    margin-bottom: 20px;
}

.review-question {
    font-size: var(--question-font-size);
    margin-bottom: 15px;
    line-height: 1.4;
    color: #333;
}

body.dark-theme .review-question {
    color: white;
}

.review-image {
    text-align: center;
    margin: 20px 0;
}

.review-image img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 10px;
}

.review-options {
    margin: 15px 0;
}

.review-option {
    background: rgba(255,255,255,0.95);
    margin: 10px 0;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05);
    font-size: var(--option-font-size);
    display: flex;
    align-items: center;
    min-height: var(--option-height);
    color: #333;
    line-height: 1.4;
}

body.dark-theme .review-option {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
}

.review-option .option-letter {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-weight: bold;
    font-size: 14px;
}

.review-option .option-text {
    flex: 1;
}

.review-option.correct {
    background: linear-gradient(90deg, rgba(0,168,107,0.7), rgba(76,175,80,0.7)) !important;
    border-color: rgba(0,168,107,0.5) !important;
    box-shadow: 0 4px 15px rgba(0,230,118,0.01) !important;
}

.review-option.wrong {
    background: linear-gradient(90deg, rgba(255,51,51,0.7), rgba(255,64,129,0.7)) !important;
    border-color: rgba(255,51,51,0.5) !important;
    box-shadow: 0 4px 15px rgba(255,82,82,0.01) !important;
}

body.dark-theme .review-option.correct .option-letter,
body.dark-theme .review-option.wrong .option-letter {
    color: white;
}

.review-answer-info {
    display: none;
}

.no-wrong {
    text-align: center;
    padding: 60px 20px;
}

.no-wrong-icon {
    font-size: 64px;
    color: var(--secondary-color);
    margin-bottom: 20px;
}

.no-wrong h3 {
    color: var(--secondary-color);
    margin-bottom: 15px;
}

/* ===== 图片相关 ===== */
.question-image {
    margin: 10px auto 2px auto;
    max-width: 80%;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
.question-image img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.1);
    object-fit: contain;
    flex: 0 1 auto;
}

body.dark-theme .question-image img {
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.image-fallback {
    color: #ff6b6b;
    font-size: 14px;
    padding: 10px;
    background: rgba(255,107,107,0.1);
    border-radius: 8px;
    margin-top: 10px;
}

/* ===== 工具类 ===== */
.game-exit-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.no-hover * {
    pointer-events: none !important;
}

.option:focus {
    outline: none;
}

.option:active,
.option-btn:active,
.grade-card:active,
.nav-btn:active {
    transform: none !important;
    box-shadow: none !important;
}

/* ===== 响应式设计 ===== */
@media (max-width: 1024px) {
    .game-container {
        flex-direction: column;
        gap: 15px;
    }
    .timer-column, .badges-column {
        position: static;
        width: 100%;
    }
}

@media (hover: none) and (pointer: coarse) {
    .option-btn:hover,
    .grade-card:hover,
    .option:hover,
    .nav-btn:hover {
        transform: none !important;
        box-shadow: none !important;
        background: inherit !important;
    }
    .grade-card:active,
    .option:active,
    .nav-btn:active {
        transform: translateY(-2px) !important;
        box-shadow: 0 5px 15px rgba(0,122,204,0.4) !important;
    }
}

@media (max-width: 768px) {
    .top-nav {
        position: fixed;
        top: 0;
        right: 0;
        left: auto;
        width: auto;
    }

    body.dark-theme .top-nav {
        background: rgba(0,0,0,0.8);
    }
    .path-display {
        font-size: 14px;
    }
    .nav-btn {
        padding: 8px 15px;
        font-size: 12px;
    }
    .hero h1 {
        font-size: 36px;
    }
    .grade-selection {
        flex-direction: column;
        align-items: center;
    }
    .grade-card {
        width: 90%;
        padding: 40px 20px;
    }
    .option-btn {
        padding: 20px 15px;
        font-size: 16px;
    }
    .game-container {
        width: 95%;
    }
    .game-column {
        width: 100%;
        padding: 20px;
        margin-top: 20px;
    }
    .stats {
        flex-direction: row;
        gap: 12px;
        text-align: center;
        font-size: 14px;
    }
    .finish-buttons {
        flex-direction: column;
        gap: 15px;
    }
    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .setting-control {
        width: 100%;
        justify-content: space-between;
    }
    .custom-modal-content {
        padding: 20px;
        width: 95%;
    }
    .custom-modal-btn {
        padding: 10px 20px;
        min-width: 100px;
        font-size: 14px;
    }
    .custom-modal-footer {
        flex-direction: column;
        gap: 10px;
    }
    .review-container {
        padding: 15px;
        margin: 10px auto;
    }
    .review-header h2 {
        font-size: 24px;
    }
    .review-question {
        font-size: 16px;
    }
    .review-option {
        padding: 8px 10px;
        min-height: 40px;
    }
    .option-letter {
        width: 26px;
        height: 26px;
        font-size: 12px;
        margin-right: 10px;
    }
    .option-text {
        font-size: 14px;
    }
    .setting-item {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px;
    }
    /* 新增：让“关于”项保持垂直排列 */
    .setting-item.about-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        height: auto !important;
    }
    .setting-label {
        flex: 0 0 auto;
        width: 90px;
        font-size: 14px;
    }
    .setting-control {
        flex: 1 1 auto;
        width: auto !important;
        justify-content: flex-end !important;
        gap: 8px;
        flex-wrap: nowrap;
    }
    .slider-range {
        min-width: 80px;
        width: 100%;
    }
    .select-box {
        min-width: 70px;
        width: auto;
    }
    .setting-control .switch,
    .setting-control span:not(.slider) {
        white-space: nowrap;
    }
}

#volumePage .selection-level,
#modePage .selection-level {
    display: flex;
    justify-content: center;
}

@media (max-width: 480px) {
    .options-grid {
        grid-template-columns: 1fr;
    }
    #volumePage .options-grid,
    #modePage .options-grid {
        grid-template-columns: 1fr;
        max-width: 300px;
    }
    .nav-buttons {
        flex-direction: column;
        gap: 10px;
    }
    .question-image {
        max-width: 95%;
    }
    .question-image img {
        max-height: 200px;
    }
    .review-option {
        padding: 12px;
    }
    .option-letter {
        width: 30px;
        height: 30px;
        margin-right: 10px;
    }
    .setting-label {
        width: 70px;
        font-size: 12px;
    }
    .setting-control {
        gap: 4px;
    }
    .slider-range {
        min-width: 60px;
    }
}