* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}
.card {
    background: #fff;
    border-radius: 0;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    height: 100%;
    padding: 2px 64px 14px 64px;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    font-size: 13px;
    color: #aaa;
    flex-shrink: 0;
}
.status-bar .search-result { color: #667eea; font-weight: 500; }
.search-bar {
    display: flex;
    justify-content: center;
    margin-bottom: 1px;
    gap: 10px;
    flex-shrink: 0;
}
.search-bar input {
    width: 60%;
    max-width: 400px;
    padding: 10px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    transition: border 0.2s;
}
.search-bar input:focus { border-color: #667eea; }
.search-bar input::placeholder { color: #bbb; }
.search-bar button {
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.search-bar button:hover { background: #5a6fd6; }
.card-content {
    display: none;
    flex: 1;
    flex-direction: column;
    justify-content: space-evenly;
    overflow: hidden;
    min-height: 0;
}
.card-content.show { display: flex; }
.word-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 0;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.word {
    font-size: clamp(28px, 4.5vw, 48px);
    font-weight: 700;
    color: #333;
    text-align: center;
    letter-spacing: 1px;
    line-height: 1.2;
    flex-shrink: 0;
}
.speaker-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    padding: 0;
    position: relative;
    flex-shrink: 0;
    border-radius: 8px;
}
/* 点击区域扩大与 hover 背景：用伪元素，不占布局空间，保证居中 */
.speaker-wrap::before {
    content: '';
    position: absolute;
    inset: -10px -14px;
    border-radius: 8px;
    transition: background 0.15s;
}
.speaker-wrap:hover::before { background: rgba(102,126,234,0.08); }
.speaker {
    font-size: clamp(20px, 2.5vw, 28px);
    line-height: 1;
    flex-shrink: 0;
    transition: transform 0.15s;
}
.speaker-wrap:hover .speaker { transform: scale(1.15); }
.speaker-wrap:active .speaker { transform: scale(0.9); }
.phonetic {
    font-size: clamp(17px, 2.2vw, 26px);
    color: #555;
    font-family: Arial, 'Helvetica Neue', sans-serif;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.rating {
    text-align: center;
    font-size: clamp(17px, 2.2vw, 26px);
    margin-bottom: 0;
    letter-spacing: 4px;
    flex-shrink: 0;
}
.rating .star-filled { color: #E53238; }
.rating .star-empty { color: #ddd; }

.sentence-speaker {
    font-size: clamp(15px, 1.8vw, 22px);
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
    position: relative;
    transition: transform 0.15s;
    border-radius: 4px;
    align-self: center;
}
/* 点击区域扩大与 hover 背景：用伪元素，不占布局空间，保证句子居中 */
.sentence-speaker::before {
    content: '';
    position: absolute;
    inset: -14px -10px;
    border-radius: 4px;
}
.sentence-speaker:hover { transform: scale(1.2); }
.sentence-speaker:hover::before { background: rgba(102,126,234,0.08); }
.sentence-speaker:active { transform: scale(0.9); }

.sentence {
    font-size: clamp(21px, 2.6vw, 30px);
    color: #555;
    line-height: 1.5;
    margin-bottom: 0;
    padding: 0 5px;
    text-align: center;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}
.sentence #sentenceText {
    display: inline;
}
.sentence .sentence-speaker {
    display: inline-block;
    flex-shrink: 0;
}
.translation {
    font-size: clamp(21px, 2.6vw, 30px);
    color: #666;
    line-height: 1.5;
    margin-bottom: 0;
    padding: 0 5px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}
.definition {
    font-size: clamp(21px, 2.6vw, 30px);
    line-height: 1.5;
    padding: 0 5px;
    text-align: center;
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
}
.definition .pos { color: #00B0F0; }
.not-found {
    text-align: center;
    color: #E53238;
    font-size: 18px;
    display: none;
    flex: 1;
    align-items: center;
    justify-content: center;
}
.not-found.show { display: flex; }
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
    padding-top: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.controls button {
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 6px 4px;
    font-size: clamp(13px, 1.5vw, 16px);
    cursor: pointer;
    transition: all 0.2s;
    width: 88px;
    min-width: 0;
    text-align: center;
    white-space: nowrap;
}
.controls button:hover { background: #5a6fd6; transform: translateY(-1px); }
.controls button:active { transform: translateY(0); }
.controls .random-btn { background: #f093fb; }
.controls .random-btn:hover { background: #e884f0; }
.controls .auto-btn { background: #4caf50; }
.controls .auto-btn:hover { background: #43a047; }
.controls .auto-btn.stop { background: #f44336; }
.controls .auto-btn.stop:hover { background: #e53935; }
.controls .speed-btn { background: #ff9800; }
.controls .speed-btn:hover { background: #f57c00; }
.controls .filter-btn { background: #9c27b0; }
.controls .filter-btn:hover { background: #7b1fa2; }
.controls .filter-btn.active-filter { background: #e040fb; }
.controls .list-btn { background: #009688; }
.controls .list-btn:hover { background: #00796b; }

.star-btn, .master-btn {
    font-size: clamp(20px, 2.5vw, 28px);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: transform 0.15s;
    flex-shrink: 0;
}
.star-btn:hover, .master-btn:hover { transform: scale(1.2); }
.star-btn.starred { filter: none; }
.star-btn:not(.starred) { opacity: 0.3; }
.master-btn.mastered { filter: none; }
.master-btn:not(.mastered) { opacity: 0.3; }
.progress {
    text-align: center;
    color: #999;
    font-size: 13px;
    padding-top: 4px;
    flex-shrink: 0;
}
@media (max-width: 700px) {
    body { padding: 0; }
    .card { padding: 2px 14px 10px 14px; border-radius: 0; }
    .search-bar { margin-bottom: 4px; }
    .search-bar input { padding: 8px 14px; font-size: 14px; }
    .search-bar button { padding: 6px 12px; font-size: 14px; }
    .card-content { justify-content: space-evenly; padding-top: 0; }
    .rating { margin-bottom: 0; }
    .controls { gap: 10px; }
    .controls button { padding: 6px 4px; min-width: 0; width: 72px; text-align: center; }
}
@media (max-width: 400px) {
    body { padding: 8px 3px; }
    .card { padding: 8px 10px; }
}

/* Word list overlay */
.word-list-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: #fff;
    z-index: 50;
    border-radius: 16px;
    flex-direction: column;
    overflow: hidden;
}
.word-list-overlay.show { display: flex; }
.word-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 2px solid #e0e0e0;
    flex-shrink: 0;
    font-size: 16px;
    font-weight: 700;
    color: #333;
}
.word-list-header button {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #999;
    padding: 0 4px;
    line-height: 1;
}
.word-list-header button:hover { color: #333; }
.word-list-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.word-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 18px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.1s;
    font-size: 15px;
}
.word-list-item:hover { background: #f5f0ff; }
.word-list-item .wl-idx {
    color: #bbb;
    font-size: 12px;
    min-width: 36px;
    text-align: right;
}
.word-list-item .wl-word {
    font-weight: 600;
    color: #333;
    min-width: 100px;
}
.word-list-item .wl-zh {
    color: #888;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mode-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 0;
    flex-shrink: 0;
    position: absolute;
    left: 34px;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    flex-wrap: nowrap;
    padding: 8px 4px;
    background: rgba(255,255,255,0.92);
    border-radius: 0 10px 10px 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.12);
    z-index: 25;
}
.mode-btn {
    flex: 0 0 auto;
    max-width: none;
    width: 100%;
    min-width: 48px;
    padding: 4px 6px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    color: #667eea;
    white-space: nowrap;
}
.mode-btn.active {
    background: #667eea;
    color: #fff;
}
.mode-btn.vocab-mode.active {
    background: #e91e63;
    color: #fff;
}
.mode-btn.spell-mode.active {
    background: #00bcd4;
    color: #fff;
}
.mode-btn.quiz-mode.active {
    background: #ff6f00;
    color: #fff;
}
.mode-btn:hover { opacity: 0.85; }
.hint-btn {
    background: #4ecdc4 !important;
}
.hint-btn:hover { background: #3dbdb5 !important; }
.level-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    padding: 2px 0;
    flex-shrink: 0;
    position: absolute;
    right: 34px;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    flex-wrap: nowrap;
    padding: 8px 4px;
    background: rgba(255,255,255,0.92);
    border-radius: 10px 0 0 10px;
    box-shadow: -2px 0 10px rgba(0,0,0,0.12);
    z-index: 25;
}
.level-btn {
    flex: 0 0 auto;
    max-width: none;
    width: 100%;
    min-width: 48px;
    padding: 4px 6px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    color: #667eea;
    white-space: nowrap;
}
.level-btn.active {
    background: #667eea;
    color: #fff;
}
.level-btn:hover { opacity: 0.85; }

/* ===== 侧栏折叠开关 ===== */
.rail-toggle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    letter-spacing: 3px;
    padding: 14px 6px;
    background: #667eea;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    z-index: 30;
    transition: background 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.rail-toggle:hover { background: #5a6fd6; }
.rail-toggle-left { left: 0; border-radius: 0 8px 8px 0; }
.rail-toggle-right { right: 0; border-radius: 8px 0 0 8px; }
body.mode-rail-collapsed .mode-bar { display: none; }
body.level-rail-collapsed .level-bar { display: none; }
body.mode-rail-collapsed .rail-toggle-left { background: #9aa0b5; }
body.level-rail-collapsed .rail-toggle-right { background: #9aa0b5; }

/* 初中模式：所有元素水平居中 */
body.middle-mode .status-bar { justify-content: center; gap: 12px; }
body.middle-mode .mode-bar,
body.middle-mode .search-bar,
body.middle-mode .word-row,
body.middle-mode .rating,
body.middle-mode .sentence,
body.middle-mode .translation,
body.middle-mode .definition,
body.middle-mode .controls,
body.middle-mode .level-bar { justify-content: center; text-align: center; }

/* ====== Dark Mode ====== */
body.dark { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); }
body.dark .card { background: #1e1e2e; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
body.dark .word { color: #e0e0e0; }
body.dark .phonetic { color: #aaa; }
body.dark .sentence { color: #bbb; }
body.dark .translation { color: #aaa; }
body.dark .definition { color: #ccc; }
body.dark .definition .pos { color: #4fc3f7; }
body.dark .status-bar { color: #888; }
body.dark .search-bar input { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
body.dark .search-bar input::placeholder { color: #666; }
body.dark .search-bar input:focus { border-color: #7c8cf8; }
body.dark .progress { color: #888; }
body.dark .rating .star-empty { color: #555; }
body.dark .mode-btn { background: #2a2a3e; color: #aaa; }
body.dark .mode-btn.active { background: #667eea; color: #fff; }
body.dark .mode-btn.vocab-mode.active { background: #e91e63; }
body.dark .level-btn { background: #2a2a3e; color: #999; border-color: #555; }
body.dark .mode-bar, body.dark .level-bar { background: rgba(30,30,46,0.92); }
body.dark .level-btn.active { background: #667eea; color: #fff; }
body.dark .word-list-overlay { background: #1e1e2e; }
body.dark .word-list-header { border-color: #333; color: #e0e0e0; }
body.dark .word-list-header button { color: #888; }
body.dark .word-list-header button:hover { color: #fff; }
body.dark .word-list-item { border-color: #2a2a3e; }
body.dark .word-list-item:hover { background: #2a2040; }
body.dark .word-list-item .wl-word { color: #e0e0e0; }
body.dark .word-list-item .wl-zh { color: #999; }
body.dark .not-found { color: #f44336; }
body.dark .speaker-wrap::before { background: transparent; }
body.dark .speaker-wrap:hover::before { background: rgba(124,140,248,0.15); }
body.dark .sentence-speaker::before { background: transparent; }
body.dark .sentence-speaker:hover::before { background: rgba(124,140,248,0.15); }
body.dark .speaker-wrap::before { background: transparent; }
body.dark .speaker-wrap:hover::before { background: rgba(124,140,248,0.15); }
body.dark .star-btn:not(.starred) { opacity: 0.2; }
body.dark .master-btn:not(.mastered) { opacity: 0.2; }

/* Clean mode: hide chrome in spell/quiz */
body.clean-mode .search-bar { display: none; }
body.clean-mode .status-bar { display: none; }
body.clean-mode .controls { display: none; }
body.clean-mode .progress { display: none; }
body.clean-mode .star-btn { display: none; }
body.clean-mode .master-btn { display: none; }

/* ====== Spelling Mode ====== */
.spell-panel { display: none; flex: 1; flex-direction: column; justify-content: flex-start; align-items: center; gap: 20px; padding: 10px; min-height: 0; overflow-y: auto; }
.spell-panel > :first-child { margin-top: auto; }
.spell-panel > :last-child { margin-bottom: auto; }
.spell-panel.show { display: flex; }
.spell-prompt { font-size: clamp(24px, 3.5vw, 40px); color: #333; text-align: center; font-weight: 600; }
body.dark .spell-prompt { color: #e0e0e0; }
.spell-input-row { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; max-width: 500px; margin: 0 auto; }
.spell-input-row input { width: 100%; }
.spell-input-row input { width: 100%; padding: 12px 16px; border: 2px solid #e0e0e0; border-radius: 10px; font-size: clamp(24px, 3.5vw, 40px); text-align: center; outline: none; transition: border 0.2s; }
.spell-input-row input:focus { border-color: #667eea; }
body.dark .spell-input-row input { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
.spell-input-row button { background: #667eea; color: #fff; border: none; border-radius: 10px; padding: 12px 32px; font-size: 18px; cursor: pointer; }
.spell-input-row button:hover { background: #5a6fd6; }
.spell-input-row .mic-btn { background: #ff5722; padding: 12px 20px; font-size: 20px; }
.spell-input-row .mic-btn:hover { background: #e64a19; }
.spell-input-row .mic-btn.listening { background: #f44336; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(244,67,54,0.4); } 50% { box-shadow: 0 0 0 12px rgba(244,67,54,0); } }
.spell-feedback { font-size: 20px; font-weight: 700; min-height: 30px; text-align: center; }
.spell-feedback.correct { color: #4caf50; }
.spell-feedback.wrong { color: #f44336; }
.spell-score { font-size: 14px; color: #999; }

/* ====== Quiz Mode ====== */
.quiz-panel { display: none; flex: 1; flex-direction: column; justify-content: center; align-items: center; gap: 16px; padding: 10px; min-height: 0; overflow-y: auto; }
.quiz-panel.show { display: flex; }
.quiz-word { font-size: clamp(28px, 4.5vw, 48px); font-weight: 700; color: #333; text-align: center; }
body.dark .quiz-word { color: #e0e0e0; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: min(760px, 100%); }
.quiz-option { padding: 14px 20px; border: 2px solid #e0e0e0; border-radius: 10px; font-size: 18px; cursor: pointer; text-align: center; transition: all 0.15s; background: #fff; }
.quiz-option:hover { border-color: #667eea; background: #f0f0ff; }
body.dark .quiz-option { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
body.dark .quiz-option:hover { border-color: #7c8cf8; background: #2a2040; }
.quiz-option.correct-pick { border-color: #4caf50; background: #e8f5e9; color: #2e7d32; }
.quiz-option.wrong-pick { border-color: #f44336; background: #ffebee; color: #c62828; }
.quiz-option.reveal-correct { border-color: #4caf50; background: #e8f5e9; color: #2e7d32; }
.quiz-score-row { display: flex; align-items: center; gap: 16px; font-size: 16px; color: #666; }
body.dark .quiz-score-row { color: #aaa; }
.quiz-score-row span { font-weight: 600; color: #333; }
body.dark .quiz-score-row span { color: #e0e0e0; }
.quiz-next { background: #667eea; color: #fff; border: none; border-radius: 10px; padding: 10px 32px; font-size: 16px; cursor: pointer; display: none; }
.quiz-next.show { display: inline-block; }
.quiz-next:hover { background: #5a6fd6; }

/* ====== Battle Mode ====== */
.battle-panel { display: none; flex: 1; min-height: 0; overflow-y: auto; flex-direction: column; }
.battle-panel.show { display: flex; }
.battle-row { display: flex; flex: 1; gap: 0; }

.battle-player { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 8px; position: relative; }
.battle-player.p1 { background: rgba(102,126,234,0.05); border-right: 2px solid #e0e0e0; }
.battle-player.p2 { background: rgba(233,30,99,0.05); }
body.dark .battle-player.p1 { background: rgba(102,126,234,0.1); border-color: #333; }
body.dark .battle-player.p2 { background: rgba(233,30,99,0.1); }

.battle-word { font-size: clamp(22px, 3vw, 34px); font-weight: 700; color: #333; text-align: center; }
body.dark .battle-word { color: #e0e0e0; }

.battle-options { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 300px; }
.battle-option { padding: clamp(8px,1.5vh,14px) clamp(10px,2vw,14px); border: 2px solid #e0e0e0; border-radius: 10px; font-size: clamp(12px, 1.8vw, 18px); cursor: pointer; text-align: center; transition: all 0.1s; background: #fff; }
.battle-option:hover { border-color: #667eea; background: #f0f0ff; }
body.dark .battle-option { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
body.dark .battle-option:hover { border-color: #7c8cf8; background: #2a2040; }
.battle-option.correct-pick { border-color: #388e3c; background: #1b5e20; color: #fff; opacity: 1; }
.battle-option.wrong-pick { border-color: #f44336; background: #ffebee; color: #c62828; }
.battle-option.reveal-correct { border-color: #388e3c; background: #1b5e20; color: #fff; opacity: 1; }
.battle-option.locked { pointer-events: none; }
.battle-mode-btn.active { background: #9c27b0; color: #fff; }
.online-mode-btn.active { background: #00897b; color: #fff; }

/* ====== Online Mode ====== */
.online-panel { display: none; flex: 1; min-height: 0; overflow-y: auto; }
.online-panel.show { display: flex; flex-direction: column; }
.online-room-ui { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; flex: 1; }
.online-title { font-size: clamp(20px, 3vw, 28px); font-weight: 700; color: #333; }
body.dark .online-title { color: #e0e0e0; }
.online-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.online-btn { padding: 12px 28px; border: none; border-radius: 10px; font-size: 16px; cursor: pointer; background: #667eea; color: #fff; transition: all 0.15s; }
.online-btn:hover { opacity: 0.85; }
.online-btn.primary { background: #00897b; font-size: 18px; padding: 14px 36px; }
.online-input { padding: 12px 16px; border: 2px solid #e0e0e0; border-radius: 10px; font-size: 20px; width: 140px; text-align: center; letter-spacing: 8px; outline: none; }
.online-input:focus { border-color: #667eea; }
body.dark .online-input { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
.online-divider { color: #999; font-size: 14px; }
.online-msg { font-size: 14px; color: #999; min-height: 20px; text-align: center; }
.online-msg.error { color: #f44336; }
.online-msg.success { color: #4caf50; }

.online-game-ui { flex: 1; display: flex; flex-direction: column; }
.online-game-header { display: flex; justify-content: center; align-items: center; gap: 20px; padding: 8px; font-size: clamp(12px,1.5vw,15px); color: #666; flex-shrink: 0; flex-wrap: wrap; }
body.dark .online-game-header { color: #aaa; }
.online-quit-btn { background: #f44336; color: #fff; border: none; border-radius: 6px; padding: 4px 12px; font-size: 12px; cursor: pointer; }
.online-game-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; overflow-y: auto; padding: 4px 0; min-height: 0; }
.online-word { font-size: clamp(26px, 4vw, 44px); font-weight: 700; color: #333; }
body.dark .online-word { color: #e0e0e0; }
.online-options { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 400px; }
.online-option { padding: 10px 16px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: clamp(13px,1.6vw,17px); cursor: pointer; text-align: center; transition: all 0.1s; background: #fff; }
.online-option:hover { border-color: #667eea; background: #f0f0ff; }
body.dark .online-option { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
body.dark .online-option:hover { border-color: #7c8cf8; background: #2a2040; }
.online-option.correct-pick { border-color: #4caf50; background: #1b5e20; color: #fff; opacity: 1; }
.online-option.wrong-pick { border-color: #f44336; background: #ffebee; color: #c62828; }
.online-option.reveal-correct { border-color: #388e3c; background: #1b5e20; color: #fff; opacity: 1; }
.online-option.locked { pointer-events: none; }
.online-game-msg { font-size: 14px; color: #999; min-height: 20px; }
.online-game-body .status-text { font-size: 16px; color: #999; }
body.dark .online-game-body .status-text { color: #888; }

/* ====== Battle Mode ====== */
.battle-panel { display: none; flex: 1; min-height: 0; overflow-y: auto; flex-direction: column; }
.battle-panel.show { display: flex; }
.battle-row { display: flex; flex: 1; gap: 0; }
.battle-player { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 8px; position: relative; }
.battle-player.p1 { background: rgba(102,126,234,0.05); border-right: 2px solid #e0e0e0; }
.battle-player.p2 { background: rgba(233,30,99,0.05); }
body.dark .battle-player.p1 { background: rgba(102,126,234,0.1); border-color: #333; }
body.dark .battle-player.p2 { background: rgba(233,30,99,0.1); }
.battle-word { font-size: clamp(22px, 3vw, 34px); font-weight: 700; color: #333; text-align: center; }
body.dark .battle-word { color: #e0e0e0; }
.battle-options { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 300px; }
.battle-option { padding: clamp(8px,1.5vh,14px) clamp(10px,2vw,14px); border: 2px solid #e0e0e0; border-radius: 10px; font-size: clamp(12px, 1.8vw, 18px); cursor: pointer; text-align: center; transition: all 0.1s; background: #fff; }
.battle-option:hover { border-color: #667eea; background: #f0f0ff; }
body.dark .battle-option { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
body.dark .battle-option:hover { border-color: #7c8cf8; background: #2a2040; }
.battle-option.correct-pick { border-color: #388e3c; background: #1b5e20; color: #fff; opacity: 1; }
.battle-option.wrong-pick { border-color: #f44336; background: #ffebee; color: #c62828; }
.battle-option.reveal-correct { border-color: #388e3c; background: #1b5e20; color: #fff; opacity: 1; }
.battle-option.locked { pointer-events: none; }
.battle-score { font-size: clamp(14px, 2vw, 20px); font-weight: 700; }
.battle-score .p1-color { color: #667eea; }
.battle-score .p2-color { color: #e91e63; }
body.dark .battle-score .p1-color { color: #7c8cf8; }
body.dark .battle-score .p2-color { color: #f06292; }
.battle-result { font-size: clamp(12px, 1.6vw, 16px); font-weight: 700; text-align: center; min-height: 24px; flex-shrink: 0; }
.battle-result.p1-win { color: #667eea; }
.battle-result.p2-win { color: #e91e63; }
body.dark .battle-result.p1-win { color: #7c8cf8; }
body.dark .battle-result.p2-win { color: #f06292; }
@media (max-width: 600px) {
    .battle-option { padding: 8px 10px; font-size: 14px; }
    .battle-options { max-width: 240px; gap: 5px; }
    .battle-word { font-size: clamp(18px, 2.5vw, 26px); }
}
.battle-mode-btn.active { background: #9c27b0; color: #fff; }
.online-mode-btn.active { background: #00897b; color: #fff; }
body.clean-mode .star-btn { display: none; }
body.clean-mode .master-btn { display: none; }
/* ===== 全屏模式 ===== */
body.fullscreen-mode { padding: 0; background: #667eea; }
body.fullscreen-mode .card { border-radius: 0; height: 100vh; padding: 8px 24px 14px 24px; }
body.fullscreen-mode .controls,
body.fullscreen-mode .mode-bar,
body.fullscreen-mode .rail-toggle-left,
body.fullscreen-mode .level-bar,
body.fullscreen-mode .rail-toggle-right,
body.fullscreen-mode .progress,
body.fullscreen-mode .search-bar,
body.fullscreen-mode .status-bar { display: none; }
.fs-toggle {
    position: fixed;
    top: 12px;
    right: 16px;
    z-index: 9999;
    padding: 9px 18px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.fs-toggle:hover { background: rgba(0,0,0,0.75); }
.fs-font-controls {
    position: fixed;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9999;
    display: none;
    flex-direction: column;
    gap: 8px;
}
body.fullscreen-mode .fs-font-controls { display: flex; }
.fs-font-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}
.fs-font-btn:hover { background: rgba(0,0,0,0.75); }

/* ===== 课本下拉菜单 ===== */
.textbook-wrap { position: relative; }
.textbook-menu {
    position: absolute;
    right: calc(100% + 8px);
    top: 0;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.22);
    min-width: 130px;
    padding: 6px;
    z-index: 60;
}
.textbook-menu.show { display: flex; }
.textbook-group {
    font-size: 12px;
    font-weight: 700;
    color: #667eea;
    padding: 7px 8px 2px;
    white-space: nowrap;
}
.textbook-item {
    font-size: 13px;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 6px;
    color: #333;
    white-space: nowrap;
}
.textbook-item:hover { background: #f0f0ff; color: #667eea; }
.textbook-item.active { background: #667eea; color: #fff; }
body.dark .textbook-menu { background: #2a2a3e; }
body.dark .textbook-item { color: #ccc; }
body.dark .textbook-item:hover { background: #2a2040; }
body.dark .textbook-item.active { background: #667eea; color: #fff; }
body.dark .textbook-group { color: #7c8cf8; }

/* ===== 多战模式（4人 2x2 网格） ===== */
.multi-panel { display: none; flex: 1; min-height: 0; overflow-y: auto; flex-direction: column; }
.multi-panel.show { display: flex; }
.multi-result { font-size: clamp(12px, 1.6vw, 16px); font-weight: 700; text-align: center; min-height: 22px; flex-shrink: 0; }
.multi-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: 1fr; flex: 1; gap: 0; min-height: 0; }
.multi-player { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 6px; position: relative; min-height: 0; }
.multi-player.mp-a { background: rgba(102,126,234,0.05); border-right: 2px solid #e0e0e0; }
.multi-player.mp-b { background: rgba(233,30,99,0.05); border-right: 2px solid #e0e0e0; }
.multi-player.mp-c { background: rgba(76,175,80,0.05); border-right: 2px solid #e0e0e0; }
.multi-player.mp-d { background: rgba(255,152,0,0.05); }
.multi-score { font-size: clamp(13px, 1.6vw, 17px); font-weight: 600; color: #666; }
.mp-a-color { color: #667eea; }
.mp-b-color { color: #e91e63; }
.mp-c-color { color: #4caf50; }
.mp-d-color { color: #ff9800; }
.multi-word { font-size: clamp(22px, 3vw, 36px); font-weight: 700; color: #333; text-align: center; }
.multi-options { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 260px; }
.multi-option { padding: clamp(5px,1.1vh,11px) clamp(8px,1.5vw,12px); border: 2px solid #e0e0e0; border-radius: 8px; font-size: clamp(18px, 2.2vw, 20px); cursor: pointer; text-align: center; transition: all 0.1s; background: #fff; }
.multi-option:hover { border-color: #667eea; background: #f0f0ff; }
.multi-option.correct-pick { border-color: #388e3c; background: #1b5e20; color: #fff; }
.multi-option.wrong-pick { border-color: #f44336; background: #ffebee; color: #c62828; }
.multi-option.reveal-correct { border-color: #388e3c; background: #1b5e20; color: #fff; }
.multi-option.locked { pointer-events: none; }
body.dark .multi-option { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
body.dark .multi-option:hover { border-color: #7c8cf8; background: #2a2040; }
body.dark .multi-word { color: #e0e0e0; }
body.dark .multi-player.mp-a { background: rgba(102,126,234,0.1); border-color: #333; }
body.dark .multi-player.mp-b { background: rgba(233,30,99,0.1); border-color: #333; }
body.dark .multi-player.mp-c { background: rgba(76,175,80,0.1); border-color: #333; }
body.dark .multi-player.mp-d { background: rgba(255,152,0,0.1); border-color: #333; }
.multi-mode-btn.active { background: #e91e63; color: #fff; }


/* ===== 多赛模式（4人） ===== */
.race-panel { display: none; flex: 1; min-height: 0; overflow-y: auto; flex-direction: column; }
.race-panel.show { display: flex; }
.race-result { font-size: clamp(12px, 1.6vw, 16px); font-weight: 700; text-align: center; min-height: 22px; flex-shrink: 0; }
.race-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: 1fr; flex: 1; gap: 0; min-height: 0; }
.race-player { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 6px; position: relative; min-height: 0; }
.race-player.rp-a { background: rgba(102,126,234,0.05); border-right: 2px solid #e0e0e0; }
.race-player.rp-b { background: rgba(233,30,99,0.05); border-right: 2px solid #e0e0e0; }
.race-player.rp-c { background: rgba(76,175,80,0.05); border-right: 2px solid #e0e0e0; }
.race-player.rp-d { background: rgba(255,152,0,0.05); }
.race-score { font-size: clamp(13px, 1.6vw, 17px); font-weight: 600; color: #666; }
.rp-a-color { color: #667eea; }
.rp-b-color { color: #e91e63; }
.rp-c-color { color: #4caf50; }
.rp-d-color { color: #ff9800; }
.race-word { font-size: clamp(22px, 3vw, 36px); font-weight: 700; color: #333; text-align: center; }
.race-options { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 260px; }
.race-option { padding: clamp(5px,1.1vh,11px) clamp(8px,1.5vw,12px); border: 2px solid #e0e0e0; border-radius: 8px; font-size: clamp(18px, 2.2vw, 20px); cursor: pointer; text-align: center; transition: all 0.1s; background: #fff; }
.race-option:hover { border-color: #667eea; background: #f0f0ff; }
.race-option.correct-pick { border-color: #388e3c; background: #1b5e20; color: #fff; }
.race-option.wrong-pick { border-color: #f44336; background: #ffebee; color: #c62828; }
.race-option.reveal-correct { border-color: #388e3c; background: #1b5e20; color: #fff; }
.race-option.locked { pointer-events: none; }
body.dark .race-option { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
body.dark .race-option:hover { border-color: #7c8cf8; background: #2a2040; }
body.dark .race-word { color: #e0e0e0; }
body.dark .race-player.rp-a { background: rgba(102,126,234,0.1); border-color: #333; }
body.dark .race-player.rp-b { background: rgba(233,30,99,0.1); border-color: #333; }
body.dark .race-player.rp-c { background: rgba(76,175,80,0.1); border-color: #333; }
body.dark .race-player.rp-d { background: rgba(255,152,0,0.1); border-color: #333; }
.race-mode-btn.active { background: #e91e63; color: #fff; }

/* ===== 对战/多战/多赛 每玩家统计 ===== */
.st { font-size: 0.82em; font-weight: 700; }
.st-ok { color: #4caf50; }
.st-bad { color: #f44336; }
.st-total { color: #f9a825; }
.st-acc { color: #000; }
body.dark .st-acc { color: #e0e0e0; }

/* 多点触控：消除触屏点击延迟，两个玩家同时点按也能各自选中；禁止长按选中/复制 */
.battle-option, .multi-option, .race-option, .quiz-option {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* 游戏面板整体禁止长按选中/复制（长按空白处也不出复制效果） */
.battle-panel, .multi-panel, .race-panel, .quiz-panel {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
