body {
    font-family: Arial;
    margin: 0;
    padding: 20px;
    /* padding-top eliminado: usando header sticky */
}

/* Header Flotante (Sticky) */
.top-header {
    position: sticky; /* Cambiado de fixed a sticky para manejo automático de altura */
    top: 0;
    left: 0;
    width: 100%;
    background: white;
    padding: 15px 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    box-sizing: border-box;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    margin: 0;
    font-size: 36px;
}

.logo {
    height: 90px;
    /* Aumentado un 80% desde 50px */
    max-width: 250px;
    object-fit: contain;
}

/* Modificamos el antiguo encabezado para que esté debajo del título en el flotante */
.encabezado {
    margin-top: 15px;
    display: flex;
    gap: 20px;
    align-items: center;
}

.encabezado label,
.encabezado input {
    font-size: 1.1em;
}

#nuevaPlanillaBtn {
    margin-left: auto;
}

.tirador {
    border: 1px solid #bbb;
    padding: 8px;
    margin-bottom: 13px;
    background: #efefef;
    font-size: 0.8em;
}

.tirador input {
    margin-right: 8px;
    margin-bottom: 6px;
}

.nombre-tirador {
    font-size: 1.5em;
    font-weight: bold;
    padding: 4px;
    width: 240px;
}

.serie {
    display: grid;
    grid-template-columns: 96px repeat(10, 27px) 72px 72px 40px 30px;
    align-items: center;
    gap: 3px;
    margin-bottom: 5px;
}

.serieLabel {
    width: 96px;
    font-weight: bold;
    font-size: 0.96em;
}

.disparo {
    width: 26px;
    height: 26px;
    border: 1px solid #888;
    background: #dcdcdc;
    text-align: center;
    line-height: 26px;
    font-weight: bold;
    cursor: pointer;
}

.disparo.vacio {
    background: #cfcfcf;
}

.disparo.editando {
    background: #ffd54f;
}

.total {
    margin-left: 8px;
    width: 64px;
}

.prom {
    width: 64px;
}

.moscas {
    width: 40px;
    text-align: center;
    font-weight: bold;
}

.serie-titulo {
    font-weight: bold;
}

.editorSerie {
    margin-top: 8px;
    padding: 8px;
    background: #f5f5f5;
    border: 1px solid #bbb;
}

.botonesPuntaje {
    display: flex;
    gap: 4px;
    align-items: center;
}

.botonPuntaje {
    width: 25px;
    height: 25px;
    font-size: 8px;
    cursor: pointer;
}

.disparo.activo {
    background: #ffd54f;
}

.editorControles {
    display: flex;
    gap: 10px;
}

.btn-img {
    cursor: pointer;
    height: 50px;
}

.btn-print {
    cursor: pointer;
    height: 50px;
    font-size: 24px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0 10px;
}

.resumenTirador {
    font-weight: bold;
    font-size: 1.6em;
}

.resumenTirador span {
    padding-right: 32px;
}

/* Estilos para Impresión */
@page {
    margin: 1.5cm;
}

@media print {

    html,
    body {
        height: 100%;
        margin: 0 !important;
        padding: 0 !important;
    }

    body {
        background: white;
    }

    .top-header {
        position: static;
        box-shadow: none;
        padding: 0;
        margin-bottom: 20px;
    }

    #nuevaPlanillaBtn,
    #agregarTiradorBtn,
    #imprimirBtn,
    .btn-eliminar,
    .editorSerie {
        display: none !important;
    }

    /* --- CONFIGURACIÓN DE TAMAÑO DE IMPRESIÓN --- */
    .tirador {
        break-inside: avoid;
        border: 1px solid #000;
        margin-bottom: 20px;
        background: white !important;
        padding: 5px;
        font-size: 0.55em;
        /* Reducido un 15% más */
    }

    .cabeceraWrap {
        display: flex !important;
        flex-direction: row !important;
        align-items: baseline !important;
        gap: 20px !important;
        margin-bottom: 10px !important;
    }

    .nombre-tirador {
        font-size: 2.6em;
        font-weight: bold;
        padding: 1px;
        width: auto !important;
        /* Permitir que ocupe lo necesario */
        min-width: 200px;
        display: inline-block !important;
        margin-bottom: 0 !important;
    }

    .camposWrap {
        display: flex !important;
        flex-direction: row !important;
        gap: 15px !important;
        align-items: baseline !important;
    }

    .campo-label {
        flex-direction: row !important;
        gap: 5px !important;
        align-items: baseline !important;
        font-size: 0.9em !important;
    }

    .campo-label input {
        width: 120px !important;
        font-weight: bold !important;
    }

    .serie {
        grid-template-columns: 68px repeat(10, 19px) 49px 49px 30px 0px;
        /* El último 0px oculta el espacio del botón de eliminar */
        /* Columnas más estrechas */
        gap: 2px;
        margin-bottom: 3px;
    }

    .serieLabel {
        width: 68px;
    }

    .disparo {
        border: 1px solid #000;
        width: 18px;
        height: 18px;
        line-height: 18px;
    }

    .resumenTirador {
        font-size: 1.1em;
    }

    /* Campos de texto sin marco solo en impresión */
    input[type="text"],
    input[type="date"],
    .nombre-tirador,
    .tirador input {
        border: none !important;
        background: transparent !important;
        padding: 0;
    }

    .serie.serieActiva {
        background: transparent !important;
    }

    .no-print {
        display: none !important;
    }

}

