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

body {
    font-family: 'Bangers', cursive;
    background: #000;
    overflow: hidden;
    color: white;
}

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

canvas { display: block; }

/* Rear-view mirror frame (desktop only, toggled with R key) */
#mirror-frame {
    display: none;
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 18vw;
    height: calc(18vw / 2.5);
    border: 2px solid rgba(180, 180, 180, 0.6);
    border-radius: 4px;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}
@media (pointer: fine) {
    /* mirror-frame visibility is controlled by JS (toggleMirror / R key) */
}
@media (max-width: 768px), (pointer: coarse) {
    #mirror-frame { display: none !important; }
}

#hud {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    pointer-events: none;
}

#speed-display {
    font-family: 'Bangers', cursive;
    font-size: 48px;
    color: #ffdd00;
    text-shadow: 3px 3px 0 #ff6600, 6px 6px 0 #cc0000;
    margin-bottom: 10px;
}

#coin-display {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 28px;
    color: #ffdd00;
}
#top-speed-display {
    font-family: 'Bangers', cursive;
    font-size: 16px;
    color: #fff;
    margin-left: 6px;
}

.coin-icon {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #ffdd00, #ff9900);
    border-radius: 50%;
    border: 3px solid #cc6600;
}

/* Wrong way indicator */
#wrong-way {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Bangers', cursive;
    font-size: 36px;
    font-weight: bold;
    color: #ff3333;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.8), 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 999;
    pointer-events: none;
    animation: wrongWayPulse 0.8s ease-in-out infinite;
}
#wrong-way-tint {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 0, 0, 0.12);
    z-index: 998;
    pointer-events: none;
    animation: wrongWayTintPulse 0.8s ease-in-out infinite;
}
@keyframes wrongWayPulse {
    0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.6; transform: translate(-50%, -50%) scale(1.05); }
}
@keyframes wrongWayTintPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Shortcut detection warning */
#shortcut-warning {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Bangers', cursive;
    font-size: 32px;
    font-weight: bold;
    color: #ff8800;
    text-align: center;
    line-height: 1.4;
    text-shadow: 0 0 20px rgba(255, 136, 0, 0.8), 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 999;
    pointer-events: none;
    animation: shortcutPulse 0.8s ease-in-out infinite;
}
#shortcut-tint {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 136, 0, 0.12);
    z-index: 998;
    pointer-events: none;
    animation: shortcutTintPulse 0.8s ease-in-out infinite;
}
@keyframes shortcutPulse {
    0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.6; transform: translate(-50%, -50%) scale(1.05); }
}
@keyframes shortcutTintPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#minimap {
    position: fixed;
    bottom: 20px;
    right: 45px;
    width: 200px;
    height: 200px;
    z-index: 100;
}

#minimap canvas {
    width: 100%;
    height: 100%;
}

/* Top buttons (settings + fullscreen) */
#top-buttons {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    gap: 10px;
}
#top-buttons button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid #ffdd00;
    background: linear-gradient(180deg, #ff6600, #cc4400);
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    line-height: 1;
}
#top-buttons button:hover {
    transform: scale(1.1);
}

/* Button tooltips */
.top-btn-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.top-btn-tip {
    position: absolute;
    top: 56px;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-family: 'Bangers', cursive;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}
.top-btn-tip .tip-key {
    color: #888;
    margin-left: 4px;
}
.top-btn-wrap:hover .top-btn-tip {
    opacity: 1;
}
.top-btn-wrap.mobile-only {
    display: none;
}
@media (pointer: coarse) {
    .top-btn-wrap.mobile-only { display: flex; }
}

/* Settings menu overlay */
#settings-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 700;
    align-items: center;
    justify-content: center;
}
#settings-overlay.open {
    display: flex;
}
#settings-menu {
    background: linear-gradient(180deg, #1a1a2e, #16213e);
    border: 3px solid #ffdd00;
    border-radius: 16px;
    padding: 30px 36px;
    max-width: 90vw;
    text-align: center;
}
#settings-overlay.menu-fullscreen {
    background: linear-gradient(180deg, #1a1a2e, #16213e);
}
#settings-overlay.menu-fullscreen #settings-menu {
    border: none;
    border-radius: 0;
    padding: 20px;
    max-width: 100vw;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
