/* Stili generali */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-image: url('openBox.png');
    background-repeat: repeat;
    background-color: #f0f2f5;
    color: #333;
}

.container {
    max-width: 900px;
    margin: 30px auto;
    background: rgba(255, 255, 255, 0.99);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

h1, h2, h3 {
    text-align: center;
    color: #79C3A0;
    font-weight: 600;
}

h1 {
    font-size: 2.5em;
    margin-bottom: 0.5em;
    text-shadow: none;
}

h2 {
    font-size: 2em;
    border-bottom: 2px solid #79C3A0;
    padding-bottom: 10px;
    margin-top: 2em;
}

h3 {
    color: #555;
}

/* --- Responsive Table Section --- */
.section {
    margin-top: 40px;
    /* Rende il contenitore della tabella scorrevole su schermi piccoli */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Per uno scorrimento più fluido su iOS */
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: rgba(248, 249, 250, 0.9);
    border-radius: 8px;
    min-width: 600px; /* Assicura che la tabella sia abbastanza larga per lo scorrimento */
}

th, td {
    border-bottom: 1px solid #dee2e6;
    padding: 15px;
    text-align: left;
    white-space: nowrap; /* Impedisce al testo di andare a capo nelle celle */
    transition: background-color 0.3s ease;
}

th {
    background-color: #79C3A0;
    color: #fff;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 1px;
}

tr:nth-child(even) {
    background-color: rgba(241, 243, 245, 0.9);
}

tr:hover {
    background-color: rgba(226, 230, 234, 0.9);
}

/* --- Stili per le colonne fisse della classifica --- */
#ranking-table th:first-child,
#ranking-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: #79C3A0; /* Colore di sfondo per l'header */
    color: #fff;
}

#ranking-table td:first-child {
    background-color: #f8f9fa; /* Colore di sfondo per le celle del body */
    color: #333;
}

#ranking-table th:nth-child(2),
#ranking-table td:nth-child(2) {
    position: sticky;
    left: 60px; /* Spostato a destra per non sovrapporsi alla prima colonna */
    z-index: 10;
    background-color: #79C3A0; /* Colore di sfondo per l'header */
    color: #fff;
}

#ranking-table td:nth-child(2) {
    background-color: #f8f9fa; /* Colore di sfondo per le celle del body */
    color: #333;
}

/* --- Allineamento specifico per la tabella della classifica --- */
#ranking-table th,
#ranking-table td {
  text-align: center; /* Centra tutte le celle della tabella per la classifica */
}

#ranking-table th:last-child,
#ranking-table td:last-child {
  text-align: right; /* Sovrascrivi per allineare a destra solo l'ultima colonna */
}

/* --- Responsive Navigation Links --- */
.navigation-links {
    text-align: center;
    margin-top: 30px;
    display: flex;
    flex-direction: column; /* Verticale su mobile */
    align-items: center;
    gap: 15px;
}

.nav-button {
    width: 100%;
    max-width: 300px;
    padding: 12px 25px;
    background-color: #F38F15;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    text-align: center;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.nav-button:hover {
    background-color: #e07b0e;
    transform: translateY(-2px);
}

/* --- Responsive Match Grid --- */
.match-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

.match-card {
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid #ced4da;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    color: #333;
    display: flex;
    flex-direction: column;
    text-align: center;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.match-card:hover {
    background-color: rgba(248, 249, 250, 0.9);
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.match-header {
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 15px;
    font-weight: bold;
}

.teams-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.team-box {
    display: flex;
    align-items: center;
    flex-direction: column;
    width: 40%;
}

.flag-placeholder {
    display: block;
    width: 40px;
    height: 30px;
    background-color: #adb5bd;
    border: 1px solid #777;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
}

.team-box .name {
    font-weight: bold;
    font-size: 1.1em;
}

.score-box {
    font-size: 3em;
    font-weight: bold;
    color: #F38F15;
}

.separator {
    background-color: #28a745;
    color: white;
    padding: 5px 10px;
    border-radius: 50px;
    font-size: 0.8em;
    font-weight: bold;
}

.match-details {
    font-size: 0.9em;
    color: #6c757d;
    margin-top: 10px;
}

.more-button {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 20px;
    background-color: #79C3A0;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.more-button:hover {
    background-color: #63a987;
}

hr {
    border: none;
    height: 1px;
    background-color: #ddd;
    margin: 40px 0;
}

.score-board {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 30px 0;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    margin-bottom: 30px;
    border: 1px solid #ced4da;
}

.team {
    text-align: center;
    font-size: 1.4em;
    font-weight: 600;
}

.score {
    font-size: 3.5em;
    font-weight: bold;
    color: #F38F15;
}

.team-name {
    font-size: 1.8em;
    color: #333;
    margin-bottom: 10px;
}

th#goals-header, th#assists-header {
    cursor: pointer;
    position: relative;
}

th#goals-header::after, th#assists-header::after {
    content: '';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
}

