/* ==========================================================================
   formazione.css — FantaUML / TorneoUML — Stagione 8 (2026)
   Pagina interattiva di schieramento formazione.
   Scheletro e proporzioni allineati a register.css / benvenuto.css.
   Mobile-first: default ≤767px, override desktop ≥768px.
   ========================================================================== */

/* --------------------------------------------------------------------------
   FONT — dichiarati qui per evitare il fallback "sottile" (Arial) quando
   l'header globale non carica DrukWide/HelveticaBold.
   -------------------------------------------------------------------------- */
@font-face {
    font-family: 'DrukWide';
    src: url('/assets/doc/DrukTextWide-MediumItalic-Trial.otf') format('opentype');
    font-weight: bold;
    font-style: italic;
}
@font-face {
    font-family: 'HelveticaBold';
    src: url('/assets/doc/HelveticaBold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

:root {
    --rosa-neon: #ff19ff;
    --viola: #790cfd;
    --vinaccia: #120028;
    --vinaccia-2: #1a0438;
    --bianco: #ffffff;
    --sfondo-box: rgba(18, 0, 40, 0.6);
    --sfondo-scuro: rgba(18, 0, 40, 0.85);
    --bordo-sottile: 1px solid rgba(255, 25, 255, 0.25);
}

/* --------------------------------------------------------------------------
   NO SCROLL ORIZZONTALE / NO MOVIMENTO LATERALE (solo scroll verticale)
   Stesso scudo di register.css/benvenuto.css: il campo può sforare ma il
   documento non si allarga, così left:50% resta il 50% del viewport.
   -------------------------------------------------------------------------- */
html {
    max-width: 100%;
    overflow-x: hidden;
}
body {
    max-width: 100%;
    overflow-x: hidden;
    touch-action: pan-y;            /* solo scroll verticale, no swipe laterale */
    overscroll-behavior-x: none;
    margin: 0;
    padding: 0;
    color: var(--bianco);
    font-family: 'HelveticaBold', Arial, sans-serif;
    background-color: var(--vinaccia);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(rgba(18, 0, 40, 0.5), rgba(18, 0, 40, 0.5)),
        url('/assets/imm/gradiente26.jpg') center / cover no-repeat;
}

main.container { padding: 10px 0 40px; }

.fanta-content {
    max-width: 420px;
    margin: 0 auto;
    padding: 0 12px;
}

.card-vinaccia {
    background: var(--sfondo-scuro);
    padding: 14px;
    border-radius: 11px;
    margin-bottom: 14px;
    border: 1px solid rgba(255, 25, 255, 0.15);
}

/* ==========================================================================
   HERO / HEADER — ordinato e mobile friendly
   ========================================================================== */
.fanta-hero { padding: 14px 16px; }

.fanta-hero__top {
    display: flex;
    align-items: center;
    gap: 12px;
}
.fanta-hero__logo {
    width: 46px; height: 46px;
    border-radius: 8px;
    object-fit: contain;
    background: rgba(255, 25, 255, 0.05);
    border: 1.5px solid rgba(255, 25, 255, 0.4);
    flex-shrink: 0;
}
.fanta-hero__id {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.fanta-hero__label {
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: rgba(255, 255, 255, 0.55);
}
.fanta-hero__team-name {
    margin: 2px 0 0;
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    font-size: 1rem;
    text-transform: uppercase;
    color: var(--rosa-neon);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fanta-hero__divider {
    border: none;
    height: 1px;
    background: linear-gradient(to right,
        rgba(255, 25, 255, 0) 0%,
        rgba(255, 25, 255, 0.35) 50%,
        rgba(255, 25, 255, 0) 100%);
    margin: 12px 0;
}

.fanta-hero__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.fanta-hero__giornata {
    margin: 0;
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    font-size: 0.95rem;
    text-transform: uppercase;
    color: var(--bianco);
}

.formazione-deadline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    font-size: 0.72rem;
    padding: 5px 10px;
    border: 1px solid var(--rosa-neon);
    border-radius: 8px;
    color: var(--rosa-neon);
}
.formazione-deadline.is-urgent {
    animation: pulseDeadline 1.4s ease-in-out infinite;
}
.formazione-deadline.is-expired {
    border-color: #ff3c3c;
    color: #ff6060;
}
@keyframes pulseDeadline {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 25, 255, 0); }
    50%      { box-shadow: 0 0 8px rgba(255, 25, 255, 0.55); }
}

.fanta-hero__hint {
    margin: 12px 0 0;
    font-size: 0.72rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
}
.fanta-hero__hint strong { color: var(--rosa-neon); }
.fanta-hero__hint i { color: var(--rosa-neon); margin-right: 4px; }

/* Box errore / sola lettura */
.fanta-error-box {
    background: var(--sfondo-scuro);
    border: 1px solid rgba(255, 60, 60, 0.4);
    border-radius: 11px;
    padding: 16px;
    margin-bottom: 14px;
    text-align: center;
}
.fanta-error-box h2 {
    font-family: 'DrukWide', sans-serif;
    color: var(--rosa-neon);
    margin: 0 0 8px;
}
.fanta-error-box .muted { opacity: 0.65; font-size: 0.72rem; }

/* ==========================================================================
   CAMPO — mobile-first, spostato 20px a sinistra
   Il wrapper è trasparente (NON una card bordata): un campo da 540px dentro
   una card stretta sforerebbe il bordo. Stesso schema di benvenuto.css.
   ========================================================================== */
.formazione-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 14px;
	margin-top: -100px !important; 
}

