@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;700;900&display=swap');

#gameCanvas {
    /* Couleurs */
    --cbu-bg-dark: #1a1a2e;
    --cbu-primary: #667eea;
    --cbu-secondary: #764ba2;
    --cbu-accent: #ff007f;
    --cbu-text: #2d3748;
    
    font-family: 'Poppins', sans-serif;
    /* Fond de la page normale */
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    display: flex; justify-content: center; align-items: center;
    width: 100%; padding: 20px;
    min-height: 650px;
}

#gameCanvas * { margin: 0; padding: 0; box-sizing: border-box; }

/* 1. WRAPPER EXTERNE (Cadre Blanc) */
#cbu-game-wrapper {
    position: relative; 
    width: 100%; max-width: 900px;
    aspect-ratio: 4 / 3;
    background: #fff;
    border-radius: 25px;
    padding: 6px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    display: flex; flex-direction: column;
}

/* 2. BOARD CONTAINER (Le jeu sombre) */
#cbu-board-container {
    width: 100%; height: 100%;
    background: var(--cbu-bg-dark);
    border-radius: 20px;
    overflow: hidden; /* Coupe tout ce qui dépasse */
    position: relative;
    display: flex; flex-direction: column;
}

/* --- PLEIN ECRAN (CORRIGÉ) --- */
#cbu-game-wrapper:fullscreen {
    width: 100vw; height: 100vh;
    border-radius: 0; padding: 0;
    /* Fond coloré identique au site */
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    display: flex; justify-content: center; align-items: center;
}

/* En plein écran, le jeu est centré */
#cbu-game-wrapper:fullscreen #cbu-board-container {
    width: auto; height: auto;
    max-width: 100%; max-height: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 20px;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    border: 6px solid #fff;
}

/* HUD */
#cbu-hud {
    height: 60px; width: 100%; flex-shrink: 0;
    background: rgba(255,255,255,0.1); 
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 25px; color: #fff; font-size: 1.1rem; z-index: 20;
}
.cbu-stat { display: flex; align-items: center; gap: 10px; font-weight: bold; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.cbu-icon { font-size: 1.3rem; }
.cbu-label { text-transform: uppercase; font-size: 0.8rem; opacity: 0.7; letter-spacing: 1px; }

.cbu-controls { display: flex; gap: 10px; pointer-events: auto; }
.cbu-btn-icon {
    background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.2); color: white;
    width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
    display: flex; justify-content: center; align-items: center; font-size: 1rem;
    transition: 0.2s;
}
.cbu-btn-icon:hover { background: white; color: var(--cbu-bg-dark); }

/* CANVAS */
#canvas-container { flex-grow: 1; width: 100%; position: relative; overflow: hidden; }
#cbu-game-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: none; }
#cbu-game-wrapper:not(:fullscreen) #cbu-game-canvas:hover { cursor: none; }

/* MENUS & CARTES (Centrage corrigé) */
.cbu-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 15, 25, 0.85); backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center;
    z-index: 50; animation: fadeIn 0.3s ease;
}
.hidden { display: none !important; }
.active { display: flex !important; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.cbu-card {
    background: white; padding: 40px; border-radius: 25px;
    width: 90%; max-width: 480px; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    color: var(--cbu-text);
    border: 4px solid #e0c3fc;
    /* CENTRAGE FLEX DU CONTENU */
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}

.cbu-title { 
    font-size: 2.5rem; margin-bottom: 10px; 
    background: linear-gradient(to right, var(--cbu-primary), var(--cbu-secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    font-weight: 900; letter-spacing: -1px;
}
.cbu-title-red { color: #f56565; font-size: 2.2rem; margin-bottom: 15px; font-weight: 800; }
.cbu-title-green { color: #48bb78; font-size: 2.2rem; margin-bottom: 15px; font-weight: 800; }
.cbu-desc { color: #718096; line-height: 1.6; margin-bottom: 30px; font-size: 1.1rem; }

/* RESULTATS */
.cbu-result-circle {
    width: 110px; height: 110px; border-radius: 50%;
    background: linear-gradient(135deg, var(--cbu-primary), var(--cbu-secondary));
    color: white; 
    /* Centrage interne du cercle */
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    font-size: 2.2rem; font-weight: bold; 
    margin-bottom: 20px; /* Pas de marge auto latérale nécessaire avec flex parent */
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4); border: 4px solid #fff;
}
.cbu-result-circle small { font-size: 0.9rem; font-weight: normal; opacity: 0.9; }

/* BOUTONS */
.cbu-btn-primary {
    background: linear-gradient(to right, var(--cbu-primary), var(--cbu-secondary));
    color: white; border: none; 
    padding: 12px 35px;
    font-size: 1.1rem; font-family: 'Poppins', sans-serif; font-weight: bold;
    border-radius: 50px; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 5px 15px rgba(118, 75, 162, 0.3);
    white-space: nowrap; min-width: 180px; display: inline-block;
}
.cbu-btn-primary:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(118, 75, 162, 0.5); }
.cbu-btn-primary.big { font-size: 1.3rem; padding: 15px 50px; }

.cbu-btn-secondary {
    background: white; border: 2px solid var(--cbu-primary); color: var(--cbu-primary);
    padding: 10px 30px; border-radius: 50px; font-weight: bold; cursor: pointer;
    font-family: 'Poppins', sans-serif; transition: 0.2s; min-width: 150px;
}
.cbu-btn-secondary:hover { background: #f3f0ff; transform: translateY(-2px); }

.cbu-actions { display: flex; gap: 15px; justify-content: center; margin-top: 25px; flex-wrap: wrap; width: 100%; }

@media (max-width: 600px) {
    #cbu-hud { padding: 0 15px; font-size: 0.8rem; }
    .cbu-title { font-size: 1.8rem; }
    .cbu-card { padding: 25px; }
}