th.sorted-asc::after {
    border-top: 5px solid #333;
}

th.sorted-desc::after {
    border-bottom: 5px solid #333;
}

/* --- Media Queries per la Responsiveness --- */
@media (max-width: 767px) {
    /* Regole per schermi piccoli (smartphone) */
    .container {
        padding: 15px; /* Riduce il padding per ottimizzare lo spazio */
    }

    /* Griglia delle partite a singola colonna su mobile */
    .match-grid {
        grid-template-columns: 1fr;
    }

    /* Bottoni di navigazione allineati verticalmente */
    .navigation-links {
        flex-direction: column;
    }

    .nav-button {
        width: 100%;
        max-width: none;
        margin: 0;
    }

    /* Riduci il font delle intestazioni della tabella su mobile */
    th, td {
        padding: 10px;
        font-size: 0.8em;
    }
}

@media (min-width: 768px) {
    /* Regole per schermi più grandi (tablet, desktop) */
    .navigation-links {
        flex-direction: row;
        justify-content: center;
    }

    .nav-button {
        width: auto;
        margin: 0 10px;
    }
}

#match-title {
    display: none;
}

.nav-button {
    width: 100%;
    max-width: 300px;
    padding: 12px 25px;
    background-color: #F38F15;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    text-align: center;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.nav-button:hover {
    background-color: #e07b0e;
    transform: translateY(-2px);
}

/* Stile per i link all'interno della classifica */
.player-table a {
    color: inherit;
    text-decoration: none;
}

/* Stile per i link quando ci si passa sopra con il mouse (opzionale) */
.player-table a:hover {
    color: #0056b3;
    text-decoration: underline;
}

#ranking-table a {
    color: inherit;
    text-decoration: none;
}

/* Stile per il link quando ci si passa sopra con il mouse (opzionale) */
#ranking-table a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.recap-header {
    text-align: center;
    margin-bottom: 20px;
}

.recap-header h2 {
    font-size: 2em;
    margin-bottom: 5px;
}

.recap-header .score {
    font-size: 3em;
    font-weight: bold;
    color: #333;
}

.recap-events {
    margin-top: 30px;
}

.event-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.event-table th, .event-table td {
    border: 1px solid #ccc;
    padding: 8px;
    text-align: left;
}

.event-table thead {
    background-color: #f2f2f2;
}

.recap-players {
    margin-top: 30px;
}

.players-tables-container {
    display: flex;
    justify-content: space-around;
    gap: 20px;
}

.team-players {
    flex: 1;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
}

.team-players h4 {
    text-align: center;
    margin-top: 0;
}

.player-list {
    list-style: none;
    padding: 0;
}

.player-list li {
    padding: 5px 0;
    border-bottom: 1px dashed #ddd;
}

.live-indicator {
    background-color: #d63333;
    color: white;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 5px;
    animation: pulse 1s 2;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Rende le tabelle scorrevoli su schermi piccoli */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Assicura che le tabelle all'interno del contenitore si adattino bene */
.table-container table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
}

.table-container th, 
.table-container td {
    white-space: nowrap;
    padding: 8px 12px;
    border: 1px solid #ddd;
    text-align: left;
}