#settings-menu h2 {
    font-family: 'Bangers', cursive;
    font-size: 36px;
    color: #ffdd00;
    margin-bottom: 24px;
    letter-spacing: 2px;
}
.settings-columns {
    display: flex;
    gap: 36px;
    align-items: flex-start;
}
.settings-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.settings-label {
    font-family: 'Bangers', cursive;
    font-size: 20px;
    color: #ccc;
    min-width: 70px;
    text-align: left;
}
.settings-value {
    font-family: 'Bangers', cursive;
    font-size: 18px;
    color: #fff;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 8px 14px;
    min-width: 150px;
    flex: 1;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
    -webkit-user-select: none;
}
.settings-value:hover, .settings-value.settings-focused {
    background: rgba(255,255,255,0.18);
    border-color: #ffdd00;
}
.settings-value.muted {
    color: #888;
}
.settings-value input {
    background: transparent;
    border: none;
    color: #fff;
    font-family: 'Bangers', cursive;
    font-size: 18px;
    text-align: center;
    width: 100%;
    outline: none;
}
.settings-value input::placeholder {
    color: #666;
}
#settings-car-preview {
    width: 220px;
    height: 120px;
    flex: 1;
}
#settings-car-preview canvas {
    width: 100%;
    height: 100%;
    border-radius: 6px;
}
.settings-close {
    margin-top: 24px;
    background: linear-gradient(180deg, #ff6600, #cc4400);
    border: 3px solid #ffdd00;
    border-radius: 10px;
    padding: 12px 30px;
    font-family: 'Bangers', cursive;
    font-size: 22px;
    color: white;
    cursor: pointer;
    transition: transform 0.1s;
    letter-spacing: 1px;
}
.settings-close:hover, .settings-close.settings-focused {
    transform: scale(1.05);
    border-color: #ffdd00;
    box-shadow: 0 0 12px 2px rgba(255, 221, 0, 0.3);
}

#settings-controls-row {
    display: none;
}

/* PWA-specific: hide fullscreen button */
@media (display-mode: fullscreen), (display-mode: standalone) {
    #fullscreen-btn { display: none !important; }
}

/* System notifications */
#notifications {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}
.notification {
    font-family: 'Bangers', cursive;
    font-size: 24px;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 8px;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}
.notification.fade-out {
    opacity: 0;
}

/* Idle overlay */
#idle-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 400;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
#idle-overlay.visible {
    display: flex;
}
#idle-message {
    font-family: 'Bangers', cursive;
    font-size: 48px;
    color: #ffdd00;
    text-align: center;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.8);
    letter-spacing: 4px;
}
#idle-message span {
    font-family: 'Bangers', cursive;
    font-size: 28px;
    color: #ccc;
    letter-spacing: 0;
    display: block;
    margin-top: 12px;
}

/* Legacy classes kept for audio.js compatibility */
.audio-btn { display: none; }
.audio-btn.muted { display: none; }
/* Lap timing display */
#lap-display {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    font-family: 'Bangers', cursive;
    font-size: 16px;
    color: #fff;
    text-align: right;
    pointer-events: none;
    text-shadow: 1px 1px 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.5);
}
#lap-display .lap-time {
    font-size: 48px;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.6);
}
#lap-display .best-lap {
    margin-top: 6px;
    font-size: 24px;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
}
#lap-display .last-lap {
    font-size: 24px;
    color: #ddd;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
}

/* Mobile: hide minimap and controls hint */
@media (max-width: 768px), (pointer: coarse) {
    #minimap { display: none !important; }
    #top-buttons { top: 10px; }
    #top-buttons button { width: 40px; height: 40px; font-size: 20px; }
    .top-btn-tip { display: none; }
    #speed-display { font-size: 32px; }
    #lap-display { top: 10px; right: 10px; font-size: 13px; }
    #lap-display .lap-time { font-size: 32px; }
    #hud { top: 10px; left: 10px; }
    #settings-menu { padding: 14px 18px; max-height: 90vh; max-width: 95vw; border-width: 2px; border-radius: 10px; }
    #settings-menu h2 { font-size: 22px; margin-bottom: 8px; letter-spacing: 1px; }
    .settings-columns { gap: 16px; }
    .settings-col { min-width: 120px; gap: 5px; }
    .settings-row { gap: 6px; }
    .settings-label { font-size: 14px; min-width: 45px; }
    .settings-value { font-size: 13px; min-width: 90px; padding: 4px 8px; border-radius: 6px; border-width: 1px; }
    .settings-value input { font-size: 13px; }
    #settings-car-preview { width: auto; height: 80px; }
    .settings-close { margin-top: 8px; padding: 6px 20px; font-size: 16px; border-width: 2px; border-radius: 7px; }
    #settings-controls-row { display: flex; }
    #notifications { left: 50%; transform: translateX(-50%); align-items: center; }
}

