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

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --gray-color: #6c757d;
    --border-color: #dee2e6;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);
}

/* 沉浸式暗黑主题 */
[data-theme="dark"] {
    --primary-color: #888888;
    --secondary-color: #666666;
    --success-color: #66bb6a;
    --error-color: #ef5350;
    --warning-color: #ffa726;
    --info-color: #42a5f5;
    --light-color: #1a1a1a;
    --dark-color: #e0e0e0;
    --gray-color: #999999;
    --border-color: #333333;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] body {
    background: #000;
}

[data-theme="dark"] .header,
[data-theme="dark"] .typing-section,
[data-theme="dark"] .keyboard-section {
    background: #111;
}

[data-theme="dark"] .text-display {
    background: #000;
    color: #fff;
}

[data-theme="dark"] .text-display .char.other-line {
    opacity: 0.15;
}

[data-theme="dark"] .text-display .char.current {
    background: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .text-display .char.correct {
    color: var(--success-color);
    background: rgba(102, 187, 106, 0.08);
}

[data-theme="dark"] .text-display .char.incorrect {
    color: var(--error-color);
    background: rgba(239, 83, 80, 0.08);
}

[data-theme="dark"] .stat-mini-item {
    background: #1a1a1a;
    color: #666;
}

[data-theme="dark"] .stat-mini-item:hover {
    background: #333 !important;
    color: #e0e0e0 !important;
    background-image: none !important;
}

[data-theme="dark"] .stat-mini-value {
    color: #e0e0e0;
}

[data-theme="dark"] .settings-btn,
[data-theme="dark"] .nav-btn {
    background: #1a1a1a;
    color: #ccc;
}

[data-theme="dark"] .settings-btn:hover,
[data-theme="dark"] .nav-btn:hover {
    background: #333;
    color: #fff;
    background-image: none;
}

[data-theme="dark"] .key {
    background: #1a1a1a;
    border-color: #333;
    color: #bbb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .key.active,
[data-theme="dark"] .key.active.finger-pinky,
[data-theme="dark"] .key.active.finger-ring,
[data-theme="dark"] .key.active.finger-middle,
[data-theme="dark"] .key.active.finger-index,
[data-theme="dark"] .key.active.finger-index-right,
[data-theme="dark"] .key.active.finger-thumb {
    background: linear-gradient(180deg, #555, #333);
    color: #fff;
}

[data-theme="dark"] .key:hover {
    background: #2a2a2a;
}

[data-theme="dark"] .key.caps-active {
    background: linear-gradient(180deg, #8b3a3a, #662222) !important;
    box-shadow: 0 0 20px rgba(180, 60, 60, 0.4) !important;
}

[data-theme="dark"] .key.caps-active::after {
    filter: drop-shadow(0 0 4px rgba(180, 60, 60, 0.6));
}

[data-theme="dark"] .keyboard {
    background: linear-gradient(180deg, #1a1a1a, #111);
}

[data-theme="dark"] .key::before {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
}

[data-theme="dark"] .key.finger-pinky { background: linear-gradient(180deg, rgba(78,205,196,0.15) 0%, rgba(78,205,196,0.05) 100%); }
[data-theme="dark"] .key.finger-ring { background: linear-gradient(180deg, rgba(232,168,124,0.15) 0%, rgba(232,168,124,0.05) 100%); }
[data-theme="dark"] .key.finger-middle { background: linear-gradient(180deg, rgba(69,183,209,0.15) 0%, rgba(69,183,209,0.05) 100%); }
[data-theme="dark"] .key.finger-index { background: linear-gradient(180deg, rgba(150,206,180,0.15) 0%, rgba(150,206,180,0.05) 100%); }
[data-theme="dark"] .key.finger-index-right { background: linear-gradient(180deg, rgba(100,181,246,0.15) 0%, rgba(100,181,246,0.05) 100%); }
[data-theme="dark"] .key.finger-thumb { background: linear-gradient(180deg, rgba(255,234,167,0.15) 0%, rgba(255,234,167,0.05) 100%); }

[data-theme="dark"] .font-settings-panel {
    background: #1a1a1a;
}

[data-theme="dark"] .font-settings-header {
    background: #111;
    border-bottom-color: #333;
    color: #e0e0e0;
}

[data-theme="dark"] .font-setting-row {
    border-bottom-color: #333;
}

[data-theme="dark"] .font-setting-row label {
    color: #ccc;
}

[data-theme="dark"] .font-btn {
    background: #2a2a2a;
    border-color: #444;
    color: #ccc;
}

[data-theme="dark"] .font-btn:hover {
    background: #555;
    border-color: #555;
    color: #fff;
}

[data-theme="dark"] #fontFamilySelect {
    background: #2a2a2a;
    border-color: #444;
    color: #ccc;
}

[data-theme="dark"] .modal-content {
    background: #1a1a1a;
}

[data-theme="dark"] .modal-header {
    background: #111;
    border-bottom-color: #333;
}

[data-theme="dark"] .modal-header h2 {
    color: #e0e0e0;
}

[data-theme="dark"] #customTextInput {
    background: #000;
    border-color: #444;
    color: #e0e0e0;
}

[data-theme="dark"] #customTextInput:focus {
    border-color: #888;
}

[data-theme="dark"] #customTextInput::placeholder {
    color: #666;
}

[data-theme="dark"] .article-item {
    background: #111;
    border-color: #333;
    color: #ccc;
}

[data-theme="dark"] .article-item:hover {
    background: #2a2a2a;
}

[data-theme="dark"] .custom-text-divider span {
    background: #1a1a1a;
    color: #666;
}

[data-theme="dark"] .key .next-dot {
    background: radial-gradient(circle, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0.15) 60%, transparent 100%);
}