.campo-container {
    position: relative;
    width: 100%;
    height: 640px;            /* < altezza campo (710): lo sbordo crea il "tuck" */
    overflow: visible;
}

.campo-calcio {
    width: 540px;
    height: 710px;
    position: absolute;
    left: 50% !important;
    right: auto !important;
    /* centrato sul viewport, poi 20px a sinistra */
    transform: translateX(calc(-50% - 0.5px)) !important;
    margin: 0 !important;
    overflow: visible;
    background: transparent;
}
.campo-calcio::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url('/assets/imm/campettofanta.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    pointer-events: none;
}

/* Slot titolari (vuoti = cerchi cliccabili) */
.posizione {
    position: absolute;
    width: 75px;
    height: 75px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    z-index: 5;
    cursor: pointer;
    border-radius: 50%;
    border: 1.5px dashed rgba(255, 25, 255, 0.4);
    background: rgba(255, 255, 255, 0.04);
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.posizione:hover {
    border-color: var(--rosa-neon);
    background: rgba(255, 25, 255, 0.12);
}
.posizione.selezionato {
    border: none;
    background: transparent;
    width: 115px;
    height: 115px;
}
.posizione .add-icon,
.panchina-slot .add-icon {
    font-size: 20px;
    color: #fff;
    font-weight: bold;
    opacity: 0.6;
}
.posizione.selezionato .add-icon,
.panchina-slot.selezionato .add-icon { display: none; }

/* ⚽ COORDINATE TITOLARI — MOBILE (campo 540×710, da benvenuto.css) */
.portiere    { bottom: 180px; left: 50%; transform: translateX(-50%); }
.difensore   { bottom: 320px; left: 50%; transform: translateX(-50%); }
.laterale-sx { bottom: 410px; left: 90px; }
.laterale-dx { bottom: 410px; right: 90px; }
.pivot       { top: 110px;    left: 50%; transform: translateX(-50%); }
.portiere.selezionato,
.difensore.selezionato,
.pivot.selezionato { transform: translateX(-50%); }

/* ==========================================================================
   PANCHINA — più alta, proporzioni register/benvenuto
   ========================================================================== */
.panchina-label {
    align-self: stretch;
    text-align: left;
    margin: 0 0 6px 4px;
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--rosa-neon);
    opacity: 0.9;
}
.panchina-label small {
    font-family: 'HelveticaBold', sans-serif;
    font-style: normal;
    font-size: 0.6rem;
    opacity: 0.7;
    margin-left: 4px;
}

.panchina-container {
    width: 100%;
    margin-top: 0;
    z-index: 6;
    position: relative;
}

.panchina {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--sfondo-box);
    padding: 16px 12px 18px;
    border-radius: 12px;
    border: var(--bordo-sottile);
}

.panchina-slot {
    width: 75px;
    height: 75px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-sizing: border-box;
    cursor: pointer;
    border-radius: 50%;
    border: 1.5px dashed rgba(255, 25, 255, 0.4);
    background: rgba(255, 255, 255, 0.04);
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.panchina-slot:hover {
    border-color: var(--rosa-neon);
    background: rgba(255, 25, 255, 0.12);
}
.panchina-slot.selezionato {
    border: none;
    background: transparent;
    width: 115px;
    height: 115px;
}

.panchina-num {
    position: absolute;
    top: -4px; right: -4px;
    width: 17px; height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    font-size: 9px;
    color: var(--rosa-neon);
    background: var(--vinaccia);
    border: 1px solid var(--rosa-neon);
    border-radius: 50%;
    z-index: 8;
    pointer-events: none;
}

/* ==========================================================================
   JERSEY SLOT (divisa + infobox su 3 righe: RUOLO / N.COGNOME / VALORE M)
   ========================================================================== */
.jersey-slot {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: visible;
}

.jersey-img {
    display: block;
    width: 95px;
    height: 95px;
    object-fit: contain;
    margin: 0 auto;
    flex-shrink: 0;
    border: none !important;
    border-radius: 0 !important;
    background: transparent;
    position: relative;
    z-index: 1;
}

.jersey-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: -18px;
    padding: 3px 6px 4px;
    background: rgba(0, 0, 0, 0.78);
    border: 1px solid var(--rosa-neon);
    border-radius: 5px;
    white-space: nowrap;
    min-width: 82px;
    max-width: 112px;
    box-sizing: border-box;
    line-height: 1.22;
    text-align: center;
    position: relative;
    z-index: 2;
}

