/* --- 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;
}