/* =========================================
   1. THEME VARIABLES
   ========================================= */

/* Default Theme: Carbon (Dark) */
:root {
    --bg-color: #111111;
    --main-color: #00d4ff;    /* Cyan Accent */
    --text-color: #444444;    /* Untyped Color */
    --font-active: #eeeeee;   /* Correct Color */
    --error-color: #ff4757;   /* Red */
    --error-bg: rgba(255, 71, 87, 0.2);
    --font-family: 'Courier New', monospace;
}

/* Cyberpunk Theme */
[data-theme="cyberpunk"] {
    --bg-color: #2b213a;
    --main-color: #fdf500;    /* Yellow */
    --text-color: #725e82;
    --font-active: #ff0070;   /* Neon Pink */
    --error-color: #00fff9;   /* Neon Blue */
    --error-bg: rgba(0, 255, 249, 0.1);
}

/* Light Theme: Paper */
[data-theme="light"] {
    --bg-color: #f5f5f5;
    --main-color: #444444;
    --text-color: #999999;
    --font-active: #000000;
    --error-color: #ca4754;
    --error-bg: rgba(202, 71, 84, 0.1);
}

/* =========================================
   2. GLOBAL STYLES
   ========================================= */

body {
    background-color: var(--bg-color);
    color: var(--font-active);
    font-family: var(--font-family);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    transition: background-color 0.4s ease, color 0.4s ease;
}

.test-container {
    width: 90%;
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* =========================================
   3. NAVIGATION & BUTTONS
   ========================================= */

.theme-switcher, .word-count-options {
    display: flex;
    gap: 20px;
    margin-bottom: 1rem;
    z-index: 10;
}

.theme-switcher button, .word-count-options button {
    background: none;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.3s;
    padding: 5px 10px;
}

.theme-switcher button {
    border: 1px solid var(--text-color);
    border-radius: 4px;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.theme-switcher button:hover, .word-count-options button:hover {
    color: var(--font-active);
    border-color: var(--main-color);
}

/* =========================================
   4. TYPING AREA (CORE ENGINE)
   ========================================= */

#quote-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    min-height: 150px;
    width: 100%;
    line-height: 2.5;
    font-size: 1.5rem;
    padding: 20px;
}

.word {
    display: flex;
    flex-wrap: nowrap; /* Keeps word letters together */
}

#quote-display span {
    position: relative;
    display: inline-block;
    white-space: pre; /* Essential for spaces to have width */
    color: var(--text-color);
    border-left: 2px solid transparent;
}

#quote-display span.correct {
    color: var(--font-active);
}

#quote-display span.incorrect {
    color: var(--error-color) !important;
    background-color: var(--error-bg);
    text-decoration: none !important;
}

/* The Blinking Caret */
#quote-display span.active {
    border-left: 2px solid var(--main-color);
    margin-left: -2px; 
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { border-color: var(--main-color); }
    50% { border-color: transparent; }
}

/* The Invisible Input */
#quote-input {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

/* =========================================
   5. RESULTS MODAL
   ========================================= */

.modal {
    display: none; /* Toggled by JS to 'flex' */
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-content {
    background: #1a1a1a;
    padding: 3rem;
    border-radius: 15px;
    text-align: center;
    border: 1px solid var(--main-color);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.1);
}

.stats-grid {
    display: flex;
    gap: 40px;
    margin: 2rem 0;
}

.label { color: #888; font-size: 0.8rem; text-transform: uppercase; }
.value { font-size: 3rem; color: var(--main-color); font-weight: bold; }

.modal-content button {
    background: var(--main-color);
    color: var(--bg-color);
    border: none;
    padding: 12px 30px;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 5px;
    font-weight: bold;
}