/* ======= 反应力测试工具样式 ======= */

.tool-title-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary-light);
}

.tool-title-wrapper i {
    font-size: 2rem;
    color: var(--primary-color);
}

.tool-title-wrapper .tool-title {
    margin-bottom: 0;
    border-bottom: none;
}

/* 模式切换按钮组 */
.mode-switcher {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    padding: 4px;
    background: var(--bg-light);
    border-radius: var(--radius-md);
}

.mode-btn {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.mode-btn:hover {
    color: var(--primary-color);
    background: var(--bg-white);
}

.mode-btn.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

/* 轮次进度提示 */
.rt-progress {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    min-height: 18px;
}

/* 反应测试主区 */
.rt-area {
    position: relative;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: linear-gradient(135deg, #5b7cfa, #3f51b5);
    border-radius: var(--radius-lg);
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    box-shadow: var(--shadow-md);
    transition: background 0.15s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.rt-area:hover {
    box-shadow: var(--shadow-lg);
}

.rt-area:active {
    transform: scale(0.99);
}

.rt-area:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* 等待状态（红） */
.rt-area.is-waiting {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
}

/* 变绿状态（绿） */
.rt-area.is-go {
    background: linear-gradient(135deg, #2ed573, #009432);
    animation: rtPulse 0.6s ease-in-out infinite;
}

/* 抢跑状态（琥珀） */
.rt-area.is-too-soon {
    background: linear-gradient(135deg, #f6d365, #f0932b);
}

.rt-text {
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
    pointer-events: none;
    z-index: 1;
    text-align: center;
    padding: 0 16px;
}

.rt-hint {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.92);
    pointer-events: none;
    z-index: 1;
    text-align: center;
    padding: 0 16px;
}

.rt-area.is-waiting .rt-text,
.rt-area.is-too-soon .rt-text {
    animation: rtPop 0.35s ease;
}

.rt-area.is-go .rt-text {
    font-size: 40px;
}

@keyframes rtPop {
    0% {
        transform: scale(0.85);
        opacity: 0.5;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes rtPulse {
    0%,
    100% {
        box-shadow: var(--shadow-md);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(46, 213, 115, 0.16), var(--shadow-md);
    }
}

/* 结果区 */
.result-section {
    margin-top: 16px;
    text-align: center;
}

.result-avg {
    font-size: 64px;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Consolas', 'Monaco', monospace;
    line-height: 1.1;
}

.avg-unit {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 6px;
}

.result-rank {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 22px;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    background: var(--primary-color);
}

.result-rank .rank-tip {
    font-weight: 400;
    font-size: 12px;
    margin-left: 8px;
    opacity: 0.9;
}

.result-rank.rank-slow {
    background: #8c8c8c;
}

.result-rank.rank-mid {
    background: #2d8cf0;
}

.result-rank.rank-good {
    background: #52c41a;
}

.result-rank.rank-fast {
    background: linear-gradient(135deg, #ff9a9e, #f6416c);
}

.new-record-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 4px 14px;
    background: linear-gradient(135deg, #ffd700, #ffb800);
    color: #7a5c00;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 20px 0 12px;
}

.stat-box {
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.stat-box .stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Consolas', 'Monaco', monospace;
    line-height: 1.2;
}

.stat-box .stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 分轮明细 */
.round-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 12px 0 16px;
}

.round-item {
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--bg-light);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
}

.round-item.good {
    background: rgba(82, 196, 26, 0.12);
    color: #389e0d;
}

.round-item.slow {
    background: rgba(255, 77, 79, 0.12);
    color: #cf1322;
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 历史最佳 */
.best-record {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

/* 暗色模式 */
[data-theme="dark"] .mode-switcher,
[data-theme="dark"] .stat-box,
[data-theme="dark"] .round-item,
[data-theme="dark"] .best-record {
    background: var(--bg-secondary);
}

[data-theme="dark"] .mode-btn:hover {
    background: var(--bg-primary);
}

[data-theme="dark"] .rt-text,
[data-theme="dark"] .rt-hint {
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* 响应式 */
@media (max-width: 768px) {
    .rt-area {
        min-height: 220px;
    }

    .result-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .rt-text {
        font-size: 26px;
    }

    .rt-area.is-go .rt-text {
        font-size: 32px;
    }

    .result-avg {
        font-size: 48px;
    }

    .avg-unit {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .rt-text {
        font-size: 22px;
    }

    .rt-hint {
        font-size: 12px;
    }

    .rt-area {
        min-height: 200px;
    }
}
