/* giochi_mobile.css - Stili ottimizzati per giochi_mobile.php (mobile-first) */

/* --- Font sempre Rajdhani Regular ovunque --- */
body,
#main-container,
#main-games-view h1,
.game-row h2,
.game-search-input,
.game-modal,
.game-modal-title,
.game-description,
.play-button,
.round-green-button {
    font-family: 'Rajdhani Regular', sans-serif;
}

/* Disabilita lo scroll orizzontale globale */
html,
body,
#main-container {
    overflow-x: hidden;
}


/* --- Contenitori principali --- */
#main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    padding: 15px;
    overflow-y: auto;
    position: relative;
    margin-bottom: 25px;
}

#main-games-view {
    display: block;
    width: 100vw;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

.games-intro-mobile {
    padding: 0 18px;
}

.games-intro-mobile p {
    margin: 0;
    text-align: center;
    line-height: 1.6;
    color: var(--color-text);
}

.games-intro-mobile p + p {
    margin-top: 10px;
}

.games-intro-mobile a {
    color: var(--color-neon-green);
}

#main-games-view h1 {
    text-align: center;
    color: var(--color-neon-blue);
    margin: 1em 0;
    font-size: clamp(1.2em, 6vw, 2.5em);
    text-shadow: 0 0 5px var(--color-neon-blue);
    font-weight: bold;
    text-transform: uppercase;
}

.game-search-input {
    width: calc(100% - 2em);
    padding: 0.8em 1em;
    margin: 1em auto;
    display: block;
    border: 1px solid var(--color-quinary);
    border-radius: 5px;
    background-color: var(--color-tertiary);
    color: var(--color-text);
    font-weight: bold;
    font-size: 0.9em;
    box-sizing: border-box;
    outline: none;
}

.game-search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.game-search-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 5px var(--color-accent);
}

.game-row {
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow: visible;
}

.game-row h2 {
    font-weight: bold;
    text-transform: uppercase;
    font-size: clamp(0.7em, 3vw, 1.2em);
    color: var(--color-neon-blue);
    text-shadow: 0 0 5px var(--color-neon-blue);
    margin: 0.5em 0;
    text-align: left;
}

.horizontal-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    width: 100%;
    margin: 0;
    padding: 0;
}

.horizontal-scroll .game-card {
    flex: 0 0 calc((100vw - 24px) / 2.5);
    width: calc((100vw - 24px) / 2.5);
    height: auto;
    aspect-ratio: 1 / 1;
    max-width: 180px;
    max-height: 180px;
    border-radius: 12px;
    border: 3px solid;
    border-image: linear-gradient(90deg, #00eaff, #37ff8b, #f751ff, #00eaff) 1;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    scroll-snap-align: start;
    margin: 0;
    padding: 0;
}

.horizontal-scroll .game-card:first-child {
    margin-left: 0;
}

.horizontal-scroll .game-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.horizontal-scroll .game-card:hover,
.horizontal-scroll .game-card:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 10px var(--cyan);
}

/* ==============================
   MODALE VERTICALE (PORTRAIT)
   ============================== */

#game-modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(12, 18, 38, 0.94);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.game-modal {
    width: 100vw;
    height: 100vh;
    border: 3px solid;
    border-image: linear-gradient(90deg, #00eaff, #37ff8b, #f751ff, #00eaff) 1;
    background: #111328;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: stretch;
    padding: 0;
    margin: 0;
    position: relative;
    overflow: hidden;
    animation: sheetUp 0.22s;
    border-radius: 0;
}

.game-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    color: #fff;
    font-size: 2.1em;
    border: none;
    z-index: 100;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.18s;
}

.game-modal-close:hover {
    color: #37ff8b;
}

.game-modal-nav {
    z-index: 2;
}

.game-modal-content {
    width: 100vw;
    height: 100vh;
    min-height: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 7.5vh 0 0 0;
    padding-bottom: clamp(16px, 4vh, 32px);
    gap: 0.7em;
    overflow: hidden;
}

