body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden; /* Prevent horizontal scrollbar */
    overflow-y: auto; /* Allow vertical scrolling */
    font-family: 'Montserrat', sans-serif; /* CHANGED FONT to Montserrat */
    font-weight: 400; /* Adjusted font weight for Montserrat */
    letter-spacing: 0.1em; /* ADDED: Adjusts letter spacing globally */
    color: white; /* Default text color, consistent with request */
    background-color: #EE2731; /* Your chosen background hex color */
    background-image: radial-gradient(ellipse farthest-corner, #ee27318e 60%, #ee2731 80%), url('assets/background.png');
    background-size: cover; /* Ensures the image covers the entire viewport */
    background-position: left; /* Centers the image */
    background-repeat: no-repeat; /* Prevents the image from repeating */
}

#countdown-container {
    position: relative;
    width: 100%;
    min-height: 100vh; /* Changed from height: 100% to min-height */
    display: flex; /* Use flexbox for overall layout */
    flex-direction: column; /* Stack items vertically */
    justify-content: flex-start; /* Changed from space-between to flex-start */
    align-items: center; /* Center horizontally */
    padding-top: 20px; /* Add padding to top of container */
    padding-bottom: 12vh; /* Make room for footer */
}

/* Main content area layout */
#main-content-area {
    display: flex;
    width: 95%;
    margin: 20px auto;
    flex: 1;
    gap: 20px;
    align-items: flex-start;
    min-height: 0; /* Allow shrinking */
}

/* Left section: Countdown (2/3) */
#countdown-section {
    flex: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

/* Right section: Daily schedule (1/3) */
#daily-schedule-section {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
}

#daily-schedule-title {
    margin: 0 0 15px 0;
    font-size: 1.2em;
    font-weight: 600;
    color: white;
    text-align: center;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
}

#daily-events-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Individual event items in the schedule list */
.schedule-event-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.9em;
    gap: 8px;
}

.schedule-event-item.past {
    opacity: 0.4;
    background: rgba(255, 255, 255, 0.05);
}

.schedule-event-item.current {
    background: rgba(255, 255, 255, 0.25);
    border-left: 3px solid #4ECDC4;
    font-weight: 600;
}

.schedule-event-item.current::before {
    content: "▶";
    color: #4ECDC4;
    margin-right: 5px;
}

.schedule-event-item.future {
    opacity: 0.9;
}

.schedule-event-time {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    white-space: nowrap;
    min-width: 50px;
}

.schedule-event-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* NEW: Styles for the Day Timeline */
#day-timeline-container {
    width: 95%; /* Full width to match layout */
    margin: 20px auto 10px auto; /* Reduced margins */
    position: relative;
    padding-top: 80px; /* Space for event text above markers */
    padding-bottom: 35px; /* Space for time labels */
    z-index: 2; /* Ensure it's above background elements */
    height: 15vh; /* Fixed 15% of viewport height */
    min-height: 120px; /* Minimum height for usability */
    transition: min-height 0.3s ease; /* Smooth transition for height changes */
}

#day-bar {
    width: 100%;
    height: 12px; /* Thicker bar */
    background-color: rgba(255, 255, 255, 0.4); /* Semi-transparent white bar */
    border-radius: 6px;
    position: relative; /* Changed from absolute to relative */
    margin-top: 10px; /* Space from events above */
}