/* Serie activa */
.serie.serieActiva .serieLabel {
    color: #1565c0;
}

.serie.serieActiva {
    background: #e3f2fd;
    border-radius: 4px;
}

/* Imagen dentro de una celda de disparo */
.disparo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Fila cabecera del tirador */
.cabeceraWrap {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

/* Grupo de campos con etiqueta */
.camposWrap {
    display: inline-flex;
    gap: 12px;
    align-items: center;
}

.campo-label {
    display: flex;
    flex-direction: column;
    font-size: 0.75em;
    color: #555;
    font-weight: bold;
}

.campo-label input {
    width: 110px;
    margin: 0;
}

/* Input de fallas */
.input-fallas {
    width: 40px;
}

/* Botón eliminar tirador */
.btn-eliminar {
    background-color: #ff4d4d;
    color: white;
    font-weight: bold;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
    margin-left: auto;
    font-size: 0.9em;
}

/* Botones de gestión de series */
.btn-eliminar-serie {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-eliminar-serie:hover {
    filter: brightness(0.8);
}

.btn-agregar-serie {
    margin-top: 2px;
    margin-bottom: 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.81em;
}

.btn-agregar-serie:hover {
    background-color: #45a049;
}

/* Íconos del editor (borrar/ok) */
.editor-icon {
    height: 25px;
    cursor: pointer;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #323232;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(100%);
    z-index: 2000;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Mejoras de foco para inputs */
input:focus {
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
    border-bottom: 2px solid #4CAF50 !important;
}

/* --- RESPONSIVIDAD (MÓVIL) --- */

.tabla-series-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin-bottom: 10px;
    border-radius: 4px;
}

@media (max-width: 800px) {
    body {
        padding: 10px !important;
        /* Ya no necesitamos padding-top fijo */
    }

    .top-header {
        padding: 10px !important;
    }

    .header-content {
        flex-direction: column !important;
        gap: 10px;
        text-align: center;
    }

    .header-content h1 {
        font-size: 1.5em; /* Un poco más pequeño para que no ocupe tanto */
    }

    .logo {
        height: 60px;
    }

    .encabezado {
        flex-direction: column !important;
        gap: 12px;
        align-items: center;
        margin-top: 10px;
    }

    .encabezado div {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    .encabezado input {
        width: 90% !important;
        text-align: center;
    }

    #nuevaPlanillaBtn {
        margin: 0 auto;
    }

    /* Tirador */
    .tirador {
        padding: 10px;
    }

    .cabeceraWrap {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .nombre-tirador {
        width: 100% !important;
        font-size: 1.3em;
    }

    .camposWrap {
        justify-content: space-between;
        width: 100%;
    }

    .campo-label {
        flex: 1;
    }

    .campo-label input {
        width: 95% !important;
    }

    .btn-eliminar {
        width: 100%;
        padding: 10px;
        margin-top: 5px;
    }

    /* Tabla scrollable */
    .serie {
        /* Mantenemos el grid pero ahora está dentro de un contenedor scrollable */
        min-width: 580px; 
    }

    /* Resumen */
    .resumenTirador {
        font-size: 1.1em;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-top: 15px;
        padding: 10px;
        background: #e0e0e0;
        border-radius: 4px;
    }

    .resumenTirador span {
        padding-right: 0;
    }

    /* Editor */
    .botonesPuntaje {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .botonPuntaje {
        width: 38px;
        height: 38px;
    }

    .editor-icon {
        height: 38px;
    }
}

/* --- FOOTER --- */
.main-footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 40px;
    color: #777;
    font-size: 0.9em;
    border-top: 1px solid #ddd;
}

.main-footer a {
    color: #4CAF50;
    text-decoration: none;
    font-weight: bold;
}

.main-footer a:hover {
    text-decoration: underline;
}

@media print {
    .main-footer {
        display: none !important;
    }
}

/* --- PÁGINA 404 --- */
.page-404 {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at center, #1a1a1a 0%, #000000 100%);
    color: white !important;
    text-align: center;
    overflow: hidden;
}

.page-404 .container {
    position: relative;
    z-index: 10;
    padding: 60px 40px;
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('../img/404.png');
    background-size: cover;
    background-position: center;
    backdrop-filter: blur(5px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8), inset 0 0 100px rgba(0, 0, 0, 0.5);
    max-width: 600px;
    width: 90%;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.page-404 h1 {
    font-size: 80px;
    margin: 0;
    color: #4CAF50 !important;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.page-404 h2 {
    font-size: 24px;
    margin: 10px 0 20px;
    font-weight: 300;
    color: white !important;
}

.page-404 p {
    font-size: 16px;
    color: #aaa !important;
    line-height: 1.6;
    margin-bottom: 30px;
}

.page-404 .btn-home {
    display: inline-block;
    padding: 12px 30px;
    background: #4CAF50;
    color: white !important;
    text-decoration: none;
    border-radius: 50px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.page-404 .btn-home:hover {
    transform: translateY(-3px);
    background: #45a049;
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

.page-404 .circle {
    position: absolute;
    border: 1px solid rgba(76, 175, 80, 0.1);
    border-radius: 50%;
    animation: pulse 4s infinite ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.1; }
    50% { transform: scale(1.2); opacity: 0.2; }
    100% { transform: scale(1); opacity: 0.1; }
}