/* Mobile touch controls */
#mobile-controls { display: none; }
.mobile-btn {
    position: fixed;
    z-index: 200;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.5);
    background: rgba(0,0,0,0.35);
    color: white;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}
.mobile-btn:active, .mobile-btn.pressed {
    background: rgba(255,255,255,0.3);
    border-color: #ffdd00;
}
#mobile-mode-btn {
    display: none;
}

/* Portrait / fullscreen overlay for mobile */
#rotate-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #111;
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: 'Bangers', cursive;
    text-align: center;
    gap: 20px;
    cursor: pointer;
}
#rotate-overlay.visible { display: flex; }
#rotate-msg, #fullscreen-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
#rotate-overlay .rotate-icon {
    font-size: 64px;
}
#rotate-msg .rotate-icon {
    animation: rotateHint 2s ease-in-out infinite;
}
#rotate-overlay .rotate-text {
    font-size: 24px;
    letter-spacing: 2px;
    color: #ffdd00;
}
@keyframes rotateHint {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-20deg); }
    75% { transform: rotate(20deg); }
}

/* ========== MAIN MENU & RACE SCREENS ========== */
#main-menu,
#race-screen,
#new-race-screen,
#waiting-room,
#race-finish-overlay,
#race-exit-confirm {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Menu screens with track backdrop: transparent bg + gradient overlay */
#main-menu,
#race-screen,
#new-race-screen,
#waiting-room {
    background: transparent;
}
#main-menu .menu-backdrop,
#race-screen .menu-backdrop,
#new-race-screen .menu-backdrop,
#waiting-room .menu-backdrop {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.75) 100%);
}
#main-menu .menu-backdrop::after,
#race-screen .menu-backdrop::after,
#new-race-screen .menu-backdrop::after,
#waiting-room .menu-backdrop::after {
    content: none;
}
#main-menu .menu-content,
#race-screen .menu-content,
#new-race-screen .menu-content,
#waiting-room .menu-content {
    position: relative;
    z-index: 1;
}

.menu-content {
    text-align: center;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 16px;
}
.menu-content::-webkit-scrollbar { display: none; }

.menu-logo {
    font-family: 'Bangers', cursive;
    font-size: 80px;
    color: #ffdd00;
    text-shadow: 4px 4px 0 #ff6600, 8px 8px 0 #cc0000;
    letter-spacing: 8px;
    margin-bottom: 32px;
}

.menu-logo-sm {
    font-family: 'Bangers', cursive;
    font-size: 48px;
    color: #ffdd00;
    text-shadow: 2px 2px 0 #ff6600;
    letter-spacing: 3px;
    margin-bottom: 16px;
}

.menu-subtitle {
    font-family: 'Bangers', cursive;
    font-size: 20px;
    color: #aaa;
    margin-bottom: 32px;
    letter-spacing: 2px;
}