/* Larghezza fissa per le colonne della tabella dei giocatori */
.players-table th:nth-child(1),
.players-table td:nth-child(1) {
    width: 10%;
}

.players-table th:nth-child(2),
.players-table td:nth-child(2) {
    width: 50%;
}

.players-table th:nth-child(3),
.players-table td:nth-child(3) {
    width: 13%;
}

.players-table th:nth-child(4),
.players-table td:nth-child(4) {
    width: 13%;
}

.players-table th:nth-child(5),
.players-table td:nth-child(5) {
    width: 14%;
}

/* Regole per il layout delle tabelle giocatori */
.players-tables-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 100%;
}

.team-players {
    width: 100%;
}

/* Imposta una larghezza fissa per le colonne della tabella delle partite */
.schedule-table th:nth-child(1),
.schedule-table td:nth-child(1) {
    width: 15%;
}

.schedule-table th:nth-child(2),
.schedule-table td:nth-child(2) {
    width: 10%;
}

.schedule-table th:nth-child(3),
.schedule-table td:nth-child(3) {
    width: 30%;
}

.schedule-table th:nth-child(4),
.schedule-table td:nth-child(4) {
    width: 30%;
}

.schedule-table th:nth-child(5),
.schedule-table td:nth-child(5) {
    width: 15%;
}

/* Rimuove la sottolineatura dai link nella tabella dei risultati */
.schedule-table a {
    text-decoration: none;
}

.score-changed {
    animation: glow-animation 1s ease-in-out;
}

@keyframes glow-animation {
    0% {
        transform: scale(1);
        color: inherit;
        text-shadow: none;
    }
    50% {
        transform: scale(1.2);
        color: #ffcc00;
        text-shadow: 0 0 10px #ffcc00, 0 0 20px #ffcc00;
    }
    100% {
        transform: scale(1);
        color: inherit;
        text-shadow: none;
    }
}

.goal-message {
    position: fixed;
    top: 50%;
    right: -100%;
    transform: translateY(-50%);
    color: #ffcc00;
    font-size: 8vw;
    font-weight: bold;
    text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    z-index: 1000;
    font-family: 'Arial Black', Gadget, sans-serif;
    display: none;
}

@keyframes scroll-goal {
    from { right: -100%; }
    to { right: 100%; }
}

/* Contenitore per il pulsante, posizionato in alto a destra */
.audio-unlock-container {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
}

/* Stile del pulsante, lo rendiamo piccolo e discreto */
.audio-unlock-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #ccc;
    background-color: rgba(255, 255, 255, 0.7);
    color: #333;
    font-size: 1.2em;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.audio-unlock-btn:hover {
    background-color: rgba(255, 255, 255, 0.9);
    transform: scale(1.1);
}

/* Stile per il contenitore del tempo di gioco */
.match-info {
    text-align: center; /* Assicurati che il contenuto sia centrato */
    margin-top: 20px;
    margin-bottom: 20px; /* Spazio sopra e sotto il blocco del tempo */
}

/* --- La tua unica e corretta definizione per l'elemento del tempo --- */
#time-display {
    display: inline-block;
    font-size: 1em; /* Valore ridotto per una scritta più piccola */
    font-weight: bold;
    color: #F38F15;
    background-color: #fff;
    padding: 15px 30px;
    border: 3px solid #79C3A0;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    letter-spacing: 2px;
    transition: all 0.3s ease;
}

/* Stile per l'effetto hover (opzionale) */
#time-display:hover {
    border-color: #F38F15;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
}

/* Regole per schermi più piccoli */
@media (max-width: 767px) {
    #time-display {
        font-size: 2em;
        padding: 10px 20px;
    }
}

/*
* Questo è il selettore che DEVE attivare l'animazione.
* Il tuo JavaScript aggiungerà la classe .live-pulse solo quando necessario.
*/
#time-display.live-pulse {
    animation: pulse-animation 2s infinite;
}

/*
* Keyframes per l'animazione di pulsazione.
* Questo blocco è corretto.
*/
@keyframes pulse-animation {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border-left-color: #79C3A0;
  animation: spin 1s ease infinite;
  margin: 50px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}