/* Turbo Raceway Styles */

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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --warning-gradient: linear-gradient(135deg, #ffd93d 0%, #ff6b6b 100%);
    
    --bg-dark: #1a1a2e;
    --bg-darker: #16213e;
    --bg-card: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.1);
    
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #a0a0a0;
    
    --font-primary: 'Inter', sans-serif;
    --font-racing: 'Orbitron', monospace;
}

body {
    font-family: var(--font-primary);
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-darker) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
.header {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-family: var(--font-racing);
    font-size: 1.8rem;
    font-weight: 900;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: -5px;
}

.nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: var(--text-primary);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    border: none;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Main Content */
.main {
    min-height: calc(100vh - 140px);
    padding: 2rem 0;
}

/* Home Page */
.home-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.hero {
    text-align: center;
    padding: 4rem 0;
    background: radial-gradient(circle at center, rgba(102, 126, 234, 0.1) 0%, transparent 70%);
}

.hero-title {
    font-family: var(--font-racing);
    font-size: 3.5rem;
    font-weight: 900;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.hero-description {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 2rem auto;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Features Section */
.features {
    padding: 4rem 0;
}

.section-title {
    font-family: var(--font-racing);
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 3rem;
    font-weight: 700;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(102, 126, 234, 0.3);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-family: var(--font-racing);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.feature-card p {
    color: var(--text-muted);
    line-height: 1.6;
}

/* How It Works */
.how-it-works {
    padding: 4rem 0;
    background: rgba(0, 0, 0, 0.2);
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.step {
    text-align: center;
}

.step-number {
    width: 60px;
    height: 60px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-racing);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 auto 1rem auto;
    color: white;
}

.step h3 {
    font-family: var(--font-racing);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.step p {
    color: var(--text-muted);
}

/* CTA Section */
.cta {
    padding: 4rem 0;
    text-align: center;
    background: radial-gradient(circle at center, rgba(102, 126, 234, 0.1) 0%, transparent 70%);
}

.cta h2 {
    font-family: var(--font-racing);
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.cta p {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Race Page */
.race-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem;
}

.race-header {
    text-align: center;
    margin-bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.race-header-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0.5rem 0;
}

.race-title {
    font-family: var(--font-racing);
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.race-title-small {
    font-family: var(--font-racing);
    font-size: 1.5rem;
    margin: 0;
    color: var(--color-text);
    font-weight: 700;
}

.race-status {
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-pending {
    background: rgba(255, 193, 7, 0.2);
    border: 1px solid #ffc107;
    color: #ffc107;
}

.status-pending .status-indicator {
    background: #ffc107;
    animation: pulse 2s infinite;
}

.status-running {
    background: rgba(40, 167, 69, 0.2);
    border: 1px solid #28a745;
    color: #28a745;
}

.status-running .status-indicator {
    background: #28a745;
    animation: pulse 1s infinite;
}

.status-completed {
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid #667eea;
    color: #667eea;
}

.status-completed .status-indicator {
    background: #667eea;
}

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

.race-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 1.5rem;
    text-align: center;
}

.info-card h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.participant-count,
.created-date,
.completed-date {
    font-family: var(--font-racing);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    margin: 2rem 0;
}

.empty-state h2 {
    font-family: var(--font-racing);
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state code {
    background: rgba(102, 126, 234, 0.2);
    padding: 0.2rem 0.5rem;
    border-radius: 5px;
    font-family: monospace;
    color: #667eea;
}

/* Participants */
.participants-section {
    margin-bottom: 3rem;
}

.participants-section h2 {
    font-family: var(--font-racing);
    font-size: 1.8rem;
    margin-bottom: 2rem;
    text-align: center;
    font-weight: 600;
}

.participants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.participant-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.participant-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border-color: rgba(102, 126, 234, 0.3);
}

.participant-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

.participant-info {
    flex: 1;
}

.participant-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.participant-username {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.participant-position {
    font-family: var(--font-racing);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* Race Controls */
.race-controls {
    text-align: center;
    margin: 3rem 0;
}

.btn-start-race {
    background: var(--success-gradient);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
}

.btn-start-race:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(79, 172, 254, 0.4);
}

.race-note {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Race Animation */
.race-animation-container {
    text-align: center;
    margin: 3rem 0;
}

.race-animation-container h2 {
    font-family: var(--font-racing);
    font-size: 2rem;
    margin-bottom: 2rem;
    font-weight: 700;
}

#raceCanvas {
    width: 100%;
    max-width: 1000px;
    min-height: 400px;
    max-height: 800px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border-radius: 20px;
    border: 2px solid var(--border-color);
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: height 0.5s ease;
}

.race-progress {
    max-width: 800px;
    margin: 0 auto;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: var(--success-gradient);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.progress-text {
    font-family: var(--font-racing);
    font-weight: 600;
    color: var(--text-secondary);
}

/* Race Results */
.race-results {
    text-align: center;
    margin: 3rem 0;
}

.race-results h2 {
    font-family: var(--font-racing);
    font-size: 2rem;
    margin-bottom: 2rem;
    font-weight: 700;
}

.winner-announcement {
    margin-bottom: 2rem;
}

.winner-announcement h3 {
    font-family: var(--font-racing);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #ffd93d;
}

.winner-card {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, rgba(255, 217, 61, 0.2) 0%, rgba(255, 107, 107, 0.2) 100%);
    border: 2px solid #ffd93d;
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.winner-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #ffd93d;
}

.winner-info {
    text-align: left;
}

.winner-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.winner-username {
    font-size: 1rem;
    color: var(--text-muted);
}

.race-again-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.btn-race-again {
    background: var(--success-gradient);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-race-again:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(79, 172, 254, 0.4);
}

.btn-archive-race {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 1rem;
}

.btn-archive-race:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(231, 76, 60, 0.4);
}

.btn-replay-race {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-replay-race:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* Footer */
.footer {
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-muted);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .race-container {
        padding: 0 1rem;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .race-title {
        font-size: 2rem;
    }
    
    .participants-grid {
        grid-template-columns: 1fr;
    }
    
    .race-info {
        grid-template-columns: 1fr;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .steps-grid {
        grid-template-columns: 1fr;
    }
    
    .hero-actions,
    .error-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .winner-card {
        flex-direction: column;
        text-align: center;
    }
    
    .winner-info {
        text-align: center;
    }
}

/* Leaderboard Modal */
.leaderboard-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modalFadeIn 0.3s ease-out;
}

.leaderboard-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f1419 100%);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 20px;
    max-width: 800px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideUp 0.4s ease-out;
    overflow: hidden;
}

.leaderboard-header {
    text-align: center;
    padding: 2rem 2rem 1rem 2rem;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    flex-shrink: 0;
}

.leaderboard-header h2 {
    color: #FFD700;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.leaderboard-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 2rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.tab-button {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.tab-button.active {
    background: rgba(255, 215, 0, 0.2);
    border-color: rgba(255, 215, 0, 0.5);
    color: #FFD700;
}

.tab-button:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
}

.leaderboard-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.leaderboard-list::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.3);
    border-radius: 3px;
}

.leaderboard-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.5);
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 0.8rem;
    border-radius: 8px;
    transition: transform 0.2s ease;
    min-height: 60px;
}

