/**
 * UNDERCOVER GAME - Custom CSS
 * Design custom pour le plateau de jeu
 */

/* ==================== ANIMATIONS ==================== */

/* Renamed to game-pulse to avoid conflicts and ensure specificity */
@keyframes game-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

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

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

@keyframes countUp {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Renamed to game-glow */
@keyframes game-glow {
    0%, 100% { box-shadow: 0 0 5px var(--primary), 0 0 10px var(--primary); }
    50% { box-shadow: 0 0 10px var(--primary), 0 0 20px var(--primary), 0 0 30px var(--primary); }
}

/* ==================== PLATEAU DE JEU ==================== */

.word-display {
    font-size: 3rem;
    font-weight: bold;
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border-radius: 1rem;
    margin: 2rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.5s ease-out;
    transition: all 0.3s ease;
}

.word-display:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

/* ==================== GRILLE DE JOUEURS ==================== */

.player-grid {
    display: grid;
    /* Limite la largeur max à 250px pour éviter l'étirement excessif sur tablettes */
    /* Sur grands écrans (>1000px), cela donne 4+ colonnes bien proportionnées */
    grid-template-columns: repeat(auto-fit, minmax(180px, 250px));
    gap: 1.5rem;
    padding: 1rem 0;
    justify-content: center; /* Centre les tuiles */
}

.player-tile {
    text-align: center;
    padding: 1.5rem;
    border: 2px solid var(--card-border-color);
    border-radius: 1rem;
    background: var(--card-background-color);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.player-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.player-tile:hover::before {
    opacity: 1;
}

.player-tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    border-color: var(--primary);
}

.player-tile.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--card-background-color) 0%, rgba(var(--primary-rgb), 0.1) 100%);
    animation: game-pulse 2s ease-in-out infinite !important; /* Force animation */
}

.player-tile.selected {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.2);
    box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.3);
}

.player-tile.dead {
    opacity: 0.4;
    filter: grayscale(100%);
    cursor: not-allowed;
    animation: fadeOut 1s ease-out;
}

.player-tile.eliminated {
    animation: shake 0.5s ease-in-out, fadeOut 1s ease-out 0.5s;
}

/* ==================== AVATARS ==================== */

.player-avatar-big {
    max-width: 90px; /* Taille maximale de l'avatar */
    width: 100%; /* S'adapte à la largeur disponible (moins le padding) */
    aspect-ratio: 1 / 1; /* Force l'avatar à rester carré */
    object-fit: cover; /* S'assure que l'image couvre l'espace sans déformation */
    border-radius: 8px;
    margin: 0 auto 1rem;
    border: 3px solid var(--card-border-color);
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.player-tile:hover .player-avatar-big {
    transform: scale(1.1);
    border-color: var(--primary);
}

.player-tile.active .player-avatar-big {
    border-color: var(--primary);
    animation: game-glow 2s ease-in-out infinite !important; /* Force animation */
}

/* ==================== VOTES ==================== */

.vote-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    animation: countUp 0.3s ease-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.vote-progress {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--card-background-color);
    border-radius: 0.5rem;
    border: 1px solid var(--card-border-color);
}

.vote-progress progress {
    width: 100%;
    height: 30px;
    border-radius: 15px;
}

.vote-progress-text {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
}

/* ==================== CHAT ==================== */

#chatLog {
    max-height: 400px;
    overflow-y: auto;
    background: var(--card-background-color);
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--card-border-color);
    scroll-behavior: smooth;
}

.chat-message {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    animation: slideIn 0.3s ease-out;
}

.chat-message strong {
    color: var(--primary);
    margin-right: 0.5rem;
}

/* ==================== MODALES ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--card-background-color);
    padding: 2rem;
    border-radius: 1rem;
    max-width: 600px;
    width: 90%;
    animation: slideIn 0.5s ease-out;
    border: 2px solid var(--primary);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-warning {
    text-align: center;
    color: white;
    padding: 2rem;
    max-width: 600px;
}

.modal-warning h1 {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: game-pulse 1s ease-in-out infinite !important; /* Force animation */
}

.modal-warning h2 {
    font-size: 2rem;
    margin: 1rem 0;
    color: #ff6b6b;
}

/* ==================== TOUR ACTUEL ==================== */

