/* Estilos Generales */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body { 
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    background-color: #111111;
    color: #ffffff;
}

/* Contenedor principal para centrar las pantallas */
#game-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Estilos para las pantallas */
.game-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 25px;
    background-color: #1a1a1a;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    width: 90%;
    max-width: 600px;
    box-sizing: border-box;
    gap: 20px;
    border: 1px solid #333;
}

.game-screen.active {
    display: flex;
}

h1 {
    color: #e0e0e0;
    margin-bottom: 15px;
    text-align: center;
    font-size: 2.2em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

p {
    text-align: center;
    color: #b0b0b0;
    line-height: 1.6;
}

.game-description {
    max-width: 80%;
    margin-bottom: 25px;
}

.input-group {
    margin-bottom: 15px;
    width: 100%;
    text-align: center;
}

label {
    display: block;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #cccccc;
}

input[type="text"] {
    padding: 14px;
    width: 80%;
    border: 1px solid #555;
    border-radius: 8px;
    background-color: #333;
    color: #ffffff;
    font-size: 1em;
    margin-bottom: 15px;
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #FF0000;
    box-shadow: 0 0 8px rgba(255, 0, 0, 0.5);
}

button {
    padding: 14px 30px;
    background-color: #FF0000;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover {
    background-color: #CC0000;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
    transform: translateY(-2px);
}

button:disabled {
    background-color: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#logout-btn {
    background-color: #555;
    margin-top: 20px;
}

#logout-btn:hover {
    background-color: #444;
}

.error-message {
    color: #ff4d4d;
    margin-top: -10px;
    min-height: 1.2em;
    font-weight: bold;
    text-align: center;
    font-size: 0.9em;
}

.user-greeting {
    font-size: 1.2em;
    color: #e0e0e0;
}

#current-username-display {
    color: #FF0000;
    font-weight: bold;
}


/* --- Estilos de la Pantalla de Juego (ID #screen3) --- */
#screen3 {
    width: 100%;
    max-width: 100%;
    height: 100%;
    display: none; /* Se activa con .active */
    grid-template-rows: 1fr auto auto 1fr; /* Oponente, Central, Botón, Jugador */
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
    background-color: #111;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

#screen3.active {
    display: grid;
}

.player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 1px solid #333;
    border-radius: 8px;
    background-color: #1c1c1c;
    position: relative;
    min-height: 200px;
}

.opponent-area { order: 1; }
.own-area { order: 4; }

.game-central-layout {
    order: 2;
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    padding: 10px 0;
}

.deck, .discard-pile {
    width: 120px;
    height: 170px;
    border: 2px dashed #444;
    background-color: #222;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1em;
    color: #888;
    border-radius: 8px;
}

.hand {
    display: flex;
    gap: 10px;
    padding: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
    flex-grow: 1;
}

.opponent-hand .card-back {
    background-color: #111;
    color: #ffffff;
    width: 80px;
    height: 110px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    font-weight: bold;
    border: 1px solid #FF0000;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.card-in-hand {
    width: 120px;
    height: 170px;
    background-color: #fff;
    border: 1px solid #333;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.card-in-hand:hover {
    transform: translateY(-55px) scale(1.8) ;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    z-index: 10;
}

.card-image {
    width: 100%;
    padding-top: 75%; /* Aspect ratio para la imagen */
    position: relative;
    background-color: #f0f0f0;
}

.card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-info {
    padding: 8px;
    font-size: 0.9em;
    color: #333;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between;
}

.card-name-value {
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 0.8em;
}

.card-effect {
    font-size: 0.7em;
    line-height: 1.3;
    color: #555;
}

#ownNameDisplay, #opponentNameDisplay {
    font-size: 1.3em;
    font-weight: bold;
    color: #e0e0e0;
    margin-bottom: 10px;
}

#btnPassTurn {
    order: 3;
    justify-self: center;
}