.event-timeline-marker {
    position: absolute;
    bottom: 45px; /* Position above the bar */
    min-width: 4px; /* Minimal width for very short events */
    height: 20px; /* Thin colored bar */
    background-color: rgba(255,255,255,0.85);
    border-radius: 4px;
    z-index: 5;
    display: flex;
    align-items: center;
    padding: 0;
    overflow: visible; /* Allow text to display above */
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Monospace for time-critical UI (prevents width jitter) */
#countdownText,
#currentTimeDisplay,
#time-labels,
#pitWindowStatus,
.event-time {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-variant-numeric: tabular-nums; /* if supported */
    letter-spacing: 0; /* override global spacing for alignment */
}

.event-timeline-marker .label {
    position: absolute;
    bottom: 100%; /* Position above the marker */
    left: 0; /* Align with left edge of marker */
    transform: none; /* Remove centering transform */
    font-size: 1.4em;
    white-space: nowrap;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    padding: 2px 4px;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
}

.event-timeline-marker.active-marker {
    outline: 2px solid #ffeb3b; /* Highlight active event */
    z-index: 6;
}

.event-timeline-marker.clipped-start::before,
.event-timeline-marker.clipped-end::after {
    content: '';
    display: block;
    width: 0; height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.event-timeline-marker.clipped-start::before {
    border-right: 6px solid rgba(0,0,0,0.5);
    margin-right: 4px;
}

.event-timeline-marker.clipped-end::after {
    border-left: 6px solid rgba(0,0,0,0.5);
    margin-left: 4px;
}

/* Keep timeline labels in sync with header sizes */
@media (max-width: 1600px) {
    .event-timeline-marker .label { font-size: 1.3em; }
}
@media (max-width: 1200px) {
    .event-timeline-marker .label { font-size: 1.1em; }
}
@media (max-width: 768px) {
    .event-timeline-marker .label { font-size: 0.9em; }
}
@media (max-width: 480px) {
    .event-timeline-marker .label { font-size: 0.7em; }
}

#current-time-marker {
    position: absolute;
    bottom: 0; /* Align with the timeline bar */
    width: 3px; /* Slightly thicker for visibility */
    height: 80px; /* Adjusted for new layout */
    background-color: #33FF33; /* Green for current time */
    z-index: 10; /* Ensure it's on top of event markers */
    transform: translateX(-50%); /* Centers the marker on its 'left' position */
    box-shadow: 0 0 4px rgba(51, 255, 51, 0.5); /* Glow effect */
}

#time-labels {
    width: 100%;
    /* margin-top: 10px; REMOVE THIS LINE */
    font-size: 1.8em; /* Enlarged to match Today's Schedule font size */
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    position: absolute; /* Position relative to #day-timeline-container */
    bottom: -20px; /* Adjusted for larger font */
    left: 0;
    height: auto; /* Allow height to adjust */
}

#time-labels span {
    position: absolute;
    top: 0; /* Relative to #time-labels */
    transform: translateX(-50%); /* Centers the text label on its 'left' position */
    white-space: nowrap; /* Prevent text from wrapping */
}

#time-labels span:nth-child(1) { left: 0%; } /* 08:00 */
#time-labels span:nth-child(2) { left: 25%; } /* 11:00 */
#time-labels span:nth-child(3) { left: 50%; } /* 14:00 */
#time-labels span:nth-child(4) { left: 75%; } /* 17:00 */
#time-labels span:nth-child(5) { left: 100%; } /* 20:00 */

.event-item {
    text-align: center;
    padding: 5px 18px;
    margin-right: 35px;
    margin-bottom: 7px;
    margin-top: 7px;
    
    font-size: 1.6em;
    flex-shrink: 0;
    color: #ffffff;
    font-weight: 300;
    transition: all 0.2s ease-in-out;
    
    position: relative;

    
}

.event-item:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -17px;
    top: 20%;
    bottom: 20%;
    width: 1px;
    background-color: rgba(255, 255, 255, 0.4);
}

.event-item:last-child {
    margin-right: 0;
}

.event-item.active {
    font-weight: 600;
    background-color: #FFFFFF;
    color: #000000;
    border-radius: 8px;
}

.event-item.upcoming {
    font-weight: 400;
    background-color: #e0e0e0c4;
    color: #000000;
    border-radius: 8px;
}

.event-item.past {
    opacity: 0.5;
    font-weight: 300;
}

.daily-events-title {
    font-size: 1.8em;
    font-weight: 600;
    color: #FFF;
    text-align: center;
    width: 100%;
    margin: 8px 0;
}

#countdown-text-overlay {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 20px 40px;
    border-radius: 18px;
    margin-top: 3vh;
    transform: translateY(-50px);
    transition: all 0.3s ease-out;
}

#countdownText {
    /* Adjusted for better fit with days display */
    font-size: clamp(3em, 10vw, 10em); /* Reduced to prevent line breaks */
    margin: 0;
    text-shadow: 3px 3px 7px black;
    font-weight: 700;
    letter-spacing: -1px; /* Less negative spacing for readability */
    color: white;
    white-space: nowrap; /* Prevent line breaks */
}

