/* ============================================
   Typing Speed Test — typing-test.css
   Complete Styles
   ============================================ */

.tt-app { max-width: 100%; }

.tt-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.tt-card-title {
    font-size: 1.3rem; font-weight: 700; color: var(--text-primary);
    margin-bottom: 1.5rem; padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    display: flex; align-items: center;
}

/* ---- Settings Bar ---- */
.tt-settings-card { padding: 1.25rem 2rem; }

.tt-settings-row {
    display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
}

.tt-setting-group { display: flex; align-items: center; gap: 10px; }

.tt-setting-label {
    font-size: .8rem; font-weight: 600; color: var(--text-muted);
    white-space: nowrap;
}

.tt-setting-btns { display: flex; gap: 4px; }

.tt-set-btn {
    padding: 6px 14px; font-size: .8rem; font-weight: 700;
    color: var(--text-secondary); background: var(--bg-secondary);
    border: 2px solid var(--border-color); border-radius: var(--radius-md);
    cursor: pointer; transition: all .15s;
}
.tt-set-btn:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.tt-set-active { background: var(--brand-primary) !important; border-color: var(--brand-primary) !important; color: #fff !important; }

/* ---- Live Stats Bar ---- */
.tt-live-bar { padding: 1rem 2rem; }

.tt-live-stats { display: flex; justify-content: space-around; gap: 12px; flex-wrap: wrap; }

.tt-live-stat { text-align: center; min-width: 70px; }

.tt-live-num {
    display: block; font-size: 1.6rem; font-weight: 800;
    color: var(--text-primary); line-height: 1.1;
}

.tt-live-label {
    font-size: .65rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .04em;
}

.tt-live-timer .tt-live-num { color: var(--brand-primary); }

.tt-progress-bar {
    height: 4px; background: var(--bg-tertiary); border-radius: 2px;
    margin-top: 12px; overflow: hidden;
}

.tt-progress-fill {
    height: 100%; width: 0; border-radius: 2px;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
    transition: width .3s linear;
}

/* ---- Typing Card ---- */
.tt-typing-card {
    border: 2px solid var(--border-color);
    transition: border-color .2s;
}
.tt-typing-card.tt-active { border-color: var(--brand-primary); }
.tt-typing-card.tt-error-flash { border-color: #ef4444; }

.tt-text-display {
    min-height: 160px; max-height: 280px; padding: 20px; background: var(--bg-secondary);
    border-radius: var(--radius-lg); margin-bottom: 16px;
    font-family: 'JetBrains Mono', monospace; font-size: 1.15rem;
    line-height: 2; position: relative; overflow-y: auto;
    user-select: none; scroll-behavior: smooth;
}

.tt-prompt {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 120px; gap: 12px;
    color: var(--text-muted); font-family: inherit;
}
.tt-prompt i { font-size: 2.5rem; opacity: .4; }
.tt-prompt span { font-size: 1rem; font-weight: 500; }

.tt-text-content { position: relative; }

/* Character styling */
.tt-char {
    position: relative; border-radius: 2px; padding: 2px 0;
    transition: color .05s;
}
.tt-char-current {
    border-bottom: 3px solid var(--brand-primary);
    animation: ttBlink 1s infinite;
}
.tt-char-correct { color: var(--text-primary); }
.tt-char-wrong { color: #ef4444; background: rgba(239,68,68,.12); border-radius: 3px; }
.tt-char-pending { color: var(--text-muted); }

@keyframes ttBlink {
    0%, 100% { border-bottom-color: var(--brand-primary); }
    50% { border-bottom-color: transparent; }
}

/* Input */
.tt-input-area { position: relative; }

.tt-input {
    width: 100%; padding: 14px 18px; font-size: 1.1rem; font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary); background: var(--bg-input);
    border: 2px solid var(--border-color); border-radius: var(--radius-lg);
    outline: none; transition: border-color .2s;
    box-sizing: border-box;
}
.tt-input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(6,182,212,.12); }
.tt-input:disabled { opacity: .5; cursor: not-allowed; }

.tt-typing-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 12px;
}

.tt-restart-btn {
    padding: 8px 18px; font-size: .85rem; font-weight: 600;
    color: var(--text-secondary); background: var(--bg-secondary);
    border: 2px solid var(--border-color); border-radius: var(--radius-md);
    cursor: pointer; transition: all .15s;
}
.tt-restart-btn:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

