/* ========= BASE ========= */
body {
    font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    min-height: 100vh;
}

.container {
    max-width: 600px; /* Limita la larghezza massima su desktop */
    margin: 0 auto;   /* Centra il contenitore orizzontalmente */
    padding: 15px 15px; /* Spaziatura interna */
    box-sizing: border-box;
    background-color: #ffffff; /* Facoltativo: sfondo bianco */
    border-radius: 20px;       /* Facoltativo: angoli arrotondati */
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); /* Facoltativo: ombra */
}

h2 {
  text-align: center;
}

/* ========= HEADER ========= */
header, .header {
    background: #264653;
    padding: 10px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    top: 0;
    z-index: 1000;
    border-radius: 20px;       /* Facoltativo: angoli arrotondati */
}

header h1, .site-title {
    margin: 0;
    font-weight: 700;
    font-size: 1.4rem;
    color: #e9c46a;
}

.logo {
    height: 50px;
    border-radius: 30%;
}

/* ========= USER ACTIONS ========= */
#user-actions {
    font-weight: 500;
}

#user-actions button,
#user-actions span {
    background: #e9c46a;
    border: none;
    color: #264653;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    margin-left: 10px;
    margin-top: 0px;
    transition: background-color 0.3s ease;
}

#user-actions button:hover {
    background: #f4d06f;
}

/* ========= LOGIN POPUP ========= */
#loginPopup {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#loginPopup.active {
    display: flex;
}

.login-form {
    background: #264653;
    padding: 30px 40px;
    border-radius: 14px;
    width: 320px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.7);
    text-align: center;
    color: #fff;
    position: relative;
}

.login-form h2 {
    margin-bottom: 20px;
    font-weight: 700;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    margin: 10px 0 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    box-sizing: border-box;
}

.login-form button {
    background-color: #e9c46a;
    border: none;
    padding: 12px 0;
    width: 100%;
    font-weight: 700;
    font-size: 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    color: #264653;
    transition: background-color 0.3s ease;
}

.login-form button:hover {
    background-color: #f4d06f;
}

