* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    overflow: hidden;
    background-color: #000;
    color: #fff;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-overlay {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    padding: 0 20px;
    z-index: 10;
    pointer-events: none;
}

#top-ui-overlay {
    position: absolute;
    top: 20px;
    left: 0;
    width: 100%;
    z-index: 10;
    pointer-events: none;
}

/* Current lap time display at the top middle */
#current-lap-time {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    z-index: 11;
    pointer-events: none;
    font-family: 'Courier New', monospace;
}

/* Checkpoints missed warning */
#checkpoints-missed {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 0, 0, 0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    z-index: 100;
    pointer-events: none;
    display: none;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Flash animation for the checkpoints missed warning */
@keyframes flash {
    0% { background-color: rgba(255, 0, 0, 0.8); }
    50% { background-color: rgba(255, 255, 255, 0.8); color: #ff0000; }
    100% { background-color: rgba(255, 0, 0, 0.8); }
}

/* Checkpoint delta display */
#checkpoint-delta {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    z-index: 100;
    pointer-events: none;
    font-family: 'Courier New', monospace;
    animation: fadeIn 0.3s ease-in-out;
}

/* Styles for different delta states */
.checkpoint-delta.faster {
    background-color: rgba(0, 255, 0, 0.8);
    color: #000;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.checkpoint-delta.slower {
    background-color: rgba(255, 0, 0, 0.8);
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.checkpoint-delta.first-time {
    background-color: rgba(255, 165, 0, 0.8);
    color: #000;
    box-shadow: 0 0 10px rgba(255, 165, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

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

#speed-display, #lap-display, #time-display {
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

#menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    z-index: 100;
    min-width: 300px;
}

#menu h1 {
    margin-bottom: 20px;
    color: #ff6b6b;
    font-size: 32px;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

#start-button, #restart-button {
    background-color: #ff6b6b;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 18px;
    border-radius: 5px;
    cursor: pointer;
    margin: 20px 0;
    transition: all 0.3s ease;
    min-width: 180px;
}

#start-button.loading {
    background-color: #444;
    cursor: not-allowed;
    opacity: 0.8;
}

#start-button:hover, #restart-button:hover {
    background-color: #ff4757;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.7);
}

#start-button.loading:hover {
    background-color: #444;
    transform: none;
    box-shadow: none;
}

#instructions {
    text-align: left;
    margin-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 20px;
}

#instructions h2 {
    margin-bottom: 15px;
    color: #ff6b6b;
    font-size: 22px;
}

#instructions p {
    margin-bottom: 8px;
    font-size: 16px;
    color: #ddd;
}

#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    z-index: 100;
    min-width: 300px;
}

#game-over h1 {
    margin-bottom: 20px;
    color: #ff6b6b;
    font-size: 32px;
}

#final-time {
    font-size: 24px;
    margin-bottom: 20px;
    color: #fff;
}

.hidden {
    display: none;
}

/* Loading indicator */
#loading {
    display: none; /* Hide the separate loading screen */
}

/* Spinner animation */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 3px solid #ff6b6b;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

/* Smaller spinner for inline use */
.spinner-inline {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 10px;
    border-width: 2px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Lap times container */
#lap-times-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

.lap-times-panel {
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 15px;
    border-radius: 5px;
    min-width: 300px;
    max-width: 350px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

/* Position for top lap times (left side) */
#top-lap-times {
    align-self: flex-start;
}

/* Position for recent lap times (right side) */
#recent-lap-times {
    align-self: flex-start;
}

.lap-times-panel h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #ff6b6b;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 5px;
}

.lap-times-panel ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.lap-times-panel li {
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.lap-times-panel li:last-child {
    border-bottom: none;
}

.lap-times-panel .position {
    font-weight: bold;
    color: #ff6b6b;
    width: 30px;
}

.lap-times-panel .lap-number {
    font-weight: bold;
    width: 80px;
}

.lap-times-panel .time {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 16px;
}

.lap-times-panel .date {
    font-size: 12px;
    color: #aaa;
    text-align: right;
}

/* Highlight the best lap time */
.lap-times-panel li:first-child .time {
    color: #ffdd59;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    #lap-times-container {
        padding: 0 10px;
    }
    
    .lap-times-panel {
        min-width: 200px;
        max-width: 45%;
        padding: 10px;
        font-size: 14px;
    }
    
    .lap-times-panel h3 {
        font-size: 14px;
    }
    
    .lap-times-panel .date {
        display: none;
    }
    
    .lap-times-panel .time {
        font-size: 14px;
    }
}

/* Lap time delta display */
#lap-time-delta {
    position: absolute;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    z-index: 100;
    pointer-events: none;
    font-family: 'Courier New', monospace;
    animation: fadeIn 0.3s ease-in-out;
}

/* Styles for different lap time delta states */
.lap-time-delta.faster {
    background-color: rgba(0, 255, 0, 0.8);
    color: #000;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.lap-time-delta.slower {
    background-color: rgba(255, 0, 0, 0.8);
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.lap-time-delta.first-time {
    background-color: rgba(255, 165, 0, 0.8);
    color: #000;
    box-shadow: 0 0 15px rgba(255, 165, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

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

/* Credits links */
#credits {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    z-index: 100;
}

#credits a {
    color: #ff6b6b;
    text-decoration: none;
    font-size: 14px;
    opacity: 0.8;
    transition: all 0.3s ease;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 4px;
}

#credits a:hover {
    opacity: 1;
    transform: translateY(-2px);
    text-shadow: 0 0 5px rgba(255, 107, 107, 0.7);
}

/* FPS counter */
#fps-counter {
    position: absolute;
    bottom: 15px;
    left: 15px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
    z-index: 100;
    font-family: 'Courier New', monospace;
    border: 1px solid rgba(255, 107, 107, 0.3);
    text-shadow: 0 0 5px rgba(255, 107, 107, 0.5);
} 