:root {
    --bg-color: #323437;
    --main-color: #e2b714;
    --caret-color: #e2b714;
    --sub-color: #646669;
    --text-color: #d1d0c5;
    --error-color: #ca4754;
    --navbar-height: 84px;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'JetBrains Mono', monospace;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    width: 100%;
    height: var(--navbar-height);
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(50, 52, 55, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(100, 105, 105, 0.3);
    position: relative;
    z-index: 1000;
}

.navbar-inner {
    width: 100%;
    max-width: 1400px;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.logo {
    font-size: 1.5rem;
    color: var(--main-color);
    font-weight: bold;
}

.nav-templates {
    display: flex;
    gap: 0.5rem;
}

.nav-template-btn {
    background: var(--sub-color);
    border: none;
    color: var(--text-color);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.nav-template-btn:hover {
    background: var(--main-color);
    color: var(--bg-color);
    transform: translateY(-1px);
}

.nav-template-btn.active {
    background: var(--main-color);
    color: var(--bg-color);
    box-shadow: 0 2px 8px rgba(226, 183, 20, 0.3);
}

/* Main Content Layout */
.main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 0;
    gap: 2rem;
    min-height: calc(100vh - var(--navbar-height));
}

.nav-btn {
    background: none;
    border: none;
    color: var(--sub-color);
    cursor: pointer;
    font-family: inherit;
    margin-left: 1rem;
    transition: 0.3s;
}

.nav-btn:hover { color: var(--text-color); }
.highlight { color: var(--main-color); }

/* Typing Area */
.test-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 1000px;
    max-width: 90%;
    height: 100%;
}

.stats-row {
    display: flex;
    gap: 2rem;
    font-size: 1.2rem;
    color: var(--main-color);
    margin-bottom: 1rem;
}

.template-toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.template-btn {
    background: var(--sub-color);
    border: none;
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.template-btn:hover {
    background: var(--main-color);
    color: var(--bg-color);
}

.template-btn.active {
    background: var(--main-color);
    color: var(--bg-color);
}

.typing-area {
    overflow-y: auto;
    scrollbar-width: none;
    transition: box-shadow 0.3s ease;
}

.typing-area.typing-active {
    box-shadow:
        0 0 30px rgba(226, 183, 20, 0.4),
        0 0 60px rgba(226, 183, 20, 0.2),
        inset 0 0 20px rgba(226, 183, 20, 0.1);
    border: 1px solid rgba(226, 183, 20, 0.3);
    background: linear-gradient(145deg, rgba(226, 183, 20, 0.05), rgba(226, 183, 20, 0.02));
}

.char.active {
    text-shadow: 0 0 10px rgba(226, 183, 20, 0.6);
}

.typing-area::-webkit-scrollbar {
    display: none;
}


#typingInput {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.char.correct { color: var(--text-color); }
.char.wrong { color: var(--error-color); }
.char {
    position: relative;
    font-size: 1.4rem;
    line-height: 1.6;
}

.char.active::before {
    content: "";
    position: absolute;
    left: -2px;
    top: 0;
    width: 2px;
    height: 2.2rem;
    background: var(--caret-color);
    animation: blink 1s infinite;
}


@keyframes blink {
    50% { border-color: transparent; }
}

/* Modal UI */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-color);
    padding: 3rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 350px;
}

.modal-content input {
    background: #2c2e31;
    border: none;
    padding: 0.8rem;
    color: white;
    border-radius: 4px;
}

.action-btn {
    background: var(--main-color);
    border: none;
    padding: 0.8rem;
    cursor: pointer;
    font-weight: bold;
}

.restart-hint {
    text-align: center;
    margin-top: 3rem;
    color: var(--sub-color);
    font-size: 0.8rem;
}

kbd {
    background: #444;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Sidebar */
.sidebar {
    width: 300px;
    height: 100%;
    background: rgba(50, 52, 55, 0.95);
    backdrop-filter: blur(10px);
    border-left: 1px solid rgba(100, 105, 105, 0.3);
    padding: 2rem 1.5rem;
    overflow-y: auto;
    scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-title {
    color: var(--main-color);
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(100, 105, 105, 0.3);
    padding-bottom: 0.5rem;
}

/* High Scores */
.high-scores {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: rgba(44, 46, 49, 0.5);
    border-radius: 6px;
    font-size: 0.9rem;
}

.rank {
    color: var(--main-color);
    font-weight: bold;
    width: 30px;
}

.name {
    flex: 1;
    color: var(--sub-color);
}

.score {
    color: var(--text-color);
    font-weight: 500;
}

/* User Stats */
.user-stats {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(100, 105, 105, 0.2);
}

.stat-label {
    color: var(--sub-color);
    font-size: 0.9rem;
}

.stat-value {
    color: var(--text-color);
    font-weight: 500;
}

/* Multiplayer */
.multiplayer-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.multiplayer-btn {
    background: var(--main-color);
    border: none;
    color: var(--bg-color);
    padding: 0.6rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.3s ease;
}

.multiplayer-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(226, 183, 20, 0.3);
}

.multiplayer-btn.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

.room-code-section {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.room-code-section input {
    background: rgba(44, 46, 49, 0.8);
    border: 1px solid rgba(100, 105, 105, 0.3);
    color: var(--text-color);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-family: inherit;
    flex: 1;
}

.active-room {
    background: rgba(44, 46, 49, 0.5);
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
}

.active-room p {
    margin: 0.5rem 0;
    color: var(--sub-color);
    font-size: 0.9rem;
}

/* Profile */
.profile-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--main-color), var(--caret-color));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(226, 183, 20, 0.3);
}

.avatar-circle {
    color: var(--bg-color);
    font-weight: bold;
    font-size: 1.5rem;
}

.profile-info {
    text-align: center;
}

.username {
    color: var(--text-color);
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.level {
    color: var(--main-color);
    font-size: 0.9rem;
}

.profile-btn {
    background: var(--sub-color);
    border: none;
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.profile-btn:hover {
    background: var(--main-color);
    color: var(--bg-color);
}

/* Recent Tests */
.recent-tests {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recent-test-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: rgba(44, 46, 49, 0.3);
    border-radius: 4px;
    font-size: 0.9rem;
}

.test-date {
    color: var(--sub-color);
}

.test-result {
    color: var(--text-color);
    font-weight: 500;
}

/* Theme Variations */
.theme-cyber {
    --bg-color: #0a0a0a;
    --main-color: #00ff41;
    --caret-color: #00ff41;
    --sub-color: #666666;
    --text-color: #ffffff;
    --error-color: #ff073a;
}

.theme-matrix {
    --bg-color: #000000;
    --main-color: #00ff00;
    --caret-color: #00ff00;
    --sub-color: #004400;
    --text-color: #00ff00;
    --error-color: #ff0000;
}

.theme-dark {
    --bg-color: #1a1a1a;
    --main-color: #ff6b6b;
    --caret-color: #ff6b6b;
    --sub-color: #555555;
    --text-color: #ffffff;
    --error-color: #ff4757;
}

.theme-neon {
    --bg-color: #0f0f23;
    --main-color: #00d4ff;
    --caret-color: #00d4ff;
    --sub-color: #444444;
    --text-color: #ffffff;
    --error-color: #ff3838;
}