:root {
    /* Color Variables */
    --primary-gold: #ffd700;
    --dark-green: #1a3d1a;
    --medium-green: #2c5530;
    --track-green: #8fbc8f;
    --error-red: #e74c3c;
    --success-green: #27ae60;
    --warning-orange: #f39c12;
    --info-blue: #4a90e2;
    
    /* Odds Colors */
    --odds-favorite: #4169E1;
    --odds-strong: #32CD32;
    --odds-moderate: #FFD700;
    --odds-long: #FF8C00;
    --odds-longshot: #DC143C;
    
    /* Selection Color */
    --selection-green: #00ff41;
    
    /* Spacing */
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --radius-round: 20px;
    
    /* Transitions */
    --transition-fast: 0.1s ease;
    --transition-standard: 0.3s ease;
    --transition-slow: 0.5s ease;
}

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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, var(--medium-green), var(--dark-green));
    color: white;
    height: 100vh;
    overflow-x: hidden;
}

.screen {
    display: none;
    width: 100%;
    height: 100vh;
}

.screen.active {
    display: block;
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    text-align: center;
}

.login-container h1 {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    color: var(--primary-gold);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.login-container p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#username {
    padding: 12px 20px;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: white;
    backdrop-filter: blur(10px);
    min-width: 300px;
}

#username::placeholder {
    color: rgba(255,255,255,0.7);
}

#login-form button {
    padding: 12px 20px;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    background: #ffd700;
    color: #1a3d1a;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

#login-form button:hover {
    background: #ffed4e;
    transform: translateY(-2px);
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-gold);
}

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

#user-balance {
    background: var(--primary-gold);
    color: var(--dark-green);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-round);
    font-weight: bold;
}


.game-container {
    display: flex;
    padding: 2rem;
    gap: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

.main-content {
    flex: 1;
    min-width: 0;
}

.leaderboard-sidebar {
    width: 300px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 2rem;
}

.leaderboard-sidebar h3 {
    color: #ffd700;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.2rem;
}

/* Race Info */
.race-info {
    text-align: center;
    margin-bottom: 2rem;
}

#race-title {
    font-size: 2rem;
    color: #ffd700;
    margin-bottom: 0.5rem;
}

.race-status {
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-size: 1.2rem;
}

#race-phase {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.phase-betting {
    background: #4a90e2;
    color: white;
}

.phase-racing {
    background: #f39c12;
    color: white;
}

.phase-results {
    background: #27ae60;
    color: white;
}

#time-remaining {
    padding: 0.5rem 1rem;
    background: #e74c3c;
    border-radius: 20px;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

/* Race Track */
.race-track {
    position: relative;
    background: #8fbc8f;
    border-radius: 10px;
    margin: 2rem 0;
    padding: 1rem;
    min-height: 600px;
    overflow: hidden;
    display: none; /* Hidden by default, shown only during racing */
}

.track-lanes {
    position: relative;
    height: 100%;
}

.horse-lane {
    display: flex;
    align-items: center;
    height: 28px;
    margin: 2px 0;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    position: relative;
    overflow: hidden;
}

.horse {
    position: absolute;
    left: 0;
    width: 30px;
    height: 24px;
    background: #8B4513;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
    font-weight: bold;
    transition: left 0.1s ease;
    z-index: 10;
}

/* Racing horse colors based on odds */
.horse.odds-favorite {
    background: linear-gradient(135deg, #4169E1, #6495ED);
    border: 2px solid #4169E1;
}

.horse.odds-strong {
    background: linear-gradient(135deg, #32CD32, #7CFC00);
    border: 2px solid #32CD32;
}

.horse.odds-moderate {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 2px solid #FFD700;
    color: #333;
}

.horse.odds-long {
    background: linear-gradient(135deg, #FF8C00, #FF4500);
    border: 2px solid #FF8C00;
}

.horse.odds-longshot {
    background: linear-gradient(135deg, #DC143C, #B22222);
    border: 2px solid #DC143C;
}

/* Player's bet horses glow effect */
.horse.player-bet {
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8), 0 0 25px rgba(255, 215, 0, 0.6), 0 0 35px rgba(255, 215, 0, 0.4);
    border: 3px solid var(--primary-gold);
    animation: pulse-glow 1.5s ease-in-out infinite alternate;
    z-index: 20;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.8), 0 0 25px rgba(255, 215, 0, 0.6), 0 0 35px rgba(255, 215, 0, 0.4);
    }
    100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 1), 0 0 30px rgba(255, 215, 0, 0.8), 0 0 40px rgba(255, 215, 0, 0.6);
    }
}

.horse-info {
    position: absolute;
    left: 40px;
    font-size: 12px;
    color: #333;
    font-weight: bold;
}

.finish-line {
    position: absolute;
    right: 10px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: repeating-linear-gradient(
        0deg,
        #000,
        #000 10px,
        #fff 10px,
        #fff 20px
    );
}