/* Titolo gioco - più grande, più margin/padding sopra */
.game-modal-title {
    color: var(--cyan, #00eaff);
    font-size: 1.35em;
    font-weight: bold;
    margin: 1.4vh 0 0.15em 0;
    text-align: center;
    line-height: 1.2;
    max-width: 94vw;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    letter-spacing: 0.01em;
    padding-top: 0.5vh;
    padding-left: clamp(36px, 6vw, 48px);
    padding-right: clamp(36px, 6vw, 48px);
    min-height: calc(1.2em * 2);
    max-height: calc(1.2em * 2);
}

/* Card anteprima ancora più grande */
.modal-card {
    width: 94vw;
    max-width: 370px;
    max-height: 370px;
    min-width: 150px;
    min-height: 150px;
    aspect-ratio: 1/1;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 0.7em auto;
    background: none;
    box-shadow: none;
    border: none;
    padding: 0;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    margin-bottom: clamp(12px, 2vh, 20px);
}

.modal-card img,
.modal-card video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 17px;
    background: #10102c;
    display: block;
}

/* Descrizione max 3 righe, peso normale */
.game-description {
    /* Testo e spaziatura */
    color: var(--text-color, #e0e0e0);
    font-size: 1.04em;
    line-height: 1.22;
    margin: 0 0 0.7em 0;
    text-align: center;
    font-weight: normal;

    /* Altezza esatta per 9 linee */
    height: calc(1.22em * 9);
    overflow-y: auto;
    overflow-x: hidden;

    /* Spazio orizzontale */
    padding: 0 1em;
    box-sizing: border-box;

    /* Nascondi scrollbar ma mantieni lo scroll */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE 10+ */
}

.game-description::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}


.game-description::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}


.game-description::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

/* Bottone verde rotondo: più "pressable" + più padding sotto */

/* Bottone verde “pressable” */
.round-green-button {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 36%, #00ff88 70%, #009944 100%);
    box-shadow: 0 8px 16px rgba(0, 153, 68, 0.27), 0 2px 4px rgba(16, 16, 44, 0.4);
    border: 2.5px solid #fff3;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        box-shadow 0.14s cubic-bezier(.33, 1.62, .58, 1),
        transform 0.11s cubic-bezier(.33, 1.62, .58, 1);
    position: relative;
    user-select: none;
}

.round-green-button:active {
    box-shadow: 0 1px 2px rgba(0, 153, 68, 0.47), 0 0 1px rgba(16, 16, 44, 0.53);
    transform: scale(0.96) translateY(2px);
}

/* Testo dentro il bottone: centrato */
.round-green-button span,
.play-button span {
    display: block;
    width: 90%;
    text-align: center;
    line-height: 1.13;
    font-size: 0.96em;
    font-weight: bold;
    color: #0f0253;
    white-space: normal;
    word-break: break-word;
    pointer-events: none;
}

@media (max-width: 480px) {
    .modal-card {
        max-width: 210px;
        max-height: 210px;
        min-width: 100px;
        min-height: 100px;
    }

    .play-button,
    .round-green-button {
        width: 65px;
        height: 65px;
        min-width: 65px;
        min-height: 65px;
        font-size: 1em;
        margin-bottom: 7vh;
    }

    .game-modal-title {
        font-size: 1.20em;
    }
}

