* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', sans-serif; }
body { background: #1a1d24; color: #fff; min-height: 100vh; }

/* Barre de Navigation */
.navbar {
    background: #12141a;
    padding: 12px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #2ecc71;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 100;
    min-height: 64px;
}

.nav-brand {
    font-size: 1.4rem;
    font-weight: bold;
    color: #fff;
    text-decoration: none;
    transition: opacity 0.2s;
}
.nav-brand:hover { opacity: 0.8; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    background: #1e222b;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #3a4150;
    font-size: 0.95rem;
}

/* Boutons de la Navbar */
.btn-nav {
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
}

.btn-leaderboard {
    background: #2c313e;
    color: #f1c40f;
    border: 1px solid #f1c40f;
}
.btn-leaderboard:hover {
    background: #f1c40f;
    color: #1a1d24;
}

.btn-logout {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    border: 1px solid #e74c3c;
}
.btn-logout:hover {
    background: #e74c3c;
    color: #fff;
}

.btn-login {
    background: #3498db;
    color: #fff;
}
.btn-login:hover { background: #2980b9; }

.btn-register {
    background: #2ecc71;
    color: #fff;
}
.btn-register:hover { background: #27ae60; }

/* Structure Générale */
.main-content { display: flex; justify-content: center; padding: 20px; }
.container { width: 100%; max-width: 1200px; background: #242832; border-radius: 12px; padding: 20px; }
header { display: flex; justify-content: space-between; margin-bottom: 15px; }
.canvas-container {
    width: 100%;
    background: #0f2414;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 15px;
    border: 2px solid #2ecc71;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

/* Bandeau de commentaires de course : au-dessus de la piste, jamais superposé aux couloirs */
.course-banner {
    background: linear-gradient(90deg, #12141a, #1e222b);
    color: #f1c40f;
    padding: 9px 16px;
    font-weight: bold;
    font-size: 0.95rem;
    text-align: center;
    border-bottom: 2px solid #2ecc71;
    letter-spacing: 0.4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease-in-out;
}

canvas { display: block; width: 100%; height: auto; }
.pari-panel { display: flex; gap: 10px; align-items: center; justify-content: center; background: #1e222b; padding: 12px; border-radius: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.control-group { display: flex; flex-direction: column; gap: 5px; }
select, input {
    background: #132e1c;
    color: #eafaf1;
    border: 1px solid #2ecc71;
    padding: 8px;
    border-radius: 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
select:focus, input:focus {
    outline: none;
    border-color: #f1c40f;
    box-shadow: 0 0 0 2px rgba(241, 196, 15, 0.25);
}
select option {
    background: #132e1c;
    color: #eafaf1;
}

/* Boutons de Jeu */
button { cursor: pointer; border: none; padding: 10px 18px; border-radius: 8px; font-weight: bold; transition: all 0.2s ease-in-out; }
button:active { transform: scale(0.96); }
.btn-primary { background: #2ecc71; color: #fff; }
.quick-bets { display: flex; gap: 8px; justify-content: center; margin-bottom: 15px; flex-wrap: wrap; }
.btn-quick { background: #3a4150; color: #fff; }

.auth-box {
    background: #242832;
    padding: 45px 40px;
    border-radius: 16px;
    text-align: center;
    min-width: 340px;
    max-width: 400px;
    width: 100%;
    margin: 40px auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    border: 1px solid #3a4150;
}
.auth-box h2 {
    font-size: 1.6rem;
    margin-bottom: 30px;
    color: #2ecc71;
}
.auth-box form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.auth-box .input-group {
    position: relative;
    width: 100%;
}
.auth-box input[type="text"],
.auth-box input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
}
.auth-box .input-group input[type="password"],
.auth-box .input-group input[type="text"].password-field {
    padding-right: 44px;
}
.auth-box .toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    color: #a0a5b5;
    line-height: 1;
}
.auth-box .toggle-password:hover { color: #2ecc71; }
.auth-box .btn-primary {
    margin-top: 12px;
    padding: 12px;
    font-size: 1.05rem;
}
.auth-box .flash-message {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid #e74c3c;
    color: #e74c3c;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 22px;
    font-size: 0.9rem;
}
.leader-table { width: 100%; margin-top: 15px; border-collapse: collapse; text-align: center; }
.leader-table th, .leader-table td { padding: 10px; border-bottom: 1px solid #3a4150; text-align: center; }
.leaderboard-box { max-width: 560px; }

/* Styles du Hub & Cartes */
.hub-container { text-align: center; max-width: 900px; width: 100%; }
.games-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-top: 20px; }
.game-card { background: #242832; padding: 25px; border-radius: 16px; border: 1px solid #3a4150; transition: transform 0.2s, box-shadow 0.2s; }
.game-card:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(0,0,0,0.4); }
.game-card.disabled { opacity: 0.5; filter: grayscale(80%); }
.game-icon { font-size: 3rem; margin-bottom: 10px; }

.btn-card {
    display: inline-block;
    margin-top: 18px;
    padding: 10px 22px;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #fff;
    font-weight: bold;
    text-decoration: none;
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
    transition: all 0.2s ease-in-out;
}
.btn-card:hover {
    /* Pas de translateY ici : la .game-card parente bouge déjà au hover, */
    /* un second mouvement sur le bouton donnait un effet de double décalage. */
    box-shadow: 0 6px 16px rgba(46, 204, 113, 0.5);
    background: linear-gradient(135deg, #34e77e, #2ecc71);
}

.btn-card-disabled {
    display: inline-block;
    margin-top: 18px;
    padding: 10px 22px;
    background: #3a4150;
    color: #8a91a0;
    font-weight: bold;
    text-decoration: none;
    border-radius: 25px;
    cursor: not-allowed;
}

/* Écran de chargement (transition immersive avant d'entrer dans un jeu) */
.game-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #12141a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease-in-out;
}
.game-loading-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
.game-loading-icon {
    font-size: 4rem;
    margin-bottom: 18px;
    animation: loading-pulse 1s ease-in-out infinite;
}
.game-loading-text {
    color: #eafaf1;
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 24px;
    letter-spacing: 0.3px;
}
.game-loading-bar-track {
    width: 260px;
    height: 8px;
    background: #242832;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #3a4150;
}
.game-loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2ecc71, #34e77e);
    border-radius: 6px;
    transition: width 0.2s ease-out;
}
@keyframes loading-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.solde-nav-badge {
    background: #1e222b;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #2ecc71;
    color: #2ecc71;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
}

/* Modale Pop-up Résultat */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: #242832;
    border: 2px solid #3a4150;
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.visible .modal-card {
    transform: scale(1);
}

.modal-icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 10px;
}

.modal-card h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.modal-card p {
    font-size: 1.1rem;
    color: #a0a5b5;
    line-height: 1.5;
}