* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #0f0f0f;
    color: white;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh; 
    width: 100vw;
    overflow: hidden; 
}

.hidden { display: none !important; }

/* Menú Principal */
.menu-container {
    background: #1a1a1a;
    padding: 25px;
    border-radius: 15px;
    margin-top: 5vh;
    width: 90%;
    max-width: 350px;
    text-align: center;
    border: 1px solid #333;
}

/* Marcador TV - Reducimos su altura para darle más espacio al tablero */
.scoreboard {
    display: flex;
    justify-content: center;
    gap: 15px;
    height: 8vh; /* Bajamos de 12vh a 8vh */
    align-items: center;
    width: 100%;
    padding-top: 5px;
}

.player-pill {
    padding: 5px 20px;
    background: #222;
    border-radius: 50px;
    font-size: 2.8vh; /* Texto un poco más grande */
    border: 2px solid transparent;
}

.player-pill.active {
    background: #ffcc00;
    color: black;
    border-color: white;
    box-shadow: 0 0 15px rgba(255,204,0,0.4);
}

/* Tablero TV - Ahora ocupa el 90% del alto */
.grid-board {
    display: grid;
    gap: 0.5vh; /* ESPACIO MÍNIMO ENTRE CARTAS */
    padding: 1vh;
    background: rgba(255,255,255,0.02);
    border-radius: 10px;
    height: 90vh; 
    width: auto;
    margin: 0 auto;
}

.label-ref {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5vh;
    font-weight: bold;
    color: #ffcc00;
}

/* CARTAS MAXIMIZADAS */
.card {
    /* Calculamos para que 6 cartas ocupen casi todo el 90vh del tablero */
    height: 13.5vh; 
    aspect-ratio: 3 / 4; 
    perspective: 1000px;
}

/* Ajuste dinámico: Si solo hay 4 filas (4x4), las cartas pueden ser aún más grandes */
.grid-board:not(:has(.card:nth-child(20))) .card {
    height: 19vh; 
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s ease-in-out;
    transform-style: preserve-3d;
}

.card.flipped .card-inner { transform: rotateY(180deg); }

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 4px; /* Bordes más rectos para que se vean más juntas */
    border: 1px solid rgba(255,255,255,0.5);
}

.card-front {
    background-image: url('cover.jpg');
    background-size: cover;
    background-position: center;
}

.card-back {
    background-color: white;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transform: rotateY(180deg);
}

.card.matched {
    opacity: 0.15;
    filter: grayscale(100%);
}

/* --- MÓVIL (Se mantiene funcional) --- */
#view-mobile {
    width: 100%;
    max-width: 500px;
    padding: 10px;
    height: 100vh;
    overflow-y: auto; 
    display: flex;
    flex-direction: column;
}

.mobile-controls {
    display: grid;
    gap: 5px;
}

.coord-btn {
    padding: 12px 0;
    font-size: 1rem;
    font-weight: bold;
    background: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 5px;
}

.invisible-btn { visibility: hidden; pointer-events: none; }

.btn-reset {
    width: 100%;
    padding: 15px;
    background: #c0392b;
    color: white;
    margin-top: 15px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
}
