.countdown {
    text-align: center;
}

.countdown h1 {
    font-size: 30px !important;
}

.target {
    font-weight: bold;
}

.social-analytics-widget {
    font-family: 'Montserrat', sans-serif !important;
    /*background-color: #f4e3c3 !important;*/
    padding: 20px !important;
    border-radius: 10px !important;
    /* box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;*/
    text-align: left !important;
    margin: auto !important;
}

/* Layout a griglia */
.grid-container {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    grid-gap: 20px !important;
    justify-content: center !important;
    align-items: stretch !important;
}

/* Full width per le visite al sito */
.full-width {
    grid-column: span 2 !important;
}

/* Elementi della griglia */
.grid-item {
    background: #fff5e3 !important;
    padding: 15px !important;
    text-align: center !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
    min-width: 0 !important;
    /* Prevents expansion from nowrap content */
}

/* Titoli */
.widget-title {
    color: #d94e48 !important;
    font-size: 24px !important;
    margin-bottom: 20px !important;
    text-transform: uppercase !important;
    font-weight: bold !important;
}

/* Sezione follower e recensioni */
.social-scan {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 5px 0 20px 0 !important;
    background-color: #fff5e3 !important;
    padding: 20px !important;
    border-radius: 5px !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Icone social */
.social-logo {
    width: 100px !important;
    height: 100px !important;
    margin-right: 10px !important;
}

/* Flip counter per i numeri */
.flip-counter {
    display: flex !important;
    gap: 5px !important;
    justify-content: center !important;
}

/* Stile numeri */
.flip-digit {
    width: 40px !important;
    height: 60px !important;
    font-size: 40px !important;
    font-weight: bold !important;
    color: #d94e48 !important;
    background-color: #f4e3c3 !important;
    border-radius: 5px !important;
    text-align: center !important;
    line-height: 60px !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Colori per Instagram e Google */
.instagram-color {
    background-color: #dd2a7b !important;
    color: #fff !important;
}

.google-color {
    background-color: #4285f4 !important;
    color: #fff !important;
}

/* Contenitore delle squadre */
.team-container {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px !important;
    align-items: start !important;
    text-align: center !important;
}

/* Squadre */
.team-scan {
    background-color: #fff5e3 !important;
    padding: 10px !important;
    border-radius: 5px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.team-name {
    font-size: 20px !important;
    color: #333 !important;
    text-transform: uppercase !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
}

/* Evidenzia il team in vantaggio */
.in-advantage .team-name {
    font-weight: bold !important;
    color: #d94e48 !important;
}

.in-advantage .flip-digit {
    font-weight: bold !important;
    background-color: #ffecd6 !important;
    color: #d94e48 !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2) !important;
}

/* Bonus */
.bonus-wrapper {
    width: 100% !important;
    text-align: left !important;
    margin-top: 15px !important;
    display: flex !important;
    flex-direction: column !important;
}

.bonus-points {
    font-weight: bold !important;
    color: #d94e48 !important;
}

.bonus-reason {
    font-style: italic !important;
    color: #666 !important;
}

/* Media query per mobile */
@media (max-width: 768px) {
    .grid-container {
        grid-template-columns: 1fr !important;
    }

    .full-width {
        grid-column: span 1 !important;
    }

    .team-container {
        grid-template-columns: 1fr !important;
    }

    .flip-digit {
        width: 30px !important;
        height: 40px !important;
        font-size: 24px !important;
        line-height: 40px !important;
    }
}

/*Media Query Fire Stick TV*/
@media screen and (-webkit-device-pixel-ratio: 2) {
    .countdown {
        text-align: center;
    }

    .countdown h1 {
        font-size: 22px !important;
        /* Ridotto per adattarsi meglio */
        margin-bottom: 10px !important;
    }

    .social-analytics-widget {
        font-family: 'Montserrat', sans-serif !important;
        background-color: #f4e3c3 !important;
        padding: 10px !important;
        /* Riduzione padding */
        border-radius: 8px !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
        text-align: center !important;
        margin: auto !important;
        max-width: 95vw !important;
        /* Evita che esca dai bordi */
    }

    /* Griglia a due colonne ottimizzata per TV */
    .grid-container {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        /* Mantiene due colonne */
        grid-gap: 10px !important;
        /* Spaziatura ridotta */
        justify-content: center !important;
        align-items: stretch !important;
        width: 100% !important;
    }

    /* Elementi della griglia */
    .grid-item {
        background: #fff5e3 !important;
        padding: 8px !important;
        /* Riduzione padding */
        text-align: center !important;
        border-radius: 8px !important;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
        max-width: 90vw !important;
    }

    /* Visite sito a larghezza piena */
    .full-width {
        grid-column: span 2 !important;
        /* Mantiene la riga intera */
    }

    /* Titoli ottimizzati */
    .widget-title {
        font-size: 20px !important;
        /* Ridotto per stare in TV */
        margin-bottom: 8px !important;
    }

    /* Sezione follower e recensioni */
    .social-scan {
        flex-direction: row !important;
        padding: 8px !important;
        /* Spazio ridotto */
        justify-content: space-evenly !important;
    }

    /* Icone social ridotte */
    .social-logo {
        width: 60px !important;
        /* Ridotte per adattarsi alla griglia */
        height: 60px !important;
        margin-right: 5px !important;
    }

    /* Flip counter per numeri */
    .flip-counter {
        display: flex !important;
        gap: 2px !important;
        justify-content: center !important;
    }

    /* Stile numeri */
    .flip-digit {
        width: 30px !important;
        /* Ridotto per adattarsi */
        height: 45px !important;
        font-size: 28px !important;
        /* Ridotto per evitare tagli */
        line-height: 45px !important;
    }

    /* Squadre */
    .team-container {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        /* Mantiene due colonne */
        gap: 8px !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
    }

    /* Nomi squadre */
    .team-name {
        font-size: 16px !important;
        /* Più piccolo per adattarsi */
    }

    /* Evidenziazione squadra in vantaggio */
    .in-advantage .flip-digit {
        background-color: #ffecd6 !important;
        color: #d94e48 !important;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2) !important;
    }

    /* Bonus */
    .bonus-wrapper {
        width: 100% !important;
        text-align: center !important;
        margin-top: 5px !important;
    }

    .bonus-points {
        font-size: 14px !important;
    }

    .bonus-reason {
        font-size: 12px !important;
    }
}

/*Anti Standby FireTV*/
@keyframes keep-awake {
    0% {
        transform: translateX(0px);
    }

    50% {
        transform: translateX(1px);
    }

    100% {
        transform: translateX(0px);
    }
}

.anti-standby {
    animation: keep-awake 30s infinite;
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    background: transparent;
}

/* Gallery Styles */
.saw-gallery-container {
    margin: 30px auto;
    padding: 25px;
    background: #fff5e3 !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
    max-width: 1200px;
}

.saw-gallery-title {
    font-family: 'Montserrat', sans-serif !important;
    color: #d94e48 !important;
    text-transform: uppercase !important;
    font-weight: bold !important;
    margin-bottom: 25px !important;
    text-align: center !important;
    font-size: 28px !important;
}

.saw-gallery-grid {
    display: grid !important;
    /* auto-fit makes items expand to fill row, minmax(350px) helps limit to ~3 columns on desktop */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr)) !important;
    gap: 20px !important;
}

.saw-gallery-item {
    position: relative !important;
    overflow: hidden !important;
    border-radius: 8px !important;
    aspect-ratio: 1 / 1 !important;
    /* Square ratio for uploaded photos */
    background: #f4e3c3 !important;
}

.saw-gallery-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    transition: transform 0.5s ease !important;
    display: block !important;
}

