body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card {
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border-radius: 8px;
    margin-bottom: 20px;
    border: none;
}

.card-header {
    border-radius: 8px 8px 0 0 !important;
    font-weight: 500;
}

.btn {
    border-radius: 5px;
    padding: 8px 16px;
    font-weight: 500;
}

.btn-primary {
    background-color: #0d6efd;
}

.btn-success {
    background-color: #198754;
}

.btn-info {
    background-color: #0dcaf0;
    color: #fff;
}

.table {
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 8px;
    overflow: hidden;
}

.table-dark th {
    background-color: #212529;
    color: white;
}

.score-display {
    background-color: #f8f9fa;
    padding: 10px 15px;
    border-radius: 5px;
    font-weight: bold;
    display: inline-block;
}

.match-date {
    color: #6c757d;
    font-size: 0.9rem;
}

.jumbotron {
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.nav-tabs .nav-link {
    color: #495057;
    font-weight: 500;
}

.nav-tabs .nav-link.active {
    color: #0d6efd;
    font-weight: 600;
}

/* Playoff bracket styling */
.bracket {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 220px;
}

.bracket-match {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin: 10px 0;
    padding: 10px;
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.bracket-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bracket-team-name {
    font-weight: 500;
}

.bracket-score {
    font-weight: bold;
    color: #0d6efd;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .bracket {
        flex-direction: column;
    }
    
    .bracket-round {
        width: 100%;
        margin-bottom: 20px;
    }
}

/* ==========================================================================
   OTTIMIZZAZIONE MOBILE (audit responsive Sportento)
   Larghezze di riferimento: 320 / 375 / 390 / 430 (smartphone),
   768 (tablet verticale), 1024 (tablet orizzontale).
   Le regole sotto agiscono SOLO sotto i breakpoint indicati: la resa desktop
   resta invariata.
   ========================================================================== */

/* Immagini mai piu' larghe del contenitore */
img {
    max-width: 100%;
}

/* Logo della navbar: proporzionato alla barra (48px desktop, 40px su schermi
   piccoli), cosi' l'intestazione scura resta compatta e il menu non va a capo. */
.navbar-logo {
    height: 48px;
    width: auto;
    margin-right: 5px;
    display: block;
}

/* Contenitori con scorrimento: inerzia nativa su touch */
.table-responsive,
.bracket,
.tv-table-scroll,
.tv-bracket-scroll {
    -webkit-overflow-scrolling: touch;
}

/* Bracket playoff: non deve mai sfondare la pagina, scorre in orizzontale */
.bracket {
    overflow-x: auto;
}

/* ------------------------- Tablet / navbar collassata (<= 991.98px) ------- */
@media (max-width: 991.98px) {
    .navbar-logo {
        height: 40px;
    }

    /* Il menu a tendina non deve mai superare l'altezza utile dello schermo */
    .navbar-collapse {
        max-height: 78vh;
        overflow-y: auto;
    }

    /* Voci di menu comode da toccare con il dito */
    .navbar-nav .nav-link {
        padding: 0.7rem 0.25rem;
        font-size: 1.02rem;
    }

    .navbar-nav .dropdown-item {
        padding: 0.55rem 0.75rem;
    }

    /* Campo di ricerca a tutta larghezza sotto le voci */
    .navbar form.d-flex {
        width: 100%;
        margin: 0.5rem 0 0.25rem;
    }

    .navbar form.d-flex .form-control {
        flex: 1 1 auto;
        min-width: 0;
    }

    .session-countdown {
        margin: 0.35rem 0;
    }
}

/* ------------------------------- Smartphone (<= 767.98px) ---------------- */
@media (max-width: 767.98px) {
    /* 16px impedisce lo zoom automatico dei campi su iOS */
    input,
    select,
    textarea,
    .form-control,
    .form-select {
        font-size: 16px;
    }

    /* Pulsanti piu' facili da centrare con il pollice */
    .btn {
        padding: 0.6rem 1rem;
    }

    .btn-sm,
    .btn-group-sm > .btn {
        padding: 0.45rem 0.8rem;
    }

    /* Titoli piu' contenuti per non spezzare le parole */
    h1, .h1 { font-size: 1.65rem; }
    h2, .h2 { font-size: 1.4rem; }
    h3, .h3 { font-size: 1.2rem; }
    .display-4 { font-size: 2rem; }
    .display-5 { font-size: 1.7rem; }
    .lead { font-size: 1.05rem; }

    .table {
        font-size: 0.92rem;
    }
}

/* --------------------------- Smartphone piccoli (<= 575.98px) ------------ */
@media (max-width: 575.98px) {
    .container,
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    .card-body { padding: 1rem; }
    .card-header { padding: 0.75rem 1rem; }
    .jumbotron { padding: 1.5rem 1rem; }

    .table { font-size: 0.875rem; }
    .table > :not(caption) > * > * { padding: 0.45rem 0.5rem; }

    /* Il bracket torna in colonna e non serve piu' lo scroll orizzontale */
    .bracket { overflow-x: visible; }
}