.leaderboard-entry:hover {
    transform: translateX(5px);
}

.leaderboard-entry.position-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 165, 0, 0.1) 100%);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.leaderboard-entry.position-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.2) 0%, rgba(169, 169, 169, 0.1) 100%);
    border: 1px solid rgba(192, 192, 192, 0.3);
}

.leaderboard-entry.position-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.2) 0%, rgba(160, 82, 45, 0.1) 100%);
    border: 1px solid rgba(205, 127, 50, 0.3);
}

.leaderboard-entry.position-other {
    background: rgba(60, 60, 80, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.entry-position {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 40px;
    font-size: 1.5rem;
    font-weight: bold;
    margin-right: 1rem;
    flex-shrink: 0;
}

.entry-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.entry-avatar.fallback {
    background: rgba(102, 126, 234, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
}

.entry-info {
    flex: 1;
    margin-right: 1rem;
}

.entry-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    margin-bottom: 0.2rem;
}

.entry-winner {
    font-size: 0.9rem;
    color: #FFD700;
    font-weight: bold;
}

.entry-time {
    font-size: 1.1rem;
    font-weight: bold;
    min-width: 80px;
    text-align: right;
}

.entry-time.podium {
    color: #FFD700;
}

.entry-time.dnf {
    color: #ff6b6b;
}

.leaderboard-footer {
    text-align: center;
    padding: 1.5rem 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.leaderboard-footer p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.btn-close-leaderboard {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    padding: 0.8rem 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-close-leaderboard:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(50px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes entrySlideIn {
    from { opacity: 0; transform: translateX(-50px); }
    to { opacity: 1; transform: translateX(0); }
}