#currentSessionInfo {
    font-size: 2.5em; /* Reduced from 4.0em for better balance */
    margin-bottom: 15px;
    text-shadow: 2px 2px 5px black;
    font-weight: 500;
    line-height: 1.2;
    color: white;
}

#currentSessionInfo span {
    font-size: 1.4em; /* Increased for event name */
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
}

/* Status text (Starts In, Ends In, etc.) */
#currentSessionInfo .status-text {
    font-size: 1em; /* Normal size for status text */
    font-weight: 400;
    opacity: 0.9;
}

/* Footer container */
#footer-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 10vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1vh 3vw; /* Increased horizontal padding */
    background: rgba(0, 0, 0, 0.3);
    z-index: 10;
    box-sizing: border-box;
}

#footer-left {
    height: 100%;
    display: flex;
    align-items: center;
}

#footer-right {
    display: flex;
    align-items: center;
    gap: 40px; /* Increased gap between controls and time */
}

#footer-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Control buttons styling */
#footer-controls button {
    background-color: rgb(0, 0, 0);
    color: white;
    border: 2px solid white;
    padding: 8px 16px;
    font-size: 1.1em;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.7;
    transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.3s ease;
    font-family: 'Montserrat', sans-serif;
    outline: none;
}

#footer-controls button:hover {
    background-color: rgba(0, 0, 0, 0.247);
    border-color: #FFF;
    opacity: 1.0;
}

#footer-controls button:active {
    background-color: rgba(255, 255, 255, 0);
}

#currentDelayDisplay {
    margin: 0 10px;
    font-size: 1.2em;
    font-weight: 500;
    color: white;
    text-shadow: 1px 1px 3px black;
    min-width: 100px;
    text-align: center;
    transition: opacity 0.3s ease;
}

#currentTimeDisplay {
    font-size: 1.5em;
    font-weight: 600;
    color: white;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
    font-family: 'Courier New', monospace;
    display: flex;
    align-items: center;
    height: 100%;
}

/* NEW: Class for half transparency */
.half-transparent {
    opacity: 0.5;
}

/* Logo Styling */
#race-logo {
    height: 80%;
    width: auto;
    object-fit: contain;
    opacity: 0.9;
    transition: all 0.3s ease-out;
    display: block;
}

#menu-icon {
    position: absolute;
    top: 25px;
    right: 25px;
    z-index: 100;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 30px; /* Keep icon width, but ensure internal elements adapt */
    height: 25px; /* Keep icon height */
    padding: 0; /* Remove fixed padding here; let dots handle spacing */
    box-sizing: content-box;
}

#menu-icon .dot {
    width: 5px; /* Ensure width and height are equal */
    height: 5px; /* Ensure width and height are equal */
    background-color: white;
    border-radius: 50%; /* Guarantees a circle */
    margin: 2px auto; /* Center dots horizontally within the 30px #menu-icon width */
    flex-shrink: 0; /* Prevent dots from shrinking below their defined size */
}

/* Full Schedule Overlay */
#events-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9); /* Darker overlay background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#events-overlay.visible {
    visibility: visible;
    opacity: 1;
}

#events-overlay-content {
    background-color: #2a2a2a;
    padding: 20px;
    border-radius: 10px;
    position: relative;
    max-height: 90%;
    overflow-y: auto;
    color: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    /* Adjust these values to make the overlay wider */
    width: 90%;   /* Try a larger percentage, e.g., 90% */
    max-width: 600px; /* Increase the maximum allowed width, e.g., 800px */
}

/* Center the overlay title */
#events-overlay-content h2 {
    text-align: center; /* Center the "Full Schedule" or "Event Timetable" header */
    margin-top: 0; /* Remove default top margin if needed */
    margin-bottom: 20px; /* Add some space below the header */
}

#close-overlay-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2em;
    color: #fff;
    cursor: pointer;
    background: none;
    border: none;
    padding: 5px;
}

#all-events-list div {
    display: flex; /* Enable flexbox for horizontal alignment */
    justify-content: space-between; /* Pushes content to the ends */
    align-items: center; /* Vertically center items */
    padding: 8px 15px;
    border-bottom: 1px solid rgba(255, 208, 0, 0.1);
    font-size: 1.1em;
    /* Remove word-spacing as flexbox will handle spacing now */
}