[data-theme="dark"] .key.next-key {
    box-shadow: 0 0 16px rgba(255,255,255,0.15), 0 0 0 2px rgba(255,255,255,0.3) inset;
}

[data-theme="dark"] .finger-line.visible {
    stroke-opacity: 0.15;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    color: var(--dark-color);
    line-height: 1.6;
}

.page-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom:15px;
    padding: 16px 24px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    flex-wrap: wrap;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
}

.logo i {
    font-size: 28px;
}

/* 紧凑版统计面板 */
.stats-mini {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.stat-mini-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--light-color);
    border-radius: 8px;
    font-size: 16px;
    color: var(--gray-color);
    transition: all 0.3s ease;
    min-width: 80px;
    justify-content: center;
}

.stat-mini-item:hover {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-mini-item:hover i,
.stat-mini-item:hover .stat-mini-value,
.stat-mini-item:hover .stat-unit {
    color: white;
}

.stat-mini-item i {
    font-size: 16px;
    color: var(--primary-color);
}

.stat-mini-item.error i {
    color: var(--error-color);
}

.stat-mini-item:hover.error {
    background: linear-gradient(135deg, var(--error-color), #c82333);
}

.stat-mini-value {
    font-weight: 600;
    color: var(--dark-color);
    font-variant-numeric: tabular-nums;
}

#accuracy,
#wpm {
    display: inline-block;
    width: 2.2em;
    text-align: right;
}

.stat-unit {
    font-size: 14px;
    color: var(--gray-color);
    font-weight: 500;
}

/* 自定义 tooltip 样式 */
.stat-mini-item[title]:hover::after {
    content: attr(title);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark-color);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    animation: tooltip-fade 0.2s ease;
}

.stat-mini-item[title]:hover::before {
    content: '';
    position: absolute;
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--dark-color);
    z-index: 1000;
    pointer-events: none;
}

.stat-mini-item {
    position: relative;
}

@keyframes tooltip-fade {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.settings-group {
    display: flex;
    gap: 8px;
}

.settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: var(--light-color);
    color: var(--dark-color);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

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

.settings-btn.muted {
    color: var(--gray-color);
}

.nav {
    display: flex;
    gap: 12px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    background: var(--light-color);
    color: var(--dark-color);
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.nav-btn i {
    font-size: 14px;
}

/* 字体设置面板 */
.font-settings-panel {
    display: none;
    position: fixed;
    top: 80px;
    right: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    z-index: 100;
    min-width: 280px;
    overflow: hidden;
}

.font-settings-panel.show {
    display: block;
    animation: slideDown 0.3s ease;
}

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

.font-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--light-color);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 14px;
    color: var(--dark-color);
}

.font-settings-header span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.font-settings-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.font-settings-close:hover {
    background: var(--error-color);
    color: white;
}

.font-settings-body {
    padding: 16px;
}

.font-setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.font-setting-row:last-child {
    border-bottom: none;
}

.font-setting-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--dark-color);
}

.font-setting-row label i {
    width: 16px;
    color: var(--gray-color);
}

.font-setting-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.font-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--dark-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

#fontSizeValue, #lineHeightValue {
    min-width: 50px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
}