.login-form .close-btn {
    position: absolute;
    top: 10px;
    right: 14px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

.login-error {
    background: #e63946;
    border-radius: 6px;
    padding: 8px;
    font-weight: 600;
    margin-bottom: 10px;
}

.login-form .close-btn {
    all: unset; /* Resetta tutti gli stili ereditati */
    position: absolute;
    top: 10px;
    right: 14px;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
}

/* ========= FORM STANDARD ========= */
form {
    background: white;
    color: #212121;
    padding: 15px 20px;
    border-radius: 8px;
    max-width: 450px;
    margin-bottom: 30px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

label {
    display: block;
    margin-top: 12px;
    font-weight: 600;
}

input[type="text"],
input[type="number"],
input[type="color"] {
    width: 100%;
    padding: 8px 10px;
    margin-top: 6px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box;
}


.torneo-header h2 {
    flex: 1;
    text-align: center;
    margin: 10px;
}

.btn-small {
    font-size: 0.8rem;
    padding: 6px 10px;
    width: auto;
    display: inline-block;
}


/* ========= MESSAGGI ========= */
.message {
    margin-bottom: 20px;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    color: white;
}

.message.success {
    background-color: #2a9d8f;
}

.message.error {
    background-color: #e63946;
}

/* ========= FOOTER ========= */
.footer {
    color: #264653;
    text-align: center;
    padding: 20px 50px;
    border-radius: 10px;       /* Facoltativo: angoli arrotondati */
}

.footer .social a {
    color: #FDD835;
    margin: 0 10px;
    text-decoration: none;
    font-weight: 600;
}

.footer .social a:hover {
    color: #FB8C00;
}

.footer p {
    margin: 5px 0;
}

.group-card {
    background-color: #fdfdfd;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin: 20px 0;
    padding: 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.group-title {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #333;
    border-bottom: 2px solid #ccc;
    padding-bottom: 5px;
}

.table-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.table-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    font-size: 0.95rem;
}

.table-header {
    background-color: #e9ecef;
    font-weight: bold;
    border-bottom: 1px solid #ccc;
}
.table-row.grid {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr 1fr 1fr 1fr;
    align-items: center;
    gap: 5px;
}

.tabella-partite {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.grid-4 {
    display: grid;
    grid-template-columns: 2fr 3fr 3fr 2fr;
    gap: 5px;
    align-items: center;
}

.table-row {
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    font-size: 0.95rem;
}

/* ========= RESPONSIVE ========= */
@media (max-width: 480px) {
    
    .login-form {
        width: 80%;
        padding: 20px;
    }

    header h1, .site-title {
    margin: 0;
    font-weight: 700;
    font-size: 1.0rem;
    color: #e9c46a;
    text-align: center;
}

.torneo h3 {
    margin: 0;
    color: #264653;
    font-size: 1.1rem;
}

    .table-row {
        font-size: 0.75rem;
        padding: 1px 1px;
    }

    .table-row > div {
        padding: 1 4px;
    }
  .grid {
        gap: 4px; /* riduce la distanza tra le colonne */
        font-size: 0.75rem;
        padding: 1px 0;
    }
}

body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: #f7f9fc;
            margin: 0; padding: 20px;
            color: #333;
        }
        h1 {
            color: #264653;
        }
        form {
            background: white;
            padding: 15px 20px;
            border-radius: 8px;
            max-width: 450px;
            margin-bottom: 30px;
            box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        }
        label {
            display: block;
            margin-top: 12px;
            font-weight: 600;
        }
        input[type="text"],
        input[type="number"],
        input[type="color"] {
            width: 100%;
            padding: 8px 10px;
            margin-top: 6px;
            border: 1px solid #ccc;
            border-radius: 6px;
            font-size: 1rem;
            box-sizing: border-box;
        }
        button {
            margin-top: 18px;
            background-color: #2a9d8f;
            border: none;
            color: white;
            font-weight: 700;
            font-size: 1rem;
            padding: 10px 0;
            width: 100%;
            border-radius: 6px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        button:hover {
            background-color: #21867a;
        }
        .message {
            margin-bottom: 20px;
            padding: 10px;
            border-radius: 6px;
            font-weight: 600;
            color: white;
        }
        .message.success {
            background-color: #2a9d8f;
        }
        .message.error {
            background-color: #e63946;
        }
        .torneo {
            background: #26465317;
            padding: 15px 20px;
            margin-bottom: 15px;
            border-radius: 8px;
            border-left: 10px solid;
            box-shadow: 0 4px 10px rgba(0,0,0,0.05);
            cursor: pointer;
            user-select: none;
        }
        .torneo h3 {
            margin: 0;
            color: #264653;
        }

        /*
        .torneo .details {
            margin-top: 8px;
            display: none;
            color: #555;
        }
            */
        .date-icon, .edit-date, 
.open-score-icon {
    background-color: transparent;
    border: none;
    font-size: 18px;  /* dimensione più piccola per adattarsi al mobile */
    cursor: pointer;
    padding: 4px;
    margin: 0;
    line-height: 1;
}

.date-icon:hover, .edit-date, 
.open-score-icon:hover {
    opacity: 0.8;
}


.date-form input[type="date"] {
    font-size: 14px;
    padding: 2px;
}

.date-form button {
    font-size: 14px;
    margin-left: 4px;
}

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-picker input[type="radio"] {
  display: none;
}

.color-picker label {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border 0.2s ease;
}

.color-picker input[type="radio"]:checked + label {
  border: 2px solid #000;
}

.error-alert {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #f44336;
  color: white;
  padding: 14px 20px;
  border-radius: 6px;
  font-size: 16px;
  z-index: 99999; /* più alto di overlay e modale */
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.error-alert button {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
}
.toggle-btn-group {
  display: flex;
  gap: 10px;
}
.toggle-btn-group input[type="radio"] {
  display: none;
}
.toggle-btn-group label {
  padding: 8px 15px;
  border: 1px solid #ccc;
  border-radius: 20px;
  cursor: pointer;
  user-select: none;
  transition: all 0.3s ease;
}
.toggle-btn-group input[type="radio"]:checked + label {
  background-color: #3498db;
  color: white;
  border-color: #2980b9;
}


/* Container del tabellone */
.bracket-container {
    overflow-x: auto;
    padding: 1rem;
}

/* Struttura del bracket */
.bracket {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    min-width: 600px;
}

/* Ogni colonna/round */
.round {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Titolo round */
.round-title {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

/* Casella match */
.match {
    background: #f9f9f9;
    border: 1px solid #ccc;
    border-radius: 6px;
    width: 100px;
    padding: 4px;
    margin: 10px 0;
    text-align: center;
    font-size: 0.75rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Giocatore */
.player {
    padding: 4px;
    border-bottom: 1px solid #e0e0e0;
}

.player:last-child {
    border-bottom: none;
}

/* Responsivo */
@media (max-width: 768px) {
    .match {
        width: 100px;
        font-size: 0.7rem;
    }
    .round-title {
        font-size: 0.8rem;
    }
}

/* Margini dinamici per centrare i match in turni successivi */
.round-1 .match {
    margin-top: 70px;
    margin-bottom: 30px;
}
.round-2 .match {
    margin-top: 140px;
    margin-bottom: 130px;
}
.round-3 .match {
    margin-top: 300px;
}

  .modal {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}

.torneo-blocco {
    margin-bottom: 20px;
}

.torneo-blocco h3 {
    border-bottom: 1px solid #ccc;
    padding-bottom: 4px;
    margin-bottom: 8px;
}

@media (max-width: 600px) {
  .prossime-partite li span {
    font-size: 12px;
  }

  .prossime-partite h2,
  .prossime-partite h3 {
    font-size: 16px;
  }

  .prossime-partite span.quadratino {
    width: 10px;
    height: 10px;
  }
}

.torneo-header {
  width: 100%;
  padding: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    margin-top: 10px;
}

.torneo-header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap; /* Per adattarsi su schermi piccoli */
}

.left-side {
  flex: 1;
  min-width: 200px;
}

.right-side {
  flex-shrink: 0;
    margin-right: 12px;
}

.live-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-box {
  display: flex;
  align-items: center;
  gap: 5px;
}

.live-dot {
  width: 10px;
  height: 10px;
  background-color: red;
  border-radius: 50%;
  animation: blink 1s infinite;
}

.live-text {
  font-weight: bold;
  color: red;
}

.scrolling-matches {
  overflow: hidden;
  max-width: 400px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.versione-app {
    font-size: 0.7em; /* oppure ad esempio 12px */
    font-style: italic;
}


.date-form {
    position: relative;
    z-index: 999;
    background: white;
    padding: 10px;
    border: 1px solid #ccc;
    max-width: 100%;
    box-sizing: border-box;
    margin-top: 5px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.flatpickr-calendar {
    z-index: 1000 !important;
    max-width: 100vw;
}

.form-date {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-date {
  width: 100px;
}

.btn-save {
  width: 100px;
  padding: 15px;
  cursor: pointer;
}

.btn-clear {
  width: 50px;
  background: #ff0000;
  color: #ffffff;
  border: none;
  padding: 11px;
  cursor: pointer;
  font-size: 20px; /* così icona è visibile */
  display: flex;
  justify-content: center;
  align-items: center;
}
