/* --- VARIABLES GLOBALS --- */
:root {
    --bg-color: #0f0a1d;
    --card-bg: #1a1429;
    --input-bg: #251d3a;
    --text-color: #ffffff;
    --accent-cyan: #00e5ff;
    --accent-purple: #9d50bb;
    --green: #2ecc71;
    --red: #e74c3c;
    --gradient: linear-gradient(90deg, #9d50bb 0%, #6e48aa 50%, #00e5ff 100%);
}

/* --- RESET I BASE --- */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Roboto, sans-serif;
    display: flex;
    justify-content: center;
    padding: 20px;
    margin: 0;
}

.main-container, .card {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

/* --- LOGO I SUBTÍTOLS --- */
.logo-text {
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 0;
    background: linear-gradient(to bottom, #fff 40%, #a29bfe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 0.8rem;
    letter-spacing: 4px;
    color: #888;
    margin: 5px 0 25px 0;
    text-transform: uppercase;
}

/* --- TARGETES I CONTENIDORS --- */
.card-input, .targeta, .how-to-play, .card {
    background: var(--card-bg);
    border: 1px solid #332a4d;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 15px;
    text-align: left;
    box-sizing: border-box;
}

.card-input label {
    display: block;
    font-size: 0.75rem;
    font-weight: bold;
    color: #aaa;
    margin-bottom: 10px;
    letter-spacing: 1.5px;
}

/* --- INPUTS UNIFICATS (ESTIL CODI) --- */
input[type="text"], select, #select-categoria {
    width: 100%;
    height: 54px;
    background: var(--input-bg);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-align: center;
    box-sizing: border-box;
    outline: none;
    margin-bottom: 10px;
}

input::placeholder {
    color: rgba(255, 255, 255, 0.2);
    text-transform: none;
    letter-spacing: normal;
}

#codi-sala {
    letter-spacing: 8px;
    font-weight: 900;
}

/* --- BOTONS --- */
button {
    width: 100%;
    height: 54px;
    border: none;
    border-radius: 12px;
    font-weight: 900;
    font-size: 1rem;
    cursor: pointer;
    text-transform: uppercase;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin-top: 10px;
}

/* Botó Principal (Crear) */
.btn-crear {
    background: var(--gradient);
    color: #000;
    box-shadow: 0 0 20px rgba(157, 80, 187, 0.3);
}

/* Botó Secundari (Entrar / Altres) */
.btn-entrar, button.accent {
    background: var(--accent-cyan);
    color: #000;
}

button.secondary {
    background: #332a4d;
    color: white;
}

button:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

button:active {
    transform: scale(0.96);
}

/* --- CONTENIDOR MIXT (INPUT + BOTÓ) --- */
.input-with-button {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.input-with-button input { margin-bottom: 0; flex: 1; }
.input-with-button button { margin-top: 0; width: 110px; }

/* --- DIVISOR --- */
.divider {
    position: relative;
    margin: 30px 0;
    border-bottom: 1px solid #332a4d;
}

.divider span {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-color);
    padding: 0 15px;
    color: #555;
    font-size: 0.8rem;
}

/* --- ELEMENTS DE JOC --- */
.hidden { display: none; }

.rol-revelat {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 20px 0;
    padding: 15px;
    background: var(--input-bg);
    border-radius: 12px;
    text-align: center;
}

.impostor { color: var(--red); border: 2px solid var(--red); }
.ciutada { color: var(--green); border: 2px solid var(--green); }

.jugador-item {
    padding: 15px;
    border-bottom: 1px solid #332a4d;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- CARTA GIRATÒRIA --- */
.flip-card {
    background-color: transparent;
    width: 280px;
    height: 350px;
    perspective: 1000px;
    margin: 20px auto;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    cursor: pointer;
}

.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 20px;
    border: 4px solid var(--accent-purple);
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

.flip-card-front { background-color: var(--card-bg); color: white; }
.flip-card-back { background-color: #251d3a; color: white; transform: rotateY(180deg); }

/* --- ALERTES I ANIMACIONS --- */
.alerta-empat {
    background: #f39c12;
    color: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: bold;
    text-align: center;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

.animacio-reset {
    animation: spinNovaPartida 1.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards !important;
}

@keyframes spinNovaPartida {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(720deg); }
}

/* --- LLISTA INSTRUCCIONS --- */
.how-to-play ul { padding-left: 20px; }
.how-to-play li {
    font-size: 0.85rem;
    color: #bbb;
    margin-bottom: 10px;
}
.how-to-play li::before {
    content: "•";
    color: var(--accent-cyan);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

.eliminat { opacity: 0.5; pointer-events: none; }

.mode-espectador {
    filter: grayscale(0.8);
    pointer-events: none; /* No poden clicar botons */
    opacity: 0.7;
}

.mode-espectador::before {
    content: "👀 ESTÀS OBSERVANT";
    display: block;
    background: #000;
    color: #fff;
    padding: 10px;
    font-weight: bold;
    text-align: center;
    border-radius: 10px;
    margin-bottom: 20px;
}

.nom-eliminat {
    color: var(--red);
    text-decoration: line-through;
}

/* --- CONTENIDOR DE RESULTATS DE VOTACIÓ --- */
/* --- FINESTRA EMERGENT DE RESULTATS --- */
#resultat-votacio {
    display: none; 
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 320px;
    background-color: var(--card-bg); /* Utilitza el teu lila fosc */
    border: 2px solid var(--accent-cyan); /* Vora neó */
    border-radius: 20px;
    padding: 30px 20px;
    z-index: 2000;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 229, 255, 0.2);
    animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* El text on es diu qui ha mort o qui guanya */
#text-resultat {
    color: var(--text-color);
    line-height: 1.4;
    margin-bottom: 20px;
}

/* El botó de Nova Partida (quan aparegui) */
#btnNovaPartida {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 50px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(157, 80, 187, 0.4);
    transition: transform 0.2s;
}