#fontFamilySelect {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    background: white;
    cursor: pointer;
}

#fontFamilySelect:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 文章选择器 */
.article-selector {
    margin-bottom: 16px;
}

.article-selector > label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 10px;
}

.article-selector > label i {
    color: var(--primary-color);
}

.article-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 120px;
    overflow-y: auto;
    padding: 8px;
    background: var(--light-color);
    border-radius: 8px;
}

.article-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    color: var(--dark-color);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.article-item:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.article-item i {
    font-size: 12px;
    opacity: 0.7;
}

.custom-text-divider {
    display: flex;
    align-items: center;
    margin: 16px 0;
    color: var(--gray-color);
    font-size: 12px;
}

.custom-text-divider::before,
.custom-text-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.custom-text-divider span {
    padding: 0 12px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

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

.main-content {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* 全屏模式：隐藏标题栏，主内容区居中 */
:fullscreen .header,
:-webkit-full-screen .header {
    display: none;
}

:fullscreen,
:-webkit-full-screen {
    overflow: hidden;
}

:fullscreen .main-content,
:-webkit-full-screen .main-content {
    justify-content: center;
    height: 100vh;
}

.typing-section {
    background: white;
    border-radius: 16px 16px 0 0;
    padding: 30px;
    box-shadow: var(--shadow-md);
    margin-bottom: 0;
}

.text-container {
    margin-bottom: 20px;
}

.text-display {
    background: var(--light-color);
    padding: 24px;
    border-radius: 12px;
    font-size: 18px;
    line-height: 2;
    max-height: 220px;
    overflow-y: auto;
    color: var(--dark-color);
    font-family: 'Courier New', monospace;
    border: none;
    transition: box-shadow 0.3s ease;
    cursor: text;
    outline: none;
    user-select: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 126, 234, 0.3) transparent;
}

.text-display:empty:before {
    content: attr(data-placeholder);
    color: var(--gray-color);
    pointer-events: none;
}

.text-display:focus-within {
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
    caret-color: transparent;
}

.text-display .char {
    padding: 2px 1px;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease, opacity 0.25s ease, filter 0.25s ease;
}

body.performance-mode .text-display .char {
    transition: none;
}

/* 当前行：高亮加粗 */
.text-display .char.current-line {
    opacity: 1;
    /* font-weight: bold; */
}

/* 非当前行：淡化（不用 filter/grayscale，避免触发合成层） */
.text-display .char.other-line {
    opacity: 0.25;
}

.text-display .char.correct {
    color: var(--success-color);
    background: rgba(20, 20, 20, 0.1);
}

.text-display .char.incorrect {
    color: var(--error-color);
    background: rgba(220, 53, 69, 0.1);
}

/* 当行内已输入的字符保持鲜明 */
.text-display .char.current-line.correct {
    color: var(--success-color);
    background: rgba(40, 167, 69, 0.1);
}

.text-display .char.current-line.incorrect {
    color: var(--error-color);
    background: rgba(220, 53, 69, 0.1);
}

.text-display .char.current {
    background: rgba(102, 126, 234, 0.35);
    color: var(--dark-color);
    animation: blink 1s infinite;
}

body.performance-mode .text-display .char.current {
    animation: none;
}

@keyframes blink {
    0%, 45% { opacity: 1; }
    50%, 95% { opacity: 0.6; }
    100% { opacity: 1; }
}

.input-container {
    position: relative;
}

.typing-input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    font-family: 'Microsoft YaHei', sans-serif;
    resize: none;
    height: 80px;
    transition: all 0.3s ease;
    background: white;
}

.typing-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.typing-input::placeholder {
    color: var(--gray-color);
}

.progress-section {
    line-height: 0;
}

.progress-bar {
    width: 100%;
    height: 2px;
    background: var(--border-color);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: #a8d5a2;
    transition: width 0.3s ease;
}

body.performance-mode .progress-fill {
    transition: none;
}

.keyboard-section {
    background: white;
    border-radius: 0 0 16px 16px;
    padding: 30px;
    box-shadow: var(--shadow-md);
    margin-top: 0;
}

.keyboard-wrapper {
    display: flex;
    justify-content: center;
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 16px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.key {
    min-width: 50px;
    height: 50px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-color);
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    user-select: none;
}

.key > span:not(.next-dot) {
    position: relative;
    z-index: 1;
}

.key::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    border-radius: 1px;
}