@keyframes sheetUp {
    from {
        transform: translateY(80px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==============================
   MODALE ORIZZONTALE (LANDSCAPE)
   ============================== */
@media screen and (orientation: landscape) {

    #game-modal-overlay,
    .game-modal {
        width: 100vw;
        height: 100vh;
        overflow: hidden;
        display: flex;
    }

    .game-modal {
        flex-direction: column;
    }

    .game-modal-content {
        display: flex;
        flex-direction: row;
        width: 100vw;
        height: 100vh;
        padding: 0;
        gap: 0;
        overflow: hidden;
        align-items: stretch;
        /* Allunga entrambe le colonne */
    }

    .left-col {
        width: 54vw;
        max-width: 58vw;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        padding: 3vh 1vw 3vh 2vw;
        /* STESSO padding-top e bottom della .right-col */
        box-sizing: border-box;
        gap: 0.3em;
    }

    .left-col>.game-modal-title {
        margin: 0 0 0.2em 0;
        /* Togli ogni margine-top qui */
        font-size: 2em;
        text-align: left;
        width: 100%;
        max-width: 95%;
        line-height: 1.18;
        white-space: normal;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        padding-top: 0;
        /* Togli padding top che aveva in portrait */
    }

    .left-col .modal-card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        flex: 1 1 auto;
        margin: 0;
        padding: 0;
        display: flex;
        align-items: flex-start;
        justify-content: flex-start;
        aspect-ratio: 16/9;
        background: none;
    }

    .right-col {
        width: 46vw;
        min-width: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        padding: 3vh 2vw 3vh 1vw;
        box-sizing: border-box;
        gap: 0.7em;
    }

    .right-col .game-description {
        margin: 0.1em 0 2em 0;
        line-height: 1.32;
        text-align: left;
        font-size: 1.09em;
        color: var(--text-color, #e0e0e0);
        background: none;
        max-width: 100%;
        padding: 0 0.8em;
        height: calc(1.32em * 5);
        min-height: calc(1.32em * 5);
        overflow-y: auto;
        overflow-x: hidden;
        box-sizing: border-box;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .right-col .game-description::-webkit-scrollbar {
        display: none;
    }

    .right-col .round-green-button,
    .right-col .pressable {
        margin: 2em auto 0 auto !important;
        display: flex !important;
        align-self: center !important;
        flex-shrink: 0 !important;
        /* Così NON si schiaccia */
        width: 86px !important;
        /* Come portrait, nessuna altra width diversa */
        height: 86px !important;
        border-radius: 50% !important;
    }
}

/* 1) Wrapper pressable: sempre flex & square */
.pressable {
    display: flex !important;
    justify-content: center;
    align-items: center;
    width: 70px !important;
    height: 70px !important;
    position: relative;
}

/* 2) Shadow dietro più sottile/scura per simulare profondità */
.pressable .shadow {
    position: absolute;
    left: 5px;
    /* o 4px, da regolare */
    top: 8px;
    /* o 6px, da regolare */
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.32);
    z-index: 0;
    filter: blur(0.5px);
}

/* 3) Edge intermedio nascosto (o tenue) */
.pressable .edge {
    width: 0 !important;
    height: 0 !important;
    background: none !important;
}

/* 4) Front: cerchio verde arcade */
.pressable .front {
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    background: radial-gradient(circle at 30% 30%, #00cc44 0%, #007733 100%) !important;
    box-shadow:
        inset -3px -3px 8px rgba(255, 255, 255, 0.4),
        inset 3px 3px 8px rgba(0, 0, 0, 0.4),
        0 6px 12px rgba(0, 0, 0, 0.5) !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    position: relative;
    z-index: 1;
}

/* Ultimo ritocco: rimuovo padding e inline-block dal front */
.pressable .front {
    /* Azzeriamo padding e forziamo box-sizing */
    padding: 0 !important;
    box-sizing: border-box !important;

    /* Flex per centrare eventualmente icone/testo (anche se è vuoto) */
    display: flex !important;
    justify-content: center;
    align-items: center;
}

.pressable .shadow {
    display: none !important;
}


/* —– iOS-only fixes —– */
@supports (-webkit-touch-callout: none) {

    /* #1: usa 100% di altezza anziché 100vh, per far apparire tutta la modale */
    #game-modal-overlay,
    .game-modal {
        height: 100% !important;
    }

    .game-modal-content {
        height: 100% !important;
        padding-bottom: env(safe-area-inset-bottom)
            /* per spostare sopra la barra sotto iPhone X+ */
        ;
    }

    /* #2: leggermente ridimensiona anteprima per iOS */
    .modal-card {
        width: 90vw !important;
        max-width: 320px !important;
        max-height: 35vh !important;
    }
}

/* === MODALE: FIX LANDSCAPE (contenitori identici + fit nel viewport) === */
@media (orientation: landscape) {
    .game-modal {
        max-height: 86vh;
    }

    .game-modal-content {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        padding: 16px 0;
        /* niente padding orizzontale: i gutter sono sulle colonne */
        box-sizing: border-box;
        max-height: calc(86vh - 32px);
        /* la modale non scrolla; solo la descrizione lo farà */
        overflow: hidden;
    }

    .left-col,
    .right-col {
        display: flex;
        flex-direction: column;
        min-height: 0;
        /* fondamentale per far “stringere” i figli */
        box-sizing: border-box;
    }

    /* Gutter SOLO ai bordi esterni */
    .left-col {
        padding-left: 16px;
        padding-right: 0;
    }

    .right-col {
        padding-left: 0;
        padding-right: 16px;
    }

    .left-col .game-modal-title {
        margin: 0 0 8px 0;
    }

    /* Card media: copertina e video identici per area */
    .modal-card {
        position: relative;
        width: 100%;
        aspect-ratio: 16 / 9;
        /* shape stabile in landscape */
        height: auto;
        max-height: 48vh;
        /* garantisce fit nel viewport con titolo sopra */
        background: #000;
        border-radius: 12px;
        overflow: hidden;
    }

    /* IMG e VIDEO occupano esattamente la stessa area */
    .modal-card>img,
    .modal-card>video {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
        /* nessun “salto” quando switcha */
        display: block;
        background: #000;
    }

    /* Solo la descrizione scorre; bottone resta visibile */
    .right-col .game-description {
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
        padding-right: 4px;
        /* spazio per eventuale scrollbar */
        margin-top: 8px;
    }

    /* Bottone: resta a destra, non si allarga */
    .right-col .round-green-button {
        align-self: flex-start;
        margin-top: 12px;
    }
}

/* === MODALE: fix bottone in PORTRAIT (testo "GIOCA" su una riga, centrato) === */
@media (orientation: portrait) {

    /* centra davvero il bottone nella colonna singola */
    .game-modal-content>.round-green-button {
        display: grid;
        place-items: center;
        margin: 12px auto 0;
        /* centra orizzontalmente */
    }

    /* testo sempre su una riga, dimensione adattiva */
    .round-green-button span {
        display: inline-block;
        white-space: nowrap;
        /* NO a capo */
        line-height: 1;
        /* più compatto */
        letter-spacing: 0;
        /* evita allargamenti */
        font-size: clamp(11px, 3.5vw, 14px);
        /* adatta ai device piccoli */
        text-align: center;
    }
}

/* === MODALE: portrait — bottone non attaccato in basso === */
@media (orientation: portrait) {

    /* un filo di padding sotto al contenuto della modale */
    .game-modal-content {
        padding-bottom: 16px;
    }

    /* bottone centrato con margine inferiore come prima */
    .game-modal-content>.round-green-button {
        margin: 12px auto 16px;
        /* prima era 12px auto 0 */
    }
}

/* === ANDROID LANDSCAPE FIX: viewport reale + layout a griglia che si adatta === */

/* 1) Usa l’unità dinamica del viewport dove disponibile (Android/Chrome moderni) */
@supports (height: 100dvh) {

    #game-modal-overlay,
    .game-modal,
    .game-modal-content {
        height: 100dvh !important;
        max-height: 100dvh !important;
    }

    .game-modal {
        max-height: 100dvh !important;
    }
}

/* 2) Solo LANDSCAPE: colonne che non si sovrappongono e figli che possono “stringere” */
@media (orientation: landscape) {

    /* Contenitore principale: nessuno scroll qui; lo farà solo la descrizione */
    .game-modal-content {
        display: grid !important;
        grid-template-columns: 54vw 46vw;
        gap: 12px;
        padding: 16px 0;
        /* gutter esterni restano sulle colonne */
        overflow: hidden;
        min-height: 0;
        /* fondamentale su Android */
        box-sizing: border-box;
    }

    /* Colonne come griglie: SX = titolo (auto) + media (1fr)  |  DX = descrizione (1fr) + bottone (auto) */
    .left-col,
    .right-col {
        display: grid !important;
        min-height: 0;
        /* consente ai figli di non “spingere fuori” il viewport */
        box-sizing: border-box;
    }

    .left-col {
        grid-template-rows: auto 1fr;
        padding: 3vh 1vw 3vh 2vw;
        /* gutter solo esterno sinistro */
        align-content: start;
    }

    .right-col {
        grid-template-rows: 1fr auto;
        padding: 3vh 2vw 3vh 1vw;
        /* gutter solo esterno destro */
        align-content: start;
    }

    /* Titolo: non deve sovrapporsi, resta blocco proprio */
    .left-col>.game-modal-title {
        margin: 0 0 8px 0;
        width: 100%;
        max-width: 95%;
        line-height: 1.18;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: normal;
    }

    /* 3) Card media: occupa TUTTO lo spazio disponibile della riga 2 (1fr), proporzione 16:9 */
    .left-col .modal-card {
        position: relative;
        width: 100%;
        height: 100%;
        /* riempi lo spazio libero della colonna */
        max-height: 100%;
        /* non oltre il viewport */
        aspect-ratio: 16 / 9;
        margin: 0;
        border-radius: 12px;
        overflow: hidden;
        background: #000;
        min-height: 0;
        /* evita “stretch” su Android */
    }

    /* IMG e VIDEO: stessa area, senza coprire titolo/descrizione */
    .left-col .modal-card>img,
    .left-col .modal-card>video {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
        display: block;
        background: #000;
    }

    /* Descrizione: unico elemento scrollabile */
    .right-col .game-description {
        min-height: 0;
        overflow: auto;
        margin: 0.1em 0 1.2em 0;
        padding-right: 6px;
        /* spazio per scrollbar */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .right-col .game-description::-webkit-scrollbar {
        display: none;
    }

    /* Bottone: resta visibile, non si schiaccia */
    .right-col .round-green-button {
        align-self: flex-start;
        justify-self: start;
        margin-top: 12px;
        flex-shrink: 0;
    }
}

/* ===== Viewport robusto (iOS vs Android) ===== */

/* Base (già presente altrove): modale non oltre il viewport classico */
.game-modal {
    max-height: 86vh;
}

.game-modal-content {
    max-height: calc(86vh - 32px);
}

/* Preferisci 100svh quando disponibile (iOS Safari) → evita zoom/ingrandimenti */
@supports (height: 100svh) {

    #game-modal-overlay,
    .game-modal,
    .game-modal-content {
        height: 100svh !important;
        max-height: 100svh !important;
    }

    .game-modal-content {
        max-height: calc(100svh - 32px) !important;
    }
}

/* Se 100svh non c’è ma c’è 100dvh (tipico Android) → usa dvh per avere altezza reale */
@supports (height: 100dvh) {

    #game-modal-overlay,
    .game-modal,
    .game-modal-content {
        height: 100dvh !important;
        max-height: 100dvh !important;
    }

    .game-modal-content {
        max-height: calc(100dvh - 32px) !important;
    }
}

/* ===== Landscape: layout anti–sovrapposizione + bottone sempre visibile (Android) ===== */
@media (orientation: landscape) {

    /* Griglia principale: extra spazio in basso per non tagliare il bottone */
    .game-modal-content {
        padding: 16px 0 24px;
        /* ↑ bottom extra */
        overflow: hidden;
        min-height: 0;
    }

    /* Due colonne: SX = titolo+media | DX = descrizione+btn */
    .left-col,
    .right-col {
        display: grid !important;
        min-height: 0;
        box-sizing: border-box;
        align-content: start;
    }

    .left-col {
        grid-template-rows: auto 1fr;
        padding: 3vh 1vw 3vh 2vw;
        /* gutter solo a SINISTRA */
    }

    .right-col {
        grid-template-rows: 1fr minmax(86px, auto);
        /* riserva sempre spazio al bottone tondo */
        padding: 3vh 2vw 3vh 1vw;
        /* gutter solo a DESTRA */
    }

    /* Titolo: massimo due righe per non “mangiare” la card video */
    .left-col .game-modal-title {
        margin: 0 0 8px 0;
        width: 100%;
        max-width: 95%;
        line-height: 1.18;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: normal;
        display: -webkit-box;
        --webkit-line-clamp: 2;
        /* ← tronca a 2 righe */
        -webkit-box-orient: vertical;
    }

    /* Card media: riempie la riga 2 senza sforare; cover e video identici */
    .left-col .modal-card {
        position: relative;
        width: 100%;
        height: 100%;
        /* occupa lo spazio disponibile */
        max-height: 100%;
        aspect-ratio: 16 / 9;
        /* proporzione stabile */
        border-radius: 12px;
        overflow: hidden;
        background: #000;
        min-height: 0;
    }

    .left-col .modal-card>img,
    .left-col .modal-card>video {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
        display: block;
        background: #000;
    }

    /* Descrizione: unico elemento scrollabile */
    .right-col .game-description {
        min-height: 0;
        overflow: auto;
        margin: 0.1em 0 1.2em 0;
        padding-right: 6px;
        /* spazio per scrollbar */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .right-col .game-description::-webkit-scrollbar {
        display: none;
    }

    /* Bottone: non si schiaccia, non viene tagliato */
    .right-col .round-green-button {
        align-self: start;
        justify-self: start;
        margin-top: 12px;
        margin-bottom: 4px;
        /* piccolo cuscinetto dal bordo basso */
        flex-shrink: 0;
    }
}

/* Tutti i nomi/classi che EJS usa di solito per il pad virtuale */
.ejs_virtualGamepad_parent,
#virtualGamepad,
.virtual-gamepad,
[id*="ejs-virtual-gamepad"],
[class*="virtualGamepad"] {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}
/* ===== Game modal refactor (mobile, stile welcome/login) ===== */
#game-modal-overlay {
    background: rgba(0, 0, 0, 0.45);
    padding: clamp(8px, 2vw, 16px);
}

#game-modal-overlay .game-modal {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border: 2px solid var(--color-accent);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.65);
    box-shadow:
        0 0 18px rgba(0, 194, 255, 0.35),
        inset 0 0 12px rgba(0, 194, 255, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#game-modal-overlay .game-modal-content {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 2.2vw, 16px);
    padding: clamp(18px, 4vw, 24px);
    padding-top: clamp(34px, 6vw, 44px);
    height: 100%;
    box-sizing: border-box;
}

#game-modal-overlay .game-modal-title {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(0.95rem, 3.2vw, 1.2rem);
    line-height: 1.2;
    color: var(--color-accent);
    margin: 0;
    text-align: center;
    padding: 0 clamp(36px, 6vw, 48px);
    min-height: calc(1.2em * 2);
    max-height: calc(1.2em * 2);
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-shadow:
        0 0 3px rgba(0, 194, 255, 0.45),
        0 0 6px rgba(0, 194, 255, 0.35);
}

#game-modal-overlay .modal-card {
    width: 100%;
    max-width: 92vw;
    aspect-ratio: 16 / 9;
    min-height: 180px;
    max-height: 45vh;
    margin: 0 auto clamp(12px, 2vh, 20px);
    border-radius: 12px;
    border: 1px solid rgba(0, 194, 255, 0.3);
    background: rgba(7, 10, 20, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

#game-modal-overlay .modal-card img,
#game-modal-overlay .modal-card video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #070a14;
    display: block;
}

#game-modal-overlay .game-description {
    margin: 0;
    font-family: 'Rajdhani', sans-serif;
    font-size: clamp(0.95rem, 3.2vw, 1.05rem);
    line-height: 1.4;
    color: var(--color-text);
    overflow: auto;
    padding-right: 4px;
    position: relative;
    scrollbar-width: none;
    max-height: clamp(240px, 40vh, 420px);
    min-height: clamp(180px, 26vh, 260px);
    flex: 1 1 auto;
}

#game-modal-overlay .game-description::-webkit-scrollbar {
    display: none;
}

#game-modal-overlay .game-description::before,
#game-modal-overlay .game-description::after {
    content: "";
    position: sticky;
    left: 0;
    right: 0;
    height: 20px;
    display: block;
    pointer-events: none;
    z-index: 2;
}

#game-modal-overlay .game-description::before {
    top: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
}