.menu-modes {
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.menu-settings-link {
    font-family: 'Bangers', cursive;
    font-size: 24px;
    color: #888;
    cursor: pointer;
    margin-top: 24px;
    letter-spacing: 1px;
    transition: color 0.15s;
}
.menu-settings-link:hover,
.menu-settings-link.menu-focused {
    color: #ffdd00;
}

.menu-mode-box {
    background: linear-gradient(180deg, #1a1a2e, #16213e);
    border: 3px solid rgba(255, 221, 0, 0.3);
    border-radius: 16px;
    padding: 28px 32px;
    min-width: 220px;
    max-width: 280px;
    flex: 1;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    text-align: center;
}

.menu-mode-box:hover,
.menu-mode-box.menu-focused {
    transform: translateY(-4px);
    border-color: #ffdd00;
    box-shadow: 0 8px 32px rgba(255, 221, 0, 0.15);
}

.mode-icon {
    margin-bottom: 12px;
}

.mode-title {
    font-family: 'Bangers', cursive;
    font-size: 28px;
    color: #ffdd00;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.mode-desc {
    font-family: 'Bangers', cursive;
    font-size: 15px;
    letter-spacing: 1px;
    color: #999;
    line-height: 1.4;
}

/* Menu buttons */
.menu-btn-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.menu-btn {
    background: linear-gradient(180deg, #ff6600, #cc4400);
    border: 3px solid #fff;
    border-radius: 10px;
    padding: 12px 28px;
    font-family: 'Bangers', cursive;
    font-size: 20px;
    color: white;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
    letter-spacing: 1px;
}

.menu-btn:hover,
.menu-btn.menu-focused {
    transform: scale(1.05);
    border-color: #ffdd00;
    box-shadow: 0 0 14px rgba(255, 221, 0, 0.4);
}

.menu-btn-secondary {
    background: linear-gradient(180deg, #444, #333);
    border-color: #666;
}

.menu-btn-secondary:hover,
.menu-btn-secondary.menu-focused {
    border-color: #ffdd00;
    box-shadow: 0 0 14px rgba(255, 221, 0, 0.4);
}

/* Track selector with inline preview */
.menu-option-track {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
}
.menu-option-track canvas {
    width: 120px;
    height: 120px;
    border-radius: 6px;
}

/* Menu options (new race screen) */
.menu-option-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 12px;
}

.menu-option-label {
    font-family: 'Bangers', cursive;
    font-size: 28px;
    color: #ccc;
    width: 70px;
    text-align: right;
}

.menu-option-value {
    font-family: 'Bangers', cursive;
    font-size: 20px;
    color: #fff;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px 20px;
    min-width: 180px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
}

.menu-option-value:hover,
.menu-option-value.menu-focused {
    background: rgba(255,255,255,0.18);
    border-color: #ffdd00;
}

/* Race list */
.race-list-items {
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.race-list-items::-webkit-scrollbar { display: none; }

.race-list-empty {
    font-family: 'Bangers', cursive;
    font-size: 20px;
    color: #888;
    padding: 24px;
    letter-spacing: 1px;
    line-height: 1.4;
    text-align: center;
    white-space: pre-line;
}

.race-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 8px;
    transition: border-color 0.15s, background 0.15s;
}

.race-list-item.joinable {
    cursor: pointer;
}

.race-list-item.joinable:hover,
.race-list-item.joinable.menu-focused {
    border-color: #ffdd00;
    background: rgba(0, 0, 0, 0.65);
}

.race-list-track {
    font-family: 'Bangers', cursive;
    font-size: 20px;
    color: #fff;
}

.race-list-info {
    font-family: 'Bangers', cursive;
    font-size: 13px;
    color: #aaa;
}

.race-list-state {
    font-family: 'Bangers', cursive;
    font-size: 16px;
    padding: 4px 10px;
    border-radius: 6px;
}

.race-state-waiting {
    color: #0f0;
    background: rgba(0, 255, 0, 0.1);
    border: 1px solid rgba(0, 255, 0, 0.3);
}

.race-state-racing {
    color: #ff6600;
    background: rgba(255, 102, 0, 0.1);
    border: 1px solid rgba(255, 102, 0, 0.3);
}

#waiting-room .menu-subtitle {
    font-size: 26px;
    margin-bottom: 20px;
}
#waiting-room .menu-btn-row {
    margin-top: 12px;
}
#waiting-room .menu-settings-link {
    margin-top: 10px;
}

/* Waiting room */
.wr-layout {
    display: flex;
    align-items: flex-start;
    gap: 40px;
    margin-bottom: 24px;
    justify-content: center;
}

.wr-track-side {
    flex-shrink: 0;
}
.wr-track-side canvas {
    width: 160px;
    height: 160px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    border: 2px solid rgba(255,255,255,0.08);
}

.wr-info-side {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 200px;
    text-align: left;
}

.wr-track-info {
    font-family: 'Bangers', cursive;
    font-size: 26px;
    color: #fff;
}

.wr-players {
    max-height: 240px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.wr-players::-webkit-scrollbar { display: none; }

.wr-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    margin-bottom: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
}

.wr-player-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.3);
}

