/* =========================
   BASE: NO SCROLL ORIZZONTALE
   ========================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

body.app-container {
    min-height: 100vh;
}

/* =========================
   HEADER - MOBILE / TABLET (<= 1230px)
   ========================= */

@media screen and (max-width: 1230px) {

    header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem !important;
        height: auto !important; /* Forza altezza auto per evitare sovrapposizioni */
    }

    /* 1) Logo + titolo */
    header > div:nth-child(1) {
        order: 1;
        width: 100% !important;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.4rem;
    }

    header img[alt="Logo HexyCards"] {
        width: 1.9rem;
        height: 1.9rem;
    }

    header span.text-lg {
        font-size: 1.2rem !important;
        font-weight: 600;
    }

    /* 2) Barra con bottoni - ALLINEATA A DESTRA */
    header > div:nth-child(3) {
        order: 2;
        width: 100% !important;
        display: flex;
        align-items: center;
        justify-content: flex-end; /* Spinge tutto a destra */
        gap: 0.7rem; /* Distanza tra bottone e switch */
    }

    #import-button {
        padding: 0.35rem 0.6rem !important;
        font-size: 0.8rem !important;
        flex-shrink: 0;
    }

    /* Area switch tema: ora sta vicino al bottone */
    header > div:nth-child(3) > div {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        margin-left: 0 !important; /* Rimosso auto per evitare il buco in mezzo */
        flex-shrink: 0;
    }

    header > div:nth-child(3) span.text-sm {
        font-size: 0.75rem !important;
    }

    /* 3) Info del mazzo - SOTTO I BOTTONI */
    header > div:nth-child(2) {
        order: 3;
        width: 100% !important;
        text-align: left;
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
    }

    #deck-title {
        font-size: 0.95rem !important;
    }

    #deck-metadata {
        font-size: 0.72rem !important;
    }
}

/* =========================
   ACTION BOXES (Giusta / Sbagliata / Salta)
   ========================= */

@media screen and (max-width: 1230px) {
    #action-boxes {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        column-gap: 0.4rem;
        row-gap: 0.4rem;
    }

    #action-boxes button {
        padding: 0.4rem 0.35rem !important;
        border-radius: 0.6rem !important;
    }

    #action-boxes span.text-4xl {
        font-size: 1.5rem !important;
        line-height: 1.1;
    }

    #action-boxes span.text-sm,
    #action-boxes span.md\:text-base {
        font-size: 0.7rem !important;
    }
}

/* =========================
   BARRA DI STATO IN BASSO
   ========================= */

@media screen and (max-width: 1230px) {
    .status-bar-root > div {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
        padding-top: 0.4rem !important;
        padding-bottom: 0.4rem !important;
    }

    .status-bar-root .flex.space-x-4 {
        flex-wrap: wrap;
        row-gap: 0.2rem;
    }

    .status-bar-root button {
        width: 100%;
        justify-content: center;
        font-size: 0.8rem !important;
        padding: 0.4rem 0.6rem !important;
    }
}

/* =========================
   MAIN / CARD AREA (< 600px)
   ========================= */

@media screen and (max-width: 600px) {
    main {
        padding: 0.75rem !important;
        margin-top: 2vh;
        margin-bottom: 2vh;
    }

    #question-text {
        font-size: 1rem !important;
    }

    .mcq-option-button-default {
        padding: 0.5rem 0.7rem;
        font-size: 0.9rem;
    }
}

/* =========================
   EXTRA COMPATTAZIONE (Altezza < 550px)
   ========================= */

@media screen and (max-width: 1230px) and (max-height: 550px) {
    header { padding: 0.3rem 0.5rem !important; gap: 0.25rem; }
    main { margin-top: 1vh; margin-bottom: 1vh; }
    #action-boxes span.text-4xl { font-size: 1.2rem !important; }
}

/* =========================
   SMARTPHONE STRETTI (< 445px)
   ========================= */

@media screen and (max-width: 445px) {
    header > div:nth-child(3) {
        flex-wrap: wrap;
        justify-content: flex-end; /* Mantiene l'allineamento a destra anche se va a capo */
    }

    #shuffle-button {
        order: 3;
        width: 100%;
    }
}

footer {
    padding: 0.3rem !important;
    font-size: 0.7rem !important;
}