:root {
    /* DaiSy | Gruppo BCC Design System Tokens */
    --bcc-blu: #003594;
    --bcc-verde-medio: #006F34;
    --bcc-verde-b2b: #008766;
    --bcc-verde-scuro: #00491F;
    --bcc-verde-scuro-b2b: #006D52;
    --bcc-grigio-perla-digital: #F8F9FA;
    --bcc-nero: #000000;
    --bcc-nero-digital: #202020;
    --bcc-bianco: #FFFFFF;
    --bcc-font-family: "Montserrat", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: #000;
    font-family: var(--bcc-font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Modale di benvenuto (DaiSy | Gruppo BCC Design System) ──────────────── */

#instructions {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 200;
    pointer-events: auto;
    overflow-y: auto;
}

/* Contenitore esterno bianco e Card default perla (DaiSy | Gruppo BCC Design System) */
#overlay {
    position: relative;
    width: fit-content;
    max-width: 100%;
    background-color: var(--bcc-bianco);
    border-radius: 0;
    border: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    cursor: default;
}

.carta-contenitore {
    background-color: var(--bcc-grigio-perla-digital);
    border-radius: 0;
    box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.1);
    margin: 1.25rem;
    padding: 44px 48px;
    color: var(--bcc-nero);
    font-family: var(--bcc-font-family);
    text-align: left;
    display: flex;
    flex-direction: column;
}

.carta-contenitore > :first-child {
    margin-top: 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

.modal-logo {
    width: 147px;
    height: auto;
    margin-top: 7px;
    display: block;
    user-select: none;
}

/* Micro CTA Icona Chiudi Modale (DaiSy | Gruppo BCC Design System) */
.modale-chiudi {
    position: relative;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    margin: 0;
    background-color: transparent;
    border: 0;
    border-radius: 100%;
    color: var(--bcc-verde-medio);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    outline: 0;
    z-index: 1;
    transition: color 0.3s ease;
}

.modale-chiudi svg {
    width: 1.5rem;
    height: 1.5rem;
    display: block;
}

.modale-chiudi::after {
    content: "";
    position: absolute;
    width: 2.625rem;
    height: 2.625rem;
    border-radius: 100%;
    background-color: var(--bcc-verde-scuro);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.modale-chiudi:hover,
.modale-chiudi:focus,
.modale-chiudi:focus-visible {
    color: var(--bcc-bianco);
    outline: none;
}

.modale-chiudi:hover::after,
.modale-chiudi:focus::after,
.modale-chiudi:focus-visible::after {
    opacity: 1;
}

.modal-title {
    margin: 44px 0 48px 0;
    color: var(--bcc-blu);
    font-family: var(--bcc-font-family);
    font-size: 2.125rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    letter-spacing: 0;
}

.modal-instructions {
    display: flex;
    flex-direction: column;
    gap: 36px;
    padding-left: 0;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 32px;
}

.instruction-icon {
    width: 75px;
    height: 75px;
    flex-shrink: 0;
    border: 2.5px solid var(--bcc-blu);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
}

.instruction-icon img {
    width: 59px;
    height: 59px;
    display: block;
    user-select: none;
}

.instruction-text p {
    margin: 0;
    color: var(--bcc-nero);
    font-family: var(--bcc-font-family);
    font-size: 1.25rem;
    font-weight: 400;
    line-height: 1.2;
}

.instruction-text strong {
    font-weight: 700;
}

.modal-footer {
    margin-top: 48px;
    padding-left: 0;
    display: flex;
    justify-content: center;
}

/* CTA Primaria Alta (DaiSy | Gruppo BCC Design System) */
.cta-primaria {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 398px;
    max-width: 100%;
    min-height: 68px;
    padding: 0.875rem 2.5rem;
    border: none;
    border-radius: 2.125rem;
    background-color: var(--bcc-verde-medio);
    box-shadow: 0 0.188rem 0.625rem rgba(0, 0, 0, 0.1);
    color: var(--bcc-bianco);
    font-family: var(--bcc-font-family);
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.cta-primaria:hover,
.cta-primaria:focus-visible {
    background-color: var(--bcc-verde-scuro);
    color: var(--bcc-bianco);
    text-decoration: underline;
    outline: none;
}

@media (max-width: 820px), (max-height: 780px) {
    .carta-contenitore {
        margin: 0.75rem;
        padding: 28px 24px;
    }

    .modale-chiudi svg {
        width: 1.125rem;
        height: 1.125rem;
    }

    .modale-chiudi::after {
        width: 2rem;
        height: 2rem;
    }

    .modal-title {
        margin: 28px 0 32px 0;
        font-size: 1.75rem;
    }

    .modal-instructions {
        gap: 24px;
        padding-left: 0;
    }

    .instruction-item {
        gap: 20px;
    }

    .instruction-icon {
        width: 60px;
        height: 60px;
    }

    .instruction-icon img {
        width: 47px;
        height: 47px;
    }

    .instruction-text p {
        font-size: 1rem;
        line-height: 1.35;
    }

    .modal-footer {
        margin-top: 32px;
        padding-left: 0;
        justify-content: center;
    }

    .cta-primaria {
        width: auto;
        min-width: 260px;
        min-height: 54px;
        font-size: 1rem;
    }
}

/* ── Scena 3D & Controlli ────────────────────────────────────────────────── */

#css-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

#css-container > div {
    pointer-events: auto;
}

#joystick-left, #joystick-right {
    position: absolute;
    bottom: 20px;
    width: 150px;
    height: 150px;
    z-index: 100;
    pointer-events: auto;
    display: none; /* Initially hidden, shown via JS if mobile */
}

#joystick-left {
    left: 20px;
}

#joystick-right {
    right: 20px;
}

/* ── Landscape prompt ─────────────────────────────────────────────────────── */

#landscape-prompt {
    display: none; /* shown via JS on portrait mobile only */
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(10, 10, 20, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #fff;
    text-align: center;
}

#landscape-prompt-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 32px;
}

#landscape-icon {
    font-size: 5rem;
    line-height: 1;
    animation: rotate-hint 1.8s ease-in-out infinite;
}

#landscape-prompt-inner p {
    font-size: 1.2rem;
    margin: 0;
    opacity: 0.85;
    max-width: 260px;
    line-height: 1.5;
}

@keyframes rotate-hint {
    0%   { transform: rotate(0deg);   }
    30%  { transform: rotate(-90deg); }
    70%  { transform: rotate(-90deg); }
    100% { transform: rotate(0deg);   }
}
