/* Race Page Styles */
.race-page {
    max-width: 1300px;
    margin: 0 auto;
    padding: 20px;
}

.race-page h1 {
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.race-page p {
    font-size: 1.2em;
    line-height: 1.6;
}

/* Race Chart Container */
#race-chart-container {
    width: 1200px;
    height: 600px;
    margin: 0 auto 20px;
    background-color: #2a2a2a;
    padding: 10px;
    border: 1px solid #444444;
    border-radius: 8px;
}

/* Loading and Error States */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #ffffff;
    font-size: 18px;
}

.spinner {
    border: 4px solid #444444;
    border-top: 4px solid #d4a017;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #ff4444;
    font-size: 18px;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 10px auto;
    padding: 15px;
    background-color: #333333;
    border-radius: 8px;
    border: 1px solid #555555;
    flex-wrap: wrap;
    width: 1190px;
}

.controls label {
    color: #d4a017;
    font-weight: bold;
    margin-right: 5px;
}

.controls select {
    background-color: #2a2a2a;
    color: #ffffff;
    border: 1px solid #555555;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
}

.controls select:focus {
    outline: none;
    border-color: #d4a017;
}

.controls button {
    background-color: #d4a017;
    color: #1a1a1a;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: bold;
    margin-right: 10px;
    border-radius: 4px;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.controls button:hover {
    background-color: #f4c127;
}

.controls button:disabled {
    background-color: #666666;
    color: #999999;
    cursor: not-allowed;
}

.controls input[type="range"] {
    margin-right: 10px;
    vertical-align: middle;
}

.controls span {
    color: #ffffff;
    font-weight: bold;
    margin-right: 20px;
}

/* Animation Controls Specific Styles */
#animation-controls {
    justify-content: flex-start;
}

#animation-controls label {
    margin-left: 20px;
    margin-right: 10px;
}

#animation-controls #timeline-slider {
    width: 200px;
}

/* Race Chart SVG Styles */
#raceSvg {
    display: block;
    margin: 0 auto;
}

/* D3 Chart Element Styles */
.player-bar {
    cursor: pointer;
}

.player-bar:hover {
    stroke-width: 2;
    filter: brightness(1.1);
}

.player-avatar {
    cursor: pointer;
}

.player-label {
    pointer-events: none;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.score-label {
    pointer-events: none;
}

.rank-label {
    pointer-events: none;
}

.chart-title {
    pointer-events: none;
}

.timestamp-display {
    pointer-events: none;
}

/* Axis Styles */
.x-axis text {
    fill: #ffffff;
}

.y-axis text {
    fill: #ffffff;
}

.x-axis line,
.y-axis line {
    stroke: #666666;
}

.x-axis path,
.y-axis path {
    stroke: #666666;
}

.x-label,
.y-label {
    fill: #d4a017;
    font-weight: bold;
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    .race-page {
        padding: 10px;
        max-width: 100%;
    }
    
    .race-page h1 {
        font-size: 1.8em;
        margin-bottom: 15px;
    }
    
    .race-page p {
        font-size: 1em;
        margin-bottom: 20px;
    }
    
    /* Make chart container responsive */
    #race-chart-container {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 250px;
        margin: 0 0 15px 0;
        padding: 8px;
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    /* Scale down SVG for mobile */
    #raceSvg {
        width: 100%;
        height: auto;
        max-height: 400px;
        min-height: 250px;
    }
    
    /* Make controls responsive */
    .controls {
        width: 100%;
        max-width: 100%;
        margin: 5px 0;
        padding: 10px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    /* Stack control groups vertically on mobile */
    #race-controls,
    #animation-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    /* Mobile-friendly form elements */
    .controls label {
        margin-bottom: 5px;
        margin-right: 0;
        display: block;
        font-size: 14px;
    }
    
    .controls select {
        width: 100%;
        margin-bottom: 10px;
        padding: 8px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .controls button {
        width: 100%;
        margin: 5px 0;
        padding: 12px;
        font-size: 16px;
    }
    
    .controls input[type="range"] {
        width: 100%;
        margin: 5px 0;
    }
    
    .controls span {
        margin: 5px 0;
        text-align: center;
        display: block;
    }
    
    /* Adjust timeline controls for mobile */
    #animation-controls #timeline-slider {
        width: 100%;
    }
    
    #animation-controls label {
        margin-left: 0;
    }
}

/* Small mobile devices */
@media screen and (max-width: 480px) {
    .race-page {
        padding: 5px;
    }
    
    .race-page h1 {
        font-size: 1.5em;
    }
    
    #race-chart-container {
        padding: 5px;
        min-height: 200px;
    }
    
    #raceSvg {
        max-height: 300px;
        min-height: 200px;
    }
    
    .controls {
        padding: 8px;
    }
    
    .controls label {
        font-size: 12px;
    }
    
    .controls select,
    .controls button {
        font-size: 14px;
        padding: 10px;
    }
}