:root {
    --bg-color: #f1f5f9;
    --surface-color: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent: #0ea5e9;
    --accent-hover: #0284c7;
    --correct: #10b981;
    --incorrect-text: #ef4444;
    --incorrect-bg: #fee2e2;
    --untyped: #94a3b8;
    --border: #e2e8f0;
    --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Courier New', Courier, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background-color: var(--surface-color);
    padding: 1rem 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    justify-content: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--accent);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
}

/* HUD Styling */
#hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 3rem;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
}

/* Typing Area */
#typing-section {
    position: relative;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#loading {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.25rem;
    display: none;
}
#loading.active {
    display: block;
}

#quote-display {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    line-height: 2.2rem;
    letter-spacing: 0.02em;
    color: var(--untyped);
    user-select: none;
    display: flex;
    flex-wrap: wrap;
}

#quote-display.hidden {
    display: none;
}

.instructions {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Character States */
.char {
    position: relative;
    border-radius: 2px;
    transition: all 0.1s ease;
}

.char.correct {
    color: var(--correct);
}

.char.incorrect {
    color: var(--incorrect-text);
    background-color: var(--incorrect-bg);
}

.char.active {
    color: var(--text-primary);
    border-bottom: 3px solid var(--accent);
}

/* Results Section & Charts */
#results-section {
    text-align: center;
}

#results-section.hidden {
    display: none;
}

#results-section h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--accent);
}

.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-wrapper {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.chart-wrapper h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

.svg-container {
    width: 100%;
    height: 200px;
}

svg.custom-chart {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Button */
#restart-btn {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

#restart-btn:hover {
    background-color: var(--accent-hover);
}

#restart-btn:active {
    transform: scale(0.98);
}

/* Responsive */
@media (max-width: 768px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
    #quote-display {
        font-size: 1.25rem;
    }
    #hud {
        padding: 1rem;
    }
    .stat-value {
        font-size: 2rem;
    }
}