/* ==========================================================================
   1. RESET Y CONFIGURACIÓN BASE
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   2. TERRENO DE JUEGO (PITCH CONTAINER)
   ========================================================================== */
.pitch-container {
    max-width: 850px;
    margin: 1rem auto 2rem;
    background: #149966;
    border: 4px solid #ffffff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    width: calc(100% - 1.5rem);
    position: relative
}

/* Selectores tácticos superiores */
.tactic-selector-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    color: white;
}

.tactic-selector-container select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-weight: bold;
    font-size: 0.85rem;
}

/* Botón principal de guardado */
.btn-guardar-alineacion {
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: bold;
    background: #ffffff;
    color: #137c55;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s ease;
}

.btn-guardar-alineacion:active {
    transform: scale(0.97);
}

/* Filas tácticas del campo (DF, MC, DL, PT) */
.pitch-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin: 14px 0;
    gap: 4px;
}

/* ==========================================================================
   3. SLOTS DE JUGADORES Y CASILLAS
   ========================================================================== */
.slot-jugador {
    width: 126px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 6px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px dashed #999;
    position: relative; /* Clave para el anclaje de badges en esquinas */
}

.slot-jugador:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.slot-jugador.ocupado {
    border: 2px solid #2e7d32;
    background: #ffffff;
}

.slot-jugador.xi-ideal {
    border: 2px solid #00b7ff;
    box-shadow: 0 0 10px rgba(0, 208, 255, 0.8);
    background: hsl(192, 87%, 39%);
}

.slot-jugador.xi-ideal .slot-nombre {
    color: #ffffff;
}

.slot-jugador.pendiente {
    border: 2px solid #413e2e;
    box-shadow: 0 0 10px rgba(159, 158, 149, 0.8);
    opacity: 0.8;
    filter: grayscale(40%);
}

.slot-jugador.no-jugo {
    border: 2px solid #2e7d32;
    background: #ffffff;
}

.slot-posicion {
    font-size: 0.7rem;
    font-weight: bold;
    color: #666;
    text-transform: uppercase;
}

.slot-nombre {
    font-size: 0.8rem;
    font-weight: bold;
    margin: 0.8rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-badge {
    font-size: 0.65rem;
    padding: 2px 4px;
    border-radius: 4px;
    display: block;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-vacio { 
    background: #ffebee; 
    color: #c62828; 
}

.badge-listo { 
    background: #e8f5e9; 
    color: #2e7d32; 
    font-weight: bold;
}

/* ==========================================================================
   4. BADGES EN ESQUINAS DE MINIATURAS (RENOMBRADOS)
   ========================================================================== */
/* Regla general para badges absolutos */
.badge-corner {
    position: absolute;
    font-size: 0.65rem;
    font-weight: 800;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 1px;
}

/* Esquina superior izquierda: Capitán */
.corner-top-left {
    top: -6px;
    left: -6px;
}

.badge-capitan {
    background: #fbbf24;
    color: #78350f;
    border: 1px solid #f59e0b;
}

/* Esquina superior derecha: Gol */
.goles-icon-corner {
    position: absolute;
    top: -0.500rem;     /* Equivalente a -6px */
    right: -0.800rem;    /* Equivalente a -6px */
    background: #fff;
    border-radius: 50%;
    width: 1.55rem;      /* Equivalente a 20px */
    height: 1.26rem;     /* Equivalente a 20px */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem; /* Equivalente a 10px */
    font-weight: bold;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3); /* 0 2px 4px en rem */
    z-index: 5;
}

/* Esquina superior derecha: Gol */
.asistencias-icon-corner {
    position: absolute;
    top: -0.500rem;     /* Equivalente a -6px */
    right: 0.625rem;    /* Equivalente a -6px */
    background: #fff;
    border-radius: 50%;
    width: 1.55rem;      /* Equivalente a 20px */
    height: 1.26rem;     /* Equivalente a 20px */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem; /* Equivalente a 10px */
    font-weight: bold;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3); /* 0 2px 4px en rem */
    z-index: 5;
}