#game-modal-overlay .game-description::after {
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
}

#game-modal-overlay .game-modal-actions {
    margin-top: auto;
    display: flex;
    gap: clamp(8px, 2vw, 12px);
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    row-gap: 10px;
    position: relative;
    z-index: 3;
    margin-bottom: clamp(16px, 3vh, 28px);
    padding-top: clamp(6px, 1.4vh, 12px);
}

#game-modal-overlay .round-green-button,
#game-modal-overlay .round-blue-button {
    width: clamp(62px, 15vw, 74px);
    height: clamp(62px, 15vw, 74px);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

#game-modal-overlay .round-green-button {
    background: radial-gradient(circle at 30% 30%, #4cffb5, #00a45a);
    box-shadow:
        inset -4px -4px 10px rgba(255, 255, 255, 0.25),
        inset 4px 4px 10px rgba(0, 0, 0, 0.35),
        0 6px 12px rgba(0, 0, 0, 0.5);
    color: #041b12;
}

#game-modal-overlay .round-blue-button {
    background: radial-gradient(circle at 30% 30%, #6ee6ff, #1a6ad6);
    box-shadow:
        inset -4px -4px 10px rgba(255, 255, 255, 0.25),
        inset 4px 4px 10px rgba(0, 0, 0, 0.35),
        0 6px 12px rgba(0, 0, 0, 0.5);
    color: #04121f;
}

