@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800;900&display=swap');

:root {
    --bg-main: #14151a;
    --glass-bg: rgba(30, 32, 44, 0.7);
    --glass-border: rgba(255, 255, 255, 0.12);
    --text-primary: #ffffff;
    --text-secondary: #a0a5b5;
    
    /* Couleurs pop et vibrantes */
    --accent: #7c3aed;
    --accent-hover: #5b21b6;
    --color-a: #ff477e; /* Rose bonbon */
    --color-a-dark: #cc1f54;
    --color-b: #0ea5e9; /* Bleu lagon */
    --color-c: #facc15; /* Jaune banane */
    --color-c-dark: #ca8a04;
    --color-d: #10b981; /* Vert menthe */
    --color-d-dark: #047857;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* 🎨 FOND ORGANIQUE ET DYNAMIQUE */
body {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(124, 58, 237, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 71, 126, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.08) 0%, transparent 60%);
      
        background-attachment: fixed;
        background-repeat: no-repeat;
        background-size: cover;
    color: var(--text-primary);


    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

/* 🎮 CONTROLES HAUT GAUCHE (PROJECTEUR) */
#top-left-controls {
    position: fixed; 
    top: 20px; 
    left: 20px; 
    z-index: 5000; 
    display: flex; 
    gap: 10px; 
    align-items: center;
}

.btn-top-nav {
    background: rgba(30, 32, 44, 0.8);
    padding: 8px 15px; /* 🟢 Plus petit qu'avant */
    border-radius: 12px;
    border: 2px solid var(--text-secondary);
    font-size: 1rem; /* 🟢 Texte plus petit */
    font-weight: bold;
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: transform 0.1s, background 0.2s, opacity 0.3s, transform 0.3s;
}

.btn-top-nav:active {
    transform: scale(0.95);
}

/* Le bouton "Passer" est invisible et intouchable par défaut */
#top-left-controls .btn-danger-hover {
    opacity: 0;
    transform: translateX(-15px);
    pointer-events: none; 
    border-color: var(--color-a); 
    color: var(--color-a);
}

/* Il apparaît avec une belle animation quand on survole toute la zone */
#top-left-controls:hover .btn-danger-hover {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.container { width: 100%; max-width: 1000px; }
.projecteur-container { max-width: 1400px; }

.text-center { text-align: center; }
.hidden { display: none !important; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-3 { margin-bottom: 30px; }

/* 🖋️ TYPOGRAPHIE LUDIQUE */
.brand-title { font-size: 4rem; font-weight: 900; letter-spacing: 2px; margin-bottom: 10px; text-transform: uppercase; text-shadow: 0 4px 15px rgba(0,0,0,0.3); }
.subtitle { font-size: 1.3rem; color: var(--text-secondary); margin-bottom: 40px; font-weight: 600; }
.section-title { font-size: 2.2rem; font-weight: 800; margin-bottom: 15px; letter-spacing: -0.5px; }
.question-title { font-size: 2.8rem; font-weight: 800; margin-bottom: 20px; line-height: 1.2; text-shadow: 0 4px 10px rgba(0,0,0,0.4); }

/* 🃏 PANNEAUX OPTIMISÉS POUR GRAND ÉCRAN */
.glass-panel {
    background: rgba(30, 32, 44, 0.85); /* Un peu plus opaque pour compenser la baisse du flou */
    backdrop-filter: blur(6px); /* 🟢 Baisse de 16px à 6px : gain de perfs massif ! */
    -webkit-backdrop-filter: blur(6px);
    border: 2px solid var(--glass-border);
    border-radius: 28px;
    padding: 35px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), inset 0 2px 0 rgba(255,255,255,0.1);
    transform: translateZ(0); /* 🟢 Force l'accélération matérielle 3D */
    will-change: transform, opacity; /* 🟢 Prévient le navigateur des animations futures */
}

/* 🕹️ BOUTONS 3D */
.btn {
    display: inline-block;
    padding: 16px 32px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    position: relative;
}