/* Esquina inferior izquierda: Tarjetas Amarillas / Rojas */
.corner-bottom-left {
    bottom: -4px;
    left: -4px;
}

.badge-card-amarilla {
    background: #fef08a;
    color: #854d0e;
    border: 1px solid #facc15;
    padding: 1px 3px;
}

.badge-card-roja {
    background: #fca5a5;
    color: #991b1b;
    border: 1px solid #ef4444;
    padding: 1px 3px;
}

/* ==========================================================================
   5. MODAL DE ESTADÍSTICAS DEL JUGADOR
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 12px;
}

.modal-content-jugador {
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.modal-content-jugador h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1.15rem;
}

.stat-input {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-input label {
    font-size: 0.78rem;
    font-weight: bold;
    margin-bottom: 4px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-input input[type="number"],
.stat-input input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
}

.input-puntos-destacado {
    font-weight: bold !important;
    font-size: 1.1rem !important;
    border: 2px solid #2e7d32 !important;
    color: #1b5e20;
}

.checkbox-group {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    background: #f1f5f2;
    padding: 8px 6px;
    border-radius: 8px;
    margin: 12px 0;
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.stat-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 12px 0;
}

.stat-full-width {
    grid-column: 1 / -1;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 18px;
}

.btn-modal-cancelar {
    padding: 10px 18px;
    background: #e0e0e0;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

.btn-modal-guardar {
    padding: 10px 18px;
    background: #2e7d32;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    flex-grow: 1;
}

/* ==========================================================================
   CONTADOR FLOTANTE DE PUNTOS TOTALES
   ========================================================================== */

.contador-puntos-flotante {
    position: absolute;
    top: 0.75rem;     /* Más pegado al borde superior */
    right: 0.75rem;    /* Más pegado al borde derecho */
    background: rgba(15, 46, 20, 0.48);
    backdrop-filter: blur(6px); /* Efecto cristal moderno */
    border: 0.125rem solid #ffd700;
    border-radius: 0.5rem;
    padding: 0.35rem 0.6rem;
    text-align: center;
    color: #ffffff;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.25);
    z-index: 10;
    min-width: 7.5rem;
    min-height: 3.5rem;
}

.contador-puntos-titulo {
    font-size: 1rem;
    text-transform: uppercase;
    color: #ffd700;
    font-weight: 700;
    letter-spacing: 0.05em;
    display: block;
    line-height: 1;
    margin-bottom: 0.1rem;
}

.contador-puntos-valor {
    font-size: 1.50rem; /* Ligeramente más compacto para que el de 3 dígitos (ej. 102) encaje holgado */
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

/* ==========================================================================
   6. RESPONSIVE MÓVIL
   ========================================================================== */
@media (max-width: 480px) {

    .btn-guardar-alineacion {
        max-width: 15rem;
    }
    .pitch-container {
        padding: 10px 6px;
    }

    .slot-jugador {
        width: 23%;
        min-width: 60px;
        padding: 4px 2px;
    }

    .slot-posicion {
        font-size: 0.65rem;
    }

    .slot-nombre {
        font-size: 0.68rem;
    }

    .status-badge {
        font-size: 0.55rem;
        padding: 2px;
    }

    .modal-content-jugador {
        padding: 16px;
    }

    .contador-puntos-flotante {
        top: 30.45rem;     /* Más pegado al borde superior */
        min-width: 3.5rem;
        max-width: 4.5rem;
        min-height: 0rem;
    }

    .contador-puntos-titulo {
        font-size: 0.55rem;
    }

    .contador-puntos-valor {
        font-size: 1.15rem; 
    }
}

/* Estilo mejorado para que la etiqueta parezca un badge de color */
.slot-posicion-jornadas {
    font-size: 0.65rem;
    font-weight: bold;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    display: block;
    margin-bottom: 2px;
}