/* =========================================
   1. VARIABLES & BASE
========================================= */
:root {
    --primary: #00f2fe;     
    --secondary: #4facfe;
    --success: #2ecc71;     
    --warning: #f1c40f;     
    --danger: #e74c3c;
    --bg-dark: #0f172a;
    --text-light: #f8fafc;
    --glass-bg: rgba(255, 255, 255, 0.07);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }
body { background-color: var(--bg-dark); color: var(--text-light); overflow-x: hidden; }
.hidden { display: none !important; }

/* =========================================
   2. PAGE D'ACCUEIL & SPLIT SCREEN
========================================= */
.home-body {
    background: url('https://images.unsplash.com/photo-1451187580459-43490279c0fa?q=80&w=2072&auto=format&fit=crop') no-repeat center center/cover;
    min-height: 100vh; display: flex; justify-content: center; align-items: center; position: relative;
    overflow-y: auto; 
}

.background-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.9) 0%, rgba(15, 23, 42, 0.6) 100%); z-index: 1;
}

.main-container { 
    position: relative; z-index: 2; display: flex; width: 95%; max-width: 1100px; 
    align-items: center; gap: clamp(20px, 4vw, 50px); transition: max-width 0.5s ease;
    margin: 20px 0;
}
.brand-panel { flex: 1; text-align: left; transition: opacity 0.4s ease, transform 0.4s ease; }
.logo-container { display: flex; align-items: center; gap: 15px; margin-bottom: clamp(10px, 2vh, 20px); }
.logo-container i { font-size: clamp(2.5rem, 5vw, 4rem); color: var(--primary); filter: drop-shadow(0 0 15px rgba(0, 242, 254, 0.5)); }
.brand-panel h1 { font-size: clamp(3rem, 6vw, 4.5rem); font-weight: 900; line-height: 1; letter-spacing: -2px; }
.brand-panel h1 span { color: var(--primary); }
.tagline { font-size: clamp(0.9rem, 1.5vw, 1.2rem); color: #cbd5e1; line-height: 1.5; max-width: 400px; }

/* =========================================
   3. LE STUDIO D'AVATAR (MODIFIÉ POUR IMG)
========================================= */
.avatar-studio-panel {
    margin-top: clamp(15px, 3vh, 30px); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--glass-border);
    border-radius: 16px; padding: clamp(15px, 2vh, 20px); backdrop-filter: blur(10px); max-width: 350px; animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.avatar-studio-panel h3 { font-size: 1.1rem; margin-bottom: clamp(10px, 1.5vh, 15px); color: white; display: flex; align-items: center; gap: 10px; }
.avatar-studio-panel h3 i { color: var(--primary); }

.avatar-preview-box {
    display: flex; justify-content: center; align-items: center; margin-bottom: clamp(10px, 2vh, 20px); padding: 10px;
    background: rgba(255, 255, 255, 0.05); border-radius: 12px; border: 1px dashed rgba(255, 255, 255, 0.2);
}
.avatar-preview-box img { 
    border-radius: 50%; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.5); 
    transition: all 0.3s ease; 
    width: clamp(70px, 15vh, 100px);
    height: clamp(70px, 15vh, 100px);
}

.avatar-customizer { display: flex; flex-direction: column; gap: clamp(8px, 1.5vh, 15px); }
.custom-row { display: flex; justify-content: space-between; align-items: center; }
.custom-row span { font-size: 0.85rem; font-weight: 600; color: #cbd5e1; }

.color-options { display: flex; gap: 6px; }
.color-btn { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.5); }
.color-btn:hover { transform: scale(1.15); }
.color-btn.active { border-color: white; transform: scale(1.2); box-shadow: 0 0 10px rgba(255, 255, 255, 0.5); }

.selector { display: flex; align-items: center; gap: 10px; background: rgba(0, 0, 0, 0.5); border-radius: 20px; padding: 4px 8px; }
.selector button { background: transparent; border: none; color: var(--primary); cursor: pointer; font-size: 0.9rem; transition: 0.2s; }
.selector button:hover { color: white; transform: scale(1.2); }
.selector span { font-weight: 800; text-align: center; font-size: 0.85rem; }

