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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e8e8e8;
    min-height: 100vh;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #ff0050, #ff6b35);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#event-info {
    font-size: 1.2em;
    color: #aaa;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    margin-bottom: 20px;
}

.track-container {
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 20px;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#trackCanvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 5px;
    background: #0a0a0a;
    touch-action: none; /* prevent touch gestures from hijacking */
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5em;
    color: #ff0050;
    animation: pulse 1.5s ease-in-out infinite;
    pointer-events: none; /* don't block clicks */
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.race-info {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.info-row:last-child {
    margin-bottom: 0;
}

.label {
    color: #aaa;
    font-weight: 600;
}

.controls {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: none;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: #e8e8e8;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(90deg, #ff0050, #ff6b35);
    font-weight: bold;
}

.btn-primary:hover {
    background: linear-gradient(90deg, #ff1a63, #ff7b45);
}

.speed-controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

.btn-small {
    margin: 0;
    padding: 8px;
    font-size: 0.9em;
}

.leaderboard {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    backdrop-filter: blur(10px);
    max-height: 500px;
    overflow-y: auto;
}

.leaderboard h3 {
    margin-bottom: 15px;
    color: #ff6b35;
}

.driver-row {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 4px solid transparent;
}

.driver-row:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.driver-row.selected {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: #ff0050;
}

.position {
    font-weight: bold;
    font-size: 1.2em;
    width: 30px;
    text-align: center;
}

.driver-color {
    width: 4px;
    height: 30px;
    margin: 0 10px;
    border-radius: 2px;
}

.driver-name {
    flex: 1;
    font-weight: 600;
}

.tyre-indicator {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    font-weight: bold;
}

.tyre-soft { background: #ff0000; color: white; }
.tyre-medium { background: #ffff00; color: black; }
.tyre-hard { background: #ffffff; color: black; }
.tyre-inter { background: #00ff00; color: black; }
.tyre-wet { background: #0000ff; color: white; }

.driver-details {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.driver-details h3 {
    margin-bottom: 15px;
    color: #ff6b35;
}

#driver-info {
    font-size: 0.95em;
}

#driver-info div {
    margin-bottom: 8px;
}

footer {
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

footer a {
    color: #ff6b35;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.disclaimer {
    font-size: 0.8em;
    color: #888;
    margin-top: 10px;
}

/* Scrollbar styling */
.leaderboard::-webkit-scrollbar {
    width: 8px;
}

.leaderboard::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.leaderboard::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.leaderboard::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 1.8em;
    }
}