#game-modal-overlay .round-green-button:active,
#game-modal-overlay .round-blue-button:active {
    transform: translateY(2px);
}

#game-modal-overlay .round-green-button span,
#game-modal-overlay .round-blue-button span {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: #061624;
    letter-spacing: 0.06em;
}

#game-modal-overlay .favorite-toggle {
    width: clamp(62px, 15vw, 74px);
    height: clamp(62px, 15vw, 74px);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: radial-gradient(circle at 30% 30%, #d7d7d7, #8d8d8d);
    color: transparent;
    font-size: 0;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
    position: relative;
    filter: grayscale(1);
    pointer-events: auto;
    touch-action: manipulation;
}

#game-modal-overlay .favorite-toggle::before {
    content: "";
    width: 88%;
    height: 88%;
    background: no-repeat center / contain url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffd36a'><path d='M12 2.2l3.05 6.18 6.83.99-4.94 4.81 1.17 6.82L12 17.9l-6.11 3.21 1.17-6.82L2.1 9.37l6.83-.99L12 2.2z'/></svg>");
    pointer-events: none;
    filter: grayscale(1) brightness(1.2) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(0deg);
    transition: transform 0.28s ease, filter 0.2s ease;
}

#game-modal-overlay .favorite-toggle::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.65);
    color: var(--color-text);
    border-radius: 10px;
    padding: 8px 12px;
    border: 2px solid var(--color-accent);
    box-shadow:
        0 0 18px rgba(0, 194, 255, 0.35),
        inset 0 0 12px rgba(0, 194, 255, 0.15);
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.82rem;
    text-align: center;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 2;
}

