:root {
    --bg: #323437;
    --text-main: #d1d0c5;
    --text-subtle: #9ca0a6; /* Lightened from #646669 for better contrast */
    --primary: #e2b714;
    --error: #ca4754;
    --correct: #d1d0c5;
    --caret: #e2b714;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto Mono', monospace;
    background-color: var(--bg);
    color: var(--text-main);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 1000px;
    padding: 40px 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 60px;
}

.title-section h1 {
    font-size: 2rem;
    color: var(--text-main);
    margin: 0;
    font-weight: 400;
}

.title-section p {
    color: var(--text-subtle);
    margin: 0 0 0 2px;
    font-size: 0.9rem;
}

.online-count {
    font-size: 0.9rem;
    color: var(--text-subtle);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #28a745;
    border-radius: 50%;
    display: inline-block;
}

/* Screens */
.screen {
    width: 100%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    animation: fadeUp 0.3s ease-out;
}

.hidden {
    display: none !important;
}

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

/* Login */
.login-card {
    text-align: center;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 0 20px; /* Add padding to container so contents don't touch edges on small screens */
}

input[type="text"] {
    display: block; /* Ensure block behavior */
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--text-subtle);
    color: var(--text-main);
    padding: 15px 0; /* Remove horizontal padding to ensure text area is perfectly centered */
    font-size: 1.5rem;
    width: 100%;
    font-family: inherit;
    text-align: center;
    margin: 0 auto 30px auto; /* Center the element itself and add bottom spacing */
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]::placeholder {
    text-align: center;
    color: var(--text-subtle);
    opacity: 0.5;
}

input[type="text"]:not(#hidden-input):focus {
    border-color: var(--primary);
}

button {
    background: transparent;
    color: var(--text-subtle);
    font-weight: bold;
    border: 2px solid var(--text-subtle);
    padding: 10px 30px;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

button:hover {
    color: var(--text-main);
    border-color: var(--text-main);
}

/* Lobby */
#lobby-screen {
    text-align: center;
}

#countdown-display {
    font-size: 6rem;
    color: var(--primary);
    margin: 40px 0;
    font-weight: bold;
}

.lobby-player-pill {
    display: inline-block;
    color: var(--text-subtle);
    margin: 5px 10px;
    font-size: 1rem;
}

/* Game Area */
.game-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 30px;
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: var(--primary);
}

#text-display {
    font-size: 1.8rem;
    line-height: 1.6;
    color: var(--text-subtle);
    user-select: none;
    text-align: left;
    word-wrap: break-word;
    margin-bottom: 60px;
    position: relative;
    outline: none;
}

#text-display span.correct {
    color: var(--text-main);
}

#text-display span.wrong {
    color: var(--error);
}

#text-display span.space-error {
    background-color: var(--error);
}

#text-display span.cursor {
    border-left: 2px solid var(--caret);
    margin-left: -1px;
    animation: blink 1s infinite;
}

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

/* Competitors */
.competitors-section {
    margin-top: auto;
    width: 100%;
    /* No header, no border */
}

.competitor-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px; /* Increased spacing */
    gap: 15px;
    width: 100%;
}

/* Highlight self */
.my-row .c-name {
    color: var(--primary);
    font-weight: bold;
}

.c-info {
    display: flex;
    flex-direction: column;
    width: 180px; /* Wider for accuracy stats */
    text-align: right;
    flex-shrink: 0;
}

.c-name {
    font-size: 0.9rem;
    color: var(--text-main);
}

.c-stats {
    font-size: 0.75rem;
    color: var(--text-subtle);
}

.c-bar-track {
    flex-grow: 1;
    height: 6px; /* Slightly thicker */
    background: #444;
    border-radius: 3px;
    overflow: hidden;
}

.c-bar-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.5s linear;
}

.c-bar-fill.finished {
    background: var(--text-main);
}

/* Non-blocking Notification */
.finish-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg);
    border: 1px solid var(--primary);
    padding: 15px 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    z-index: 200;
    animation: fadeDown 0.5s ease;
}

@keyframes fadeDown {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

#final-stats {
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: bold;
}
