/* ------------------------------------------------------------------
 * NITHAR: il caveau del segreto del codice di Murphy (js/nithar.js)
 * ------------------------------------------------------------------ */

/* durante la scena la pagina non scorre */
html.is-caveau {
    overflow: hidden;
}

/* --- il volante d'acciaio che compare dietro al logo --- */
.caveau__volante {
    position: absolute;
    left: 50%;
    top: 55.9%; /* centro del cerchio del logo */
    z-index: -1;
    width: 166.6667%; /* il cerchio del logo è il 60% del disegno */
    aspect-ratio: 1;
    translate: -50% -50%;
    scale: 0.8;
    opacity: 0;
    pointer-events: none;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55));
    transition: opacity 0.35s ease-out, scale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.caveau__volante.is-visibile {
    opacity: 1;
    scale: 1;
}

.caveau__volante svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* --- la scena: una <dialog> a tutto schermo --- */
.caveau {
    position: fixed;
    inset: 0;
    z-index: 70; /* solo se il browser non ha showModal */
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    background: #060708;
    color: #ffffff;
    font-family: 'Montserrat', sans-serif;
    touch-action: none;
    overscroll-behavior: contain;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.caveau::backdrop {
    background: transparent;
}

.caveau:focus,
.caveau:focus-visible {
    outline: none;
}

.caveau.is-ridotto {
    animation: caveauEntra 0.5s ease-out both;
}

.caveau.is-svanisce {
    opacity: 0;
    transition: opacity 0.45s ease-in;
}

/* la "telecamera": la stanza intera si sposta e si ingrandisce verso la cassaforte */
.caveau__stanza {
    position: absolute;
    inset: 0;
    transform-origin: 0 0;
    transform: translate(var(--cam-x, 0px), var(--cam-y, 0px)) scale(var(--cam-k, 1));
    transition: transform var(--durata-zoom, 1.6s) cubic-bezier(0.55, 0, 0.15, 1), opacity 0.3s ease-out;
}

.caveau__stanza.is-istantanea {
    transition: none;
}

.caveau__stanza.is-stacco {
    opacity: 0;
}

.caveau__ambiente,
.caveau__raggi {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

/* spia sulla parete di fondo e bagliore rosso dei laser */
.caveau__lampadina {
    fill: #ff3b30;
    transition: fill 0.3s ease-out;
}

.caveau__alone-rosso,
.caveau__alone-verde,
.caveau__bagliore {
    transition: opacity 0.6s ease-out;
}

.caveau__alone-verde {
    opacity: 0;
}

.caveau.is-disarmata .caveau__lampadina { fill: #39ff7a; }
.caveau.is-disarmata .caveau__alone-rosso { opacity: 0; }
.caveau.is-disarmata .caveau__alone-verde { opacity: 1; }
.caveau.is-disarmata .caveau__bagliore { opacity: 0; }

/* laser: si spengono con uno sfarfallio (e la lucina dell'emettitore si spegne) */
.caveau__led {
    fill: #ff3b30;
    transition: fill 0.25s steps(1) 0.28s;
}

.caveau__led.is-spento {
    fill: #3b1714;
}

.caveau__laser.is-spento {
    opacity: 0;
    animation: caveauLaserSpento 0.36s both;
}

.caveau__laser.is-fermo {
    animation: none;
}

.caveau__led.is-fermo {
    transition: none;
}

/* --- la cassaforte --- */
.caveau__cassaforte {
    position: absolute;
    width: 40em;
    height: 26em;
    transform-origin: 50% 100%;
    transform: scale(var(--lontano, 0.3));
    color: #ffffff;
    font-family: 'Montserrat', sans-serif;
    line-height: 1.2;
    text-align: left;
}

.caveau.is-verticale .caveau__cassaforte {
    width: 22em;
    height: 33em;
}

.caveau__cassaforte p {
    margin: 0;
}

.caveau__corpo {
    position: absolute;
    inset: 0 0 1.2em;
    padding: 1.3em;
    border-radius: 1.1em;
    background: linear-gradient(155deg, #747b84 0%, #464c54 30%, #2d3137 65%, #1d2025 100%);
    box-shadow:
        inset 0 0 0 0.18em #121417,
        inset 0.3em 0.3em 0.25em rgba(255, 255, 255, 0.12),
        inset -0.3em -0.4em 0.4em rgba(0, 0, 0, 0.45),
        0 1.6em 2.2em -0.4em rgba(0, 0, 0, 0.8);
}

.caveau.is-verticale .caveau__corpo {
    padding: 1em;
}

.caveau__bullone {
    position: absolute;
    width: 0.85em;
    height: 0.85em;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #f4f6f8, #8a929b 45%, #2c3035 100%);
    box-shadow: 0 0.08em 0.15em rgba(0, 0, 0, 0.7);
}

.caveau__bullone--1 { top: 0.24em; left: 0.24em; }
.caveau__bullone--2 { top: 0.24em; right: 0.24em; }
.caveau__bullone--3 { bottom: 0.24em; left: 0.24em; }
.caveau__bullone--4 { bottom: 0.24em; right: 0.24em; }

.caveau.is-verticale .caveau__bullone {
    width: 0.62em;
    height: 0.62em;
    margin: -0.06em;
}

.caveau__cerniere {
    position: absolute;
    top: 3.4em;
    bottom: 4.8em;
    left: 0.6em;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 1.1em;
}

.caveau__cerniere span {
    height: 4em;
    border-radius: 0.45em;
    background: linear-gradient(90deg, #33383e, #e4e8ec 40%, #8b939b 62%, #2b2f34);
    box-shadow: 0 0.15em 0.3em rgba(0, 0, 0, 0.6);
}

.caveau.is-verticale .caveau__cerniere {
    left: 0.4em;
    width: 0.9em;
}

.caveau.is-verticale .caveau__cerniere span {
    height: 3.2em;
}

.caveau__piedi {
    position: absolute;
    left: 2.4em;
    right: 2.4em;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    height: 1.7em;
}

.caveau__piedi span {
    width: 4.2em;
    height: 100%;
    border-radius: 0 0 0.45em 0.45em;
    background: linear-gradient(#1d2024, #0b0c0e);
}

.caveau__sportello {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 14em;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
        "targa schermo"
        "maniglia tasti";
    gap: 1.1em 1.8em;
    height: 100%;
    padding: 1.4em 1.6em 1.3em 2em;
    border-radius: 0.7em;
    background:
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 0.08em, rgba(0, 0, 0, 0.03) 0.08em 0.22em),
        linear-gradient(165deg, #a5acb5 0%, #767d86 38%, #585e66 72%, #484d54 100%);
    box-shadow:
        0 0 0 0.16em #17191c,
        0 0.3em 0.5em rgba(0, 0, 0, 0.6),
        inset 0 0.12em 0 rgba(255, 255, 255, 0.4),
        inset 0 -0.25em 0.5em rgba(0, 0, 0, 0.35);
}

.caveau.is-verticale .caveau__sportello {
    grid-template-columns: 4.4em minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
        "targa targa"
        "maniglia schermo"
        "tasti tasti";
    gap: 1.25em 0.9em;
    padding: 1em 1em 1em 1.35em;
}

/* schermi bassi (telefono in orizzontale): cornici più sottili, così i tasti restano grandi */
.caveau.is-bassa .caveau__corpo { padding: 0.8em; }
.caveau.is-bassa .caveau__sportello { gap: 0.8em 1.4em; padding: 0.9em 1.2em 0.8em 1.6em; }
.caveau.is-bassa .caveau__bullone { width: 0.5em; height: 0.5em; margin: -0.1em; }
.caveau.is-bassa .caveau__cerniere { left: 0.25em; }
.caveau.is-bassa .caveau__targa { padding: 0.4em 1em 0.45em; }
.caveau.is-bassa .caveau__targa-testo { font-size: 1.05em; }
.caveau.is-bassa .caveau__schermo { height: 3em; }
.caveau.is-bassa .caveau__tastierino { gap: 0.42em; padding: 0.4em; }

/* targa d'ottone: cosa c'è dentro */
.caveau__targa {
    grid-area: targa;
    position: relative;
    align-self: start;
    padding: 0.55em 1.3em 0.65em;
    border-radius: 0.3em;
    background: linear-gradient(172deg, #f6e2a0 0%, #d4ad55 40%, #a8802f 62%, #e6c978 100%);
    box-shadow:
        0 0.18em 0.35em rgba(0, 0, 0, 0.55),
        inset 0 0 0 0.09em rgba(95, 62, 12, 0.7),
        inset 0 0.12em 0 rgba(255, 255, 255, 0.65);
    color: #4b340d;
    text-align: center;
    text-transform: uppercase;
}

.caveau__targa-sopra {
    font-size: 0.58em;
    font-weight: 700;
    letter-spacing: 0.38em;
    opacity: 0.75;
}

.caveau__targa-testo {
    margin-top: 0.1em;
    font-size: 1.2em;
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: 0.06em;
    text-shadow: 0 0.06em 0 rgba(255, 244, 210, 0.8), 0 -0.04em 0 rgba(60, 38, 0, 0.5);
}

/* il custode, inciso sotto */
.caveau__targa-sotto {
    margin-top: 0.3em;
    font-size: 0.5em;
    font-weight: 700;
    letter-spacing: 0.3em;
    opacity: 0.7;
}

.caveau.is-verticale .caveau__targa {
    margin-bottom: 0.7em; /* spazio per il timbro, che non deve coprire il display */
}

.caveau.is-verticale .caveau__targa-testo {
    font-size: 1.08em;
}

.caveau__vite {
    position: absolute;
    width: 0.5em;
    height: 0.5em;
    border-radius: 50%;
    background:
        linear-gradient(45deg, transparent 42%, rgba(60, 40, 0, 0.75) 42% 58%, transparent 58%),
        radial-gradient(circle at 35% 35%, #fff3c4, #9c762a);
}

.caveau__vite:nth-child(1) { top: 0.35em; left: 0.35em; }
.caveau__vite:nth-child(2) { top: 0.35em; right: 0.35em; }
.caveau__vite:nth-child(3) { bottom: 0.35em; left: 0.35em; }
.caveau__vite:nth-child(4) { bottom: 0.35em; right: 0.35em; }

.caveau__timbro {
    position: absolute;
    right: -1em;
    bottom: -1.75em;
    padding: 0.14em 0.45em 0.1em;
    border: 0.14em solid currentColor;
    border-radius: 0.25em;
    color: rgba(206, 28, 28, 0.92);
    font-size: 1.05em;
    font-weight: 700;
    letter-spacing: 0.14em;
    line-height: 1.1;
    text-shadow: none;
    box-shadow: inset 0 0 0 0.07em rgba(206, 28, 28, 0.35);
    transform: rotate(-11deg);
}

.caveau.is-verticale .caveau__timbro {
    right: -0.4em;
    bottom: -1.6em;
    font-size: 0.86em;
}

/* il volante della cassaforte */
.caveau__maniglia {
    grid-area: maniglia;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding-top: 1em;
}

.caveau__maniglia svg {
    width: auto;
    height: 100%;
    max-height: 12.5em;
    aspect-ratio: 1;
    overflow: visible;
    filter: drop-shadow(0 0.35em 0.4em rgba(0, 0, 0, 0.55));
}

.caveau.is-verticale .caveau__maniglia {
    padding: 0;
}

.caveau.is-verticale .caveau__maniglia svg {
    width: 4.4em;
    height: 4.4em;
}

.caveau__maniglia-ruota {
    transform-box: view-box;
    transform-origin: 0 0;
}

.caveau.is-verifica .caveau__maniglia-ruota {
    animation: caveauTentativo 0.95s ease-in-out both;
}

.caveau__marca {
    position: absolute;
    left: 3.2em;
    bottom: 1.6em;
    font-size: 0.6em;
    font-weight: 700;
    font-style: italic;
    letter-spacing: 0.12em;
    color: rgba(20, 22, 26, 0.55);
    text-shadow: 0 0.08em 0 rgba(255, 255, 255, 0.25);
}

.caveau.is-verticale .caveau__marca {
    display: none;
}

/* display LCD */
.caveau__schermo {
    grid-area: schermo;
    align-self: end;
    display: flex;
    align-items: center;
    gap: 0.65em;
    height: 3.3em;
    padding: 0 0.85em;
    border-radius: 0.45em;
    background: linear-gradient(180deg, #07120a, #0d1d11);
    box-shadow:
        inset 0 0 0 0.14em #040805,
        inset 0 0.35em 0.8em rgba(0, 0, 0, 0.85),
        0 0 0 0.28em #2a2f35,
        0 0.32em 0 0.28em rgba(255, 255, 255, 0.12);
    transition: background 0.3s ease-out;
}

.caveau.is-verticale .caveau__schermo {
    align-self: center;
    margin-right: 0.28em;
}

.caveau__spia {
    flex: none;
    width: 0.75em;
    height: 0.75em;
    border-radius: 50%;
    background: #ff3b30;
    box-shadow: 0 0 0.5em #ff3b30;
    transition: background 0.3s ease-out, box-shadow 0.3s ease-out;
}

.caveau.is-disarmata .caveau__spia {
    background: #39ff7a;
    box-shadow: 0 0 0.5em #39ff7a;
}

.caveau.is-verifica .caveau__spia {
    background: #ffc531;
    box-shadow: 0 0 0.5em #ffc531;
    animation: caveauLampeggio 0.3s steps(1) infinite;
}

.caveau__display {
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    font: 700 1.05em/1 ui-monospace, 'Cascadia Mono', Menlo, Consolas, 'Courier New', monospace;
    letter-spacing: 0.1em;
    white-space: nowrap;
    text-align: center;
    color: #7dff8f;
    text-shadow: 0 0 0.35em rgba(90, 255, 130, 0.7);
}

.caveau.is-verticale .caveau__display {
    font-size: 0.92em;
    letter-spacing: 0.06em;
}

.caveau__cifre {
    display: inline-block;
}

.caveau__schermo[data-stato="attesa"] .caveau__cifre {
    animation: caveauLampeggio 1.1s steps(1) infinite;
}

.caveau__schermo[data-stato="verifica"] .caveau__cifre::after {
    content: '';
    display: inline-block;
    width: 3ch;
    text-align: left;
    animation: caveauPuntini 0.9s steps(1) infinite;
}

.caveau__schermo[data-stato="errore"] {
    background: linear-gradient(180deg, #1a0605, #2a0a08);
}

.caveau__schermo[data-stato="errore"] .caveau__display {
    color: #ff5a4f;
    text-shadow: 0 0 0.4em rgba(255, 60, 50, 0.85);
}

.caveau__schermo[data-stato="errore"] .caveau__cifre {
    animation: caveauRonzio 0.08s steps(1) 8, caveauLampeggio 0.5s steps(1) 0.64s infinite;
}

.caveau__schermo.is-pieno .caveau__cifre {
    animation: caveauRonzio 0.08s steps(1) 3;
}

.caveau__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* tastierino */
.caveau__tastierino {
    grid-area: tasti;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
    gap: 0.55em;
    min-height: 0;
    padding: 0.6em;
    border-radius: 0.55em;
    background: rgba(12, 14, 17, 0.45);
    box-shadow: inset 0 0.15em 0.4em rgba(0, 0, 0, 0.6), 0 0.08em 0 rgba(255, 255, 255, 0.18);
    outline: none;
}

.caveau.is-verticale .caveau__tastierino {
    gap: 0.6em 0.75em;
}

.caveau__tasto {
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0.3em;
    background: linear-gradient(180deg, #f3f5f7 0%, #ccd2d8 55%, #aab1b9 100%);
    color: #22262c;
    font: 700 1.3em/1 'Montserrat', sans-serif;
    box-shadow:
        0 0.16em 0 #5a6169,
        0 0.26em 0.35em rgba(0, 0, 0, 0.55),
        inset 0 0.06em 0 #ffffff,
        inset 0 -0.08em 0 rgba(0, 0, 0, 0.12);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.07s ease-out, box-shadow 0.07s ease-out, background 0.25s ease-out, color 0.25s ease-out;
}

.caveau__tasto:active,
.caveau__tasto.is-premuto {
    transform: translateY(0.13em);
    box-shadow:
        0 0.03em 0 #5a6169,
        0 0.06em 0.12em rgba(0, 0, 0, 0.55),
        inset 0 0.06em 0 rgba(255, 255, 255, 0.7);
}

.caveau__tasto:focus {
    outline: none;
}

.caveau__tasto:focus-visible {
    outline: 0.12em solid #7dff8f;
    outline-offset: 0.1em;
}

.caveau__tasto--c {
    background: linear-gradient(180deg, #ffe08a 0%, #f2b33d 60%, #d4911a 100%);
    color: #4a2c00;
}

.caveau__tasto--ok {
    background: linear-gradient(180deg, #a8f5b8 0%, #4cc46c 60%, #2f9a4d 100%);
    color: #0b2a14;
    font-size: 1.1em;
}

.caveau:not(.is-pronta) .caveau__tasto {
    cursor: default;
}

.caveau.is-allarme .caveau__tasto {
    background: linear-gradient(180deg, #ff9d94 0%, #e2453a 60%, #b3261d 100%);
    color: #2b0604;
}

/* --- grafica "da telecamera di sorveglianza" --- */
.caveau__hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    font: 600 clamp(10px, 1.05vw, 13px)/1.35 ui-monospace, 'Cascadia Mono', Menlo, Consolas, 'Courier New', monospace;
    letter-spacing: 0.12em;
    color: rgba(235, 240, 245, 0.8);
    text-shadow: 0 1px 2px #000000;
    transition: opacity 0.5s ease-out;
}

.caveau.is-stanza .caveau__hud {
    opacity: 1;
}

.caveau__hud p {
    position: absolute;
    left: 26px;
    margin: 0;
    white-space: nowrap;
}

.caveau__hud-cam { top: 20px; }
.caveau__hud-zoom { top: calc(20px + 1.5em); }
.caveau__hud-stato { bottom: 20px; }

.caveau__rec {
    display: inline-block;
    width: 0.7em;
    height: 0.7em;
    margin-right: 0.55em;
    border-radius: 50%;
    background: #ff3b30;
    box-shadow: 0 0 6px #ff3b30;
    vertical-align: -0.03em;
    animation: caveauLampeggio 1.2s steps(1) infinite;
}

.caveau.is-allarme .caveau__hud-stato {
    color: #ff6b5e;
    animation: caveauLampeggio 0.45s steps(1) infinite;
}

.caveau__angolo {
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.caveau__angolo--1 { top: 12px; left: 12px; border-right: 0; border-bottom: 0; }
.caveau__angolo--2 { display: none; } /* lì c'è il pulsante per uscire */
.caveau__angolo--3 { bottom: 12px; left: 12px; border-right: 0; border-top: 0; }
.caveau__angolo--4 { bottom: 12px; right: 12px; border-left: 0; border-top: 0; }

.caveau__esci {
    position: absolute;
    top: 10px;
    right: 10px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    background: rgba(10, 12, 15, 0.6);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    touch-action: manipulation;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease-out, visibility 0s linear 0.4s, background 0.2s ease-out;
}

.caveau.is-stanza .caveau__esci {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease-out, background 0.2s ease-out;
}

.caveau__esci:hover,
.caveau__esci:focus-visible {
    background: rgba(255, 255, 255, 0.16);
    outline: none;
    box-shadow: 0 0 0 2px #7dff8f;
}

.caveau__esci svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

/* allarme: i bordi dello schermo pulsano di rosso */
.caveau__allarme {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 50%, rgba(255, 0, 0, 0) 38%, rgba(255, 20, 20, 0.55) 100%);
}

.caveau.is-allarme .caveau__allarme {
    animation: caveauAllarme 0.9s ease-in-out infinite;
}

.caveau.is-allarme .caveau__laser,
.caveau.is-allarme .caveau__led {
    opacity: 1;
    fill: #ff3b30;
    animation: caveauLampeggio 0.45s steps(1) infinite;
}

.caveau.is-allarme .caveau__lampadina {
    fill: #ff3b30;
}

.caveau.is-allarme .caveau__alone-rosso,
.caveau.is-allarme .caveau__bagliore,
.caveau.is-allarme .caveau__spia {
    opacity: 1;
    animation: caveauLampeggio 0.45s steps(1) infinite;
}

.caveau.is-allarme .caveau__alone-verde {
    opacity: 0;
}

.caveau.is-allarme .caveau__spia {
    background: #ff3b30;
    box-shadow: 0 0 0.6em #ff3b30;
}

/* --- le porte blindate: due metà della pagina --- */
.caveau__porte {
    --fessura: clamp(9px, 1.4vw, 18px);  /* quanto si scosta ogni porta prima che i perni rientrino */
    --spessore: clamp(40px, 11vw, 120px);
    position: absolute;
    inset: 0;
    perspective: max(620px, 85vw);
    transform-style: preserve-3d;
    pointer-events: none;
}

.caveau__porta {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    transform-style: preserve-3d;
    transition: transform 0.26s cubic-bezier(0.55, 0, 0.85, 0.3); /* si richiude sbattendo */
}

.caveau__porta--sx { left: 0; }
.caveau__porta--dx { right: 0; }

.caveau.is-socchiusa .caveau__porta {
    transition: transform 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.caveau.is-socchiusa .caveau__porta--sx { transform: translateX(calc(-1 * var(--fessura))); }
.caveau.is-socchiusa .caveau__porta--dx { transform: translateX(var(--fessura)); }

.caveau.is-chiusura.is-socchiusa .caveau__porta {
    transition: transform 1.1s cubic-bezier(0.25, 0.1, 0.2, 1);
}

.caveau.is-aperta .caveau__porta {
    transition: transform 1.5s cubic-bezier(0.62, 0, 0.22, 1);
}

.caveau.is-aperta .caveau__porta--sx { transform: translateX(calc(-100% - var(--spessore))); }
.caveau.is-aperta .caveau__porta--dx { transform: translateX(calc(100% + var(--spessore))); }

.caveau__faccia {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #0b0b0d;
}

/* bordo d'acciaio e ombra sul lato interno, quando le porte si scostano */
.caveau__faccia::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-out;
}

.caveau__porta--sx .caveau__faccia::after {
    background: linear-gradient(to left, #d3d9df 0 2px, #3a3f46 2px 6px, rgba(0, 0, 0, 0.6) 6px, rgba(0, 0, 0, 0) 16%);
}

.caveau__porta--dx .caveau__faccia::after {
    background: linear-gradient(to right, #d3d9df 0 2px, #3a3f46 2px 6px, rgba(0, 0, 0, 0.6) 6px, rgba(0, 0, 0, 0) 16%);
}

.caveau.is-socchiusa .caveau__faccia::after {
    opacity: 1;
}

/* la copia della pagina: larga quanto lo schermo, ogni porta ne mostra metà */
.caveau__pagina {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    overflow: hidden;
    isolation: isolate;
    transform: translate(0, 0); /* gli elementi "fixed" delle copie si posizionano qui dentro */
}

.caveau__porta--dx .caveau__pagina {
    left: -100%;
}

.caveau__sfondo {
    position: absolute;
    z-index: -2147483647; /* sotto a tutto, anche ai livelli con z-index negativo (es. il fuoco di MARCO) */
}

/* lo spessore delle porte, visto in prospettiva quando si aprono */
.caveau__spessore {
    position: absolute;
    top: 0;
    width: var(--spessore);
    height: 100%;
    background:
        radial-gradient(circle closest-side, #050607 0 44%, #2c3136 48% 60%, transparent 64%) 50% 0 / 72% 20% repeat-y,
        linear-gradient(90deg, #2a2e34, #959da6 35%, #626970 65%, #272b30);
}

.caveau__porta--sx .caveau__spessore {
    right: 0;
    transform-origin: 100% 50%;
    transform: rotateY(-90deg);
}

.caveau__porta--dx .caveau__spessore {
    left: 0;
    transform-origin: 0 50%;
    transform: rotateY(90deg);
}

/* i perni che tengono chiuse le porte: si vedono solo nella fessura */
.caveau__perni {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 100%;
    width: calc(2 * var(--fessura));
    overflow: hidden;
    visibility: hidden;
    transition: visibility 0s linear 0.26s;
}

.caveau.is-socchiusa .caveau__perni {
    visibility: visible;
    transition: none;
}

.caveau__perno {
    position: absolute;
    left: 0;
    width: calc(2 * var(--fessura) + 30px);
    height: clamp(12px, 2.6vh, 26px);
    border-radius: 0 999px 999px 0;
    background: linear-gradient(180deg, #f6f8fa 0%, #bcc3cb 28%, #6b737c 55%, #3b4147 80%, #9aa2ab 100%);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.7);
    translate: 0 -50%;
    transition: transform 0.32s cubic-bezier(0.6, -0.45, 0.7, 1);
}

.caveau__perno:nth-child(1) { top: 10%; }
.caveau__perno:nth-child(2) { top: 30%; }
.caveau__perno:nth-child(3) { top: 50%; }
.caveau__perno:nth-child(4) { top: 70%; }
.caveau__perno:nth-child(5) { top: 90%; }

.caveau.is-sbloccata .caveau__perno {
    transform: translateX(-112%);
}

/* la luce rossa che filtra dalla fessura */
.caveau__fessura {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    margin-left: -1px;
    opacity: 0;
    pointer-events: none;
    background: linear-gradient(180deg, transparent, #ffe0d6 12%, #ff5a46 50%, #ffe0d6 88%, transparent);
    box-shadow: 0 0 8px 2px rgba(255, 80, 60, 0.75), 0 0 30px 8px rgba(255, 40, 30, 0.35);
    transition: opacity 0.35s ease-out;
}

.caveau.is-fessura .caveau__fessura {
    opacity: 1;
    animation: caveauFessura 0.38s steps(1) both;
}

.caveau.is-socchiusa .caveau__fessura {
    opacity: 0;
    animation: none;
}

/* --- la presa in giro di Murphy --- */
.caveau__beffa {
    position: absolute;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    width: max-content;
    max-width: min(560px, calc(100% - 32px));
    padding: 0.85rem 1.2rem 1rem;
    border: 1px solid rgba(255, 90, 80, 0.35);
    border-left: 4px solid #ff3b30;
    border-radius: 12px;
    background: rgba(22, 6, 6, 0.95);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 40, 30, 0.25);
    text-align: left;
    pointer-events: none;
    opacity: 0;
    translate: -50% 24px;
    transition: opacity 0.35s ease-out, translate 0.5s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.caveau__beffa.is-visibile {
    opacity: 1;
    translate: -50% 0;
}

.caveau__beffa-titolo {
    margin: 0 0 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: #ff6b5e;
}

.caveau__beffa .voce__citazione {
    font-size: 1.1rem;
    color: #ffffff;
}

.caveau__beffa .voce__autore {
    color: #ffb4aa;
}

/* --- animazioni --- */
@keyframes caveauEntra {
    from { opacity: 0; }
}

@keyframes caveauLaserSpento {
    0%   { opacity: 1; }
    16%  { opacity: 0.12; }
    30%  { opacity: 1; }
    48%  { opacity: 0.08; }
    62%  { opacity: 0.85; }
    76%  { opacity: 0; }
    100% { opacity: 0; }
}

@keyframes caveauLampeggio {
    50% { opacity: 0.2; }
}

@keyframes caveauAllarme {
    0%, 100% { opacity: 0.25; }
    50%      { opacity: 1; }
}

@keyframes caveauFessura {
    0%   { opacity: 0; }
    18%  { opacity: 1; }
    34%  { opacity: 0.25; }
    52%  { opacity: 1; }
    68%  { opacity: 0.55; }
    82%  { opacity: 1; }
}

@keyframes caveauRonzio {
    0%   { translate: -0.07em 0; }
    50%  { translate: 0.07em 0; }
}

@keyframes caveauPuntini {
    0%  { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

@keyframes caveauTentativo {
    0%   { rotate: 0deg; }
    40%  { rotate: 34deg; }
    50%  { rotate: 28deg; }
    58%  { rotate: 33deg; }
    66%  { rotate: 29deg; }
    100% { rotate: 0deg; }
}

@media (prefers-reduced-motion: reduce) {
    .caveau__volante {
        scale: 1;
        transition: opacity 0.35s ease-out;
    }

    .caveau__laser.is-spento,
    .caveau__schermo[data-stato="attesa"] .caveau__cifre,
    .caveau__schermo[data-stato="errore"] .caveau__cifre,
    .caveau__schermo.is-pieno .caveau__cifre,
    .caveau__schermo[data-stato="verifica"] .caveau__cifre::after,
    .caveau.is-verifica .caveau__maniglia-ruota,
    .caveau.is-verifica .caveau__spia,
    .caveau.is-allarme .caveau__laser,
    .caveau.is-allarme .caveau__led,
    .caveau.is-allarme .caveau__alone-rosso,
    .caveau.is-allarme .caveau__bagliore,
    .caveau.is-allarme .caveau__spia,
    .caveau.is-allarme .caveau__hud-stato,
    .caveau__rec {
        animation: none;
    }

    .caveau__schermo[data-stato="verifica"] .caveau__cifre::after {
        content: '...';
    }

    .caveau.is-allarme .caveau__allarme {
        opacity: 0.8;
        animation: none;
    }

    .caveau__laser {
        transition: opacity 0.25s ease-out;
    }

    .caveau__beffa {
        translate: -50% 0;
        transition: opacity 0.35s ease-out;
    }

    .caveau__tasto {
        transition: background 0.25s ease-out, color 0.25s ease-out;
    }

    .caveau__tasto:active,
    .caveau__tasto.is-premuto {
        transform: none;
    }
}

@media (max-width: 600px) {
    .caveau__hud p {
        left: 20px;
    }

    .caveau__hud-cam { top: 17px; }
    .caveau__hud-zoom { top: calc(17px + 1.5em); }
    .caveau__hud-stato { bottom: 17px; }

    .caveau__angolo {
        width: 16px;
        height: 16px;
    }

    .caveau__angolo--1 { top: 9px; left: 9px; }
    .caveau__angolo--3 { bottom: 9px; left: 9px; }
    .caveau__angolo--4 { bottom: 9px; right: 9px; }

    .caveau__esci {
        top: 6px;
        right: 6px;
    }

    .caveau__beffa {
        bottom: max(14px, env(safe-area-inset-bottom));
        padding: 0.75rem 1rem 0.85rem;
    }

    .caveau__beffa .voce__citazione {
        font-size: 1rem;
    }
}