#btnNovaPartida:hover {
    transform: scale(1.05);
}

/* Capa fosca darrere de la finestra per centrar l'atenció */
#resultat-votacio::before {
    content: '';
    position: fixed;
    top: -1000%;
    left: -1000%;
    width: 2000%;
    height: 2000%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px); /* Difumina el joc al darrere (opcional) */
    z-index: -1;
	pointer-events: auto;
}

@keyframes bounceIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

#resultat-votacio {
    pointer-events: none; /* Per defecte no bloqueja clics */
}

#resultat-votacio.actiu, #resultat-votacio:has(p:not(:empty)) {
    pointer-events: auto; /* Només bloqueja si hi ha text */
}

/* Estil del botó per separar el nom del número */
.btn-vot {
    display: flex;
    justify-content: space-between; /* Empeny el número a la dreta */
    align-items: center;
    padding: 10px 20px;
    margin-bottom: 8px;
    width: 100%;
    /* els teus altres estils de botó... */
}

/* La bombolla dels vots (Badge) - GRIS SÒLID I LLEGIBLE */
.vots-badge {
    background: #444 !important; /* Gris fosc sòlid (sense gradients) */
    color: #ffffff !important;   /* Text blanc pur per a màxima claredat */
    padding: 2px 12px;
    border-radius: 6px;
    font-weight: 800;            /* Text més gruixut */
    font-size: 0.9rem;
    min-width: 20px;
    text-align: center;
    border: 1px solid #555;      /* Una vora lleugerament més clara */
    box-shadow: none !important; /* Eliminem qualsevol resplendor */
    letter-spacing: 0;           /* Sense espaiat de lletres tipus input */
}

.nom-text {
    letter-spacing: 1px;
    text-transform: none; /* Opcional: si vols que els noms no siguin tot majúscules */
}



/* Quan el botó està desactivat, mantenim el gris però el fem més discret */
.btn-vot.desactivat .vots-badge {
    background: #2a2a2a !important;
    color: #777 !important;
    border-color: #333;
}
/* El missatge de confirmació (Gris neutre sense fons lila) */
.msg-confirmacio {
    color: #aaa; 
    background: transparent; 
    border: none;
    border-top: 1px solid #332a4d;
    margin-top: 25px;
    padding-top: 15px;
    font-weight: normal;
    font-style: italic;
    font-size: 0.85rem;
}

/* --- BOTÓ FLOTANT TEMA FOSC --- */
.floating-theme-btn {
    /* 1. Posicionament i mida (Evita que ocupi tota la pantalla) */
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    
    width: auto !important;      /* Forcem que no ocupi el 100% */
    height: auto !important;
    padding: 10px 20px;
    white-space: nowrap;         /* Text en una sola línia */
    
    /* 2. Estat Normal (Text Clar sobre fons del tema) */
    background-color: transparent; 
    color: #ffffff;              /* Text blanc (Clar) */
    border: 2px solid #ffffff;   /* Vora blanca */
    
    /* Estètica */
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* 3. Estat Hover (Fons Cyan/Blau) */
.floating-theme-btn:hover {
    background-color: #00e5ff;   /* Cyan elèctric */
    color: #0f0a1d;              /* Text fosc per contrastar amb el cyan */
    border-color: #00e5ff;
    /* Mantenim el centratge base al fer el transform de l'efecte */
    transform: translateX(-50%) scale(1.05); 
}

/* 4. Estat Active (Clic) */
.floating-theme-btn:active {
    transform: translateX(-50%) scale(0.95);
}

/* Ajust per a mòbils per assegurar que no s'estiri */
@media (max-width: 480px) {
    .floating-theme-btn {
        width: auto !important;
        min-width: 120px;
        bottom: 15px;
        font-size: 0.75rem;
    }
}