.btn-primary { 
    background: var(--accent); 
    color: white; 
    box-shadow: 0 6px 0 var(--accent-hover), 0 10px 20px rgba(0,0,0,0.3); 
}
.btn-primary:active { 
    transform: translateY(6px); 
    box-shadow: 0 0 0 var(--accent-hover), 0 2px 5px rgba(0,0,0,0.3); 
}

.btn-outline { 
    background: rgba(255,255,255,0.05); 
    color: var(--text-primary); 
    border: 2px solid var(--text-secondary); 
    box-shadow: 0 4px 0 var(--text-secondary);
    margin-bottom: 10px;
}
.btn-outline:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 var(--text-secondary);
}

.game-card svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.btn-large { font-size: 1.3rem; padding: 20px 40px; margin-top: 30px; }
.btn-full { width: 100%; margin-top: 15px; }

/* 📱 MANETTE JOUEUR */
.gamepad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; height: 60vh; }
.pad-btn { 
    border: none; border-radius: 24px; font-size: 3.5rem; font-weight: 900; 
    cursor: pointer; display: flex; justify-content: center; align-items: center; 
    color: white; transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.mt-4{margin-top: 15px;}

/* 🏆 DESIGN DU TOP 3 (CLASSEMENT EN DIRECT) */
#leaderboard-list li.top-1 {
    background: rgba(255, 209, 102, 0.2);
    border: 2px solid var(--color-c);
    transform: scale(1.05);
    margin-bottom: 15px;
    box-shadow: 0 0 15px rgba(250, 204, 21, 0.4);
}
#leaderboard-list li.top-1 .rank { font-size: 2rem; color: var(--color-c); text-shadow: 0 0 10px rgba(250, 204, 21, 0.8); }

/* 🚫 CACHER LES FLÈCHES DES CHAMPS NUMBER */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield; /* Pour Firefox */
    appearance: textfield;
}


#leaderboard-list li.top-2 {
    background: rgba(226, 232, 240, 0.1);
    border: 2px solid #cbd5e1;
    margin-bottom: 12px;
}
#leaderboard-list li.top-2 .rank { color: #cbd5e1; }

#leaderboard-list li.top-3 {
    background: rgba(217, 119, 6, 0.15);
    border: 2px solid #b45309;
    margin-bottom: 12px;
}
#leaderboard-list li.top-3 .rank { color: #d97706; }

