* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90d9;
    --primary-dark: #357abd;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --danger-color: #ff4d4f;
    --text-color: #333;
    --text-light: #666;
    --border-color: #d9d9d9;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.name-form input {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 10px;
}

.app-title {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo {
    height: 32px;
    width: auto;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Header user info */
.header-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 5px 10px 5px 8px;
    font-size: 13px;
    color: #fff;
}

.header-user-info.hidden {
    display: none;
}

.header-user-icon {
    font-size: 15px;
}

.header-user-name {
    font-weight: 600;
    color: #fff;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    background: rgba(255,255,255,0.15);
    color: #fecaca;
    border: 1px solid rgba(254,202,202,0.3);
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-logout:hover {
    background: rgba(239,68,68,0.2);
    border-color: rgba(254,202,202,0.6);
    color: #fff;
}

.btn-continue {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
    cursor: pointer;
}

.btn-continue:hover {
    background: #fff;
    border-color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-continue.hidden {
    display: none !important;
}

.btn-continue strong {
    font-weight: 700;
    letter-spacing: 0.5px;
}

.btn-continue-icon {
    font-size: 10px;
    margin-right: 2px;
}

.btn-header {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 16px;
    font-size: 14px;
    border-radius: 6px;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-header:hover {
    background: rgba(255, 255, 255, 0.35);
    color: #fff;
}

.admin-link {
    color: white;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    transition: all 0.3s;
}

.admin-link:hover {
    background: rgba(255, 255, 255, 0.2);
}

.app-main {
    flex: 1;
    padding: 24px;
    max-width: 1024px;
    margin: 0 auto;
    width: 100%;
}

.app-footer {
    text-align: center;
    padding: 16px;
    color: var(--text-light);
    font-size: 13px;
}

.footer-link {
    color: var(--primary-color);
    text-decoration: none;
}

.footer-link:hover {
    text-decoration: underline;
}

/* ---- 后台管理 QR 悬浮 ---- */
.admin-link-wrap {
    position: relative;
    display: inline-block;
}

.qr-popup {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px 12px 8px;
    margin-bottom: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    text-align: center;
    z-index: 100;
    white-space: nowrap;
}

.qr-popup img {
    display: block;
    border-radius: 4px;
}

.qr-tip {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #999;
}

.admin-link-wrap:hover .qr-popup {
    display: block;
}

/* 手机上隐藏二维码（触摸没有 hover） */
@media (hover: none) {
    .admin-link-wrap:hover .qr-popup {
        display: none;
    }
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.hidden {
    display: none !important;
}

.visible {
}

.name-entry {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.name-entry .card {
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.name-entry h2 {
    margin-bottom: 8px;
    color: var(--primary-color);
}

.subtitle {
    color: var(--text-light);
    margin-bottom: 24px;
}

.name-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.name-form input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color 0.3s;
    text-align: center;
}

.name-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    display: inline-block;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #f0f0f0;
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
}

.btn-block {
    display: block;
    width: 100%;
}

.config-card {
    text-align: left;
}

.config-row {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.config-item {
    flex: 1;
    min-width: 200px;
}

.config-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    background: #fff;
    transition: all 0.2s;
    user-select: none;
}

.radio-label:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-label input[type="radio"]:checked + span {
    color: var(--primary-color);
}

.radio-label:has(input:checked) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f0f5ff;
}

/* Toggle Switch */
.countdown-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.toggle-label {
    font-size: 14px;
    color: var(--text-color);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    display: none;
}

.slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.25s;
}

.slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
}

.switch input:checked + .slider {
    background: var(--primary-color);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
}

.config-user {
    padding: 12px 16px;
    background: var(--bg-color);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.config-user strong {
    color: var(--primary-color);
}

.typing-area {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
}

.typing-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    background: var(--card-bg);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.stat-item {
    text-align: center;
    flex: 1;
    min-width: 80px;
}

.stat-icon-time,
.stat-icon-speed,
.stat-icon-accuracy,
.stat-icon-progress {
    width: 18px;
    height: 18px;
    margin: 0 5px 0 0;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

.stat-icon-time svg,
.stat-icon-speed svg,
.stat-icon-accuracy svg,
.stat-icon-progress svg {
    width: 100%;
    height: 100%;
    display: block;
}

.stat-icon-time     { color: #3b82f6; }
.stat-icon-speed    { color: #f59e0b; }
.stat-icon-accuracy { color: #10b981; }
.stat-icon-progress { color: #8b5cf6; }

.stat-label {
    display: inline;
    font-size: 13px;
    color: var(--text-light);
}

.stat-label::after {
    content: '\A';
    white-space: pre;
}

.stat-value {
    display: inline-block;
    font-size: 28px;
    font-weight: 600;
    color: var(--primary-color);
}

.stat-unit {
    font-size: 14px;
    color: var(--text-light);
    margin-left: 4px;
}

.typing-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    position: relative;
    box-shadow: var(--shadow);
}

.typing-paper {
    font-family: 'SimSun', 'Songti SC', 'STSong', 'SimSun-ExtB', serif;
    font-size: 22px;
    line-height: 1.8;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    color: #333;
    font-weight: 400;
    position: relative;
}

.typing-paper.paused-overlay::after {
    content: '已暂停';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: #667eea;
    background: rgba(255,255,255,0.85);
    border-radius: var(--radius);
    z-index: 10;
    pointer-events: none;
}

.text-layer {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.text-layer .paragraph {
    border: 1px solid #93c5fd;
    border-radius: 4px;
    padding: 12px 10px;
    background: #fff;
    text-align: left;
    font-size: 22px;
    line-height: 1.6;
    color: #000;
    transition: color 0.1s;
    text-indent: 0;
    font-weight: 400;
}

.text-layer .paragraph.first-line {
    text-indent: 2em;
}

.text-layer .original-line {
    white-space: nowrap;
    overflow: visible;
    font-size: 22px;
    line-height: 1.6;
}

.text-layer .typed-line {
    white-space: nowrap;
    overflow: hidden;
    font-size: 22px;
    line-height: 1.6;
    border-top: 1px dashed #d9d9d9;
    margin-top: 8px;
    padding-top: 8px;
    height: 2em;
}

.text-layer .original-line span,
.text-layer .typed-line span {
    font-size: 22px;
    line-height: 1.6;
    transition: color 0.1s;
}

/* Original line - already typed chars: correct=gray, incorrect=red */
.text-layer .original-line .correct {
    color: #999;
}

.text-layer .original-line .incorrect {
    color: #e34d59;
    text-decoration: underline;
    text-decoration-color: #e34d59;
}

/* Typed line - keep current behavior: correct=green, incorrect=red */
.text-layer .typed-line .correct {
    color: #22c55e;
}

.text-layer .typed-line .incorrect {
    color: #e34d59;
}

.text-layer .pending {
    color: #f59a23;
}

.text-layer .default {
    color: #000;
}

.text-layer .paragraph .cursor {
    display: inline;
    padding: 0;
    margin: 0;
    color: #000;
    background: rgba(24, 144, 255, 0.12);
    outline: 1px solid rgba(24, 144, 255, 0.4);
    border-radius: 2px;
}

.text-layer .typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 1px;
    background: var(--primary-color);
    vertical-align: middle;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.hidden-input {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    padding: 0;
    border: 0;
    outline: 0;
    resize: none;
    overflow: hidden;
    background: transparent;
    color: transparent;
    caret-color: transparent;
    white-space: pre;
    z-index: -1;
}

/* ========== 右侧浮动面板 ========== */
.floating-panel {
    position: sticky;
    top: 100px;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 200;
    background: #fff;
    padding: 10px 10px;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    border: 1px solid #e8e8e8;
}

.floating-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 84px;
    height: 38px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background: #f5f7fa;
    color: #666;
    outline: none;
    padding: 0 14px;
}

.floating-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.floating-btn-label {
    font-size: 14px;
    white-space: nowrap;
    line-height: 1;
}

.floating-btn:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

/* 暂停按钮 */
.pause-btn {
    background: #667eea;
    color: #fff;
}
.pause-btn.paused {
    background: #52c41a;
}

/* 重新开始按钮 */
.restart-btn:hover {
    background: #faad14;
    color: #fff;
}

/* 结束测试按钮 */
.end-btn:hover {
    background: #ff4d4f;
    color: #fff;
}

.result-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.result-card {
    width: 100%;
    max-width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.result-card h2 {
    margin-bottom: 16px;
    color: var(--primary-color);
}

.result-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    font-size: 15px;
    color: var(--text-light);
}

.result-meta-item {
    display: inline-flex;
    align-items: center;
}

.result-meta-item strong {
    color: var(--primary-color);
}

.result-meta-sep {
    color: var(--border-color);
    user-select: none;
}

#resultDateTime {
    font-weight: 600;
    color: var(--primary-color);
}

#resultWeekday {
    font-size: 13px;
    color: var(--text-light);
}

.result-stats {
    margin-bottom: 24px;
}

.result-row {
    display: flex;
    gap: 12px;
}

.result-row .result-item {
    flex: 1;
    min-width: 0;
}

.result-item {
    background: var(--bg-color);
    padding: 16px 8px;
    border-radius: var(--radius);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.result-item.highlight {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.result-item.highlight .result-label,
.result-item.highlight .result-unit {
    color: rgba(255, 255, 255, 0.85);
}

.result-item.highlight .result-value {
    color: white;
}

.result-item.highlight .stat-icon-progress svg,
.result-item.highlight .stat-icon-speed svg,
.result-item.highlight .stat-icon-accuracy svg,
.result-item.highlight .stat-icon-time svg {
    color: rgba(255, 255, 255, 0.9);
}

.result-item .stat-icon-progress,
.result-item .stat-icon-speed,
.result-item .stat-icon-accuracy,
.result-item .stat-icon-time {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.result-item .stat-icon-progress svg,
.result-item .stat-icon-speed svg,
.result-item .stat-icon-accuracy svg,
.result-item .stat-icon-time svg {
    width: 100%;
    height: 100%;
    display: block;
}

.result-item .stat-icon-progress { color: #8b5cf6; }
.result-item .stat-icon-speed    { color: #f59e0b; }
.result-item .stat-icon-accuracy { color: #10b981; }
.result-item .stat-icon-time     { color: #3b82f6; }

.result-label {
    display: block;
    font-size: 13px;
    color: var(--text-light);
}

.result-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--primary-color);
}

.result-unit {
    font-size: 14px;
    color: var(--text-light);
    margin-left: 2px;
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 20px;
}

/* History Section */
.history-card {
    margin-top: 0;
    padding: 20px 24px;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
}

.history-card h3 {
    margin-bottom: 16px;
    font-size: 18px;
    color: var(--text-color);
}

.history-stats {
    margin-bottom: 16px;
}

.history-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-color);
    border-radius: 8px;
}

.hist-stat {
    font-size: 14px;
    color: var(--text-light);
}

.hist-stat strong {
    color: var(--primary-color);
    font-size: 16px;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table thead {
    background: var(--bg-color);
}

.history-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.history-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #f0f0f0;
    color: var(--text-color);
}

.history-table th:nth-child(1),
.history-table td:nth-child(1) {
    width: auto;
    white-space: nowrap;
}

.history-table th:nth-child(2),
.history-table td:nth-child(2) {
    width: 80px;
    white-space: nowrap;
}

.history-table th:nth-child(3),
.history-table td:nth-child(3) {
    width: 60px;
    white-space: nowrap;
}

.history-table th:nth-child(4),
.history-table td:nth-child(4) {
    width: 100px;
    white-space: nowrap;
}

.history-table th:nth-child(5),
.history-table td:nth-child(5) {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-table .text-col {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-table .time-col {
    position: relative;
}

.history-table tbody tr:hover {
    background: #fafafa;
}

.history-table .latest-row {
    background: #f0f7ff;
}

.history-table .current-result-row {
    background: #fef3c7;
}

.history-table .current-result-row:hover {
    background: #fde68a !important;
}

.current-tag {
    display: inline-block;
    background: #f59e0b;
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.tag-col {
    width: 1%;
    padding: 8px 4px !important;
    text-align: center;
}

.history-table .speed-col {
    font-weight: 600;
    color: var(--primary-color);
}

.history-table .acc-good {
    color: #52c41a;
    font-weight: 600;
}

.history-table .acc-warning {
    color: #faad14;
    font-weight: 600;
}

.history-table .acc-bad {
    color: #e34d59;
    font-weight: 600;
}

.history-table .time-col {
    color: var(--text-light);
    font-size: 13px;
    white-space: nowrap;
}

.history-empty {
    text-align: center;
    color: var(--text-light);
    padding: 24px 12px !important;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast-item {
    padding: 12px 24px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    color: var(--text-color);
    pointer-events: auto;
    animation: toastIn 0.3s ease, toastOut 0.3s ease forwards;
    animation-delay: 0s, 3.5s;
    max-width: 380px;
    text-align: center;
    line-height: 1.5;
}

.toast-item.warning {
    border-left: 4px solid #faad14;
    background: #fffbe6;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-16px); }
}

/* Countdown Overlay */
.countdown-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.30);
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 16px;
    pointer-events: none;
}

.countdown-overlay.active {
    display: flex;
}

.countdown-overlay.active.warning {
    animation: countdownFlashFrame 0.8s ease infinite;
}

@keyframes countdownFlashFrame {
    0%, 100% {
        box-shadow: inset 0 0 60px 10px rgba(220, 38, 38, 0.15);
    }
    50% {
        box-shadow: inset 0 0 120px 24px rgba(220, 38, 38, 0.35);
    }
}

.countdown-number {
    font-size: 96px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: countPulse 0.8s ease;
    line-height: 1;
}

.countdown-text {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 4px;
}

@keyframes countPulse {
    0% { opacity: 0; transform: scale(0.5); }
    40% { opacity: 1; transform: scale(1.15); }
    100% { opacity: 0.6; transform: scale(1); }
}

/* 测试结束前 5 秒红色边框闪烁 - 全屏效果 */
#warningFlash {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    border: 6px solid transparent;
    animation: none;
}

#warningFlash.active {
    display: block;
    animation: warningBorderPulse 0.8s ease infinite;
}

@keyframes warningBorderPulse {
    0%, 100% {
        border-color: rgba(220, 38, 38, 0.35);
        box-shadow: inset 0 0 50px 8px rgba(220, 38, 38, 0.15);
        background: rgba(220, 38, 38, 0.03);
    }
    50% {
        border-color: rgba(220, 38, 38, 0.75);
        box-shadow: inset 0 0 80px 18px rgba(220, 38, 38, 0.3);
        background: rgba(220, 38, 38, 0.08);
    }
}

/* Custom Modal */
.custom-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}

.custom-modal-overlay.active {
    display: flex;
}

.custom-modal {
    background: #fff;
    border-radius: 12px;
    padding: 28px 32px 20px;
    min-width: 340px;
    max-width: 420px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    animation: slideUp 0.25s ease;
}

.custom-modal-body {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 24px;
}

.custom-modal-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: var(--warning-color);
    margin-top: 2px;
}

.custom-modal-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-color);
    margin: 0;
}

.custom-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.custom-modal-actions .btn {
    min-width: 80px;
    padding: 8px 20px;
    font-size: 14px;
}

/* 重名处理弹窗 */
#duplicateModal .custom-modal-body {
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.dup-suggestion-box {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
}

.dup-label {
    font-size: 14px;
    color: var(--text-light);
    white-space: nowrap;
}

.dup-name-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius);
    padding: 4px 6px;
    background: #f8faff;
}

.dup-arrow-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: #e8f0fe;
    color: var(--primary-color);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.dup-arrow-btn:hover {
    background: var(--primary-color);
    color: #fff;
}

.dup-name-display {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 80px;
    text-align: center;
    user-select: none;
}

.dup-status {
    font-size: 12px;
    color: #e34d59;
    min-height: 18px;
    margin: 0;
}

.dup-status.ok {
    color: #22c55e;
}

.modal-title {
    font-size: 18px;
    color: var(--text-color);
    margin-bottom: 0;
    text-align: center;
}

.modal-subtitle {
    font-size: 14px;
    color: var(--text-light);
    text-align: center;
    line-height: 1.5;
}

#duplicateModal .custom-modal-actions {
    justify-content: space-between;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 密码设置按钮 */
.btn-set-pwd {
    margin-left: 4px;
    background: #e8f0fe;
    color: #1a73e8;
    border: 1px solid #c6dafc;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-set-pwd:hover {
    background: #d2e3fc;
    border-color: #a8c7fa;
}

.btn-set-pwd-result {
    background: #e8f0fe;
    color: #1a73e8;
    border: 2px dashed #93bdf8;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-set-pwd-result:hover {
    background: #d2e3fc;
    border-color: #1a73e8;
}

/* 密码模态框 */
.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 8px;
}

.modal-subtitle {
    font-size: 13px;
    color: #666;
    margin: 0 0 16px;
}

#passwordModal .custom-modal-body {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

.form-group {
    margin-bottom: 0;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-input:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.form-error {
    color: #dc2626;
    font-size: 13px;
    margin: 0;
}

/* 姓名页密码登录 */
.login-password-group {
    margin-top: 8px;
    margin-bottom: 12px;
}

.login-password-input {
    text-align: center;
    letter-spacing: 4px;
}

.password-login-toggle {
    text-align: center;
    margin-top: 12px;
}

.login-hint {
    text-align: center;
    margin-top: 8px;
    font-size: 13px;
    color: #999;
    line-height: 1.5;
}

.name-form input::placeholder {
    color: #bbb;
}

.link-sm {
    font-size: 13px;
    color: #1a73e8;
    text-decoration: none;
    cursor: pointer;
}

.link-sm:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .app-header {
        padding: 12px 16px;
    }

    .app-title {
        font-size: 16px;
    }

    .btn-header {
        font-size: 12px;
        padding: 4px 10px;
    }

    .app-main {
        padding: 16px;
    }

    .card {
        padding: 20px;
    }

    .config-row {
        flex-direction: column;
        gap: 16px;
    }

    .stats-bar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .stat-item {
        min-width: calc(50% - 4px);
    }

    .stat-value {
        font-size: 22px;
    }

    .typing-paper {
        font-size: 17px;
    }

    .text-layer .paragraph,
    .text-layer .original-line,
    .text-layer .typed-line,
    .text-layer .original-line span,
    .text-layer .typed-line span {
        font-size: 17px;
        line-height: 1.6;
    }

    .typing-area {
        flex-direction: column;
        align-items: stretch;
    }

    .floating-panel {
        position: relative;
        top: auto;
        align-self: center;
        flex-direction: row;
        order: -1;
        margin-bottom: 10px;
        padding: 8px 6px;
        gap: 6px;
        border-radius: 8px;
    }

    .floating-btn {
        min-width: 72px;
        height: 34px;
        padding: 0 10px;
        gap: 4px;
    }

    .floating-btn svg {
        width: 16px;
        height: 16px;
    }

    .floating-btn-label {
        font-size: 13px;
    }

    .result-area {
        flex-direction: column;
        align-items: center;
    }

    .result-card,
    .history-card {
        max-width: 100%;
    }

    .history-card {
        margin-top: 20px;
    }

    .result-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .result-row .result-item {
        flex: 1 1 calc(50% - 4px);
        min-width: calc(50% - 4px);
    }

    .result-meta {
        font-size: 13px;
        gap: 6px;
    }

    .result-value {
        font-size: 22px;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
    }

    .history-stats-row {
        gap: 10px;
    }

    .history-table {
        font-size: 12px;
    }

    .history-table th,
    .history-table td {
        padding: 8px 4px;
    }

    /* 手机端：姓名/测试文本列限制宽度 */
    .history-table th:nth-child(1),
    .history-table td:nth-child(1) {
        max-width: 60px;
    }

    .history-table th:nth-child(5),
    .history-table td:nth-child(5) {
        max-width: 100px;
    }
}

@media (max-width: 480px) {
    .app-container {
        min-height: 100vh;
    }

    .name-entry {
        min-height: 50vh;
    }

    .stat-item {
        min-width: 100%;
    }

    .result-stats {
        gap: 12px;
    }

    .result-row {
        gap: 12px;
    }

    .result-item {
        padding: 12px 8px;
    }
}

/* ========== 共享自定义弹窗 ========== */
.shared-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}

.shared-modal-overlay.active {
    display: flex;
}

.shared-modal-box {
    background: #fff;
    border-radius: 14px;
    padding: 28px 32px 20px;
    min-width: 340px;
    max-width: 440px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    animation: sharedSlideUp 0.25s ease;
}

.shared-modal-box-wide {
    max-width: 520px;
}

.shared-modal-body {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 24px;
}

.shared-modal-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.shared-modal-text {
    font-size: 15px;
    line-height: 1.6;
    color: #333;
    margin: 0;
    white-space: pre-line;
}

.shared-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.shared-modal-btn {
    min-width: 80px;
    padding: 9px 22px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
}

.shared-modal-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.shared-modal-btn-cancel {
    background: #f5f5f5;
    color: #666;
    border: 1px solid #e0e0e0;
}

.shared-modal-btn-cancel:hover {
    background: #eee;
}

.shared-modal-btn-confirm {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}

.shared-modal-btn-confirm:hover {
    background: linear-gradient(135deg, #5a6fd6, #6a3f96);
}

@keyframes sharedSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}
