:root {
    --bg-dark: #000000;
    --text-white: #ffffff;
    --btn-blue: #3b82f6;
    --btn-green: #10b981;
    --btn-red: #ef4444;
}

/* UTILIDADES */
.hidden { display: none !important; }

body {
    margin: 0; padding: 0;
    background-color: var(--bg-dark);
    color: var(--text-white);
    font-family: 'Roboto', sans-serif;
    /* ESTRUCTURA FLEX VERTICAL PARA TODA LA APP */
    display: flex; 
    flex-direction: column;
    height: 100vh; /* Ocupa exactamente el alto de la ventana */
    overflow: hidden; /* Evita scroll en el body, el scroll va dentro de las secciones */
}

/* HEADER Y NOMBRES */
.top-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px; background-color: #050505;
    flex-shrink: 0; /* No encoger */
}
.team-info { display: flex; align-items: center; gap: 10px; width: 40%; }
.team-name {
    background: transparent; border: none; color: white;
    font-size: 1.1rem; width: 100%; text-transform: uppercase; font-weight: bold;
}
.text-right { text-align: right; }
.team-config { display: flex; align-items: center; gap: 8px; }
.set-score { font-size: 1.8rem; font-weight: bold; color: #fff; }
.hidden-color-input { visibility: hidden; width: 0; height: 0; position: absolute; }
.team-color-icon { font-size: 1.5rem; filter: drop-shadow(0 0 2px #fff); transition: transform 0.2s; }
.team-color-icon:active { transform: scale(0.9); }

/* CONTROLES Y ESTADÍSTICAS */
.center-controls { display: flex; align-items: center; gap: 15px; }
.match-controls {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px; background-color: #111; border-bottom: 1px solid #222;
    flex-shrink: 0;
}
.stats-left, .stats-right { display: flex; gap: 15px; font-size: 1.1rem; color: #bbb; }
.stat-box {
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    padding: 4px 8px; border-radius: 4px; user-select: none;
}
.stat-box:active { background-color: #333; }

/* BOTONES */
button {
    border: none; border-radius: 5px; padding: 10px 20px;
    font-weight: bold; color: white; cursor: pointer;
}
.btn-blue { background-color: var(--btn-blue); }
.btn-green { background-color: var(--btn-green); }
.btn-red { background-color: var(--btn-red); }
.btn-start {
    background-color: #28a745 !important; color: white;
    width: 100%; padding: 15px; font-size: 1.2rem;
    margin-top: 20px; text-transform: uppercase;
}

/* --- ESTRUCTURA DE VISTAS --- */
/* Las secciones ocupan el espacio restante entre el header y el nav */
.view-section {
    display: none; /* Por defecto ocultas */
    flex-grow: 1; /* Ocupa todo el espacio vertical disponible */
    overflow: hidden; /* El scroll se maneja internamente */
    position: relative;
    width: 100%;
}

.view-section.active-view {
    display: flex; 
    flex-direction: column;
}

/* MARCADOR PRINCIPAL (Vista Completo) */
.scoreboard-main {
    flex-grow: 1; /* Ocupa el espacio restante en la vista completo */
    display: flex; justify-content: space-between;
    align-items: center; position: relative; padding: 0;
}
.score-box {
    position: relative; width: 42%; text-align: center;
    display: flex; justify-content: center; align-items: center;
    height: 100%;
}
.score-number {
    font-size: 35vw; 
    line-height: 0.8; font-weight: 900;
    cursor: pointer; user-select: none;
}
.btn-minus {
    position: absolute; bottom: 20px; right: 20px;
    background-color: #333; color: #fff; border: 1px solid #555;
    width: 50px; height: 50px; border-radius: 50%;
    font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
    z-index: 5;
}

/* PARCIALES VERTICALES */
#parciales-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 15px;
    padding-top: 20px;
    font-family: monospace;
    font-size: 1.8rem;
    color: #aaaaaa;
    z-index: 10;
    width: 16%;
    height: 100%;
    pointer-events: none;
}
.parcial-item { white-space: nowrap; }

/* VISTA SIMPLIFICADO (SOLUCIÓN ERROR BARRA INFERIOR) */
#view-simplificado.active-view {
    display: flex; 
    flex-direction: row; 
    /* Quitamos height: 100% fijo y dejamos que flex-grow del padre actúe */
    height: auto; 
}
.simple-half {
    flex: 1; display: flex; justify-content: center; align-items: center;
    position: relative; cursor: pointer; transition: background-color 0.3s;
}
.simple-score {
    font-size: 35vw; font-weight: 900; color: white;
    text-shadow: 0 0 20px rgba(0,0,0,0.5); user-select: none;
}
.simple-minus {
    background-color: rgba(0,0,0,0.4) !important; border: 2px solid white;
    width: 70px; height: 70px; font-size: 1.5rem;
}
.team-label-overlay {
    position: absolute; top: 20px; left: 20px;
    font-size: 2rem; font-weight: bold; text-transform: uppercase;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    pointer-events: none;
}

/* VISTA SECUENCIA */
.seq-header-top { display: flex; height: 50px; background: #111; flex-shrink: 0;}
.seq-team-name {
    flex: 1; display: flex; align-items: center; justify-content: center;
    font-weight: bold; text-transform: uppercase;
    text-shadow: 0 0 4px #000; font-size: 1.2rem;
}
.seq-global-score {
    background: #000; color: #fff; padding: 5px; text-align: center;
    border-bottom: 1px solid #333; font-weight: bold; flex-shrink: 0;
}
.sequence-main-scroll { 
    flex-grow: 1; /* Ocupa el espacio restante */
    overflow-y: auto; /* Scroll aquí dentro */
    padding: 10px; 
}

.seq-set-block { margin-bottom: 20px; margin-top: 10px;}
.seq-set-title { color: #fff; font-size: 1.1rem; margin-bottom: 5px; font-weight: bold; padding-left: 5px; }

.seq-timeline-wrap {
    display: flex; flex-wrap: wrap; gap: 2px; padding: 5px; background-color: #000;
}
.seq-point-wrapper {
    height: 40px; display: flex; flex-direction: column; width: 28px;
}
.seq-point-box {
    width: 28px; height: 20px; display: flex; align-items: center; justify-content: center;
    border-radius: 2px; font-size: 0.8rem; font-weight: bold; color: white;
    text-shadow: 0 0 2px #000;
}
.align-top { justify-content: flex-start; }
.align-bottom { justify-content: flex-end; }

/* VISTA HISTORIAL */
.view-title { 
    text-align: center; padding: 10px; margin: 0; background-color: #111; 
    font-size: 1.2rem; text-transform: uppercase; letter-spacing: 1px; flex-shrink: 0;
}
.history-list { 
    flex-grow: 1; overflow-y: auto; padding: 10px; 
}
.history-item {
    background: #000; padding: 15px; margin-bottom: 1px;
    border-bottom: 1px solid #333; display: flex; flex-direction: column; gap: 5px;
}
.hist-main-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 1.1rem; font-weight: bold; color: white; flex-wrap: wrap;
}
.hist-shirt { font-size: 1.2rem; text-shadow: 0 0 2px #fff;}
.hist-result { margin: 0 10px; color: white; }
.hist-details-row {
    font-size: 0.9rem; color: #bbb; display: flex; gap: 10px; align-items: center;
}
.hist-date { margin-left: auto; font-size: 0.85rem; color: #888; }
.no-history { text-align: center; color: #555; margin-top: 50px; }

/* MODAL CONFIGURACIÓN */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.95); z-index: 9999;
    display: flex; justify-content: center; align-items: center;
}
.modal-content {
    background-color: #1a1a1a; padding: 30px; border-radius: 10px;
    width: 90%; max-width: 500px; border: 1px solid #333; text-align: center;
}
.set-row {
    display: flex; justify-content: space-between; align-items: center;
    background: #2a2a2a; padding: 10px; margin-bottom: 8px; border-radius: 5px;
}
input[type="number"] {
    width: 50px; padding: 5px; text-align: center; border-radius: 4px; border: none;
}
.config-group { margin-bottom: 20px; font-size: 1.2rem; }

/* NAVEGACIÓN INFERIOR (Fixed position visualmente, pero flex en estructura) */
.bottom-nav {
    display: flex; background-color: var(--btn-blue);
    padding-bottom: env(safe-area-inset-bottom);
    flex-shrink: 0; /* IMPEDIR QUE SE ENCOJA */
    width: 100%;
    z-index: 1000; /* Siempre encima */
}
.nav-btn {
    flex: 1; background: none; border: none; color: rgba(255,255,255,0.6);
    padding: 15px 0; display: flex; flex-direction: column; align-items: center;
    gap: 5px; font-size: 0.8rem;
}
.nav-btn.active { color: white; background-color: rgba(255,255,255,0.2); }