#game-modal-overlay .favorite-toggle:active::after,
#game-modal-overlay .favorite-toggle:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

#game-modal-overlay .favorite-toggle:not(.is-favorited) {
    filter: grayscale(1) brightness(0.95);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.35);
}

#game-modal-overlay .favorite-toggle:not(.is-favorited)::before {
    filter: grayscale(1) brightness(1.15) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

#game-modal-overlay .favorite-toggle.is-favorited {
    color: #ffd36a;
    background: radial-gradient(circle at 30% 30%, #ffe7a3, #caa240);
    filter: none;
    box-shadow:
        inset -3px -3px 8px rgba(255, 255, 255, 0.2),
        inset 3px 3px 8px rgba(0, 0, 0, 0.35),
        0 6px 12px rgba(0, 0, 0, 0.45);
    border-color: rgba(255, 211, 106, 0.5);
}

#game-modal-overlay .favorite-toggle.is-favorited::before {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
    transform: translate(-50%, -50%) rotate(20deg);
}

#game-modal-overlay .favorite-toggle:active {
    transform: translateY(2px);
}

@media screen and (orientation: landscape) {
    #game-modal-overlay .game-modal-content {
        display: grid;
        grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
        gap: clamp(12px, 2vw, 20px);
    }

    #game-modal-overlay .left-col,
    #game-modal-overlay .right-col {
        min-width: 0;
        min-height: 0;
        display: flex;
        flex-direction: column;
        gap: clamp(10px, 1.6vw, 16px);
    }

    #game-modal-overlay .left-col .game-modal-title {
        text-align: left;
    }

    #game-modal-overlay .modal-card {
        max-height: 70vh;
    }

    #game-modal-overlay .game-modal-actions {
        justify-content: flex-start;
    }
}

