:root {
    --bg: #FFFFFF;
    --surface: #F4F4F4;
    --text: #1A1A1A;
    --accent: #333333;
    --correct: #4CAF50;
    --incorrect: #F44336;
    --partial: #FF9800;
    --radius: 8px;
}

[data-theme='dark'] {
    --bg: #121212;
    --surface: #1E1E1E;
    --text: #E0E0E0;
    --accent: #FFFFFF;
}

body {
    margin: 0;
    font-family: -apple-system, system-ui, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    transition: background 0.3s;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

.page {
    display: none;
    flex-direction: column;
    align-items: center;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

.active { display: flex !important; }

button {
    background-color: var(--accent);
    color: var(--bg);
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    font-weight: 600;
    margin: 0;
}

button:hover { 
    opacity: 0.9; 
}

button:active {
    transform: scale(0.98);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--accent);
    color: var(--text);
}

/* New Menu Grouping Classes */
.menu-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.menu-divider {
    width: 60%;
    height: 2px;
    background: rgba(128, 128, 128, 0.2);
    margin: 20px auto;
    border-radius: 2px;
}

.feedback-btn {
    background: transparent !important;
    border: 1px solid var(--accent) !important;
    color: var(--text) !important;
    font-size: 0.9rem !important;
}

input[type="text"] {
    background: var(--surface);
    border: 2px solid transparent;
    color: var(--text);
    padding: 16px;
    border-radius: var(--radius);
    width: 100%;
    box-sizing: border-box;
    font-size: 1.25rem;
    text-align: center;
    outline: none;
}

input[type="text"]:focus { border-color: var(--accent); }

#image-container {
    flex-grow: 1;
    width: 100%;
    max-width: 1200px;
    background: var(--surface);
    border-radius: var(--radius);
    display: block; 
    overflow: visible;
    margin: 15px 0;
    position: relative;
    padding: 10px; 
    box-sizing: border-box;
}

#score-image {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.1));
    transition: opacity 0.3s;
}

#lobby-players li {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: rgba(255,255,255,0.05);
    margin-bottom: 5px;
    border-radius: 6px;
}

.header-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    font-weight: bold;
}

.diff-badge {
    background: var(--accent);
    color: var(--bg);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-left: 10px;
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg);
    padding: 30px;
    border-radius: var(--radius);
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    max-width: 600px;
    margin-top: 20px;
}

.stat-card {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    text-align: center;
}
        
#error-banner {
    background: var(--incorrect);
    color: white;
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: none;
    text-align: center;
    max-width: 400px;
}

#osmd-container {
    background-color: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    min-height: 300px; 
    width: 100%;
    display: block !important; 
    overflow: visible; 
    margin: 10px auto;
    border: 2px solid #ccc;
    box-sizing: border-box;
}

#osmd-container svg {
    width: 100% !important;
    height: auto !important;
    display: block;
}

#library-container::-webkit-scrollbar {
    width: 8px;
}

#library-container::-webkit-scrollbar-thumb {
    background: var(--correct);
    border-radius: 10px;
}

.composer-group li:hover {
    background: rgba(0,0,0,0.08) !important;
    transform: translateX(5px);
    transition: all 0.2s ease;
}

.library-link:hover {
    color: var(--correct) !important;
    text-decoration: underline !important;
    cursor: pointer;
}

.library-link::after {
    content: " ↗";
    font-size: 0.7rem;
    opacity: 0.5;
}

/* 
.racing-card {
    position: absolute;
    width: 120px;
    height: 100%;
    background: var(--surface);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    transition: left 0.4s ease-in-out;
    border: 2px solid transparent;
}
.racing-card.is-me {
    border-color: var(--accent);
}
.racing-card strong {
    font-size: 1rem;
    margin: 2px 0;
}
*/

/* --- MULTIPLAYER TIME TRIAL TICKER --- */
#racing-dock {
    width: 100%;
    height: 45px;
    background: rgba(0, 0, 0, 0.1); /* Subtle background to distinguish it */
    border-radius: var(--radius);
    margin-bottom: 10px; /* Space between the ticker and the answer box */
    
    /* Flexbox Layout Rules */
    display: none; /* Will be set to flex by JS */
    gap: 15px;
    align-items: center;
    overflow-x: auto;
    white-space: nowrap;
    padding: 0 10px;
    box-sizing: border-box;
    scrollbar-width: none; /* Firefox */
}
#racing-dock::-webkit-scrollbar { 
    display: none; /* Chrome/Safari */
}

.ticker-item {
    display: flex;
    align-items: center;
    background: var(--surface);
    border-radius: 4px;
    padding: 5px 15px;
    height: 35px;
    transition: transform 0.4s cubic-bezier(0.2, 0, 0.2, 1), background-color 0.3s ease, order 0.4s ease;
    flex-shrink: 0;
    font-family: monospace;
    font-size: 0.95rem;
}

.ticker-me {
    border: 2px solid var(--partial);
    background: rgba(255, 152, 0, 0.1);
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.3);
}

.ticker-rank { font-weight: bold; margin-right: 8px; color: var(--text); opacity: 0.7; }
.ticker-name { margin-right: 12px; font-weight: bold; }
.ticker-stats { color: var(--correct); margin-right: 12px; }
.ticker-score { font-weight: bold; }