.game-message {
    font-size: 1.2em;
    font-weight: bold;
    color: #FFD700;
    text-align: center;
    margin-top: 10px;
    min-height: 1.5em;
}

.board-area {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 800px;
    height: 60px;
    margin: 0 auto;
    position: relative;
}

.board-cell {
    width: 50px;
    height: 50px;
    background-color: #333;
    border: 1px solid #555;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1em;
    color: #fff;
}

.player-token {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    transition: left 0.5s ease-in-out;
}

.player1-token { background-color: #e74c3c; }
.player2-token { background-color: #3498db; }


/* --- Estilos del Modal --- */
.modal-overlay {
    /* ... (Estilos ya definidos, sin cambios) ... */
}
/* ... (Resto de estilos de modal y otros elementos del juego sin cambios) ... */
/* --- ESTILOS PARA EL CREADOR DE BARAJAS --- */

/* Contenedor principal de la pantalla del deck builder */
#deck-builder-screen {
    width: 95%;
    max-width: 1400px; /* Más ancho para dos columnas */
    height: 90vh; /* Ocupa casi toda la altura de la ventana */
    justify-content: flex-start;
}

/* Layout principal: 2 columnas (biblioteca y mazo) */
.deck-builder-layout {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Dos columnas de igual tamaño */
    gap: 20px;
    width: 100%;
    height: calc(100% - 120px); /* Ajusta la altura para dejar espacio a los botones */
    overflow: hidden;
}

/* Estilo para los contenedores de biblioteca y mazo */
.card-collection, .deck-composition {
    display: flex;
    flex-direction: column;
    background-color: #111;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    overflow: hidden; /* Oculta el desbordamiento del contenedor principal */
}

.card-collection h2, .deck-composition h2 {
    margin-top: 0;
    margin-bottom: 15px;
    text-align: center;
    color: #e0e0e0;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

/* La lista de cartas con scroll y diseño de cuadrícula */
.card-list {
    flex-grow: 1;
    overflow-y: auto; /* Habilita el scroll vertical cuando hay muchas cartas */
    display: grid;
    /* Crea una cuadrícula responsive: 
       - auto-fill: llena el espacio con tantas columnas como quepan.
       - minmax(100px, 1fr): cada columna mide mínimo 100px y máximo 1 fracción del espacio.
    */
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    padding-right: 10px; /* Espacio para la barra de scroll */
}

/* Estilo para cada carta individual en la cuadrícula */
.deck-builder-card {
    position: relative;
    background-color: #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    aspect-ratio: 2.5 / 3.5; /* Proporción típica de una carta */
    display: flex;
    flex-direction: column;
    border: 1px solid #444;
}

/* CORRECCIÓN: Se define una altura para la imagen para dejar espacio al texto */
.deck-builder-card .card-image {
    height: 75%;
    background-color: #1c1c1c;
}

.deck-builder-card .card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* La imagen cubre todo el espacio sin deformarse */
}

/* CORRECCIÓN: Se asegura que el contenedor de info tenga espacio y centre el texto */
.deck-builder-card .card-info {
    height: 25%;
    padding: 6px;
    text-align: center;
    background-color: #1a1a1a;
    font-size: 0.8em;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e0e0e0;
}

/* Superposición con botón que aparece al pasar el ratón */
.card-action-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0; /* Oculto por defecto */
    transition: opacity 0.2s ease-in-out;
}

.deck-builder-card:hover .card-action-overlay {
    opacity: 1; /* Visible al pasar el ratón */
}

.card-action-overlay button {
    padding: 8px 12px;
    font-size: 0.9em;
}

/* Contenedor para los botones de guardar y volver */
.deck-builder-actions {
    margin-top: 20px;
    display: flex;
    gap: 20px;
}
.discard-piles-container {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Espacio entre las dos pilas */
    align-items: center;
}

.discard-pile {
    width: 100px; /* Un poco más pequeñas para que quepan bien */
    height: 140px;
}