.jersey-role {
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    font-size: 0.52rem;
    color: var(--rosa-neon);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}
.jersey-name {
    font-family: 'HelveticaBold', Arial, sans-serif;
    font-size: 0.6rem;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.jersey-value {
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    font-size: 0.66rem;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 1px;
}

.jersey-badge-cap {
    position: absolute;
    top: -6px; right: -6px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rosa-neon), var(--viola));
    color: #fff;
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    font-size: 0.62rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 6px rgba(255, 25, 255, 0.7);
    z-index: 10;
    pointer-events: none;
}

/* ==========================================================================
   DRAG & DROP FEEDBACK
   ========================================================================== */
.posizione.dragging .jersey-slot,
.panchina-slot.dragging .jersey-slot {
    opacity: 0.35;
    filter: grayscale(0.5);
}
.posizione.drop-target-ok,
.panchina-slot.drop-target-ok {
    outline: 2px dashed #00ff66;
    outline-offset: 4px;
    border-radius: 8px;
    background: rgba(0, 255, 102, 0.06);
}
.posizione.drop-target-no,
.panchina-slot.drop-target-no {
    outline: 2px dashed #ff3333;
    outline-offset: 4px;
    border-radius: 8px;
    background: rgba(255, 51, 51, 0.06);
}

/* ==========================================================================
   CAPITANO (divisa, non foto)
   ========================================================================== */
.capitano-container { text-align: center; }
.capitano-container h4 {
    color: var(--rosa-neon);
    text-transform: uppercase;
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    margin: 0 0 4px;
}
.capitano-container p {
    font-size: 0.68rem;
    opacity: 0.7;
    margin: 0 0 8px;
}
.capitano-selected {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px;
    background: var(--sfondo-scuro);
    border: 1px solid var(--rosa-neon);
    border-radius: 7px;
    color: #fff;
    font-family: 'HelveticaBold', sans-serif;
    font-size: 0.68rem;
    text-transform: uppercase;
}
.capitano-selected img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    background: transparent;
    border: none;
    flex-shrink: 0;
}

/* ==========================================================================
   AZIONI (Azzera / Salva) + FEEDBACK
   ========================================================================== */
.formazione-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.formazione-actions button {
    padding: 9px 18px;
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    font-size: 0.72rem;
    text-transform: uppercase;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.formazione-actions .auth-button {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border: 1px solid var(--rosa-neon);
}
.formazione-actions .auth-button:hover { background: rgba(255, 25, 255, 0.18); }
.formazione-actions .bottone-salva {
    background: linear-gradient(135deg, var(--rosa-neon), var(--viola));
    color: #fff;
    box-shadow: 0 3px 10px rgba(255, 25, 255, 0.3);
}
.formazione-actions .bottone-salva:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 13px rgba(255, 25, 255, 0.5);
}
.formazione-actions button:disabled { opacity: 0.45; cursor: not-allowed; }

.salva-feedback {
    text-align: center;
    font-size: 0.74rem;
    font-weight: bold;
    margin-top: 8px;
    min-height: 1em;
}
.salva-feedback.is-ok { color: #00ff66; }
.salva-feedback.is-err { color: #ff3333; }

/* ==========================================================================
   MODAL SELEZIONE GIOCATORE — stile register (divisa + nome caps + crest)
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(18, 0, 40, 0.85);
    backdrop-filter: blur(4px);
}
.modal-content {
    background-color: var(--vinaccia);
    margin: 8% auto;
    padding: 14px;
    border-radius: 8px;
    width: 85%;
    max-width: 402px;
    max-height: 72vh;
    overflow-y: auto;
    border: 1px solid var(--rosa-neon);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.6);
}
.modal-content h3 {
    margin: 0 0 10px;
    color: var(--rosa-neon);
    font-family: 'DrukWide', sans-serif;
    font-style: italic;
    font-size: 0.95rem;
    text-transform: uppercase;
}
.close {
    color: var(--rosa-neon);
    float: right;
    font-size: 19px;
    font-weight: bold;
    cursor: pointer;
}
.close:hover { color: #fff; }

#search-input {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 25, 255, 0.5);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-family: 'HelveticaBold', sans-serif;
    font-size: 16px;            /* ≥16px: evita l'auto-zoom su iOS/Android */
}
#search-input:focus {
    outline: none;
    border-color: var(--rosa-neon);
    box-shadow: 0 0 7px rgba(255, 25, 255, 0.4);
}

