:root {
    --bg-body: #09090b;       
    --bg-panel: #18181b;      
    --bg-sidebar: #111113;    
    --accent: #8b5cf6;        
    --accent-glow: rgba(139, 92, 246, 0.4);
    --text-main: #e4e4e7;
    --text-muted: #71717a;
    --correct: #4ade80;       
    --wrong: #f87171;         
    --caret: #8b5cf6;
    --border: #27272a;
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; }

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* SIDEBAR */
aside {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}
aside::-webkit-scrollbar { width: 5px; }
aside::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.logo {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--text-main);
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 5px;
}
.logo span { color: var(--accent); }

.menu-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 15px 0 5px 5px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.nav-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #a1a1aa;
    padding: 10px 15px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}
.nav-btn:hover { background: #27272a; color: var(--text-main); }
.nav-btn.active { 
    background: rgba(139, 92, 246, 0.15); 
    color: var(--accent); 
    border-color: rgba(139, 92, 246, 0.2);
}

/* MAIN */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

header {
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(10px);
}

.header-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-badge {
    font-size: 0.75rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 4px;
    color: var(--text-muted);
}

.mode-selector {
    background: var(--bg-panel);
    padding: 4px;
    border-radius: 8px;
    display: flex;
    gap: 4px;
    border: 1px solid var(--border);
}

.time-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}
.time-btn:hover { color: var(--text-main); }
.time-btn.active { background: var(--bg-sidebar); color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,0.5); }

/* GAME AREA */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.typing-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    background: var(--bg-panel);
    padding: 50px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    cursor: text;
    min-height: 200px;
    display: flex;
    align-items: center;
}
.typing-container.active { border-color: var(--accent); box-shadow: 0 0 30px var(--accent-glow); }

#input-field {
    position: absolute;
    top: 0; left: 0;
    opacity: 0;
    width: 100%; height: 100%;
    cursor: text;
    z-index: 10;
}

#display-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    color: var(--text-muted);
    line-height: 1.8;
    user-select: none;
    word-break: break-word;
}

.instruction {
    margin-top: 20px; font-size: 0.9rem; color: var(--text-muted); text-align: center;
}
.highlight { color: var(--accent); }

/* CHAR STYLES */
.char { transition: color 0.1s; }
.char.correct { color: var(--text-main); }
.char.wrong { color: var(--wrong); text-decoration: underline; }
.char.current { position: relative; }
.char.current::after {
    content: ''; position: absolute; left: 0; bottom: -2px;
    width: 100%; height: 3px; background: var(--accent);
    animation: blink 1s infinite;
}
.char.space-error { background: rgba(248, 113, 113, 0.2); }
.separator-char { color: var(--accent); font-weight: bold; }

@keyframes blink { 50% { opacity: 0; } }

/* STATS */
.footer-stats { margin-top: 50px; display: flex; gap: 60px; }
.stat-item { text-align: center; }
.stat-val { font-family: 'JetBrains Mono', monospace; font-size: 2.2rem; font-weight: bold; color: var(--text-main); display: block; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 5px;}

#stop-endless-btn {
    background: #ef4444; color: white; border: none; padding: 10px 20px;
    border-radius: 8px; cursor: pointer; font-weight: bold; display: none; font-size: 0.9rem;
}

/* MODAL */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.92); backdrop-filter: blur(10px);
    z-index: 100; display: none; justify-content: center; align-items: center;
}
.modal-overlay.show { display: flex; }

.modal-card {
    background: var(--bg-panel); padding: 40px; border-radius: 20px; border: 1px solid var(--border);
    text-align: center; width: 450px; box-shadow: 0 0 50px rgba(139, 92, 246, 0.1);
}
.modal-title { font-size: 1.5rem; color: var(--text-main); margin-bottom: 30px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 30px; }
.m-box { background: var(--bg-body); padding: 20px; border-radius: 12px; border: 1px solid var(--border); }
.m-val { font-size: 2.5rem; font-weight: bold; color: var(--accent); font-family: 'JetBrains Mono'; }
.m-lbl { font-size: 0.8rem; color: #a1a1aa; }
.modal-info { color: var(--text-muted); margin-bottom: 20px; }
.modal-info span { color: var(--text-main); font-weight: bold; }

.btn-primary {
    background: var(--accent); color: white; border: none; padding: 14px 35px;
    font-size: 1rem; border-radius: 10px; cursor: pointer; font-weight: 600; transition: transform 0.2s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 5px 20px var(--accent-glow); }