#all-events-list div .event-time {
    text-align: left;
    padding-right: 20px; /* Add 20 pixels of space to the right of the time */
}

#all-events-list div .event-name-text {
    flex-grow: 1; /* Allows name span to take up available space */
    text-align: right; /* Right-justifies the event name */
    padding-left: 20px; /* Add some space between time and name if needed */
}

/* Style for date headers in the full schedule overlay */
.date-header {
    background-color: #555555; /* Darker background for headers */
    color: #ffffff; /* White text */
    font-size: 1.5em; /* Larger font size */
    font-weight: 600; /* Bold text */
    text-align: center;
    padding: 10px 15px; /* Add padding */
    margin: 15px 0 10px 0; /* Spacing above and below */
    border-radius: 5px; /* Slightly rounded corners */
}

/* Style for individual event items in the full schedule overlay */
#all-events-list div {
    padding: 8px 15px; /* Add more padding for better spacing */
    border-bottom: 1px solid rgba(255, 208, 0, 0.1);
    font-size: 1.1em;
}

#all-events-list div:last-child {
    border-bottom: none;
}
/* Ensure `daily-events-header` is visible and functional */
#daily-events-header {
    /* Existing styles remain */
    position: relative;
    z-index: 2;
    width: 95%;
    margin-top: 25px;
    margin-bottom: 0px;
    padding: 4px 0;
    display: flex;
    justify-content: center; /* This centers the flex items */
    align-items: center;
    flex-wrap: wrap;
    max-height: 24vh;
    overflow: hidden;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
    transition: all 0.3s ease-out;
}

/* Adjustments for event-item within daily-events-header */
.event-item {
    text-align: center;
    padding: 5px 18px; /* Maintain padding for spacing */
    margin-right: 35px;
    margin-bottom: 7px;
    margin-top: 7px;
    font-size: 1.6em;
    flex-shrink: 0;
    color: #ffffff;
    font-weight: 300;
    transition: all 0.2s ease-in-out;
    position: relative;
    /* Ensure the content itself isn't cramped if the header is wider */
}

/* Optional: Add some responsiveness for different screen sizes */
@media (max-width: 1600px) {
    #day-timeline-container { margin: 15px auto; }
    #time-labels { font-size: 1.4em; }
    /* .event-timeline-marker height and current-time-marker height will be handled by JS and base CSS */
    #countdownText { font-size: clamp(2.5em, 9vw, 9em); }
    #currentSessionInfo { font-size: 2.2em; }
    #currentSessionInfo span { font-size: 1.3em; }
    .event-item { 
        font-size: 1.3em;
        padding: 4px 10px;
        margin-right: 30px;
        margin-bottom: 4px; 
        margin-top: 4px; 
    }
    .event-item:not(:last-child)::after { right: -15px; }
    #daily-events-header { margin-top: 20px; padding: 10px 0; }
    #countdown-text-overlay { padding: 28px 55px; transform: translateY(-35px); }
    .daily-events-title { font-size: 1.7em; }
    #delay-controls button { font-size: 1.1em; padding: 5px 12px; }
    #raceModeLeftWrapper button { font-size: 1.1em; padding: 5px 12px; }
    #currentDelayDisplay { font-size: 1.5em; margin: 0 14px; }

    #menu-icon { top: 20px; right: 20px; width: 25px; height: 20px; }
    #menu-icon .dot { width: 4px; height: 4px; margin: 1.5px 0; }
}
@media (max-width: 1200px) {
    #day-timeline-container { margin: 10px auto; }
    #time-labels { font-size: 1.2em; }
    /* .event-timeline-marker height and current-time-marker height will be handled by JS and base CSS */
    #countdownText { font-size: clamp(2.2em, 8vw, 8em); }
    #currentSessionInfo { font-size: 2em; }
    #currentSessionInfo span { font-size: 1.2em; }
    .event-item { 
        font-size: 1.1em;
        padding: 3px 8px;
        margin-right: 18px;
        margin-bottom: 3px; 
        margin-top: 3px; 
    }
    .event-item:not(:last-child)::after { right: -9px; }
    #daily-events-header { margin-top: 15px; padding: 8px 0; }
    #countdown-text-overlay { padding: 20px 40px; transform: translateY(-25px); }
    .daily-events-title { font-size: 1.5em; }
    #delay-controls button { font-size: 0.9em; padding: 4px 10px; }
    #raceModeLeftWrapper button { font-size: 0.9em; padding: 4px 10px; }
    #currentDelayDisplay { font-size: 1.3em; margin: 0 8px; }

    #menu-icon { top: 15px; right: 15px; width: 22px; height: 18px; }
    #menu-icon .dot { width: 3.5px; height: 3.5px; margin: 1.5px 0; }
}

