@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap');

:root {
    --bg: #1e1e1e;
    --fg: #d4d4d4;
    --fg-dim: #5c5c5c;
    --accent: #e2b714;
    --error: #ca4754;
    --font: 'JetBrains Mono', monospace;
}

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

body {
    background-color: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    display: flex;
    justify-content: center;
    height: 100vh;
}

.container {
    width: 100%;
    max-width: 900px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4rem;
}

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

.modes { display: flex; gap: 1.5rem; }

.mode-btn {
    background: none;
    border: none;
    color: var(--fg-dim);
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: color 0.2s;
}

.mode-btn:hover, .mode-btn.active { color: var(--fg); }

.auth-link { color: var(--fg-dim); cursor: pointer; transition: color 0.2s; }
.auth-link:hover { color: var(--accent); }

/* Views */
.view { display: none; flex-direction: column; align-items: center; text-align: center; }
.view.active { display: flex; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Home */
.hero-title { font-size: 3rem; margin-top: 4rem; color: var(--fg); }
.hero-sub { font-size: 1.2rem; color: var(--fg-dim); margin-top: 1rem; margin-bottom: 3rem; }
.action-buttons { display: flex; gap: 1rem; }

button.btn-primary, button.btn-secondary {
    padding: 0.8rem 1.5rem;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    font-weight: bold;
}
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-secondary { background: var(--fg-dim); color: var(--bg); }

/* Auth */
.auth-box { display: flex; flex-direction: column; gap: 1rem; width: 300px; margin-top: 4rem; }
.auth-box input {
    padding: 0.8rem; background: #2d2d2d; border: 1px solid var(--fg-dim);
    color: var(--fg); font-family: inherit; border-radius: 4px; outline: none;
}
.auth-box input:focus { border-color: var(--accent); }
.auth-toggle { font-size: 0.9rem; color: var(--fg-dim); cursor: pointer; margin-top: 1rem; }
.auth-toggle span:hover { color: var(--accent); text-decoration: underline; }
.error-msg { color: var(--error); font-size: 0.9rem; min-height: 1.2rem; }

/* Training */
.training-controls { display: flex; justify-content: center; margin-bottom: 2rem; width: 100%; }
.word-counts { display: flex; gap: 1rem; background: #2d2d2d; padding: 0.5rem 1rem; border-radius: 8px; }
.wc-btn { color: var(--fg-dim); cursor: pointer; transition: 0.2s; }
.wc-btn:hover, .wc-btn.active { color: var(--accent); }

.typing-container {
    font-size: 1.6rem; line-height: 1.6; position: relative; width: 100%; text-align: left;
}
.words { display: flex; flex-wrap: wrap; gap: 0.6em; user-select: none; }
.word { display: flex; }
.letter { color: var(--fg-dim); transition: color 0.1s; }
.letter.correct { color: var(--fg); }
.letter.incorrect { color: var(--error); }

/* The smooth Caret */
.caret {
    position: absolute; width: 2px; height: 1.6rem;
    background-color: var(--accent); transition: left 0.1s, top 0.1s;
    animation: blink 1s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.stats { display: flex; justify-content: center; gap: 3rem; margin-top: 2rem; font-size: 1.5rem; color: var(--accent); }
.stats.hidden { opacity: 0; pointer-events: none; }
.stat-box { display: flex; flex-direction: column; align-items: center; }
.stat-label { font-size: 0.9rem; color: var(--fg-dim); margin-bottom: 0.2rem; }
.restart-hint { margin-top: 3rem; color: var(--fg-dim); font-size: 0.9rem; }

/* Multiplayer & Friends Additions */
.hidden { display: none !important; }

/* Opponent Progress */
.match-info { width: 100%; margin-bottom: 2rem; }
.opponent-track { display: flex; align-items: center; gap: 1rem; color: var(--fg-dim); font-size: 0.9rem; }
.opp-name { min-width: 80px; text-align: right; }
.opp-progress-bar { flex-grow: 1; height: 4px; background: #2d2d2d; border-radius: 2px; overflow: hidden; }
.opp-progress-fill { width: 0%; height: 100%; background: var(--error); transition: width 0.2s linear; }

/* Friends Panel */
.friends-panel {
    position: fixed; top: 0; right: -300px; width: 300px; height: 100vh;
    background: #171717; border-left: 1px solid #2d2d2d;
    padding: 2rem; display: flex; flex-direction: column; gap: 1.5rem;
    transition: right 0.3s ease; z-index: 100;
}
.friends-panel.open { right: 0; }
.fp-header { display: flex; justify-content: space-between; align-items: center; color: var(--accent); }
.close-btn { cursor: pointer; color: var(--fg-dim); }
.close-btn:hover { color: var(--fg); }
.fp-add { display: flex; gap: 0.5rem; }
.fp-add input { flex-grow: 1; padding: 0.5rem; background: #2d2d2d; border: none; color: var(--fg); font-family: inherit; }
.fp-add button { padding: 0.5rem 1rem; background: var(--fg-dim); color: var(--bg); border: none; cursor: pointer; font-family: inherit; font-weight: bold; }
.friend-list { list-style: none; display: flex; flex-direction: column; gap: 0.8rem; }
.friend-item { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--fg); }