.tt-hint { font-size: .75rem; color: var(--text-muted); }
.tt-hint kbd {
    padding: 2px 6px; background: var(--bg-tertiary); border: 1px solid var(--border-color);
    border-radius: 4px; font-size: .7rem; font-weight: 700;
}

/* ---- Results ---- */
.tt-results-card { text-align: center; }

.tt-score-display {
    display: flex; flex-direction: column; align-items: center;
    gap: 8px; margin-bottom: 2rem;
}

.tt-score-main { display: flex; align-items: baseline; gap: 8px; }

.tt-score-num {
    font-size: 4.5rem; font-weight: 900; line-height: 1;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tt-score-unit { font-size: 1.5rem; font-weight: 700; color: var(--text-muted); }

.tt-score-grade {
    display: inline-block; padding: 6px 20px; border-radius: 20px;
    font-size: .9rem; font-weight: 700; letter-spacing: .05em;
}
.tt-grade-beginner { background: rgba(239,68,68,.12); color: #ef4444; }
.tt-grade-average { background: rgba(245,158,11,.12); color: #f59e0b; }
.tt-grade-good { background: rgba(59,130,246,.12); color: #3b82f6; }
.tt-grade-fast { background: rgba(16,185,129,.12); color: #10b981; }
.tt-grade-pro { background: rgba(139,92,246,.12); color: #8b5cf6; }
.tt-grade-elite { background: rgba(236,72,153,.12); color: #ec4899; }

/* Stats Grid */
.tt-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 2rem; text-align: left; }

.tt-stat-box {
    display: flex; align-items: center; gap: 14px; padding: 16px;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); transition: transform .2s;
}
.tt-stat-box:hover { transform: translateY(-2px); }

.tt-stat-icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
}
.tt-stat-cyan .tt-stat-icon { background: rgba(6,182,212,.12); color: var(--brand-primary); }
.tt-stat-green .tt-stat-icon { background: rgba(16,185,129,.12); color: #10b981; }
.tt-stat-blue .tt-stat-icon { background: rgba(59,130,246,.12); color: #3b82f6; }
.tt-stat-amber .tt-stat-icon { background: rgba(245,158,11,.12); color: #f59e0b; }
.tt-stat-purple .tt-stat-icon { background: rgba(139,92,246,.12); color: #8b5cf6; }
.tt-stat-rose .tt-stat-icon { background: rgba(236,72,153,.12); color: #ec4899; }

.tt-stat-data { display: flex; flex-direction: column; }
.tt-stat-num { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); line-height: 1.1; }
.tt-stat-label { font-size: .7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 3px; }

/* Chart */
.tt-chart-section { margin-bottom: 2rem; text-align: left; }
.tt-section-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin-bottom: 1rem; }

.tt-chart-container {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: 16px; position: relative;
    height: 220px;
}

/* Problem Keys */
.tt-problem-keys-section { margin-bottom: 2rem; text-align: left; }

.tt-problem-keys { display: flex; gap: 8px; flex-wrap: wrap; }

.tt-problem-key {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    background: rgba(239,68,68,.04); border: 1px solid rgba(239,68,68,.15);
    border-radius: var(--radius-md);
}
.tt-problem-key-char {
    font-family: 'JetBrains Mono', monospace; font-size: 1rem;
    font-weight: 700; color: #ef4444; background: rgba(239,68,68,.12);
    padding: 4px 10px; border-radius: 6px; min-width: 32px; text-align: center;
}
.tt-problem-key-info { display: flex; flex-direction: column; }
.tt-problem-key-count { font-size: .8rem; font-weight: 600; color: #ef4444; }
.tt-problem-key-pct { font-size: .7rem; color: var(--text-muted); }

/* Keyboard Heatmap */
.tt-heatmap-section { margin-bottom: 2rem; text-align: left; }

.tt-keyboard { display: flex; flex-direction: column; align-items: center; gap: 6px; }

.tt-kb-row { display: flex; gap: 6px; }

.tt-key {
    width: 42px; height: 42px; display: flex; align-items: center;
    justify-content: center; font-family: 'JetBrains Mono', monospace;
    font-size: .8rem; font-weight: 700; color: var(--text-secondary);
    background: var(--bg-secondary); border: 2px solid var(--border-color);
    border-radius: 8px; transition: all .2s;
}

.tt-key-space { width: 240px; }

.tt-key-hot { background: rgba(16,185,129,.15); border-color: rgba(16,185,129,.4); color: #10b981; }
.tt-key-warm { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.2); color: #10b981; }
.tt-key-error { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.4); color: #ef4444; }
.tt-key-error-hot { background: rgba(239,68,68,.25); border-color: rgba(239,68,68,.6); color: #ef4444; }

.tt-heatmap-legend {
    display: flex; justify-content: center; gap: 20px; margin-top: 12px;
    font-size: .75rem; color: var(--text-muted); font-weight: 600;
}
.tt-legend-item { display: flex; align-items: center; gap: 6px; }
.tt-legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Result Actions */
.tt-result-actions { display: flex; justify-content: center; gap: 12px; margin-top: 1.5rem; }

.tt-action-btn {
    padding: 12px 28px; font-size: 1rem; font-weight: 700;
    border: none; border-radius: var(--radius-lg); cursor: pointer;
    transition: all .2s; display: flex; align-items: center;
}
.tt-action-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    box-shadow: 0 4px 15px rgba(6,182,212,.25);
}
.tt-action-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 25px rgba(6,182,212,.4); }
.tt-action-secondary {
    color: var(--text-secondary); background: var(--bg-secondary);
    border: 2px solid var(--border-color);
}
.tt-action-secondary:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

/* History */
.tt-clear-btn {
    margin-left: auto; font-size: .8rem; font-weight: 600;
    padding: 4px 12px; border-radius: var(--radius-sm); cursor: pointer;
    border: 1px solid var(--border-color); background: transparent;
    color: var(--text-muted); transition: all .15s;
}
.tt-clear-btn:hover { border-color: #ef4444; color: #ef4444; }

.tt-history-list { display: flex; flex-direction: column; gap: 8px; }

.tt-history-row {
    display: flex; align-items: center; gap: 14px; padding: 12px 16px;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); flex-wrap: wrap;
}
.tt-history-rank {
    font-size: .75rem; font-weight: 700; color: var(--text-muted);
    min-width: 30px;
}
.tt-history-wpm { font-size: 1.2rem; font-weight: 800; color: var(--brand-primary); min-width: 80px; }
.tt-history-wpm small { font-size: .65rem; color: var(--text-muted); }
.tt-history-acc { font-size: .85rem; font-weight: 600; color: var(--text-secondary); min-width: 45px; }
.tt-history-badge {
    font-size: .65rem; font-weight: 700; padding: 2px 10px;
    border-radius: 12px; white-space: nowrap;
}
.tt-history-meta { font-size: .7rem; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* Share */
.tt-share-section { text-align: center; }
.tt-share-note { font-size: .85rem; color: var(--text-muted); margin-bottom: 12px; }
.tt-share-row { display: flex; justify-content: center; gap: 10px; }
.tt-share-btn {
    width: 44px; height: 44px; border-radius: 50%; border: none;
    color: #fff; font-size: 1.1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .2s;
}
.tt-share-btn:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(0,0,0,.2); }

/* Result Share Card */
.tt-result-share-card {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px; text-align: center;
    margin-bottom: 16px;
}
.tt-rsc-header {
    font-size: .85rem; font-weight: 700; color: var(--brand-primary);
    margin-bottom: 8px; text-transform: uppercase; letter-spacing: .05em;
}
.tt-rsc-score {
    font-size: 2.5rem; font-weight: 900; line-height: 1;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; margin-bottom: 10px;
}
.tt-rsc-details {
    display: flex; justify-content: center; gap: 16px;
    font-size: .8rem; font-weight: 600; color: var(--text-secondary);
    margin-bottom: 10px;
}
.tt-rsc-grade {
    display: inline-block; padding: 4px 16px; border-radius: 16px;
    font-size: .8rem; font-weight: 700; margin-bottom: 10px;
}
.tt-rsc-challenge {
    font-size: .85rem; font-weight: 600; color: var(--text-muted);
    font-style: italic;
}

/* Guide */
.tt-guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.tt-guide-item {
    display: flex; align-items: center; gap: 12px; padding: 14px;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.tt-guide-icon {
    width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; flex-shrink: 0;
    background: color-mix(in srgb, var(--guide-color) 12%, transparent);
    color: var(--guide-color);
}
.tt-guide-info { display: flex; flex-direction: column; }
.tt-guide-info strong { font-size: .85rem; color: var(--text-primary); }
.tt-guide-info span { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* Info & FAQ */
.tt-info-block {
    padding: 1.25rem; background: var(--bg-secondary); border-radius: var(--radius-md);
    margin-bottom: 1rem; border-left: 4px solid var(--brand-primary); text-align: left;
}
.tt-info-block:last-child { margin-bottom: 0; }
.tt-info-block h3 { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); margin-bottom: .5rem; }
.tt-info-block p { font-size: .95rem; color: var(--text-secondary); margin-bottom: 0; line-height: 1.6; }

.tt-faq-item { padding: 1.25rem; background: var(--bg-secondary); border-radius: var(--radius-md); margin-bottom: 1rem; text-align: left; }
.tt-faq-item:last-child { margin-bottom: 0; }
.tt-faq-item h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin-bottom: .5rem; }
.tt-faq-item p { font-size: .95rem; color: var(--text-secondary); margin-bottom: 0; line-height: 1.6; }

/* Prompt Enhanced */
.tt-prompt-title {
    font-size: 1.3rem; font-weight: 700; color: var(--text-primary);
    margin-top: 8px;
}
.tt-prompt-sub {
    font-size: .9rem; color: var(--text-muted); font-weight: 500;
}
.tt-prompt-badges {
    display: flex; gap: 8px; margin-top: 8px;
}
.tt-prompt-badge {
    padding: 4px 12px; font-size: .75rem; font-weight: 700;
    background: rgba(6,182,212,.08); color: var(--brand-primary);
    border: 1px solid rgba(6,182,212,.2); border-radius: 20px;
}
.tt-prompt-tips {
    display: flex; gap: 16px; margin-top: 12px;
}
.tt-prompt-tip {
    font-size: .75rem; color: var(--text-muted); font-weight: 500;
}
.tt-prompt-tip kbd {
    padding: 2px 6px; background: var(--bg-tertiary); border: 1px solid var(--border-color);
    border-radius: 4px; font-size: .7rem; font-weight: 700; margin-right: 2px;
}

/* Timer Warning */
.tt-timer-warning .tt-live-num {
    color: #ef4444 !important;
    animation: ttTimerPulse .5s infinite;
}
@keyframes ttTimerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

/* Countdown Hint */
.tt-countdown-hint {
    display: inline-block; padding: 2px 10px; background: rgba(6,182,212,.1);
    color: var(--brand-primary); border-radius: 12px; font-weight: 700;
    font-size: .8rem; margin-left: 6px;
}

/* Score Animation */
.tt-score-num {
    animation: ttScoreIn .8s ease-out;
}
@keyframes ttScoreIn {
    0% { transform: scale(0.3); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Responsive */
@media (max-width: 767.98px) {
    .tt-card { padding: 1.25rem; }
    .tt-settings-row { flex-direction: column; gap: 12px; }
    .tt-setting-group { width: 100%; justify-content: space-between; }
    .tt-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .tt-guide-grid { grid-template-columns: 1fr; }
    .tt-live-stats { gap: 8px; }
    .tt-live-num { font-size: 1.2rem; }
    .tt-score-num { font-size: 3rem; }
    .tt-key { width: 30px; height: 30px; font-size: .65rem; }
    .tt-key-space { width: 160px; }
    .tt-text-display { font-size: 1rem; line-height: 1.8; padding: 14px; min-height: 120px; }
    .tt-result-actions { flex-direction: column; }
    .tt-action-btn { width: 100%; justify-content: center; }
    .tt-rsc-details { flex-direction: column; gap: 4px; }
    .tt-prompt-badges { flex-wrap: wrap; justify-content: center; }
    .tt-prompt-tips { flex-wrap: wrap; justify-content: center; gap: 8px; }
    .tt-history-row { gap: 8px; }
    .tt-history-meta { width: 100%; margin-left: 0; }
}