/* ===== Modal fit + layout piu compatto (mobile) ===== */
#game-modal-overlay {
    align-items: stretch;
    justify-content: stretch;
    padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
}

#game-modal-overlay .game-modal {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    box-sizing: border-box;
}

#game-modal-overlay .game-modal-content {
    gap: clamp(8px, 1.6vw, 14px);
}

#game-modal-overlay .game-description {
    max-height: clamp(78px, 14vh, 128px);
}

#game-modal-overlay .game-modal-actions {
    margin-top: 6px;
}

/* ===== Mobile modal final override: bordi completi + layout stabile ===== */
#game-modal-overlay {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom)) 12px !important;
}

#game-modal-overlay .game-modal {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    box-sizing: border-box;
    margin: 0;
}

#game-modal-overlay .game-modal-content {
    width: 100%;
    height: 100%;
    max-height: 100%;
    padding: clamp(12px, 3vw, 20px);
    box-sizing: border-box;
}

/* Garantisce margine inferiore visibile e previene zoom iOS su rotazione */
#game-modal-overlay {
    --modal-edge: 12px;
    padding: calc(var(--modal-edge) + env(safe-area-inset-top))
        calc(var(--modal-edge) + env(safe-area-inset-right))
        calc(var(--modal-edge) + env(safe-area-inset-bottom))
        calc(var(--modal-edge) + env(safe-area-inset-left)) !important;
}

