/* ===== FANTACALCIO CSS PARTE 1: BASE E CONTAINER ===== */

/* Container principale con background moderno */
#fantacalcio-match-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    position: relative;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Header principale modernizzato */
#fantacalcio-match-container h2 {
    color: white;
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 30px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Frame moderno per i controlli */
.match-controls-frame {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.match-controls-frame::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2, #f093fb, #f5576c);
    background-size: 300% 100%;
    animation: gradientShift 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { 
        background-position: 0% 50%; 
    }
    50% { 
        background-position: 100% 50%; 
    }
}

/* Titolo della sezione controlli */
.controls-title {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 25px;
    position: relative;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.controls-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
}

/* ===== FANTACALCIO CSS PARTE 2: SELEZIONE SQUADRE E BOTTONI ===== */

/* Selezione squadre modernizzata */
.team-selection {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 30px;
    align-items: center;
    margin-bottom: 30px;
}

.team-selector {
    position: relative;
}

.team-selector label {
    display: block;
    font-weight: 600;
    color: #34495e;
    margin-bottom: 10px;
    font-size: 1.1rem;
    text-align: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.team-selector select {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e8ecef;
    border-radius: 15px;
    font-size: 1rem;
    font-weight: 500;
    background: white;
    color: #2c3e50;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 20px;
    cursor: pointer;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.team-selector select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.team-selector select:hover {
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
}

/* Divider VS modernizzato */
.vs-divider {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: 900;
    font-size: 1.5rem;
    padding: 20px;
    border-radius: 50%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    position: relative;
    animation: pulse 2s ease-in-out infinite;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    }
    50% { 
        transform: scale(1.05); 
        box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
    }
}

/* Action buttons modernizzati */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-modern {
    padding: 15px 30px;
    border: none;
    border-radius: 15px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 180px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.btn-generate {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.4);
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(40, 167, 69, 0.5);
}

.btn-generate:disabled {
    background: linear-gradient(135deg, #6c757d, #adb5bd);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.btn-export {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.4);
}

.btn-export:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(0, 123, 255, 0.5);
}

.btn-print {
    background: linear-gradient(135deg, #6f42c1, #5a2d91);
    color: white;
    box-shadow: 0 8px 25px rgba(111, 66, 193, 0.4);
}

.btn-print:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(111, 66, 193, 0.5);
}

/* Effetto ripple per i button */
.btn-modern::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.4s ease;
    transform: translate(-50%, -50%);
}

.btn-modern:active::before {
    width: 120%;
    height: 120%;
}

/* ===== FANTACALCIO CSS PARTE 3: LOADING E STATI ===== */

/* Loading spinner modernizzato */
#loading-container {
    text-align: center;
    padding: 40px 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    margin: 20px 0;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.loading-spinner {
    display: inline-block;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-spinner p {
    color: #2c3e50;
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Stili per error e success containers */
#error-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.fantacalcio-error {
    color: #721c24;
    border-left: 4px solid #dc3545;
    padding-left: 15px;
}

.fantacalcio-error h3 {
    margin: 0 0 10px 0;
    color: #dc3545;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.fantacalcio-success {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 15px;
    border-radius: 12px;
    margin: 15px 0;
    text-align: center;
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.4);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Legenda modernizzata */
.legend-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 25px;
    border-radius: 20px;
    margin: 20px 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.legend-container h4 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    font-size: 14px;
    color: #6c757d;
}

.legend-grid div {
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.legend-grid div:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 1);
}

.legend-grid strong {
    color: #2c3e50;
    font-weight: 700;
}

/* NUOVO: Sezione e bottone calcola partita */
.calculate-match-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 30px;
    margin: 30px 0;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-align: center;
}

.btn-calculate {
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
    color: white;
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
    font-size: 1.2rem;
    padding: 18px 40px;
}

.btn-calculate:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(255, 107, 107, 0.5);
}

/* ===== FANTACALCIO CSS PARTE 4: FORMAZIONI E LAYOUT ===== */