.saw-gallery-item:hover .saw-gallery-img {
    transform: scale(1.05) !important;
}

/* Video Styles */
.saw-video-container {
    margin: 30px auto;
    max-width: 1200px;
    padding: 25px;
    background: #fff5e3 !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
}

.saw-video-wrapper {
    position: relative !important;
    padding-bottom: 56.25% !important;
    /* 16:9 Aspect Ratio */
    height: 0 !important;
    overflow: hidden !important;
    border-radius: 8px !important;
    background: #000 !important;
}

.saw-video-wrapper iframe,
.saw-video-wrapper video {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: 0 !important;
}

/* For self-hosted video which might be different ratio */
.saw-video-wrapper video {
    object-fit: contain !important;
}

@media (max-width: 768px) {

    .saw-gallery-container,
    .saw-video-container {
        padding: 15px;
        margin: 15px auto;
    }

    .saw-gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
        gap: 15px !important;
    }

    .saw-gallery-title {
        font-size: 22px !important;
    }
}

/* Ticker Implementation (added safely) */
.saw-ticker-container {
    display: flex !important;
    align-items: center !important;
    background: #fff !important;
    border: 1px solid #f4e3c3 !important;
    border-radius: 4px !important;
    padding: 5px 10px !important;
    margin-top: 10px !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    position: relative !important;
}

.saw-ticker-label {
    font-weight: bold !important;
    font-size: 13px !important;
    color: #d94e48 !important;
    margin-right: 10px !important;
    background: #fff !important;
    z-index: 2 !important;
    flex-shrink: 0 !important;
}

.saw-ticker-viewport {
    flex-grow: 1 !important;
    overflow: hidden !important;
    position: relative !important;
}

.saw-ticker-content {
    display: inline-block !important;
    padding-left: 100% !important;
    animation: saw-ticker-scrolling 30s linear infinite !important;
    font-size: 14px !important;
    color: #666 !important;
    font-style: italic !important;
}

@keyframes saw-ticker-scrolling {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* Viewport-fitting Gallery for TV (Adaptive) */
@media screen and (-webkit-device-pixel-ratio: 2) {
    .saw-gallery-container.tv-fit {
        height: calc(100vh - 80px) !important;
        /* Space for countdown and margins */
        margin: 0 !important;
        padding: 10px !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .saw-gallery-container.tv-fit .saw-gallery-title {
        font-size: 20px !important;
        margin-bottom: 5px !important;
        flex-shrink: 0 !important;
        text-align: center !important;
    }

    .saw-gallery-container.tv-fit .saw-gallery-grid {
        flex-grow: 1 !important;
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-content: center !important;
        gap: 10px !important;
        height: 100% !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    .saw-gallery-container.tv-fit .saw-gallery-item {
        flex: 1 1 200px !important;
        /* Base width but flexible */
        max-height: 45% !important;
        /* Max height to allow at least 2 rows */
        height: auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: transparent !important;
    }

    .saw-gallery-container.tv-fit .saw-gallery-img {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        /* Ensure image is fully visible */
        max-height: 100% !important;
    }
}