#players-list {
    max-height: 48vh;
    overflow-y: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.player-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.2s;
}
.player-item:hover { background: rgba(255, 25, 255, 0.12); }

/* la "foto" ora è la DIVISA, a sinistra */
.player-item__pic {
    width: 38px !important;
    height: 38px !important;
    margin-right: 10px;
    object-fit: contain;
    border: none !important;
    border-radius: 0 !important;
    background: transparent;
    flex-shrink: 0;
}

.player-info {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
}
.player-info strong {
    font-family: 'HelveticaBold', Arial, sans-serif;
    font-size: 0.8rem;
    color: var(--bianco);
    text-transform: uppercase;
}
.player-info small {
    font-size: 0.62rem;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* logo squadra alla fine */
.player-item__crest {
    width: 22px !important;
    height: 22px !important;
    margin-left: 8px;
    object-fit: contain;
    border: none !important;
    border-radius: 0 !important;
    background: transparent;
    flex-shrink: 0;
}

/* giocatore già schierato altrove */
.player-item--in-use {
    border-left: 2px solid var(--rosa-neon);
    background: rgba(255, 25, 255, 0.04);
}
.player-in-use-badge {
    width: fit-content;
    margin-top: 2px;
    padding: 1px 5px;
    font-size: 0.55rem;
    color: var(--rosa-neon);
    background: rgba(255, 25, 255, 0.1);
    border-radius: 3px;
}

/* ==========================================================================
   MODAL AZIONE (Cosa vuoi fare?)
   ========================================================================== */
.modal-content--small {
    max-width: 280px;
    text-align: center;
}
.modal-content--small button {
    width: 100%;
    padding: 9px;
    margin: 4px 0;
    border: 1px solid rgba(255, 25, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    font-family: 'HelveticaBold', sans-serif;
    font-weight: bold;
    font-size: 0.72rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s;
}
.modal-content--small button:hover { background: rgba(255, 25, 255, 0.15); }
.modal-content--small #actionCambia {
    background: linear-gradient(135deg, var(--rosa-neon), var(--viola));
    border: none;
}

/* ==========================================================================
   DESKTOP (≥ 768px)
   ========================================================================== */
@media (min-width: 768px) {
    .fanta-content { max-width: 720px; padding: 0 24px; }

    .fanta-hero__logo { width: 54px; height: 54px; }
    .fanta-hero__team-name { font-size: 1.25rem; }
    .fanta-hero__giornata { font-size: 1.1rem; }
    .formazione-deadline { font-size: 0.8rem; }
    .fanta-hero__hint { font-size: 0.78rem; }

    .campo-container {
        height: 780px;        /* < 860 del campo: sbordo = tuck */
        margin-top: -10px;
    }
    .campo-calcio {
        width: 650px;
        height: 860px;
        left: 50% !important;
        transform: translateX(calc(-50% - 0.5px)) !important;
    }

    .posizione { width: 90px; height: 90px; }
    .posizione.selezionato { width: 130px; height: 130px; }

    /* ⚽ COORDINATE TITOLARI — DESKTOP (campo 650×860) */
    .portiere    { bottom: 210px; left: 50%; transform: translateX(-50%); }
    .difensore   { bottom: 390px; left: 50%; transform: translateX(-50%); }
    .laterale-sx { bottom: 530px; left: 90px; }
    .laterale-dx { bottom: 530px; right: 90px; }
    .pivot       { top: 130px;    left: 50%; transform: translateX(-50%); }
    .portiere.selezionato,
    .difensore.selezionato,
    .pivot.selezionato { transform: translateX(-50%); }

    .panchina-container { margin-top: 0; }
    .panchina { gap: 16px; padding: 18px 16px 22px; }
    .panchina-slot { width: 90px; height: 90px; }
    .panchina-slot.selezionato { width: 130px; height: 130px; }
    .panchina-label { font-size: 0.8rem; }

    .jersey-img { width: 115px; height: 115px; }
    .jersey-info {
        margin-top: -22px;
        min-width: 92px;
        max-width: 125px;
        padding: 3px 8px 4px;
    }
    .jersey-role { font-size: 0.55rem; }
    .jersey-name { font-size: 0.62rem; }
    .jersey-value { font-size: 0.72rem; }
}