/* Category label styles */
.category-label {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.75em;
    margin-right: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    body, html {
        overflow-y: auto; /* Ensure scrolling is enabled on mobile */
    }
    
    #countdown-container {
        min-height: auto; /* Allow natural height */
        padding-bottom: 20px; /* Remove space for footer since it's hidden */
    }
    
    /* Mobile layout: vertical stack */
    #main-content-area {
        flex-direction: column;
        gap: 15px;
        margin-bottom: 20px; /* Add margin to ensure visibility */
    }
    
    #countdown-section {
        width: 100%;
    }
    
    #daily-schedule-section {
        width: calc(100% - 30px); /* Account for margins */
        max-height: 300px;
        padding: 15px;
        margin: 0 15px; /* Add equal left and right margins */
        box-sizing: border-box; /* Include padding in width calculation */
    }
    
    #daily-schedule-title {
        font-size: 1.1em;
    }
    
    .schedule-event-item {
        font-size: 0.85em;
        padding: 6px 10px;
    }
    
    .schedule-event-time {
        min-width: 45px;
    }
    
    /* Hide footer on mobile */
    #footer-container {
        display: none;
    }
    
    /* Hide race mode and delay controls on mobile */
    #raceModeLeftWrapper {
        display: none;
    }
    
    #delay-controls {
        display: none;
    }
    
    #currentDelayDisplay {
        display: none;
    }
    
    /* Hide race mode modal on mobile */
    #raceModeModal {
        display: none !important;
    }
    
    #day-timeline-container { margin: 5px auto; }
    #time-labels { font-size: 1em; }
    /* .event-timeline-marker height and current-time-marker height will be handled by JS and base CSS */
    #countdownText { font-size: clamp(2em, 7vw, 6em); }
    #currentSessionInfo { font-size: 1.6em; }
    #currentSessionInfo span { font-size: 1.1em; }
    #currentSessionInfo .status-text { font-size: 0.9em; }
    .event-item { 
        font-size: 0.9em;
        padding: 2px 6px;
        margin-right: 12px;
        margin-bottom: 2px; 
        margin-top: 2px; 
    }
    .event-item:not(:last-child)::after { right: -6px; }
    #countdown-text-overlay { padding: 15px 20px; transform: translateY(-10px); }
    .daily-events-title { font-size: 1.2em; }
    #menu-icon { top: 10px; right: 10px; width: 18px; height: 15px; }
    #menu-icon .dot { width: 3mm; height: 3px; margin: 1px 0; }
}
@media (max-width: 480px) {
    #main-content-area {
        gap: 10px;
    }
    
    #daily-schedule-section {
        max-height: 250px;
        padding: 12px;
        margin: 0 10px; /* Add margins for 480px screens too */
    }
    
    #daily-schedule-title {
        font-size: 1em;
        margin-bottom: 10px;
    }
    
    .schedule-event-item {
        font-size: 0.8em;
        padding: 5px 8px;
        gap: 5px;
    }
    
    .schedule-event-time {
        min-width: 40px;
        font-size: 0.9em;
    }
        max-height: 25vh; /* Adjust height if needed */
    }
    .event-item {
        font-size: 0.7em; /* Even smaller font for events */
        padding: 1px 4px;
        margin-right: 8px; /* Reduce margin to pack more items */
        margin-bottom: 2px;
        margin-top: 2px;
    }
    .event-item:not(:last-child)::after { right: -4px; /* Adjust separator position */ }
    #countdown-text-overlay {
        padding: 8px 15px; /* Reduce padding significantly */
        margin-top: 0vh; /* Adjust top margin for smaller screens */
        transform: translateY(0); /* Potentially remove or reduce transform on small screens */
    }
    /* #countdownText { font-size: 4em; } <-- REMOVED */
    #currentSessionInfo { font-size: 1.2em; /* Smaller info text */ }
    #currentSessionInfo span { font-size: 1.5em; /* Smaller info span text */ }
    #delay-controls button {
        font-size: 0.6em; /* Smaller buttons */
        padding: 2px 6px;
    }
    #delay-controls { margin-bottom: 0px;
                      position: sticky; }
    #raceModeLeftWrapper { left: 5px; bottom: 15px; }
    #raceModeLeftWrapper button { font-size: 0.7em; padding: 2px 6px; }
    #currentDelayDisplay {
        font-size: 0.9em; /* Smaller delay display */
        margin: 0 4px;
    }
    /* Footer adjustments for very small screens */
    #footer-container {
        padding: 0.5vh 1.5vw; /* Small but present horizontal padding */
    }
    
    #footer-right {
        gap: 15px; /* Minimum gap for small screens */
    }
    
    #footer-controls {
        gap: 5px;
    }
    
    #footer-controls button {
        padding: 5px 8px;
        font-size: 0.8em;
    }
    
    #currentDelayDisplay {
        font-size: 0.9em;
        min-width: 70px;
        margin: 0 3px;
    }
    
    #currentTimeDisplay {
        font-size: 1em;
    }
    /* Timeline adjustments for very small screens */
    #day-timeline-container {
        height: 35px; /* Make timeline container smaller */
        margin: 0px auto;
    }
    #day-bar {
        top: 0px; /* Adjust bar position */
        height: 4px;
    }
    .event-timeline-marker {
        top: -8px; /* Adjust marker position */
        height: 12px;
    }
    .event-timeline-marker.active-marker {
        height: 16px;
        top: -8px;
    }
    #current-time-marker {
        top: -9px; /* Adjust time marker position */
        height: 16px;
    }
    #time-labels {
        /* Adjusted for 480px screen */
        top: 8px; /* Move labels closer to the bar */
        font-size: 0.8em; /* Slightly smaller font for better fit */
        margin-top: 0px; /* Remove the original margin-top */
        padding: 0 5px; /* Add horizontal padding to prevent edge overlap */
        box-sizing: border-box; /* Include padding in the width calculation */
    }
    
}