/* Betting Panel */
.betting-panel {
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    padding: 1.5rem;
    margin: 2rem 0;
    border: 2px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.1);
    transition: all 0.3s ease;
}

.betting-panel:hover {
    border-color: rgba(255, 215, 0, 0.5);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.2);
}

.betting-panel h3 {
    color: #ffd700;
    margin-bottom: 1rem;
    text-align: center;
}

.bet-types {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.bet-type {
    padding: 0.8rem 1.5rem;
    border: 2px solid rgba(255,255,255,0.3);
    background: transparent;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.bet-type.active,
.bet-type:hover {
    background: #ffd700;
    color: #1a3d1a;
    border-color: #ffd700;
}

.bet-section {
    display: none;
}

.bet-section.active {
    display: block;
}

.horses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.horse-bet-btn {
    padding: 0.75rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-standard);
    text-align: center;
}

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

.horse-bet-btn.selected,
.horse-btn.selected {
    border: 3px solid var(--selection-green);
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.5);
    transform: scale(1.02);
}

/* Odds-based color scaling */
.horse-bet-btn.odds-favorite {
    background: linear-gradient(135deg, rgba(65, 105, 225, 0.3), rgba(65, 105, 225, 0.1));
    border-color: rgba(65, 105, 225, 0.5);
}

.horse-bet-btn.odds-strong {
    background: linear-gradient(135deg, rgba(50, 205, 50, 0.3), rgba(50, 205, 50, 0.1));
    border-color: rgba(50, 205, 50, 0.5);
}

.horse-bet-btn.odds-moderate {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
    border-color: rgba(255, 215, 0, 0.5);
}

.horse-bet-btn.odds-long {
    background: linear-gradient(135deg, rgba(255, 140, 0, 0.3), rgba(255, 140, 0, 0.1));
    border-color: rgba(255, 140, 0, 0.5);
}

.horse-bet-btn.odds-longshot {
    background: linear-gradient(135deg, rgba(220, 20, 60, 0.3), rgba(220, 20, 60, 0.1));
    border-color: rgba(220, 20, 60, 0.5);
}

/* Hover effects for odds-based colors */
.horse-bet-btn.odds-favorite:hover {
    background: linear-gradient(135deg, rgba(65, 105, 225, 0.4), rgba(65, 105, 225, 0.2));
}

.horse-bet-btn.odds-strong:hover {
    background: linear-gradient(135deg, rgba(50, 205, 50, 0.4), rgba(50, 205, 50, 0.2));
}

.horse-bet-btn.odds-moderate:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.4), rgba(255, 215, 0, 0.2));
}

.horse-bet-btn.odds-long:hover {
    background: linear-gradient(135deg, rgba(255, 140, 0, 0.4), rgba(255, 140, 0, 0.2));
}

.horse-bet-btn.odds-longshot:hover {
    background: linear-gradient(135deg, rgba(220, 20, 60, 0.4), rgba(220, 20, 60, 0.2));
}

/* Odds Legend */
.odds-legend {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.odds-legend h4 {
    color: #ffd700;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 140px;
}

/* Sidebar specific styles for odds legend */
.leaderboard-sidebar .odds-legend {
    margin-top: 1.5rem;
}

.leaderboard-sidebar .legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.leaderboard-sidebar .legend-item {
    min-width: auto;
    flex: none;
}

.leaderboard-sidebar .legend-item span {
    font-size: 0.8rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.3);
}

.legend-color.odds-favorite {
    background: linear-gradient(135deg, rgba(65, 105, 225, 0.6), rgba(65, 105, 225, 0.3));
}

.legend-color.odds-strong {
    background: linear-gradient(135deg, rgba(50, 205, 50, 0.6), rgba(50, 205, 50, 0.3));
}

.legend-color.odds-moderate {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.6), rgba(255, 215, 0, 0.3));
}

.legend-color.odds-long {
    background: linear-gradient(135deg, rgba(255, 140, 0, 0.6), rgba(255, 140, 0, 0.3));
}

.legend-color.odds-longshot {
    background: linear-gradient(135deg, rgba(220, 20, 60, 0.6), rgba(220, 20, 60, 0.3));
}

.legend-item span {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
}

.horse-name {
    font-weight: bold;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.odds {
    font-size: 0.8rem;
    opacity: 0.8;
    line-height: 1.2;
}

.bet-instructions {
    text-align: center;
    color: #ccc;
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* Box Trifecta Betting */
.trifecta-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.trifecta-selection-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    color: #ccc;
}

.clear-btn {
    background: #555;
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-standard);
}

.clear-btn:hover {
    background: #666;
}

.mystery-btn {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-standard);
    margin-right: 0.5rem;
}

.mystery-btn:hover {
    background: linear-gradient(135deg, #9b59b6, #af7ac5);
    transform: translateY(-1px);
}

.place-bet-btn {
    padding: 1rem 2rem;
    background: #ffd700;
    color: #1a3d1a;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.place-bet-btn:hover:not(:disabled) {
    background: #ffed4e;
    transform: translateY(-2px);
}

.place-bet-btn:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
    transform: none;
}