/* =========================================
   NOUVEAU : WIDGET XP ET LEVEL UP
========================================= */
/* Placé à gauche pour ne pas chevaucher les Toasts */
.xp-widget {
    position: fixed; top: 20px; left: 20px; z-index: 1000;
    background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border); border-radius: 12px;
    padding: 10px 15px; display: flex; align-items: center; gap: 15px;
    cursor: pointer; transition: all 0.3s ease; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.5s ease-out forwards;
}
.xp-widget:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: 0 8px 20px rgba(0, 242, 254, 0.2); }

.level-badge {
    background: linear-gradient(135deg, #fbc531, #e1b12c);
    color: #0f172a; width: 45px; height: 45px; border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.3rem; font-weight: 900; border: 2px solid white;
    box-shadow: 0 0 10px rgba(251, 197, 49, 0.5); flex-shrink: 0;
}

.xp-bar-container { width: 140px; display: flex; flex-direction: column; gap: 6px; }
.xp-info { display: flex; justify-content: space-between; font-size: 0.75rem; font-weight: 700; }
.xp-label { color: var(--primary); }
.xp-values { color: #cbd5e1; font-size: 0.7rem; }
.xp-track { width: 100%; height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.5); }
.xp-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 4px; transition: width 0.6s cubic-bezier(0.25, 1, 0.5, 1); box-shadow: 0 0 8px rgba(0, 242, 254, 0.5); }

.level-up-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.95); z-index: 9999;
    display: flex; justify-content: center; align-items: center;
    text-align: center;
}
.level-up-content { animation: levelUpPop 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.level-up-icon { font-size: 5rem; color: #fbc531; margin-bottom: 20px; animation: pulseGlow 1.5s infinite; }
.level-up-title { font-size: clamp(2.5rem, 5vw, 4rem); color: white; text-transform: uppercase; font-weight: 900; letter-spacing: 2px; margin-bottom: 10px; text-shadow: 0 0 20px rgba(251, 197, 49, 0.8); }
.level-up-desc { font-size: clamp(1.2rem, 2.5vw, 1.8rem); color: var(--primary); font-weight: 600; }
#new-level-display { font-size: clamp(2rem, 3vw, 2.5rem); color: #fbc531; font-weight: 900; text-shadow: 0 0 15px rgba(251, 197, 49, 0.5); }

@keyframes levelUpPop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes pulseGlow {
    0% { filter: drop-shadow(0 0 10px rgba(251, 197, 49, 0.5)); transform: scale(1); }
    50% { filter: drop-shadow(0 0 30px rgba(251, 197, 49, 1)); transform: scale(1.1); }
    100% { filter: drop-shadow(0 0 10px rgba(251, 197, 49, 0.5)); transform: scale(1); }
}

/* =========================================
   4. PANNEAU DROIT (VERRE)
========================================= */
.glass-panel {
    flex: 1; background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border); padding: clamp(20px, 3vw, 40px); border-radius: 24px; box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4); 
    max-width: 450px; width: 100%; max-height: 95vh; overflow-y: auto; transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}
.glass-panel::-webkit-scrollbar { width: 6px; }
.glass-panel::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }

