* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============ ROOT COLORS (LIGHT THEME) ============ */
:root {
    --primary: #2563eb;
    --primary-soft: #dbeafe;

    --success: #16a34a;
    --error: #dc2626;
    --warning: #f59e0b;

    --background: #f8fafc;        /* page white */
    --surface: #ffffff;           /* cards */
    --surface-light: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #475569;

    --border: #e2e8f0;
}

/* ============ BODY ============ */
body {
    min-height: 100vh;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    color: var(--text-primary);
    font-family: "Inter", system-ui, -apple-system, sans-serif;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

/* ============ MAIN CARD ============ */
.test-container,
.results-container {
    width: 100%;
    max-width: 820px;
    background: var(--surface);
    border-radius: 18px;
    border: 1px solid var(--border);
    padding: clamp(20px, 5vw, 40px);
    box-shadow:
        0 10px 30px rgba(15, 23, 42, 0.08);
    animation: fadeIn 0.5s ease;
}

/* ============ STATS BAR ============ */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.stat {
    text-align: center;
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    font-size: clamp(24px, 6vw, 32px);
    font-weight: 700;
    color: var(--primary);
}

/* ============ PARAGRAPH ============ */
.paragraph-container {
    margin-bottom: 28px;
    padding: 22px;
    background: var(--surface-light);
    border-radius: 14px;
    border: 1px solid var(--border);
    min-height: 100px;
}

.paragraph {
    font-size: clamp(16px, 4vw, 20px);
    line-height: 1.8;
    color: var(--text-secondary);
}

/* ============ PREVIEW ============ */
.preview-container {
    margin-bottom: 22px;
}

.preview-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 6px;
}

.preview {
    background: #ffffff;
    border-radius: 10px;
    padding: 16px;
    min-height: 60px;
    border: 1px solid var(--border);
    font-family: "JetBrains Mono", monospace;
}

/* Typed Characters */
#typedCharacters {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.char {
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
}

.char.correct {
    color: var(--success);
    background: #dcfce7;
}

.char.incorrect {
    color: var(--error);
    background: #fee2e2;
}

/* ============ INPUT BOX (BLENDED) ============ */
.typing-input {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    background: #ffffff;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    margin-bottom: 24px;
    transition: all 0.25s ease;
}

.typing-input:focus {
    outline: none;
    border-color: white;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.typing-input::placeholder {
    color: #94a3b8;
}

/* ============ BUTTON ============ */
.btn-primary {
    width: 100%;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.4);
}

/* ============ RESULTS ============ */
.results-container h2 {
    font-size: clamp(28px, 6vw, 36px);
    margin-bottom: 28px;
    color: var(--primary);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.result-box {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 16px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.05);
}

.result-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.result-value {
    font-size: clamp(26px, 6vw, 34px);
    font-weight: 700;
    color: var(--primary);
}

/* ============ UTIL ============ */
.hidden {
    display: none !important;
}

/* ============ ANIMATION ============ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 480px) {
    .stats-bar {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}
