:root {
    --bg: #0a0e17;
    --surface: #111827;
    --surface2: #1c2333;
    --border: #2a3347;
    --accent: #00e5ff;
    --accent2: #ff6b35;
    --text: #e2e8f0;
    --text-muted: #64748b;
    --correct: #3b82f6;
    --error: #ef4444;
    --done: #22c55e;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --font-display: 'Syne', sans-serif;
    --font-body: 'Source Sans Pro', sans-serif;
}

/*  Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Body  */
body {
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.6;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.masthead {
    padding: 1.6em 2.5em;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: baseline;
    gap: 1.2em;
}

.masthead h1 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text);
}

.accent {
    color: var(--accent);
}

.tagline {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 0;
}

/* Main layout  */
.main {
    flex: 1;
    display: flex;
    gap: 2em;
    padding: 2.5em 2.5em;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

/*  Test area  */
.test-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1em;
}

/*  Origin text box  */
#origin-text {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2em 1.4em;
}

#origin-text p {
    font-family: var(--font-mono);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
    margin: 0;
    letter-spacing: 0.02em;
}

/*  Progress bar */
#progress-bar {
    height: 5px;
    background: var(--surface2);
    border-radius: 99px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 99px;
    transition: width 0.1s ease;
}

/*  Textarea wrapper  */
.test-wrapper {
    border: 3px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.test-wrapper textarea {
    width: 100%;
    display: block;
    padding: 1.2em 1.4em;
    font-family: var(--font-mono);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
    background: var(--surface);
    border: none;
    outline: none;
    resize: none;
    letter-spacing: 0.02em;
}

.test-wrapper textarea::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* Meta row */
.meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    flex-wrap: wrap;
}

.stat-group {
    display: flex;
    gap: 1em;
}

.stat-box {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7em 1.2em;
    min-width: 90px;
    text-align: center;
}

.stat-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 2px;
    text-transform: uppercase;
}

.timer {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.05em;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

/*  Reset button  */
#reset {
    padding: 0.65em 1.5em;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--accent2);
    background: transparent;
    border: 2px solid var(--accent2);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

#reset:hover {
    background: var(--accent2);
    color: white;
}

/*Scores sidebar  */
.scores-panel {
    width: 200px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.4em 1.2em;
    display: flex;
    flex-direction: column;
    gap: 1em;
    align-self: flex-start;
}

.scores-panel h2 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
}

#score-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}

.score-item {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5em 0.7em;
}

.no-scores {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

#clear-scores {
    padding: 0.45em 0.8em;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

#clear-scores:hover {
    border-color: var(--error);
    color: var(--error);
}

/* Responsive  */
@media (max-width: 680px) {
    .main {
        flex-direction: column;
        padding: 1.5em 1em;
    }

    .scores-panel {
        width: 100%;
    }

    .masthead {
        flex-direction: column;
        gap: 0.2em;
    }

    .stat-group {
        flex-wrap: wrap;
    }
}