:root {
    --bg-color: #0d0d0d;
    --primary: #ff8c00; 
    --text: #ffa500; 
    --card-width: 100px;
    --card-height: 150px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body { background-color: var(--bg-color); color: var(--text); overflow: hidden; }
.screen { display: none; width: 100vw; height: 100vh; }
.screen.active { display: flex; }

.glow { text-shadow: 0 0 10px var(--primary), 0 0 20px var(--primary); color: var(--primary); font-weight: bold; }

/* ACCUEIL & MENU & LOBBY */
#welcome-screen, #menu-screen, #lobby-screen { justify-content: center; align-items: center; background: radial-gradient(circle, #1a1510 0%, #0d0d0d 100%);}
.welcome-container { display: flex; flex-direction: column; align-items: center; gap: 60px; }

/* Disposition Titre et Carte */
.title-container { display: flex; flex-direction: column; align-items: center; gap: 40px; }

/* Titre Flottant */
.big-title { 
    font-size: 5.5rem; margin: 0; letter-spacing: 2px; 
    animation: floatTitle 4s ease-in-out infinite; 
    transform-origin: center;
}
@keyframes floatTitle {
    0%, 100% { transform: translateY(0px) rotate(-1deg); }
    50% { transform: translateY(-15px) rotate(1deg); text-shadow: 0 0 25px var(--primary), 0 0 40px var(--primary); }
}

/* Carte Tournante 3D Organique */
.spinning-card { 
    width: 120px; 
    height: 180px; 
    perspective: 1200px; 
    animation: floatOrganic 6s ease-in-out infinite; 
}
.card-inner { 
    width: 100%; height: 100%; 
    position: relative; 
    transform-style: preserve-3d; 
    animation: spinY 5s linear infinite; 
}
.card-face { 
    position: absolute; width: 100%; height: 100%; 
    backface-visibility: hidden; 
    background-image: url('assets/cards/uno_card.png'); 
    background-size: cover; border-radius: 8px; 
    box-shadow: 0 0 20px rgba(255,140,0,0.5); 
    border: 2px solid #fff;
}
/* La deuxième face retournée de 180° pour ne jamais être en miroir */
.card-back-3d { transform: rotateY(180deg); }

@keyframes floatOrganic {
    0%, 100% { transform: translateY(0px) rotateX(15deg) rotateZ(5deg); }
    50% { transform: translateY(-25px) rotateX(-5deg) rotateZ(-5deg); }
}
@keyframes spinY {
    from { transform: rotateY(0deg); } 
    to { transform: rotateY(360deg); } 
}

/* Bouton JOUER "Outline" */
.btn-lobby.btn-huge { 
    padding: 15px 70px; 
    font-size: 2.2rem; 
    border-radius: 12px; 
    background: transparent;
    border: 3px solid var(--primary);
    color: #fff;
    box-shadow: none;
    transition: all 0.3s ease;
}
.btn-lobby.btn-huge:hover { 
    background: transparent; 
    box-shadow: 0 0 30px var(--primary), inset 0 0 15px var(--primary); 
    transform: scale(1.05); 
    text-shadow: 0 0 10px #fff;
}

/* MENU CONFIGURATION */
.menu-container { background: #1a1a1a; padding: 30px; border-radius: 12px; box-shadow: 0 0 20px rgba(255, 140, 0, 0.2); width: 400px; text-align: center; border: 1px solid #331f00; }
.menu-container h1 { margin-bottom: 20px; font-size: 2.5rem; }
.form-group { margin-bottom: 20px; text-align: left; }
.form-group label { display: block; margin-bottom: 8px; font-weight: bold; }
input[type="text"] { width: 100%; padding: 10px; border-radius: 6px; border: 1px solid var(--primary); outline: none; background: #0d0d0d; color: var(--text); }
.avatar-selection { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.avatar-option { width: 100px; height: 100px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: transform 0.2s; }
.avatar-option:hover { transform: scale(1.1); }
.avatar-option.selected { border-color: var(--primary); box-shadow: 0 0 15px var(--primary); }
.lobby-buttons { display: flex; justify-content: space-between; gap: 10px; }
.btn-lobby { flex: 1; padding: 10px; background: var(--primary); color: #000; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; transition: all 0.2s; text-transform: uppercase; letter-spacing: 1px;}
.btn-lobby:hover { background: #ffaa33; box-shadow: 0 0 10px var(--primary); transform: scale(1.05);}
#connection-status { margin-top: 15px; font-style: italic; color: #ffaa33; }

/* Liste des joueurs (Salle d'attente) */
.lobby-players { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; max-height: 300px; overflow-y: auto; text-align: left;}
.lobby-player-item { display: flex; align-items: center; gap: 15px; background: rgba(0,0,0,0.6); padding: 10px 15px; border-radius: 8px; border: 1px solid #444; }
.lobby-player-item img { width: 45px; height: 45px; border-radius: 50%; border: 2px solid var(--primary); object-fit: cover; }
.lobby-player-item span { font-weight: bold; font-size: 1.1rem; color: #fff;}

/* JEU */
#game-screen { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(circle, #1a1510 0%, #0d0d0d 100%); }
#turn-indicator { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); padding: 10px 20px; border-radius: 20px; font-size: 1.2rem; z-index: 100; border: 1px solid var(--primary);}

/* Conteneur des adversaires */
#opponents-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }
.opponent { position: absolute; pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 5px; opacity: 0.6; transition: all 0.3s; transform: translate(-50%, -50%) scale(1); }
.opponent.active-turn { opacity: 1; transform: translate(-50%, -50%) scale(1.15); filter: drop-shadow(0 0 15px var(--primary)); }
.opponent img { width: 120px; height: 120px; border-radius: 50%; border: 3px solid var(--primary); object-fit: cover;}

/* Badge UNO Protégé */
.uno-protected-badge { position: absolute; top: 5px; right: -10px; background: #e63946; color: #fff; padding: 4px 10px; border-radius: 8px; font-weight: bold; font-size: 1.1rem; box-shadow: 0 0 15px #e63946; transform: rotate(15deg); z-index: 10; border: 2px solid #fff; animation: popBadge 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popBadge { 0% { transform: scale(0) rotate(0deg); } 100% { transform: scale(1) rotate(15deg); } }

.opponent-info { display: flex; align-items: center; gap: 5px; flex-direction: column; margin-top: -5px;}
.opponent-info span { font-size: 1rem; background: rgba(0,0,0,0.8); padding: 2px 10px; border-radius: 10px; color: var(--text); border: 1px solid #444;}

/* Mini Cartes des adversaires */
.opponent-hand { display: flex; justify-content: center; margin-top: 5px; }
.mini-card { width: 35px; height: 53px; background-image: url('assets/cards/uno_card.png'); background-size: cover; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.8); border: 1px solid rgba(255,255,255,0.1); margin-left: -20px; }
.mini-card:first-child { margin-left: 0; }

.btn-uno { background: var(--primary); color: #000; border: none; border-radius: 4px; padding: 4px 12px; font-weight: bold; cursor: pointer; box-shadow: 0 0 10px rgba(255,140,0,0.5); transition: background-color 0.3s; }
.btn-uno:active { transform: scale(0.95); }
.btn-uno:disabled { background: #444; color: #777; box-shadow: none; cursor: not-allowed; opacity: 0.5; }

/* Table */
.table-center { display: flex; justify-content: center; align-items: center; gap: 50px; z-index: 5; margin-bottom: 100px; }
.deck, .discard-pile { width: var(--card-width); height: var(--card-height); position: relative; perspective: 1000px; }
.card-back { width: 100%; height: 100%; background-image: url('assets/cards/uno_card.png'); background-size: 100% 100%; border-radius: 8px; box-shadow: 0 4px 15px rgba(255, 140, 0, 0.2); cursor: pointer; transition: transform 0.2s; }
.deck .card-back:hover { transform: translateY(-5px); box-shadow: 0 4px 20px rgba(255, 140, 0, 0.4); }

.card { width: var(--card-width); height: var(--card-height); background-size: cover; background-position: center; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.8); transition: transform 0.3s; transform-origin: bottom center; }
.discard-pile-container { position: relative; }
.color-indicator { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; display: none; box-shadow: 0 0 10px rgba(255,255,255,0.5);}

/* Joueur */
.player-area { position: absolute; bottom: 0; width: 100%; display: flex; flex-direction: column; align-items: center; padding-bottom: 20px; z-index: 20;}
.player-info { display: flex; align-items: center; gap: 15px; margin-bottom: 10px; background: rgba(0,0,0,0.8); padding: 10px 20px; border-radius: 30px; transition: all 0.3s; border: 1px solid transparent;}
.player-info.active-turn { box-shadow: 0 0 15px var(--primary); border-color: var(--primary); }
.player-info img { width: 80px; height: 80px; border-radius: 50%; border: 2px solid var(--primary); object-fit: cover;}

.hand { display: flex; justify-content: center; gap: -40px; perspective: 1000px; max-width: 90vw; overflow-x: auto; padding: 20px 0; -ms-overflow-style: none; scrollbar-width: none; }
.hand::-webkit-scrollbar { display: none; }
.hand .card { margin-left: -40px; position: relative; cursor: pointer; }
.hand .card:first-child { margin-left: 0; }
.hand .card:hover { transform: translateY(-30px) rotateY(5deg) scale(1.1); z-index: 10; }

/* Modale */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.9); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: #1a1a1a; padding: 30px; border-radius: 10px; text-align: center; border: 1px solid var(--primary); box-shadow: 0 0 30px rgba(255,140,0,0.3);}
.modal-content h3 { margin-bottom: 20px; font-size: 1.5rem;}
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.color-btn { width: 80px; height: 80px; border: 2px solid transparent; border-radius: 8px; cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.5); transition: all 0.1s;}
.color-btn:hover { border-color: #fff; transform: scale(1.1);}
.color-btn:active { transform: scale(0.95); }

.flying-card { pointer-events: none; }

/* FEEDBACKS */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: rgba(0,0,0,0.9); border: 1px solid var(--primary); color: var(--text); padding: 12px 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(255,140,0,0.5); animation: fadein 0.3s, fadeout 0.3s 2.7s forwards; font-weight: bold; }

@keyframes fadein { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeout { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(20px); } }

#big-message-overlay, #end-screen { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; display: flex; justify-content: center; align-items: center; z-index: 3000; opacity: 0; transition: opacity 0.3s; background: rgba(0,0,0,0.85); }
#big-message-overlay.show, #end-screen.show { opacity: 1; pointer-events: auto; }
.big-message-content { background: radial-gradient(circle, #2a1a00 0%, #000 100%); border: 2px solid var(--primary); padding: 50px 80px; border-radius: 20px; text-align: center; box-shadow: 0 0 50px var(--primary); display: flex; flex-direction: column; align-items: center; gap: 20px; transform: scale(0.8); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
#big-message-overlay.show .big-message-content, #end-screen.show .big-message-content { transform: scale(1); }
.big-message-content img { width: 140px; height: 140px; border-radius: 50%; border: 4px solid var(--primary); box-shadow: 0 0 20px var(--primary); object-fit: cover; }
.big-message-content h2 { font-size: 4rem; text-transform: uppercase; margin: 0; }
.big-message-content p { font-size: 1.5rem; color: #fff; margin: 0; font-weight: bold;}