.pad-btn.ans-a { background: var(--color-a); box-shadow: 0 8px 0 var(--color-a-dark), 0 15px 20px rgba(0,0,0,0.3); }
.pad-btn.ans-b { background: var(--color-b); box-shadow: 0 8px 0 #0284c7, 0 15px 20px rgba(0,0,0,0.3); }
.pad-btn.ans-c { background: var(--color-c); box-shadow: 0 8px 0 var(--color-c-dark), 0 15px 20px rgba(0,0,0,0.3); color: #1a1a1a; text-shadow: none;}
.pad-btn.ans-d { background: var(--color-d); box-shadow: 0 8px 0 var(--color-d-dark), 0 15px 20px rgba(0,0,0,0.3); color: #1a1a1a; text-shadow: none;}

.pad-btn:active { transform: translateY(8px); box-shadow: 0 0 0 transparent, 0 5px 10px rgba(0,0,0,0.2); }

/* 🖥️ PROJECTEUR LAYOUT */
.projecteur-layout {
    display: grid; grid-template-columns: 3fr 1fr; gap: 30px;
    width: 100%; max-width: 1600px; height: 85vh;
}

.main-game-area { display: flex; flex-direction: column; justify-content: center; overflow-y: auto; }
.main-game-area::-webkit-scrollbar { display: none; }
.main-game-area { -ms-overflow-style: none; scrollbar-width: none; }

/* 🎫 BADGE CODE SALON */
.room-code-display {
    font-size: 3.5rem; font-weight: 900; color: #1a1a1a; background: var(--color-c);
    display: inline-block; padding: 15px 40px; border-radius: 20px;
    margin-bottom: 30px; letter-spacing: 4px; box-shadow: 0 8px 0 var(--color-c-dark), 0 15px 30px rgba(0,0,0,0.4);
    transform: rotate(-2deg);
}

/* 🏆 LEADERBOARD */
.sidebar-leaderboard { display: flex; flex-direction: column; overflow-y: auto; border-radius: 28px; }
.leaderboard-title { font-size: 2rem; font-weight: 800; margin-bottom: 20px; border-bottom: 2px solid var(--glass-border); padding-bottom: 15px; text-align: center; color: white; }
#leaderboard-list { list-style: none; padding: 0 10px; }
#leaderboard-list li { 
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; background: rgba(255,255,255,0.03); margin-bottom: 10px;
    border-radius: 16px; font-size: 1.3rem; font-weight: 600; transition: transform 0.2s;
}
#leaderboard-list li:hover { transform: scale(1.02); background: rgba(255,255,255,0.08); }
.rank { font-size: 1.5rem; color: var(--color-c); text-shadow: 0 2px 4px rgba(0,0,0,0.5); }

/* 🤔 GRILLE DE RÉPONSES */
.answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; text-align: left; margin-top: 20px; }
.answer-box { 
    padding: 20px 30px; border-radius: 20px; font-size: 1.8rem; font-weight: 700; 
    display: flex; align-items: center; gap: 20px; border: 3px solid rgba(255,255,255,0.1);
    transform: translateZ(0);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}
.letter { 
    background: rgba(0,0,0,0.3); min-width: 55px; height: 55px; display: flex; 
    justify-content: center; align-items: center; border-radius: 14px; 
    font-size: 1.6rem; font-weight: 900; color: white;
}

/* 🏎️ EFFET DÉPASSEMENT CLASSEMENT (FORMULE 1) */
.overtake-flash {
    background: rgba(250, 204, 21, 0.4) !important; /* Flash jaune doré */
    box-shadow: 0 0 20px rgba(250, 204, 21, 0.6) !important;
    border: 1px solid var(--color-c);
    color: white;
}

/* Couleurs spécifiques boites projo */
.ans-a { background: var(--color-a); color: white; border-color: var(--color-a-dark); }
.ans-b { background: var(--color-b); color: white; border-color: #0284c7; }
.ans-c { background: var(--color-c); color: #1a1a1a; border-color: var(--color-c-dark); } 
.ans-c .letter { background: rgba(255,255,255,0.4); color: #1a1a1a; }
.ans-d { background: var(--color-d); color: #1a1a1a; border-color: var(--color-d-dark); }
.ans-d .letter { background: rgba(255,255,255,0.4); color: #1a1a1a; }

/* 🎭 EFFETS DE JEU */
.progress-zone { margin-top: 40px; padding-top: 25px; border-top: 2px dashed var(--glass-border); }
.players-grid { display: flex; flex-wrap: wrap; gap: 12px; list-style: none; justify-content: center; }
.inline-status li { font-size: 1rem; padding: 8px 18px; border-radius: 12px; font-weight: 700; text-transform: uppercase;}
.not-answered { background: rgba(255,255,255,0.05) !important; color: var(--text-secondary) !important; border: 2px dashed rgba(255,255,255,0.2); }
.answered { background: var(--color-d) !important; color: #1a1a1a !important; box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4); }

.fade-out { opacity: 0.15; transform: scale(0.95) translateY(10px); filter: grayscale(80%); transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1); }
.correct-answer { transform: scale(1.05); box-shadow: 0 0 40px rgba(250, 204, 21, 0.5); border: 4px solid #fff; z-index: 10; transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* 📱 INPUTS JOUEUR */
.input-group input, .input-group select, textarea { 
    width: 100%; padding: 18px; font-size: 1.2rem; font-weight: 600; background: rgba(0,0,0,0.3); 
    border: 2px solid var(--glass-border); border-radius: 16px; color: white; 
    text-align: center; outline: none; transition: all 0.2s; 
}
.input-group input:focus, textarea:focus { border-color: var(--accent); background: rgba(0,0,0,0.5); }

/* 📥 BOUTON TÉLÉCHARGER PHOTO */
.download-photo-btn {
    position: absolute;
    bottom: 45px; /* Placé juste au-dessus de la zone blanche du Polaroid */
    right: 15px;
    background: rgba(16, 185, 129, 0.9); /* Vert menthe pour correspondre à une action positive */
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: opacity 0.3s, transform 0.2s;
    z-index: 20;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    line-height: 1;
}

.download-photo-btn:hover { transform: scale(1.1); }
.download-photo-btn:active { transform: scale(0.9); }

/* Sur ordinateur (mode projo), on le cache par défaut et on l'affiche au survol */
@media (min-width: 769px) {
    .download-photo-btn { opacity: 0; }
    .masonry-item:hover .download-photo-btn { opacity: 1; }
}

/* Sur téléphone, il reste visible en permanence pour pouvoir cliquer dessus */
@media (max-width: 768px) {
    .download-photo-btn { opacity: 1 !important; }
}



/* ❌ BOUTON SUPPRIMER PHOTO (PROJECTEUR) */
.delete-photo-btn {
    position: absolute; 
    top: 10px; 
    left: 10px; 
    background: rgba(239, 71, 111, 0.9);
    color: white; 
    border: 2px solid white; 
    border-radius: 50%; 
    width: 40px; 
    height: 40px;
    font-size: 1.2rem; 
    cursor: pointer; 
    opacity: 0; 
    transition: opacity 0.3s, transform 0.2s;
    z-index: 10; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.5); 
    display: flex; 
    justify-content: center; 
    align-items: center;
    /* 🟢 FIX MOBILE : Forcer l'annulation des marges invisibles du navigateur */
    padding: 0;
    line-height: 1;
}
.delete-photo-btn:hover { transform: scale(1.1); }
.masonry-item:hover .delete-photo-btn { opacity: 1; }

/* 🟢 FIX SCROLL ET CADRAGE SPECIFIQUE AU PHOTOWALL */
.projecteur-layout.photowall-mode .main-game-area {
    justify-content: flex-start; /* Empêche le bug qui coupe le haut et le bas */
    padding-top: 40px;
    padding-bottom: 80px; /* Marge pour le défilement en bas */
}

/* 📸 MUR DE PHOTOS (MASONRY PATCHWORK) */
.masonry-wall {
    column-count: 4; 
    column-gap: 25px; /* Un peu plus d'espace entre les colonnes */
    padding: 20px 40px; /* 🟢 Marge critique pour ne pas rogner les photos inclinées */
    width: 100%;
}

.masonry-item {
    position: relative; break-inside: avoid; margin-bottom: 30px; border-radius: 6px;
    overflow: hidden; box-shadow: 0 15px 35px rgba(0,0,0,0.6);
    border: 12px solid var(--polaroid-color, #f8f9fa); 
    border-bottom-width: 16px; 
    background: var(--polaroid-color, #f8f9fa);
    transform: translate(0, var(--random-y, 0)) rotate(var(--random-rot, 0deg));
    animation: popPhoto 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), floatPhoto 6s ease-in-out infinite 0.6s;
    transition: transform 0.3s ease, z-index 0.3s; z-index: 1;
}

.masonry-item:hover { z-index: 50; transform: scale(1.1) rotate(0deg) !important; }
.masonry-item img { width: 100%; display: block; object-fit: cover; border-radius: 4px; }
.photo-caption {
    position: relative; padding: 12px 5px 0 5px; 
    background: var(--polaroid-color, #f8f9fa); 
    color: #1a1a1a;
    font-size: 1.3rem; font-weight: 900; text-align: center; word-wrap: break-word;
}

/* 💖 BOUTON LIKE & ANIMATION TIKTOK */
.like-btn-container {
    position: absolute;
    top: 15px; /* 🟢 Remonté en haut ! */
    right: 15px;
    background: rgba(0,0,0,0.6);
    border-radius: 30px;
    padding: 6px 12px; /* 🟢 Rendu un peu plus fin */
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    z-index: 20;
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255,255,255,0.2);
    transition: transform 0.1s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.like-btn-container:active {
    transform: scale(0.85);
}

.like-icon { font-size: 1.2rem; user-select: none; pointer-events: none; } /* 🟢 Emoji plus petit */
.like-counter { color: white; font-weight: 900; font-size: 1.1rem; pointer-events: none; } /* 🟢 Texte plus petit */

.floating-heart {
    position: absolute;
    font-size: 2.5rem;
    pointer-events: none;
    z-index: 100;
    animation: flyUpHeart 1.5s ease-out forwards;
}

@keyframes flyUpHeart {
    0% { transform: translate(0, 0) scale(0.5); opacity: 1; }
    80% { opacity: 1; }
    /* Les coeurs suivent maintenant une direction X et Y qu'on donne en JS */
    100% { transform: translate(var(--drift-x), var(--drift-y)) scale(1.5); opacity: 0; }
}

/* 📱 PROJECTEUR SUR SMARTPHONE (VUE SCROLLABLE VERTICALE) */
@media (max-width: 768px) {
    .projecteur-layout.photowall-mode .masonry-wall {
        column-count: 1; /* Une seule colonne */
        padding: 10px;
    }
    
    .projecteur-layout.photowall-mode .masonry-item {
        /* On annule les rotations mathématiques pour un flux propre */
        --random-rot: 0deg !important;
        --random-y: 0px !important;
        margin-bottom: 25px;
    }
}

/* ✨ ANIMATIONS FUN */
@keyframes floatLogo { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-12px) rotate(1deg); } }
svg { animation: floatLogo 6s ease-in-out infinite; }

@keyframes floatPhoto {
    0%, 100% { transform: translate(0, var(--random-y, 0)) rotate(var(--random-rot, 0deg)); }
    50% { transform: translate(0, calc(var(--random-y, 0) - 8px)) rotate(calc(var(--random-rot, 0deg) + 2deg)); }
}
@keyframes popPhoto {
    0% { transform: scale(0.3) translateY(100px) rotate(-25deg); opacity: 0; }
    100% { transform: scale(1) translate(0, var(--random-y, 0)) rotate(var(--random-rot, 0deg)); opacity: 1; }
}


/* 🎈 FLOTTAISON DOUCE DES BOUTONS DU MENU */
@keyframes floatButton {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); } /* Flottaison de 5px vers le haut */
}

/* On applique l'animation uniquement aux boutons des cartes du menu */
.game-card .btn {
    animation: floatButton 5s ease-in-out infinite;
}

/* On décale l'animation pour que les deux boutons ne montent pas exactement en même temps (effet plus naturel) */
.game-card .btn-primary {
    animation-delay: 1.5s;
}

/* 🟢 TRÈS IMPORTANT : On coupe l'animation quand on clique pour garder l'effet 3D d'enfoncement ! */
.game-card .btn:active {
    animation: none !important;
}

/* 📱 RESPONSIVE & MOBILE */
@media (max-width: 1200px) {
    .projecteur-layout { grid-template-columns: 1fr; height: auto; gap: 20px;}
    .sidebar-leaderboard { max-height: 400px; }
    .question-header { flex-direction: column; align-items: stretch !important; }
    .masonry-wall { column-count: 3; }
}

@media (max-width: 768px) {
    .masonry-wall { column-count: 2; }
    .answers-grid { grid-template-columns: 1fr; gap: 15px; }
    .answer-box { padding: 15px 20px; font-size: 1.3rem; border-radius: 16px; border-width: 2px;}
    .letter { min-width: 40px; height: 40px; font-size: 1.2rem; border-radius: 10px;}
    .room-code-display { font-size: 2.2rem; padding: 10px 20px; transform: rotate(0deg);}
    .glass-panel { padding: 25px 20px; border-radius: 24px; }
    .question-title { font-size: 1.8rem; }
    
    .gamepad-grid { gap: 15px; height: 50vh; }
    .pad-btn { font-size: 2.8rem; border-radius: 20px; box-shadow: 0 6px 0, 0 10px 15px rgba(0,0,0,0.3); }
    .pad-btn:active { transform: translateY(6px); }
    .btn { padding: 14px 20px; border-radius: 12px; font-size: 1rem;}

    /* Centrage Mobile */
    body { min-height: -webkit-fill-available; }
    html { height: -webkit-fill-available; }
    #ecran-photowall { margin: auto; width: 100%; }

    #modal-action-code, #ecran-mort, #ecran-fin-quizz, #ecran-fin-anecdote {
        height: 100dvh;
    }
}