.wr-player-name {
    font-family: 'Bangers', cursive;
    font-size: 20px;
    color: #fff;
}

.wr-player-creator {
    font-family: 'Bangers', cursive;
    font-size: 18px;
    color: #ffdd00;
    background: rgba(255, 221, 0, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 1px;
}

/* Race countdown overlay */
#race-countdown {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bangers', cursive;
    font-size: 120px;
    color: #ffdd00;
    text-shadow: 4px 4px 0 rgba(0,0,0,0.5);
    pointer-events: none;
}

/* Player Panel (F1-style tower, left side below HUD) */
#player-panel {
    position: fixed;
    top: 120px;
    left: 20px;
    z-index: 100;
    pointer-events: none;
    min-width: 220px;
    max-width: 300px;
    background: rgba(0, 0, 0, 0.40);
    border-radius: 8px;
    padding: 12px 10px 10px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#panel-track-name {
    font-family: 'Bangers', cursive;
    font-size: 22px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
    padding-left: 4px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

#panel-lap-info {
    font-family: 'Bangers', cursive;
    font-size: 18px;
    color: #ccc;
    margin-bottom: 8px;
    padding-left: 4px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
}

.panel-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    font-family: 'Bangers', cursive;
    font-size: 20px;
    color: #ddd;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    border-radius: 4px;
    margin-bottom: 2px;
}

.panel-row-local {
    color: #ffdd00;
    background: rgba(255, 221, 0, 0.08);
}

.panel-row-idle {
    opacity: 0.45;
}

.panel-pos {
    font-size: 21px;
    min-width: 20px;
    text-align: right;
}

.panel-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 3px rgba(0,0,0,0.5);
}

.panel-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-time {
    font-size: 17px;
    color: inherit;
    min-width: 60px;
    text-align: right;
}

/* Race finish dialog */
.race-finish-pos {
    font-family: 'Bangers', cursive;
    font-size: 28px;
    color: #fff;
    margin-bottom: 16px;
}

.race-finish-rankings {
    margin-bottom: 16px;
}

.finish-table {
    margin: 0 auto;
    border-collapse: collapse;
    font-family: 'Bangers', cursive;
    font-size: 15px;
}

.finish-table th {
    color: #aaa;
    padding: 4px 16px;
    border-bottom: 1px solid #555;
    text-align: left;
}

.finish-table td {
    color: #fff;
    padding: 6px 16px;
}

.finish-row-me td {
    color: #ffdd00;
    font-weight: bold;
}

/* Exit confirmation */
.exit-confirm-text {
    font-family: 'Bangers', cursive;
    font-size: 28px;
    color: #ccc;
    margin-bottom: 24px;
}

/* Home button — visible when #top-buttons is shown (during gameplay) */

/* Mobile adjustments for menus */
@media (max-width: 768px), (pointer: coarse) {
    .menu-logo { font-size: 48px; letter-spacing: 4px; }
    .menu-logo-sm { font-size: 28px; }
    .menu-subtitle { font-size: 14px; margin-bottom: 20px; }
    .menu-modes { gap: 12px; }
    .menu-mode-box { padding: 16px 18px; min-width: 150px; }
    .mode-title { font-size: 20px; }
    .mode-desc { font-size: 11px; }
    .mode-icon { width: 40px; height: 40px; }
    .menu-btn { padding: 8px 18px; font-size: 16px; }
    .menu-option-label { font-size: 22px; width: 55px; }
    .menu-option-value { font-size: 16px; padding: 6px 12px; min-width: 140px; }
    .menu-option-track canvas { width: 90px; height: 90px; }
    .wr-layout { gap: 20px; }
    .wr-track-side canvas { width: 110px; height: 110px; }
    #waiting-room .menu-subtitle { font-size: 20px; }
    .race-list-track { font-size: 16px; }
    .race-list-info { font-size: 11px; }
    #race-countdown { font-size: 80px; }
    #player-panel { min-width: 180px; max-width: 250px; top: 100px; left: 10px; padding: 8px 8px 6px; }
    #panel-track-name { font-size: 17px; }
    .panel-row { font-size: 14px; gap: 6px; padding: 3px 4px; }
    .panel-pos { font-size: 15px; min-width: 18px; }
    .panel-time { font-size: 13px; }
}