.glass-panel h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; margin-bottom: 5px; }
.sub-text { color: #94a3b8; margin-bottom: clamp(10px, 2vh, 20px); font-size: 0.9rem; }

.input-group { position: relative; margin-bottom: clamp(10px, 2vh, 20px); }
.input-group i { position: absolute; top: 50%; left: 15px; transform: translateY(-50%); color: #94a3b8; font-size: 0.9rem; }
.input-group input { width: 100%; padding: clamp(10px, 1.5vh, 15px) 15px clamp(10px, 1.5vh, 15px) 40px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--glass-border); border-radius: 12px; color: white; font-size: 0.95rem; outline: none; transition: all 0.3s ease; }
.input-group input:focus { border-color: var(--primary); background: rgba(0, 0, 0, 0.5); }

.user-welcome { display: flex; align-items: center; gap: 15px; margin-bottom: clamp(15px, 2.5vh, 25px); padding-bottom: clamp(10px, 2vh, 20px); border-bottom: 1px solid var(--glass-border); }
.avatar { width: clamp(45px, 6vh, 55px); height: clamp(45px, 6vh, 55px); display: flex; justify-content: center; align-items: center; overflow: hidden; border-radius: 50%; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.settings-box { margin-bottom: clamp(10px, 2vh, 20px); }
.settings-box label { display: block; margin-bottom: 6px; font-weight: 600; color: #cbd5e1; font-size: 0.85rem; }
.custom-select { width: 100%; padding: clamp(8px, 1.5vh, 12px) 15px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--glass-border); border-radius: 10px; color: white; font-size: 0.9rem; outline: none; cursor: pointer; transition: all 0.3s; }
.custom-select:disabled { opacity: 0.5; cursor: not-allowed; }
.custom-select option { background: var(--bg-dark); }

/* CLASSEMENT RELATIF ET AMIS */
.leaderboard-box { background: rgba(0, 0, 0, 0.4); border-radius: 12px; padding: clamp(10px, 1.5vh, 15px); margin-bottom: clamp(10px, 2vh, 20px); border: 1px solid var(--glass-border); }
.leaderboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.leaderboard-header h3 { font-size: 0.95rem; color: #fbc531; margin: 0; }

#leaderboard-list { list-style: none; padding-right: 5px; }
#leaderboard-list li { display: flex; align-items: center; padding: 6px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); gap: 10px; border-radius: 8px; transition: 0.2s; }
#leaderboard-list li:last-child { border-bottom: none; }
#leaderboard-list li.is-me { background: rgba(0, 242, 254, 0.15); border: 1px solid var(--primary); transform: scale(1.02); box-shadow: 0 4px 10px rgba(0, 242, 254, 0.2); }

.rank-badge { min-width: 25px; text-align: center; font-weight: 900; font-size: 0.8rem; color: #94a3b8; }
.rank-badge.top1 { color: #fbc531; font-size: 0.95rem; text-shadow: 0 0 10px rgba(251, 197, 49, 0.5); }

.score-name { font-weight: 600; color: #f8fafc; font-size: 0.85rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-value { font-weight: 800; color: #4cd137; font-size: 0.85rem; }

.fl-filter-btn { transition: 0.2s; opacity: 0.6; }
.fl-filter-btn.active { opacity: 1; transform: scale(1.05); box-shadow: 0 0 10px rgba(0,0,0,0.3); }

/* BOUTONS GÉNÉRAUX */
.action-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-primary { flex: 1; padding: clamp(10px, 1.5vh, 15px); background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border: none; border-radius: 12px; font-size: clamp(0.9rem, 1.5vw, 1.1rem); font-weight: 700; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 10px; transition: transform 0.2s, box-shadow 0.2s; white-space: nowrap; }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { padding: clamp(8px, 1vh, 12px) 15px; background: rgba(255, 255, 255, 0.1); color: white; border: 1px solid var(--glass-border); border-radius: 12px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.9rem; }
.btn-secondary:hover { background: rgba(231, 76, 60, 0.8); border-color: rgba(231, 76, 60, 1); }
.info-text { text-align: center; margin-top: clamp(10px, 1.5vh, 15px); font-size: 0.75rem; color: #64748b; }

@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.4); } 70% { box-shadow: 0 0 0 15px rgba(0, 242, 254, 0); } 100% { box-shadow: 0 0 0 0 rgba(0, 242, 254, 0); } }
.glow-effect { animation: glow 2s infinite; }

/* =========================================
   5. LE SALON MULTIJOUEUR (LOBBY) - RESPONSIVE
========================================= */
.main-container:has(#party-lobby-screen:not(.hidden)) .brand-panel { display: none; }
.glass-panel:has(#party-lobby-screen:not(.hidden)) { 
    max-width: 1200px; width: 95vw; height: clamp(550px, 90vh, 900px); 
    padding: clamp(15px, 3vh, 30px); display: flex; flex-direction: column; overflow: hidden; 
}

#party-lobby-screen:not(.hidden) {
    flex: 1; display: grid; gap: clamp(10px, 2vh, 15px); min-height: 0;
    grid-template-columns: 1fr 1.5fr; 
    grid-template-rows: auto auto minmax(100px, 1fr) auto; 
    grid-template-areas: 
        "header header" 
        "players players" 
        "settings chat" 
        "actions actions"; 
}

#party-lobby-screen .party-header { grid-area: header; text-align: center; border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
#party-lobby-screen .party-header h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); margin-bottom: 0; }

.room-code-container { margin: 5px 0; background: rgba(0,0,0,0.5); padding: 5px 15px; border-radius: 8px; border: 1px dashed var(--primary); display: inline-block; }

#party-lobby-screen .party-settings-box { 
    grid-area: settings; background: rgba(0, 0, 0, 0.3); border-radius: 12px; padding: clamp(10px, 2vh, 20px); 
    border: 1px solid var(--glass-border); display: flex; flex-direction: column; justify-content: center; height: 100%;
}
.setting-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: clamp(6px, 1vh, 10px); }
.setting-row:last-of-type { margin-bottom: 0; }
.setting-row label { font-size: 0.85rem; font-weight: 600; color: #cbd5e1; }
.setting-row .custom-select { width: 55%; padding: 6px 10px; font-size: 0.85rem; }

#party-lobby-screen .players-grid { 
    grid-area: players; display: grid; gap: 10px; 
    grid-template-columns: repeat(5, minmax(80px, 1fr)); 
}

.player-slot { 
    position: relative; background: rgba(0, 0, 0, 0.5); border: 1px solid var(--glass-border); 
    border-radius: 12px; padding: clamp(8px, 1.5vh, 15px) 5px; display: flex; flex-direction: column; 
    align-items: center; transition: all 0.3s; text-align: center;
}
.player-slot.empty { background: transparent; border: 2px dashed rgba(255, 255, 255, 0.2); opacity: 0.6; }
.player-slot.ready { border-color: var(--success); box-shadow: 0 0 10px rgba(46, 204, 113, 0.3); background: rgba(46, 204, 113, 0.1); transform: translateY(-2px); }

/* Avatars dans le lobby avec IMG */
.slot-avatar { width: clamp(40px, 6vh, 55px); height: clamp(40px, 6vh, 55px); display: flex; justify-content: center; align-items: center; font-size: 1.2rem; margin-bottom: 8px; position: relative; }
.slot-avatar img { width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,0.5); object-fit: cover; }
.slot-avatar svg { width: 100%; height: 100%; } 
.slot-rank-badge { position: absolute; top: -5px; right: -5px; background: linear-gradient(135deg, #fbc531, #e1b12c); color: #000; font-size: 0.6rem; font-weight: 900; padding: 2px 5px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.5); border: 1px solid #fff; z-index: 5; }

.slot-name { font-size: 0.8rem; font-weight: 700; color: white; margin-bottom: 3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.slot-status { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.status-waiting { color: var(--warning); }
.status-ready { color: var(--success); }

.kick-btn {
    position: absolute; top: 5px; left: 5px; background: var(--danger); color: white; border: none; border-radius: 50%;
    width: 20px; height: 20px; font-size: 0.6rem; cursor: pointer; display: flex; justify-content: center; align-items: center;
    opacity: 0.7; transition: all 0.2s; z-index: 10;
}
.kick-btn:hover { opacity: 1; transform: scale(1.1); box-shadow: 0 0 8px rgba(231, 76, 60, 0.8); }

#party-lobby-screen .chat-container { grid-area: chat; height: 100%; display: flex; flex-direction: column; min-height: 0; }
#party-lobby-screen .action-buttons { grid-area: actions; margin-top: 0; }

/* =========================================
   6. PAGE DE JEU & HUD
========================================= */
.game-body { overflow: hidden; background: #000; }
.game-hud { position: absolute; top: clamp(10px, 2vh, 20px); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; gap: 10px; width: 95%; max-width: 700px; pointer-events: none; }
.hud-item { pointer-events: auto; flex: 1; background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(10px); padding: 8px 12px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.1); display: flex; flex-direction: column; align-items: center; box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
.hud-item .label { font-size: clamp(0.55rem, 1vw, 0.65rem); font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; }
.hud-item .value { font-size: clamp(1.1rem, 2vw, 1.3rem); font-weight: 900; color: var(--primary); text-shadow: 0 0 10px rgba(0, 242, 254, 0.5); }

.timer-container { position: relative; overflow: hidden; }
#timer-bar { position: absolute; bottom: 0; left: 0; height: 4px; background: var(--primary); width: 100%; transition: width 1s linear; }

#pano { width: 100vw; height: 100vh; position: absolute; }

.floating-action-btn {
    position: absolute; bottom: clamp(15px, 3vh, 30px); left: clamp(15px, 3vw, 30px); width: clamp(50px, 8vh, 60px); height: clamp(50px, 8vh, 60px); border-radius: 50%;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px); border: 1px solid var(--glass-border);
    color: white; font-size: clamp(1.2rem, 2vw, 1.5rem); cursor: pointer; display: flex; justify-content: center; align-items: center;
    z-index: 100; transition: all 0.3s ease; box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}
.floating-action-btn:hover { background: rgba(0, 242, 254, 0.2); border-color: var(--primary); color: var(--primary); transform: translateY(-5px); }

/* =========================================
   7. MINI CARTE & RÉSULTATS
========================================= */
#map-container {
    position: absolute; bottom: clamp(15px, 3vh, 30px); right: clamp(15px, 3vw, 30px); width: clamp(250px, 30vw, 320px); height: clamp(180px, 25vh, 220px); 
    background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px); padding: 8px; border-radius: 12px; 
    display: flex; flex-direction: column; gap: 8px; transition: all 0.4s; z-index: 10; border: 1px solid rgba(255,255,255,0.1); 
}
#map-container:not(.fullscreen-map):hover { width: clamp(300px, 40vw, 450px); height: clamp(250px, 40vh, 350px); transform: translateY(-5px); }
#mini-map { width: 100%; height: 100%; border-radius: 8px; }
#btn-valider { padding: clamp(8px, 1.5vh, 12px); background: var(--success); color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: 800; font-size: clamp(1rem, 1.5vw, 1.2rem); text-transform: uppercase; transition: 0.2s; }
#btn-valider:hover:not(:disabled) { background: #27ae60; }
#btn-valider:disabled { background: #4b6584; cursor: not-allowed; opacity: 0.8; }
#map-container.fullscreen-map { bottom: 0; right: 0; width: 100vw; height: 100vh; padding: 0; border: none; border-radius: 0; z-index: 500; }
#map-container.fullscreen-map #mini-map { border-radius: 0; }
#map-container.fullscreen-map #btn-valider { display: none; }

#result-modal { position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; background: transparent; z-index: 1000; display: flex; align-items: center; pointer-events: none; padding-left: 20px; }
.modal-content { pointer-events: auto; background: rgba(15, 23, 42, 0.9); backdrop-filter: blur(15px); border: 1px solid var(--glass-border); border-radius: 20px; padding: clamp(20px, 3vh, 30px); width: clamp(300px, 90vw, 350px); max-height: 95vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,0.8); text-align: center; animation: slideInLeft 0.5s; overflow-y: auto; }
@keyframes slideInLeft { from { transform: translateX(-120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.modal-content h2 { font-size: clamp(1.4rem, 2.5vw, 1.8rem); color: #fbc531; margin-bottom: 15px; }
.result-stats { display: flex; flex-direction: column; align-items: center; margin: 10px 0; flex-shrink: 0; }
.stat-circle { width: clamp(80px, 15vh, 110px); height: clamp(80px, 15vh, 110px); border: 5px solid var(--primary); border-radius: 50%; display: flex; flex-direction: column; justify-content: center; align-items: center; margin-bottom: 10px; background: rgba(0,0,0,0.4); }
.stat-circle span { font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 900; color: white; line-height: 1; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
.stat-circle label { font-size: 0.7rem; color: #94a3b8; text-transform: uppercase; margin-top: 5px; }

/* =========================================
   8. TOASTS & CHAT COMMUN
========================================= */
/* ===== FIX #2 & #3 : Écran d'attente amélioré avec animation ===== */
#waiting-screen { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(15, 23, 42, 0.97); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    z-index: 2000; display: flex; justify-content: center; align-items: center; 
    animation: fadeInWaiting 0.3s ease-out;
}
@keyframes fadeInWaiting { 
    from { opacity: 0; } 
    to { opacity: 1; } 
}

.waiting-content { 
    text-align: center; padding: 30px 40px; border-radius: 20px; min-width: 300px; 
    max-width: 450px; animation: waitingPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes waitingPop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.waiting-content h2 { 
    font-size: 1.5rem; color: var(--primary); margin-bottom: 10px; 
    text-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
}
.waiting-content p { 
    color: #cbd5e1; font-size: 0.95rem; line-height: 1.5; 
}

.loader { border: 5px solid rgba(255, 255, 255, 0.1); border-top: 5px solid var(--primary); border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin: 0 auto 15px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Liste des joueurs dans l'écran d'attente (optionnelle, pour plus tard) */
.waiting-players-list {
    margin-top: 20px; display: flex; flex-direction: column; gap: 8px;
    max-height: 200px; overflow-y: auto; padding: 0 5px;
}
.waiting-players-list::-webkit-scrollbar { width: 4px; }
.waiting-players-list::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }

.waiting-player-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; background: rgba(0, 0, 0, 0.3); border-radius: 10px;
    border: 1px solid var(--glass-border); gap: 10px;
}
.waiting-player-item.done { border-color: var(--success); background: rgba(46, 204, 113, 0.1); }
.waiting-player-item.done .waiting-status { color: var(--success); }
.waiting-player-name { font-size: 0.85rem; font-weight: 700; color: white; flex: 1; text-align: left; }
.waiting-status { font-size: 0.75rem; font-weight: 800; color: var(--warning); text-transform: uppercase; }

#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: rgba(15, 23, 42, 0.9); backdrop-filter: blur(10px); border: 1px solid var(--glass-border); color: white; padding: 12px 15px; border-radius: 8px; border-left: 5px solid var(--primary); box-shadow: 0 10px 30px rgba(0,0,0,0.5); display: flex; align-items: center; gap: 12px; min-width: 220px; animation: slideInRight 0.4s ease-out forwards; }
.toast.success { border-left-color: var(--success); } .toast.danger { border-left-color: var(--danger); } .toast.warning { border-left-color: var(--warning); }
.toast i { font-size: 1.3rem; } .toast.success i { color: var(--success); } .toast.danger i { color: var(--danger); } .toast.warning i { color: var(--warning); }
.toast-content { display: flex; flex-direction: column; } .toast-title { font-weight: 700; font-size: 0.85rem; } .toast-msg { font-size: 0.75rem; color: #cbd5e1; }
@keyframes slideInRight { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.fade-out { animation: fadeOutRight 0.4s ease-in forwards; }
@keyframes fadeOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }

.chat-container { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--glass-border); border-radius: 12px; padding: clamp(10px, 1.5vh, 15px); display: flex; flex-direction: column; gap: 10px; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 5px; font-size: 0.85rem; scroll-behavior: smooth; }
.chat-msg { max-width: 85%; padding: 8px 12px; border-radius: 10px; word-wrap: break-word; line-height: 1.4; }
.chat-msg.system { align-self: center; background: transparent; color: var(--warning); font-size: 0.75rem; font-style: italic; padding: 4px; }
.chat-msg.others { align-self: flex-start; background: rgba(255, 255, 255, 0.1); color: white; border-bottom-left-radius: 2px; }
.chat-msg.me { align-self: flex-end; background: var(--primary); color: #0f172a; font-weight: 600; border-bottom-right-radius: 2px; }
.chat-sender { display: block; font-size: 0.65rem; font-weight: 800; margin-bottom: 2px; text-transform: uppercase; }
.chat-msg.me .chat-sender { display: none; }
.chat-input-area { display: flex; gap: 8px; margin-top: 5px; flex-shrink: 0; }
.chat-input-area input { flex: 1; padding: 10px 12px; background: rgba(0, 0, 0, 0.5); border: 1px solid var(--glass-border); border-radius: 10px; color: white; outline: none; font-size: 0.9rem; }
.chat-input-area button { padding: 8px 15px; background: var(--primary); color: #0f172a; border: none; border-radius: 10px; cursor: pointer; font-size: 1rem; }

/* =========================================
   9. SYSTÈME D'AMIS & SOCIAL
========================================= */
.floating-social-btn {
    position: fixed; bottom: clamp(15px, 3vh, 30px); right: clamp(15px, 3vw, 30px); z-index: 1000;
    width: clamp(50px, 8vh, 60px); height: clamp(50px, 8vh, 60px); border-radius: 50%;
    background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(10px);
    border: 1px solid var(--primary); color: var(--primary);
    font-size: clamp(1.2rem, 2vw, 1.5rem); cursor: pointer; display: flex; justify-content: center; align-items: center;
    box-shadow: 0 5px 15px rgba(0, 242, 254, 0.3); transition: all 0.3s;
}
.floating-social-btn:hover { background: var(--primary); color: #0f172a; transform: translateY(-5px) scale(1.05); }
.badge-dot { position: absolute; top: 0; right: 0; width: 12px; height: 12px; background: var(--danger); border-radius: 50%; border: 2px solid #0f172a; }

.friends-side-panel {
    position: fixed; top: 0; right: -350px; width: 100%; max-width: 350px; height: 100vh;
    background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border); z-index: 1001; transition: right 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,0.5);
}
.friends-side-panel.open { right: 0; }

.fs-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 15px 15px; border-bottom: 1px solid var(--glass-border); }
.fs-header h3 { font-size: 1.1rem; color: white; display: flex; align-items: center; gap: 10px; }
.fs-header h3 i { color: var(--primary); }
#btn-close-friends { background: transparent; border: none; color: #94a3b8; font-size: 1.3rem; cursor: pointer; transition: 0.2s; }
#btn-close-friends:hover { color: var(--danger); transform: scale(1.1); }

.fs-tabs { display: flex; border-bottom: 1px solid var(--glass-border); background: rgba(0,0,0,0.2); }
.fs-tab-btn { flex: 1; padding: 12px 0; background: transparent; border: none; color: #94a3b8; font-weight: 600; font-size: 0.85rem; cursor: pointer; transition: 0.3s; position: relative; }
.fs-tab-btn:hover { color: white; background: rgba(255,255,255,0.05); }
.fs-tab-btn.active { color: var(--primary); }
.fs-tab-btn.active::after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 3px; background: var(--primary); }
.fs-tab-btn .badge { background: var(--danger); color: white; padding: 2px 6px; border-radius: 10px; font-size: 0.65rem; margin-left: 5px; }

.fs-content { flex: 1; padding: 15px; overflow-y: auto; }
.fs-content::-webkit-scrollbar { width: 4px; }
.fs-content::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }

.friends-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.friend-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 10px; transition: 0.2s; }
.friend-item:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }

.friend-info { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.friend-avatar { width: 35px; height: 35px; display: flex; justify-content: center; align-items: center; position: relative; border-radius: 50%; flex-shrink: 0; }
.friend-avatar img { width: 100%; height: 100%; border-radius: 50%; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); object-fit: cover; }
.status-dot { position: absolute; bottom: 0; right: 0; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #0f172a; z-index: 5;}
.status-dot.online { background: var(--success); box-shadow: 0 0 5px var(--success); }
.status-dot.offline { background: #64748b; }

.friend-name { font-size: 0.85rem; font-weight: 700; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-status-text { font-size: 0.65rem; color: #94a3b8; }

.friend-actions { display: flex; gap: 5px; flex-shrink: 0; }
.fa-btn { width: 28px; height: 28px; border-radius: 6px; border: none; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 0.8rem; transition: 0.2s; color: white; background: rgba(255,255,255,0.1); }
.fa-btn:hover { transform: scale(1.1); }
.fa-btn.msg { background: rgba(0, 242, 254, 0.2); color: var(--primary); }
.fa-btn.msg:hover { background: var(--primary); color: #0f172a; }
.fa-btn.invite { background: rgba(46, 204, 113, 0.2); color: var(--success); }
.fa-btn.invite:hover { background: var(--success); color: white; }
.fa-btn.accept { background: var(--success); color: white; }
.fa-btn.decline { background: var(--danger); color: white; }

.private-chat-box {
    position: fixed; bottom: 100px; right: clamp(15px, 3vw, 30px); width: clamp(280px, 90vw, 320px); height: clamp(300px, 50vh, 400px);
    background: rgba(15, 23, 42, 0.98); border: 1px solid var(--glass-border); border-radius: 16px;
    z-index: 990; display: flex; flex-direction: column; box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popUp { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }

.pc-header { padding: 12px 15px; border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center; background: rgba(0, 242, 254, 0.1); border-top-left-radius: 16px; border-top-right-radius: 16px; color: var(--primary); }
#btn-close-pc { background: transparent; border: none; color: white; cursor: pointer; font-size: 1.1rem; transition: 0.2s; }
#btn-close-pc:hover { color: var(--danger); transform: scale(1.1); }

.pc-messages { flex: 1; padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.pc-messages::-webkit-scrollbar { width: 4px; }
.pc-messages::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }

.pc-input { padding: 10px; border-top: 1px solid var(--glass-border); display: flex; gap: 8px; }
.pc-input input { flex: 1; padding: 8px 12px; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 20px; color: white; outline: none; font-size: 0.85rem; }
.pc-input button { width: 35px; height: 35px; border-radius: 50%; background: var(--primary); border: none; color: #0f172a; cursor: pointer; display: flex; justify-content: center; align-items: center; transition: 0.2s; flex-shrink: 0; }
.pc-input button:hover { transform: scale(1.1); }

/* =========================================
   10. SALONS PUBLICS (NAVIGATEUR)
========================================= */
.lobby-badge {
    background: rgba(0, 242, 254, 0.2); color: var(--primary); border: 1px solid var(--primary);
    padding: 2px 6px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; margin-right: 4px; display: inline-block; margin-bottom: 4px;
}
.lobby-badge.full { background: rgba(231, 76, 60, 0.2); color: var(--danger); border-color: var(--danger); }

/* =========================================
   11. MEDIA QUERIES (ÉCRANS PC PORTABLE / MAC)
========================================= */
@media (max-width: 1024px), (max-height: 800px) {
    .main-container { max-width: 900px; gap: 20px; }
    .glass-panel { padding: 20px; }
    .glass-panel:has(#party-lobby-screen:not(.hidden)) { padding: 15px; }
    #party-lobby-screen { gap: 10px; }
    .party-settings-box { padding: 10px; }
    .player-slot { padding: 10px 5px; }
    .action-buttons { flex-direction: row; }
}

@media (max-width: 768px) {
    /* Cache le widget XP sur mobile pour faire de la place ou le met en haut au milieu */
    .xp-widget { top: 10px; left: 50%; transform: translateX(-50%); width: auto; padding: 8px 10px; }
    .xp-widget:hover { transform: translate(-50%, -3px); }

    .main-container { flex-direction: column; width: 95%; margin: 80px auto 20px auto; gap: 20px; }
    .brand-panel { text-align: center; display: flex; flex-direction: column; align-items: center; }
    .logo-container { justify-content: center; }
    .glass-panel { max-width: 100%; width: 100%; }
    .glass-panel:has(#party-lobby-screen:not(.hidden)) { height: auto; min-height: 80vh; }
    
    #party-lobby-screen:not(.hidden) {
        grid-template-columns: 1fr;
        grid-template-areas: 
            "header" 
            "players" 
            "settings" 
            "chat" 
            "actions";
    }
    #party-lobby-screen .players-grid { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); }
}