#game-modal-overlay .game-modal {
    height: calc(100% - (var(--modal-edge) * 2));
    max-height: calc(100% - (var(--modal-edge) * 2));
}

#game-modal-overlay .game-modal-content {
    height: 100%;
    max-height: 100%;
}

#game-modal-overlay .modal-card,
#game-modal-overlay .modal-card img,
#game-modal-overlay .modal-card video {
    max-width: 100%;
    max-height: 100%;
}

#game-modal-overlay .game-modal-actions {
    width: 100%;
    justify-content: center;
    align-items: center;
    margin-top: clamp(6px, 1.2vh, 12px);
    gap: clamp(8px, 2vw, 12px);
}

#game-modal-overlay .game-modal-actions .round-green-button,
#game-modal-overlay .game-modal-actions .round-blue-button,
#game-modal-overlay .game-modal-actions .favorite-toggle {
    width: clamp(62px, 15vw, 74px) !important;
    height: clamp(62px, 15vw, 74px) !important;
    min-width: clamp(62px, 15vw, 74px) !important;
    min-height: clamp(62px, 15vw, 74px) !important;
    flex: 0 0 auto;
    margin: 0 !important;
}

@media (orientation: landscape) {
    #game-modal-overlay .game-modal-actions .round-green-button,
    #game-modal-overlay .game-modal-actions .round-blue-button,
    #game-modal-overlay .game-modal-actions .favorite-toggle {
        width: clamp(56px, 12vw, 70px) !important;
        height: clamp(56px, 12vw, 70px) !important;
        min-width: clamp(56px, 12vw, 70px) !important;
        min-height: clamp(56px, 12vw, 70px) !important;
    }
}

@media (orientation: landscape) {
    #game-modal-overlay .game-modal-content {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    }

    #game-modal-overlay .game-modal-actions {
        justify-content: center;
    }
}