/* Race Results */
.race-results {
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    padding: 2rem;
    margin: 2rem 0;
    text-align: center;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.race-results h3 {
    color: #ffd700;
    margin-bottom: 2rem;
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    margin: 0.8rem 0;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.result-item:first-child {
    background: rgba(255, 215, 0, 0.3);
    border: 2px solid #ffd700;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.result-item:nth-child(2) {
    background: rgba(192, 192, 192, 0.3);
    border: 2px solid #c0c0c0;
}

.result-item:nth-child(3) {
    background: rgba(205, 127, 50, 0.3);
    border: 2px solid #cd7f32;
}

#payout-info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 8px;
    font-size: 1.1rem;
}

/* Enhanced Race Results */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.horses-results-section,
.trifecta-section,
.winners-section,
.personal-results-section {
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 1.5rem;
}

.winner-item {
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 1rem;
    margin: 0.5rem 0;
    border-left: 4px solid #ffd700;
}

.winner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.winner-rank {
    color: #ffd700;
    font-size: 1.1rem;
    min-width: 25px;
}

.winner-name {
    flex: 1;
    margin-left: 0.5rem;
}

.winner-amount {
    color: #4CAF50;
    font-size: 1.1rem;
}

.winner-bets {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.bet-detail {
    font-size: 0.9rem;
    color: #ccc;
    background: rgba(0,0,0,0.2);
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
}

/* Active Bets Display */
.active-bets {
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    padding: 1rem;
    margin: 1rem 0;
    border: 2px solid rgba(255, 215, 0, 0.3);
}

/* Active bets in sidebar styling */
.leaderboard-sidebar .active-bets {
    margin: 1.5rem 0 1rem 0;
    padding: 1rem;
}

.active-bets h4 {
    color: #ffd700;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.1rem;
}

/* Sidebar active bets header */
.leaderboard-sidebar .active-bets h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.bet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    margin: 0.5rem 0;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    border-left: 4px solid #4a90e2;
}

/* Sidebar bet items */
.leaderboard-sidebar .bet-item {
    padding: 0.6rem 0.75rem;
    margin: 0.4rem 0;
    font-size: 0.9rem;
}

.bet-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.bet-type {
    font-weight: bold;
    color: #ffd700;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.bet-selection {
    color: #ccc;
    font-size: 0.9rem;
    margin-top: 0.2rem;
}

.bet-amount {
    font-weight: bold;
    color: #4CAF50;
    font-size: 1rem;
}

.bet-potential {
    font-size: 0.8rem;
    color: #ccc;
    margin-top: 0.2rem;
}


.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    margin: 0.5rem 0;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    font-size: 0.9rem;
}

.leaderboard-item:first-child {
    background: rgba(255, 215, 0, 0.2);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.leaderboard-item:nth-child(2) {
    background: rgba(192, 192, 192, 0.2);
    border: 1px solid rgba(192, 192, 192, 0.3);
}

.leaderboard-item:nth-child(3) {
    background: rgba(205, 127, 50, 0.2);
    border: 1px solid rgba(205, 127, 50, 0.3);
}

.leaderboard-rank {
    font-weight: bold;
    margin-right: 0.5rem;
    min-width: 20px;
}

.leaderboard-name {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-balance {
    font-weight: bold;
    color: #ffd700;
}

/* Contact Footer */
.contact-footer {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 1000;
}

.contact-btn {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.contact-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

/* Error Messages */
.error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #e74c3c;
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    z-index: 1001;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
    25% { transform: translate(-50%, -50%) rotate(1deg); }
    75% { transform: translate(-50%, -50%) rotate(-1deg); }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-container {
        flex-direction: column;
    }
    
    .leaderboard-sidebar {
        width: 100%;
        position: static;
        order: -1;
    }
    
    .leaderboard-sidebar h3 {
        margin-bottom: 0.5rem;
    }
    
    .leaderboard-item {
        padding: 0.6rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .game-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .race-status {
        flex-direction: column;
        gap: 1rem;
    }
    
    .bet-types {
        flex-direction: column;
    }
    
    .horses-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.5rem;
    }
    
    .horse-bet-btn {
        padding: 0.5rem;
    }
    
    .horse-name {
        font-size: 0.8rem;
        margin-bottom: 0.2rem;
    }
    
    .odds {
        font-size: 0.7rem;
    }
    
    .game-container {
        padding: 1rem;
        gap: 1rem;
    }
    
    .winner-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .winner-name {
        margin-left: 0;
    }
    
    .bet-detail {
        font-size: 0.8rem;
    }
    
    .horses-results-section,
    .trifecta-section,
    .winners-section,
    .personal-results-section {
        padding: 1rem;
    }
    
    .active-bets {
        padding: 1rem;
        margin: 0.5rem 0;
    }
    
    .leaderboard-sidebar .active-bets {
        margin: 1rem 0;
        padding: 0.75rem;
    }
    
    .bet-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .bet-amount {
        align-self: flex-end;
    }
}