.current-turn-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    padding: 1.5rem;
    border-radius: 0.5rem;
    text-align: center;
    margin-bottom: 2rem;
    animation: slideIn 0.5s ease-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.current-turn-banner h2 {
    margin: 0;
    color: white;
    font-size: 1.8rem;
}

/* ==================== PHASES ==================== */

.phase-transition {
    animation: fadeIn 0.5s ease-out;
}

.phase-header {
    text-align: center;
    padding: 2rem 0;
    animation: slideIn 0.5s ease-out;
}

.phase-header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==================== VICTOIRE ==================== */

.victory-screen {
    text-align: center;
    padding: 3rem;
    animation: slideIn 0.8s ease-out;
}

.victory-screen h1 {
    font-size: 4rem;
    margin-bottom: 2rem;
    animation: game-pulse 2s ease-in-out infinite !important; /* Force animation */
}

.victory-team {
    display: inline-block;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border-radius: 2rem;
    font-size: 2rem;
    font-weight: bold;
    color: white;
    margin: 1rem 0;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.player-result {
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 0.5rem;
    background: var(--card-background-color);
    border: 2px solid var(--card-border-color);
    transition: all 0.3s ease;
}

.player-result.winner {
    border-color: #4caf50;
    background: rgba(76, 175, 80, 0.1);
}

.player-result.loser {
    border-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
    .word-display {
        font-size: 2rem;
        padding: 1.5rem;
    }

    .player-grid {
        /* FORCE 2 colonnes exactement, avec largeur max 250px pour éviter l'étirement */
        grid-template-columns: repeat(2, minmax(150px, 250px));
        gap: 1rem;
        justify-content: center; /* Centre les tuiles */
    }

    .player-avatar-big {
        width: 70px;
        height: 70px;
    }

    .modal-warning h1 {
        font-size: 3rem;
    }

    .modal-warning h2 {
        font-size: 1.5rem;
    }

    .victory-screen h1 {
        font-size: 3rem;
    }
}

/* ==================== UTILITAIRES ==================== */

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* ==================== COULEURS PRIMAIRES (Variables CSS) ==================== */

:root {
    --primary-rgb: 52, 152, 219; /* Pour les effets rgba */
}

/* ==================== BOUTONS AMÉLIORÉS ==================== */

button:not(.outline) {
    transition: all 0.3s ease;
}

button:not(.outline):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

button:not(.outline):active {
    transform: translateY(0);
}

button.primary {
    background: var(--primary);
    font-size: 1.5rem;
    padding: 1rem 3rem;
}

button.secondary {
    margin-top: 1rem;
}

/* ==================== LOBBY - STATS LEGEND ==================== */

.stats-legend {
    color: #7f8c8d;
    margin: 0.3rem 0 0.8rem 0;
    font-size: 0.75rem; /* Mobile par défaut */
}

@media (min-width: 768px) {
    .stats-legend {
        font-size: 0.95rem; /* PC/Tablette */
    }
}

/* ==================== MODALES "PASS DEVICE" (Harmonisation) ==================== */
.modal-pass-device-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 12, 16, 0.95); /* Optimisé Firefox : rgba plus opaque au lieu de backdrop-filter */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease-out;
    padding: 1rem; /* Marge de sécurité mobile */
}

.modal-pass-device-card {
    background: linear-gradient(145deg, rgba(30, 34, 45, 0.95), rgba(15, 17, 25, 0.98));
    border: 1px solid rgba(52, 152, 219, 0.3);
    border-radius: 1.5rem;
    padding: 2.5rem 2rem;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Effet rebond à l'ouverture */
    position: relative;
    overflow: hidden;
}

/* Effet de brillance discret sur la carte */
.modal-pass-device-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(52, 152, 219, 0.05) 0%, transparent 60%);
    pointer-events: none;
}

.modal-pass-device-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(52, 152, 219, 0.4));
}

.modal-pass-device-title {
    font-size: 1.1rem;
    color: #95a5a6;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
}

.modal-pass-device-name {
    font-size: 2.2rem;
    font-weight: 900;
    margin: 1rem 0 2rem 0;
    background: linear-gradient(135deg, #3498db 0%, #9b59b6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    padding-bottom: 0.2rem; /* Pour éviter de couper les jambages */
}

.modal-pass-device-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 0.75rem;
    background: linear-gradient(90deg, #3498db, #2980b9);
    border: none;
    color: white;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.modal-pass-device-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.5);
}

.modal-pass-device-btn:active {
    transform: translateY(0);
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(2deg); }
}