:root {
    --primary: #6a1b9a;    /* Morado oscuro principal */
    --primary-light: #9c4dcc; /* Morado más claro */
    --accent: #ffb74d;     /* Naranja para destacados */
    --bg: #f3e5f5;         /* Fondo lila muy suave */
    --text: #333;          /* Color de texto principal */
    --white: #ffffff;
    --success: #4caf50;    /* Verde */
    --danger: #f44336;     /* Rojo */
}

/* --- ESTILOS GENERALES --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    margin: 0;
    padding: 0;
    text-align: center;
    color: var(--text);
    padding-bottom: 60px; /* Espacio para no tapar contenido al final */
    overscroll-behavior-y: contain; /* Evita el rebote de scroll en móviles */
}

/* --- ENCABEZADO --- */
header {
    background-color: var(--primary);
    color: var(--white);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

/* --- GESTIÓN DE PANTALLAS --- */
.screen {
    display: none; /* Ocultas por defecto */
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: block; /* Solo la activa se ve */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- PANTALLA DE CONFIGURACIÓN (SETUP) --- */
.card-panel {
    background: var(--white);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.input-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

input[type="text"] {
    padding: 12px;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-size: 1rem;
    flex: 1; /* Ocupa el espacio disponible */
}

/* Lista de jugadores añadidos */
ul#players-list-setup {
    list-style: none;
    padding: 0;
    margin-bottom: 20px;
}

ul#players-list-setup li {
    background: #f5f5f5;
    margin: 8px 0;
    padding: 10px;
    border-radius: 5px;
    border-left: 4px solid var(--primary-light);
    font-weight: 500;
    text-align: left;
    padding-left: 15px;
}

/* Caja de configuración de rondas */
.settings-box {
    margin: 25px 0;
    padding: 15px;
    background: #ede7f6; /* Fondo morado muy suave */
    border-radius: 8px;
    border: 1px dashed var(--primary);
}

.settings-box label {
    font-weight: bold;
    color: var(--primary);
    font-size: 1.1rem;
}

.settings-box input {
    width: 70px;
    text-align: center;
    font-size: 1.3rem;
    padding: 5px;
    margin-left: 10px;
    border: 2px solid var(--primary-light);
    border-radius: 5px;
    font-weight: bold;
    color: var(--primary);
}

.small-text {
    font-size: 0.85rem;
    color: #666;
    margin-top: 8px;
}

/* --- PANTALLA DE JUEGO --- */

/* Marcador superior (Scroll horizontal) */
.scoreboard {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 5px;
    background: var(--white);
    margin-bottom: 20px;
    border-radius: 8px;
    scrollbar-width: none; /* Ocultar scrollbar Firefox */
}
.scoreboard::-webkit-scrollbar { display: none; } /* Ocultar scrollbar Chrome */

.score-pill {
    background: #eee;
    padding: 8px 16px;
    border-radius: 20px;
    white-space: nowrap;
    border: 2px solid transparent;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.score-pill.active {
    background: #e1bee7;
    border-color: var(--primary);
    color: var(--primary);
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Área central de juego */
.turn-indicator {
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.turn-indicator .label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 1px;
}

.turn-indicator h2 {
    margin: 5px 0;
    color: var(--primary);
    font-size: 1.8rem;
}

/* Contenedor de la Imagen */
.card-display {
    margin-bottom: 25px;
}

.img-container {
    width: 100%;
    max-width: 500px; /* Ancho máximo de la tarjeta */
    min-height: 250px; /* Altura mínima para evitar saltos */
    background: #e0e0e0;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
    border: 4px solid var(--primary-light);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    position: relative;
}

.img-container img {
    width: 100%;
    height: auto;
    display: block;
}

#placeholder-text {
    padding: 20px;
    color: #555;
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Botones de Control */
.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

button {
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: transform 0.1s, opacity 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

button:active { transform: scale(0.98); }
button:disabled { background: #ccc; cursor: not-allowed; opacity: 0.7; }

.btn-primary { background: var(--primary); color: var(--white); width: 100%; }
.btn-small { background: var(--white); color: var(--primary); text-decoration: none; padding: 6px 12px; border-radius: 5px; font-size: 0.85rem; font-weight: bold; }
.btn-action { background: var(--primary-light); color: var(--white); width: 90%; }
.btn-success { background: var(--success); color: var(--white); width: 90%; }

/* Clases de utilidad */
.hidden { display: none !important; }

/* --- MODAL DE PUNTUACIÓN (POPUP) --- */
.modal {
    position: fixed;
    top: 0; left: 0; 
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); /* Fondo oscuro */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: var(--white);
    padding: 25px;
    border-radius: 15px;
    width: 90%;
    max-width: 450px;
    max-height: 90vh; /* Máximo alto de pantalla */
    overflow-y: auto; /* Scroll si hay muchos jugadores */
    text-align: left;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.modal-content h3 { margin-top: 0; color: var(--primary); text-align: center; }
.instruction { text-align: center; color: #666; font-size: 0.9rem; margin-bottom: 15px; }

/* Filas de puntuación dentro del modal */
.player-score-row {
    background: #f9f9f9;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    border-left: 6px solid var(--primary-light);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.player-name {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--primary);
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

/* Checkboxes y Inputs del Modal */
.check-container {
    display: flex;
    align-items: center;
    margin: 8px 0;
    cursor: pointer;
    font-size: 1rem;
}

.check-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    accent-color: var(--success);
}

.check-container.special {
    color: #c62828; /* Rojo oscuro */
    font-size: 0.9rem;
    margin-top: 10px;
    padding-top: 5px;
    border-top: 1px dashed #ddd;
}

.vote-input {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    background: #fff;
    padding: 5px;
    border-radius: 5px;
    font-size: 0.95rem;
}

.vote-input input[type="number"] {
    width: 50px;
    text-align: center;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.modal-actions {
    margin-top: 20px;
    text-align: center;
}

/* --- PANTALLA FIN DEL JUEGO --- */
#game-over-screen { text-align: center; }
#game-over-screen h2 { color: var(--accent); text-shadow: 1px 1px 2px rgba(0,0,0,0.2); margin-bottom: 30px; }

.rank-row {
    background: white;
    padding: 15px 20px;
    margin: 15px 0;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.rank-row.winner {
    background: #fff9c4; /* Amarillo claro */
    border: 2px solid #fbc02d; /* Borde dorado */
    transform: scale(1.05);
    font-weight: bold;
    font-size: 1.3rem;
    margin-bottom: 25px;
}

.rank-row.winner .rank-pos { color: #f57f17; }
.rank-pos { font-weight: 800; color: #999; width: 40px; text-align: left; }
.rank-name { flex-grow: 1; text-align: left; }
.rank-score { font-weight: bold; color: var(--primary); background: #f3e5f5; padding: 5px 10px; border-radius: 15px; }

/* --- NUEVOS ESTILOS AÑADIDOS --- */

/* Imagen del logo principal */
.game-logo {
    width: 100%;
    max-width: 200px; /* Ajusta el tamaño aquí */
    height: auto;
    border-radius: 15px;
    margin: 10px auto 20px auto;
    display: block;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border: 3px solid white;
}

.game-logo-small {
    max-width: 100px;
    border-radius: 10px;
    margin: 0 auto 15px auto;
}

/* Caja de Advertencia de Reglas */
.rules-warning {
    background-color: #fff3e0; /* Naranja muy suave */
    border: 1px solid #ffb74d;
    color: #e65100; /* Naranja oscuro texto */
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.4;
    text-align: left;
}

.rules-warning strong {
    color: #ef6c00;
}

/* Footer con Copyright */
.main-footer {
    margin-top: 30px;
    padding: 10px;
    font-size: 0.85rem;
    color: #777;
    border-top: 1px solid #e0e0e0;
}

.main-footer strong {
    color: var(--primary);
}