.key.dual-label {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.key.dual-label .key-shift-symbol {
    font-size: 11px;
    color: #999;
    line-height: 1;
}

.key.dual-label .key-base-label {
    font-size: 15px;
    line-height: 1;
    font-weight: 600;
}

.key.active .key-shift-symbol {
    color: rgba(255, 255, 255, 0.8);
}

.key:hover {
    background: var(--light-color);
    transform: translateY(-2px);
}

.key.active,
.key.active.finger-pinky,
.key.active.finger-ring,
.key.active.finger-middle,
.key.active.finger-index,
.key.active.finger-index-right,
.key.active.finger-thumb {
    background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
    color: white;
    transform: translateY(2px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.key.finger-pinky { background: linear-gradient(180deg, rgba(78,205,196,0.08) 0%, rgba(78,205,196,0.03) 100%); border-bottom: 3px solid #4ecdc4; }
.key.finger-ring { background: linear-gradient(180deg, rgba(232,168,124,0.08) 0%, rgba(232,168,124,0.03) 100%); border-bottom: 3px solid #e8a87c; }
.key.finger-middle { background: linear-gradient(180deg, rgba(69,183,209,0.08) 0%, rgba(69,183,209,0.03) 100%); border-bottom: 3px solid #45b7d1; }
.key.finger-index { background: linear-gradient(180deg, rgba(150,206,180,0.08) 0%, rgba(150,206,180,0.03) 100%); border-bottom: 3px solid #96ceb4; }
.key.finger-index-right { background: linear-gradient(180deg, rgba(100,181,246,0.08) 0%, rgba(100,181,246,0.03) 100%); border-bottom: 3px solid #64b5f6; }
.key.finger-thumb { background: linear-gradient(180deg, rgba(255,234,167,0.08) 0%, rgba(255,234,167,0.03) 100%); border-bottom: 3px solid #ffeaa7; }

.key.caps-active {
    background: linear-gradient(180deg, #ff6b6b, #ee5a5a) !important;
    color: white !important;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.8), 0 0 40px rgba(255, 107, 107, 0.4) !important;
    border-color: #ff6b6b !important;
    animation: caps-pulse 1.5s ease-in-out infinite;
}

.key.caps-active::after {
    content: '🔒';
    position: absolute;
    top: -10px;
    right: -8px;
    font-size: 12px;
    line-height: 1;
    filter: drop-shadow(0 0 4px rgba(255, 107, 107, 0.8));
}

@keyframes caps-pulse {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(255, 107, 107, 0.8), 0 0 40px rgba(255, 107, 107, 0.4);
    }
    50% { 
        box-shadow: 0 0 30px rgba(255, 107, 107, 1), 0 0 60px rgba(255, 107, 107, 0.6);
    }
}

.key.wide { min-width: 75px; }
.key.extra-wide { min-width: 100px; }
.key.space { min-width: 300px; }

/* Next-key dot indicator */
.key {
    overflow: visible;
}

.key .next-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 107, 59, 0.9) 0%, rgba(255, 107, 59, 0.3) 60%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
    pointer-events: none;
}

.key.next-key .next-dot {
    opacity: 1;
    animation: dot-pulse 0.8s ease-in-out infinite;
}

body.performance-mode .key,
body.performance-mode .key .next-dot,
body.performance-mode .finger-line,
body.performance-mode .fingertip {
    transition: none !important;
}

body.performance-mode .key.next-key .next-dot {
    animation: none;
}

.key.next-key {
    box-shadow: 0 0 12px rgba(255, 107, 59, 0.5), 0 0 0 2px rgba(255, 107, 59, 0.6) inset;
}

@keyframes dot-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.5); }
}

/* SVG finger lines - full viewport overlay */
.finger-lines-svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
}

.finger-line {
    stroke-width: 2;
    stroke-opacity: 0;
    fill: none;
    transition: stroke-opacity 0.25s ease;
}

.finger-line.visible {
    stroke-opacity: 0.3;
}

/* 指尖覆盖层 — 固定在页面上，覆盖在键盘上方 */
.fingertips-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 50;
}

body.performance-mode .finger-lines-svg,
body.performance-mode .fingertips-overlay {
    display: none;
}

.fingertip {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    opacity: 0.2;
    /* 将由 JS 设置 transform，用 CSS transition 实现平滑移动 */
    transition: transform 0.08s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    will-change: transform;
}

.fingertip::before {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    z-index: 1;
}

/* 保留 ::after 可扩展，当前为空 */

/* 左手颜色 */
.fingertip.finger-pinky.left  { background: linear-gradient(135deg, #4ecdc4, #3dbdb5); box-shadow: 0 4px 12px rgba(78,205,196,0.5); }
.fingertip.finger-ring.left   { background: linear-gradient(135deg, #e8a87c, #d4956b); box-shadow: 0 4px 12px rgba(232,168,124,0.5); }
.fingertip.finger-middle.left { background: linear-gradient(135deg, #45b7d1, #34a7c0); box-shadow: 0 4px 12px rgba(69,183,209,0.5); }
.fingertip.finger-index.left  { background: linear-gradient(135deg, #96ceb4, #85bda3); box-shadow: 0 4px 12px rgba(150,206,180,0.5); }
.fingertip.finger-thumb.left  { display: none; }

/* 右手颜色 */
.fingertip.finger-pinky.right  { background: linear-gradient(135deg, #4ecdc4, #3dbdb5); box-shadow: 0 4px 12px rgba(78,205,196,0.5); }
.fingertip.finger-ring.right   { background: linear-gradient(135deg, #e8a87c, #d4956b); box-shadow: 0 4px 12px rgba(232,168,124,0.5); }
.fingertip.finger-middle.right { background: linear-gradient(135deg, #45b7d1, #34a7c0); box-shadow: 0 4px 12px rgba(69,183,209,0.5); }
.fingertip.finger-index.right  { background: linear-gradient(135deg, #96ceb4, #85bda3); box-shadow: 0 4px 12px rgba(150,206,180,0.5); }
.fingertip.finger-thumb.right  { display: none; }

/* 当前按下 */
.fingertip.pressed {
    transform-origin: center center;
    filter: brightness(1.2);
    transition: transform 0.04s ease;
}

/* 下一个目标：微微放大呼吸 */
.fingertip.target {
    animation: fingertip-breathe 1.2s ease-in-out infinite;
}

body.performance-mode .fingertip.target {
    animation: none;
}

@keyframes fingertip-breathe {
    0%, 100% { box-shadow: 0 4px 12px rgba(102,126,234,0.3); }
    50%      { box-shadow: 0 4px 20px rgba(102,126,234,0.7); }
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal.show {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--light-color);
}

.modal-header h2 {
    font-size: 20px;
    color: var(--dark-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-color);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--error-color);
    color: white;
}

.modal-body {
    padding: 24px;
}

#customTextInput {
    width: 100%;
    height: 120px;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

#customTextInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--light-color);
}

.btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--light-color);
    color: var(--dark-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

@media (max-width: 1024px) {
    .hands-wrapper {
        gap: 100px;
    }

    .key {
        min-width: 40px;
        height: 40px;
        font-size: 12px;
    }

    .key.wide { min-width: 60px; }
    .key.extra-wide { min-width: 80px; }
    .key.space { min-width: 240px; }

    .stats-mini {
        gap: 10px;
    }

    .stat-mini-item {
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .page-wrapper {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        padding: 14px 16px;
    }

    .header-left {
        flex-direction: column;
        gap: 12px;
        width: 100%;
        justify-content: center;
    }

    .header-right {
        width: 100%;
        justify-content: center;
    }

    .stats-mini {
        justify-content: center;
        gap: 8px;
    }

    .stat-mini-item {
        padding: 5px 8px;
        font-size: 11px;
    }

    .stat-mini-item i {
        font-size: 12px;
    }

    .logo {
        font-size: 18px;
    }

    .logo i {
        font-size: 24px;
    }

    .nav-btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .nav-btn-text {
        display: none;
    }

    .typing-section {
        padding: 20px;
    }

    .text-display {
        font-size: 16px;
        padding: 16px;
    }

    .keyboard-section {
        padding: 20px;
    }

    .keyboard {
        padding: 12px;
    }

    .key {
        min-width: 32px;
        height: 32px;
        font-size: 11px;
    }

    .key.dual-label .key-shift-symbol { font-size: 8px; }
    .key.dual-label .key-base-label { font-size: 10px; }

    .key.wide { min-width: 48px; }
    .key.extra-wide { min-width: 64px; }
    .key.space { min-width: 180px; }

    .fingertip {
        width: 24px;
        height: 24px;
    }

    .fingertip::after {
        font-size: 8px;
    }

    .font-settings-panel {
        position: fixed;
        top: auto;
        bottom: 20px;
        left: 20px;
        right: 20px;
        min-width: auto;
    }

    .settings-group {
        display: none;
    }
}