/* --- Race Mode Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background-color: #333;
    color: white;
    padding: 20px 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    width: 90%;
    max-width: 400px;
}

.modal-content h2 {
    margin-top: 0;
}

.modal-error {
    color: #ffb3b3; /* Light red for error text */
    min-height: 1.2em; /* Reserve space to prevent layout shift */
    margin-bottom: 10px;
    font-weight: bold;
}

.modal-inputs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.modal-inputs input {
    width: 80px;
    padding: 10px;
    font-size: 1.2em;
    text-align: center;
    border-radius: 5px;
    border: 1px solid #555;
    background-color: #444;
    color: white;
}

/* Hide number input spinners on Chrome, Safari, Edge, Opera */
.modal-inputs input::-webkit-outer-spin-button,
.modal-inputs input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Hide number input spinners on Firefox */
.modal-inputs input[type=number] {
   appearance: none;
    -moz-appearance: textfield;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-buttons button {
    padding: 10px 20px;
    font-size: 1em;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

#setRaceDelayBtn {
    background-color: #4CAF50; /* Green */
    color: white;
}

#setRaceDelayBtn:hover {
    background-color: #45a049;
}

#cancelRaceDelayBtn {
    background-color: #f44336; /* Red */
    color: white;
}

#cancelRaceDelayBtn:hover {
    background-color: #da190b;
}

#currentTimeDisplay {
    display: none; /* Hidden by default, shown via media query */
    font-size: 2em;
    font-weight: 600;
    color: white;
    text-shadow: 1px 1px 3px black;
    margin-bottom: 8px;
    text-align: center;
}

@media (min-width: 1600px) {
    #currentTimeDisplay {
        display: block;
    }
}