/* Container principale per le formazioni */
.formations-container {
    padding: 0 20px;
}

/* Container per ogni squadra */
.team-container {
    margin: 25px 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 20px;
}

/* Layout squadra: tabella + liste laterali */
.team-layout {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.titolari-table-container {
    flex: 2.5;
    min-width: 0;
}

.side-lists {
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 10px;
    min-width: 280px;
}

/* Titoli delle formazioni */
.formation-title {
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 15px;
    padding: 12px;
    border-radius: 12px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.formation-title.casa {
    background: linear-gradient(135deg, #28a745, #20c997);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
}

.formation-title.trasferta {
    background: linear-gradient(135deg, #007bff, #0056b3);
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.3);
}

/* Dettagli formazione */
.formation-details {
    background: rgba(248, 249, 250, 0.9);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid rgba(233, 236, 239, 0.5);
}

.formation-details div {
    margin: 5px 0;
    font-size: 18px;
    color: #495057;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Stili per le liste laterali */
.panchinari-list,
.rigoristi-list {
    flex: 1;
    background: rgba(248, 249, 250, 0.9);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(233, 236, 239, 0.5);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    min-height: 200px;
}

.panchinari-list h5,
.rigoristi-list h5 {
    margin: 0 0 8px 0;
    font-size: 12px;
    font-weight: bold;
    color: #495057;
    text-align: center;
    padding-bottom: 6px;
    border-bottom: 2px solid #e9ecef;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.panchinari-list ol,
.rigoristi-list ol {
    margin: 0;
    padding-left: 14px;
    list-style-type: decimal;
}

.panchinari-list li,
.rigoristi-list li {
    padding: 3px 0;
    color: #495057;
    font-size: 10px;
    line-height: 1.3;
    border-bottom: 1px dotted #dee2e6;
    word-wrap: break-word;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.panchinari-list li:last-child,
.rigoristi-list li:last-child {
    border-bottom: none;
}

/* Effetto hover sui panchinari per indicare che sono cliccabili */
.panchinari-list li:hover {
    transform: translateX(5px);
    font-weight: 600;
}

.panchinari-list li::after {
    content: '👁️';
    position: absolute;
    right: 5px;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 12px;
}

.panchinari-list li:hover::after {
    opacity: 1;
}

/* ===== FANTACALCIO CSS PARTE 5: TABELLE E INPUT ===== */

/* Tabella ottimizzata */
.formation-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

/* Headers delle tabelle */
.formation-table th {
    padding: 8px 3px;
    text-align: center;
    font-weight: bold;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Righe della tabella */
.formation-table td {
    padding: 4px 2px;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
    border-right: 1px solid #e9ecef;
    vertical-align: middle;
}

/* Riga totalizzatore */
.formation-table .totals-row {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef) !important;
    border-top: 2px solid #6c757d;
    font-weight: bold;
    color: #2c3e50;
}

.formation-table .totals-row td {
    background: inherit !important;
    font-weight: bold;
    font-size: 11px;
    border-bottom: 2px solid #6c757d;
    border-right: 1px solid #6c757d;
    padding: 8px 5px;
}

.formation-table .totals-row .player-name {
    text-align: center !important;
    font-size: 11px !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #495057;
    padding-left: 5px !important;
}

.formation-table .totals-row .total-value {
    color: #007bff;
    font-size: 12px;
    font-weight: 900;
}

.player-name {
    text-align: left !important;
    font-weight: 600;
    color: #2c3e50;
    padding-left: 6px !important;
    min-width: 25px !important;
    max-width: 35px;
    font-size: 11px !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.player-name.compact {
    width: 55px;
    font-size: 13px !important;
    padding-left: 4px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Rimuove spinner da TUTTI gli input numerici */
.score-select {
    width: 35px;
    padding: 2px 3px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 11px;
    font-weight: bold;
    background: white;
    color: #495057;
    text-align: center;
    cursor: text;
    transition: all 0.2s ease;
    min-height: 18px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -moz-appearance: textfield;
}

.score-select::-webkit-outer-spin-button,
.score-select::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.score-select:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.score-select:hover {
    border-color: #667eea;
    background: #f8f9fa;
}

/* Celle della tabella - AGGIORNATA CON RS (RIGORE SBAGLIATO) */
.formation-table td.voto,
.formation-table td.gol-fatti,
.formation-table td.assist,
.formation-table td.gol-subiti,
.formation-table td.rigore-parato,
.formation-table td.rigore-sbagliato,
.formation-table td.ammonizione,
.formation-table td.espulsione,
.formation-table td.autogol {
    padding: 1px 2px;
    text-align: center;
    vertical-align: middle;
    width: 15px;
    min-width: 20px;
    max-width: 30px;
}

/* ===== FANTACALCIO CSS PARTE 6: STILI INPUT SPECIFICI ===== */

/* Input specifico per Gol Fatti - solo numeri interi */
.score-select.gol-fatti-input {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    font-weight: bold;
    border: 2px solid #28a745;
}

.score-select.gol-fatti-input:focus {
    border-color: #20c997;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.3);
    background: #28a745;
}

.score-select.gol-fatti-input:hover {
    border-color: #20c997;
    background: linear-gradient(135deg, #20c997, #28a745);
}

/* Input specifico per Rigori Parati - solo numeri interi */
.score-select.rigore-parato-input {
    background: linear-gradient(135deg, #2e04ff, #2e04ff);
    color: white;
    font-weight: bold;
    border: 2px solid #2e04ff;
}

.score-select.rigore-parato-input:focus {
    border-color: #2e04ff;
    box-shadow: 0 0 0 2px rgba(46, 4, 255, 0.3);
    background: #2e04ff;
}

.score-select.rigore-parato-input:hover {
    border-color: #2e04ff;
    background: linear-gradient(135deg, #2e04ff, #2e04ff);
}

/* Input specifico per Rigori Sbagliati - NUOVO */
.score-select.rigore-sbagliato-input {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    font-weight: bold;
    border: 2px solid #dc3545;
}

.score-select.rigore-sbagliato-input:focus {
    border-color: #c82333;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.3);
    background: #dc3545;
}

.score-select.rigore-sbagliato-input:hover {
    border-color: #c82333;
    background: linear-gradient(135deg, #c82333, #dc3545);
}

/* Input specifico per Ammonizioni - solo 0 o 1 */
.score-select.ammonizione-input {
    background: linear-gradient(135deg, #E2F702, #E2F702);
    color: rgb(0, 0, 0);
    font-weight: bold;
    border: 2px solid #E2F702;
}

.score-select.ammonizione-input:focus {
    border-color: #E2F702;
    box-shadow: 0 0 0 2px rgb(226, 247, 2);
    background: #E2F702;
}

.score-select.ammonizione-input:hover {
    border-color: #E2F702;
    background: linear-gradient(135deg, #E2F702, #E2F702);
}

/* Input specifico per Espulsioni - solo 0 o 1 */
.score-select.espulsione-input {
    background: linear-gradient(135deg, #FF2226, #FF2226);
    color: white;
    font-weight: bold;
    border: 2px solid #FF2226;
}

.score-select.espulsione-input:focus {
    border-color: #FF2226;
    box-shadow: 0 0 0 2px rgba(255, 34, 38, 0.946);
    background: #FF2226;
}

.score-select.espulsione-input:hover {
    border-color: #FF2226;
    background: linear-gradient(135deg, #FF2226, #FF2226);
}

/* Input specifico per Assist - sfondo verde con testo nero */
.score-select.assist-input {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    font-weight: bold;
    border: 2px solid #28a745;
}

.score-select.assist-input:focus {
    border-color: #20c997;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.3);
    background: #28a745;
    color: white;
}

.score-select.assist-input:hover {
    border-color: #20c997;
    background: linear-gradient(135deg, #20c997, #28a745);
    color: white;
}

/* Input specifico per Gol Subiti - sfondo rosso con testo bianco */
.score-select.gol-subiti-input {
    background: linear-gradient(135deg, #FF2226, #FF2226);
    color: white;
    font-weight: bold;
    border: 2px solid #FF2226;
}

.score-select.gol-subiti-input:focus {
    border-color: #FF2226;
    box-shadow: 0 0 0 2px rgba(255, 34, 38, 0.946);
    background: #FF2226;
}

.score-select.gol-subiti-input:hover {
    border-color: #FF2226;
    background: linear-gradient(135deg, #FF2226, #FF2226);
}

/* Input specifico per Autogol - sfondo rosso con testo bianco */
.score-select.autogol-input {
    background: linear-gradient(135deg, #FF2226, #FF2226);
    color: white;
    font-weight: bold;
    border: 2px solid #FF2226;
}

.score-select.autogol-input:focus {
    border-color: #FF2226;
    box-shadow: 0 0 0 2px rgba(255, 34, 38, 0.946);
    background: #FF2226;
}

.score-select.autogol-input:hover {
    border-color: #FF2226;
    background: linear-gradient(135deg, #FF2226, #FF2226);
}

/* Cella GS non disponibile (non portiere) */
.formation-table .gol-subiti-disabled {
    background: #f405e4a7 !important;
    color: #f405e4a7 !important;
    text-align: center !important;
    vertical-align: middle !important;
    font-style: italic;
    border: 1px solid #dee2e6 !important;
}

.formation-table .gol-subiti-disabled::before {
    content: "N/D";
    font-size: 11px;
    color: white;
}

/* ===== FANTACALCIO CSS PARTE 7: COLORAZIONE RUOLI GIOCATORI ===== */

/* Portiere - Sfondo giallo */
.formation-table tbody tr.player-row.portiere td {
    background-color: #fff3cd !important;
    border: 1px solid #ffeaa7;
    color: #000000 !important;
}

/* Difensori - Sfondo verde */
.formation-table tbody tr.player-row.difensore td {
    background-color: #d4edda !important;
    border: 1px solid #00b894;
    color: #000000 !important;
}

/* Centrocampisti - Sfondo azzurro */
.formation-table tbody tr.player-row.centrocampista td {
    background-color: #d1ecf1 !important;
    border: 1px solid #74b9ff;
    color: #000000 !important;
}

/* Attaccanti - Sfondo rosso */
.formation-table tbody tr.player-row.attaccante td {
    background-color: #f8d7da !important;
    border: 1px solid #e17055;
    color: #000000 !important;
}

/* Input nei campi colorati - mantiene leggibilità */
.formation-table tbody tr.player-row td input.score-select {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: #000000 !important;
}

/* Riga totali - mantiene lo stile esistente */
.formation-table .totals-row td {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef) !important;
    color: #000000 !important;
}

/* ===== COLORAZIONE PANCHINARI PER RUOLO ===== */

/* Portieri panchinari - Sfondo giallo chiaro */
.panchinari-list li.panchinaro-portiere {
    background-color: #fff9c4 !important;
    border-left: 4px solid #ffd700 !important;
    padding: 6px 8px !important;
    margin: 2px 0 !important;
    border-radius: 4px !important;
    color: #000000 !important;
    border-bottom: 1px solid #f9e79f !important;
}

/* Difensori panchinari - Sfondo azzurro chiaro */
.panchinari-list li.panchinaro-difensore {
    background-color: #e3f2fd !important;
    border-left: 4px solid #2196f3 !important;
    padding: 6px 8px !important;
    margin: 2px 0 !important;
    border-radius: 4px !important;
    color: #000000 !important;
    border-bottom: 1px solid #bbdefb !important;
}

/* Centrocampisti panchinari - Sfondo verde chiaro */
.panchinari-list li.panchinaro-centrocampista {
    background-color: #e8f5e8 !important;
    border-left: 4px solid #4caf50 !important;
    padding: 6px 8px !important;
    margin: 2px 0 !important;
    border-radius: 4px !important;
    color: #000000 !important;
    border-bottom: 1px solid #c8e6c9 !important;
}

/* Attaccanti panchinari - Sfondo arancione chiaro */
.panchinari-list li.panchinaro-attaccante {
    background-color: #fff3e0 !important;
    border-left: 4px solid #ff9800 !important;
    padding: 6px 8px !important;
    margin: 2px 0 !important;
    border-radius: 4px !important;
    color: #000000 !important;
    border-bottom: 1px solid #ffcc02 !important;
}

/* Hover effects per i panchinari */
.panchinari-list li.panchinaro-portiere:hover {
    background-color: #fff59d !important;
    transform: translateX(2px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.3);
}

.panchinari-list li.panchinaro-difensore:hover {
    background-color: #bbdefb !important;
    transform: translateX(2px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
}

.panchinari-list li.panchinaro-centrocampista:hover {
    background-color: #c8e6c9 !important;
    transform: translateX(2px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.panchinari-list li.panchinaro-attaccante:hover {
    background-color: #ffcc02 !important;
    transform: translateX(2px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(255, 152, 0, 0.3);
}

/* ===== FANTACALCIO CSS PARTE 8: SISTEMA CALCOLO E POPUP ===== */

/* Container principale dei risultati di calcolo */
.calculation-results {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 30px;
    margin: 30px 0;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Titolo del risultato */
.result-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 25px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Punteggio finale grande */
.final-score {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin: 30px 0;
    font-size: 3rem;
    font-weight: 900;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Box del punteggio di ogni squadra */
.team-score {
    text-align: center;
    padding: 20px;
    border-radius: 15px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    min-width: 200px;
}

.team-score.casa {
    background: linear-gradient(135deg, #28a745, #20c997);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
}

.team-score.trasferta {
    background: linear-gradient(135deg, #007bff, #0056b3);
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.3);
}

.team-score small {
    font-size: 0.8rem;
    opacity: 0.9;
}

/* Separatore VS */
.vs-separator {
    font-size: 2rem;
    color: #6c757d;
    font-weight: 900;
}

/* Grid per i dettagli bonus */
.bonus-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 30px;
}

/* Container bonus per singola squadra */
.team-bonus {
    background: rgba(248, 249, 250, 0.9);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(233, 236, 239, 0.5);
}

.team-bonus h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1.2rem;
}

/* Singola riga di bonus */
.bonus-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dotted #dee2e6;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.bonus-item:last-child {
    border-bottom: none;
    font-weight: bold;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px solid #dee2e6;
}

/* Errore di calcolo */
.calculation-error {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    text-align: center;
    box-shadow: 0 8px 25px rgba(220, 53, 69, 0.4);
}

.calculation-error h3 {
    margin: 0 0 10px 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.calculation-error p {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ===== STILI PER IL POPUP DEI PANCHINARI ===== */

/* Overlay del popup */
.player-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInOverlay 0.3s ease-out;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

/* Container principale del popup */
.player-popup-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 25px;
    padding: 0;
    margin: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    max-width: 600px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideInPopup 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

@keyframes slideInPopup {
    from {
        transform: scale(0.8) translateY(50px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* ===== FANTACALCIO CSS PARTE 9: HEADER E CONTENUTO POPUP ===== */

/* Header del popup con gradiente animato */
.player-popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.player-popup-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2, #f093fb, #f5576c);
    background-size: 300% 100%;
    animation: gradientShift 3s ease-in-out infinite;
}

/* Bottone di chiusura */
.player-popup-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-weight: bold;
}

.player-popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Titolo del popup */
.player-popup-title {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    padding-right: 50px;
}

.player-popup-subtitle {
    margin: 5px 0 0 0;
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 500;
}

/* Contenuto del popup - SCROLLABLE */
.player-popup-content {
    padding: 25px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    max-height: calc(85vh - 120px);
}

/* Personalizzazione scrollbar per WebKit (Chrome, Safari, Edge) */
.player-popup-content::-webkit-scrollbar {
    width: 8px;
}

.player-popup-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.player-popup-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 4px;
}

.player-popup-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8, #6b4190);
}

/* Firefox scrollbar */
.player-popup-content {
    scrollbar-width: thin;
    scrollbar-color: #667eea rgba(0, 0, 0, 0.1);
}

/* Sezione loading */
.player-popup-loading {
    text-align: center;
    padding: 40px 20px;
}

.popup-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.player-popup-loading p {
    color: #666;
    font-size: 1.1rem;
    margin: 0;
}

/* Sezione errore */
.player-popup-error {
    text-align: center;
    padding: 30px 20px;
    color: #dc3545;
}

.player-popup-error h4 {
    margin: 0 0 15px 0;
    color: #dc3545;
    font-size: 1.3rem;
}

.player-popup-error p {
    margin: 0;
    color: #666;
}

/* Sezioni ottimizzate per scrolling */
.player-info-section,
.stats-section {
    margin-bottom: 20px;
}

/* Griglia delle statistiche */
.player-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

/* Singola statistica */
.player-stat-item {
    background: rgba(248, 249, 250, 0.8);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(233, 236, 239, 0.5);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.player-stat-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.15);
    background: rgba(255, 255, 255, 0.9);
}

.player-stat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    transition: width 0.3s ease;
}

.player-stat-item:hover::before {
    width: 8px;
}

/* Label della statistica */
.player-stat-label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Valore della statistica */
.player-stat-value {
    font-size: 1.5rem;
    font-weight: 900;
    color: #2c3e50;
    margin: 0;
}

/* Colori specifici per diverse statistiche */
.player-stat-item.voto .player-stat-value {
    color: #667eea;
}

.player-stat-item.gol .player-stat-value {
    color: #28a745;
}

.player-stat-item.rigori .player-stat-value {
    color: #007bff;
}

.player-stat-item.negativi .player-stat-value {
    color: #dc3545;
}

.player-stat-item.assist .player-stat-value {
    color: #17a2b8;
}

/* ===== FANTACALCIO CSS PARTE 10: SEZIONI INFO, RESPONSIVE E MEDIA QUERY ===== */

/* Sezione info giocatore */
.player-info-section {
    background: rgba(102, 126, 234, 0.05);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.player-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.player-info-item {
    display: flex;
    flex-direction: column;
}

.player-info-label {
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.player-info-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c3e50;
}

/* Sezioni speciali per voti positivi/negativi */
.stats-section-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
    position: relative;
}

.stats-section-title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 50px;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

/* Animazione di uscita popup */
.player-popup-overlay.closing {
    animation: fadeOutOverlay 0.3s ease-in forwards;
}

.player-popup-overlay.closing .player-popup-container {
    animation: slideOutPopup 0.3s cubic-bezier(0.4, 0, 0.8, 1) forwards;
}

@keyframes fadeOutOverlay {
    to {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
}

@keyframes slideOutPopup {
    to {
        transform: scale(0.8) translateY(50px);
        opacity: 0;
    }
}

/* Previeni scroll del body quando popup è aperto */
body.popup-open {
    overflow: hidden;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    #fantacalcio-match-container {
        padding: 10px;
        border-radius: 15px;
    }

    #fantacalcio-match-container h2 {
        font-size: 2rem;
        margin-bottom: 20px;
    }

    .match-controls-frame {
        padding: 20px;
        border-radius: 15px;
        margin-bottom: 20px;
    }

    .controls-title {
        font-size: 1.5rem;
    }

    .team-selection {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .vs-divider {
        justify-self: center;
        width: 60px;
        height: 60px;
        padding: 15px;
        font-size: 1.2rem;
    }

    .action-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn-modern {
        min-width: 200px;
        padding: 12px 24px;
    }

    .team-layout {
        flex-direction: column;
        gap: 15px;
    }
    
    .side-lists {
        flex-direction: column;
        min-width: auto;
        gap: 8px;
    }
    
    .legend-grid {
        grid-template-columns: 1fr;
    }

    .calculate-match-section {
        padding: 20px;
        margin: 20px 0;
    }
    
    .btn-calculate {
        font-size: 1rem;
        padding: 15px 30px;
    }

    /* Responsive popup mobile */
    .player-popup-container {
        margin: 10px;
        max-width: 95vw;
        max-height: 90vh;
    }
    
    .player-popup-header {
        padding: 15px 20px;
    }
    
    .player-popup-title {
        font-size: 1.5rem;
    }
    
    .player-popup-content {
        padding: 15px;
        max-height: calc(90vh - 100px);
    }
    
    .player-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .player-info-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .player-stat-value {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    #fantacalcio-match-container {
        padding: 5px;
        border-radius: 10px;
    }

    .match-controls-frame {
        padding: 15px;
        margin: 10px 0;
    }

    .controls-title {
        font-size: 1.3rem;
    }

    .team-selector select {
        padding: 12px 15px;
        font-size: 0.9rem;
    }

    .btn-modern {
        padding: 12px 20px;
        font-size: 0.9rem;
        min-width: 160px;
    }

    /* Responsive popup mobile piccolo */
    .player-popup-container {
        margin: 5px;
        border-radius: 15px;
        max-height: 95vh;
    }
    
    .player-popup-header {
        padding: 12px 15px;
    }
    
    .player-popup-title {
        font-size: 1.3rem;
        padding-right: 45px;
    }
    
    .player-popup-close {
        width: 35px;
        height: 35px;
        font-size: 20px;
        top: 10px;
        right: 12px;
    }
    
    .player-popup-content {
        padding: 10px;
        max-height: calc(95vh - 80px);
    }
    
    .player-stat-item {
        padding: 12px;
    }
    
    .player-stat-value {
        font-size: 1.2rem;
    }

    .player-stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== RESPONSIVE PER IL SISTEMA DI CALCOLO ===== */
@media (max-width: 768px) {
    .calculation-results {
        padding: 20px;
        margin: 20px 0;
        border-radius: 15px;
    }
    
    .result-title {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }
    
    .final-score {
        flex-direction: column;
        gap: 15px;
        font-size: 2rem;
    }
    
    .team-score {
        min-width: auto;
        width: 100%;
        max-width: 250px;
        margin: 0 auto;
    }
    
    .vs-separator {
        font-size: 1.5rem;
        order: 0;
    }
    
    .bonus-details {
        grid-template-columns: 1fr;
        gap: 15px;
        margin-top: 20px;
    }
    
    .team-bonus {
        padding: 15px;
    }
    
    .team-bonus h4 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
}

@media (max-width: 480px) {
    .calculation-results {
        padding: 15px;
        margin: 15px 0;
    }
    
    .result-title {
        font-size: 1.3rem;
    }
    
    .final-score {
        font-size: 1.5rem;
        gap: 10px;
    }
    
    .team-score {
        padding: 15px;
    }
    
    .bonus-item {
        padding: 6px 0;
        font-size: 14px;
    }
}

/* ===== STILI PER STAMPA ===== */
@media print {
    #fantacalcio-match-container {
        background: white !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        min-height: auto !important;
    }

    .match-controls-frame {
        display: none !important;
    }
    
    #loading-container,
    #error-container {
        display: none !important;
    }
    
    .team-container {
        background: white !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
    
    .legend-container {
        background: white !important;
        backdrop-filter: none !important;
        border: 1px solid #000 !important;
    }

    .calculate-match-section {
        display: none !important;
    }

    .calculation-results {
        background: white !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
        border: 1px solid #000 !important;
        page-break-inside: avoid;
    }
    
    .team-score.casa,
    .team-score.trasferta {
        background: white !important;
        color: #000 !important;
        text-shadow: none !important;
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
    
    .team-bonus {
        background: white !important;
        border: 1px solid #000 !important;
    }

    .player-popup-overlay {
        display: none !important;
    }
}
