.arcade-container {
    position: relative;
    margin-top: 8vw;
    width: max-content;
    margin-left: auto;
    margin-right: auto;
    transition: transform 1.5s cubic-bezier(0.4, 0, 0.2, 1), margin-bottom 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center 30%;
    margin-bottom: 0;
}

/* Utility classes per separare lo stile dall'HTML */
.hide {
    display: none !important;
}

.no-transition {
    transition: none;
}

.arcade-container.zoomed {
    transform: scale(2);
    margin-bottom: 60vw;
}

.arcade-image {
    height: 90vw;
    width: auto;
    display: block;
    position: relative;
    z-index: 10;
    pointer-events: none;
}

.arcade-screen {
    position: absolute;
    top: 31%; 
    left: 50%;
    transform: translate(-50%, -50%);
    width: 68%; 
    height: 27%; 
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    background-color: #1e1e1e;
    container-type: inline-size; 
}

/* Sfondo decorativo dello schermo */
.arcade-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.45;
    background-image: url('../assets/images/background_screen.png');
    background-size: cover;
    background-position: center;
    transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.arcade-container.zoomed .arcade-screen::before {
    opacity: 0.15;
}

.arcade-container.no-transition .arcade-screen::before {
    transition: none;
}

.screen-content {
    position: relative;
    z-index: 1;
    width: 90%;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.insert-coin {
    font-family: var(--primary-font);
    color: var(--neutral-light);
    font-size: 8cqw; /* misura magica per lo schermo del cabinato */
    text-align: center;
    animation: blinkSlow 2s infinite;
    line-height: 1.8;
    text-shadow: 0 0 6cqw rgba(0, 0, 0, 0.4);
}

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

.arcade-footer {
    position: absolute;
    bottom: 1.2%;
    left: 50%;
    transform: translateX(-50%);
    width: 88%;
    text-align: center;
    z-index: 20;
    font-family: var(--secondary-font);
    color: var(--neutral-light);
    font-size: 1.8vw;
    background-color: #0f0f0f;
    padding: 1.5vw 1vw;
    border-radius: 0.8vw;
    letter-spacing: 0.2vw;
}

.arcade-footer p {
    margin: 0.5vw 0;
    line-height: 1.5;
}

.arcade-footer p:first-child {
    font-size: 2.5vw;
}

.author-name {
    color: var(--tertiary-color);
}

.grid-background {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-image: url('../assets/images/background.png');
    background-position: bottom center;
    background-repeat: no-repeat;
    background-size: 100% auto;
    z-index: -1;
    transform: translateZ(0);
    will-change: transform;
}

/* Bottom banner */
.start-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(135deg, 
        rgba(187, 137, 225, 0.95) 0%, 
        rgba(57, 154, 162, 0.95) 100%);
    padding: 25px 20px;
    text-align: center;
    z-index: 100;
    box-shadow: 0 -4px 30px black;
    border-top: 3px solid black;
    opacity: 0.98;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s ease, visibility 0.5s;
    visibility: visible;
}

.start-banner.hidden {
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
    visibility: hidden; /* Nasconde completamente il banner agli screen reader quando è chiuso */
}

.start-banner-text {
    font-family: var(--primary-font);
    font-size: var(--font-medium);
    color: var(--neutral-dark);
    text-transform: uppercase;
}

.tasto {
    display: inline-block;
    padding: 10px 16px;
    background: var(--neutral-dark);
    color: var(--neutral-light);
    border-radius: 6px;
    font-family: var(--primary-font);
    font-size: clamp(12px, 1.8vw, 18px);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
    border: 2px solid var(--secondary-color);
}

/* --- Schermo Menu --- */
.screen-view {
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--neutral-light);
    padding: 2rem;
    min-height: 100vh;
}

.menu-container {
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.menu-title {
    font-size: 11cqw;
    color: var(--tertiary-color);
    -webkit-text-stroke: 0.1cqw #000000;
    text-shadow: 0 0 3cqw rgba(149, 149, 149, 0.3);
    font-family: var(--secondary-font);
    margin-bottom: 0.5cqw;
}

.menu-subtitle {
    font-size: 4.5cqw;
    color: var(--neutral-light);
    font-family: var(--tertiary-font);
    margin-bottom: 3cqw;
}

.menu-options {
    display: grid;
    grid-template-rows: repeat(4, 1fr);
    gap: 1.5cqw;
    width: 65%;
}

.menu-option {
    background-color: rgba(0, 0, 0, 0.25);
    padding: 1cqw 0.5cqw;
    text-decoration: none;
    color: var(--neutral-light);
    
    /* Effetto doppio bordo */
    border: 0.4cqw solid var(--tertiary-color);
    box-shadow: inset 0 0 0 0.3cqw var(--secondary-color);
    
    border-radius: 10px;
    transition: background-color 0.3s ease;
    
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.5cqw;
    position: relative;
}

.menu-option::before {
    content: '';
    position: absolute;
    left: -10cqw;
    width: 8cqw;
    height: 8cqw;
    background-image: url('../assets/images/star.webp');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0;
    pointer-events: none;
}

.menu-option:hover::before,
.menu-option:focus-visible::before {
    opacity: 1;
}

.menu-icon {
    width: 9cqw;
    height: 9cqw;
    display: block;
    margin: 0 3cqw;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.icon-tutorial { background-image: url('../assets/images/tutorial_icon.png'); }
.icon-game { background-image: url('../assets/images/game_icon.png'); }
.icon-leaderboard { background-image: url('../assets/images/leaderboard_icon.png'); }
.icon-settings { background-image: url('../assets/images/settings_icon.png'); }

.menu-option-title {
    margin-left: 2cqw;
    font-family: var(--tertiary-font);
    font-size: 7.5cqw;
    text-shadow: 0 1cqw 3cqw var(--secondary-color);
}

/* --- Schermata di Caricamento Gioco --- */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-family: var(--primary-font);
    color: var(--neutral-light);
}

.loading-logo {
    width: 60cqw;
    height: auto;
    margin-bottom: 4cqw; 
}

.progress-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 110%;
    gap: 3cqw;
    margin-bottom: 1.5cqw;
}

#loading-percentage {
    font-family: var(--secondary-font);
    font-size: 12cqw;
    color: var(--primary-color);
    -webkit-text-stroke: 0.1cqw #000000;
    text-shadow: 0 0 3cqw rgba(161, 161, 161, 0.7);
    min-width: 16cqw;
    text-align: right;
}

.progress-bar-container {
    flex-grow: 1; 
    height: 8cqw;
    background-color: rgba(247, 247, 247, 0.12);
    border: 0.3cqw solid var(--primary-color);
    border-radius: 7px;
    padding: 0.4cqw;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--tertiary-color));
    transition: width 0.2s ease-out;
    box-shadow: 0 0 2cqw var(--neutral-dark);
    border-radius: 4px;
}

#loading-text {
    font-size: 3cqw;
    color: var(--neutral-light);
    margin-top: 1.5cqw;
}

.play-button {
    font-size: 4cqw;
    padding: 5cqw 15cqw;
    text-shadow: 0 1cqw 3cqw var(--secondary-color);
    margin-top: 7cqw;
}

/* --- Interfaccia Gioco (Top Bar) --- */
#topbargame {
    position: absolute;
    top: -7%;
    left: -5cqw;
    width: 100cqw;
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 3cqw 10cqw 0.5cqw 9cqw;
    z-index: 10;
    background-color: rgba(24, 33, 38, 0.70);
    border-bottom: 0.3cqw solid var(--secondary-color);
    box-shadow: 0 1cqw 2cqw rgba(0, 0, 0, 0.5);
}

#topbargame.active {
    display: flex;
}

.score-container {
    font-family: var(--primary-font);
    font-size: 3.5cqw;
    color: var(--tertiary-color);
    text-shadow: 0 0 1cqw var(--tertiary-color);
}

.lives-container {
    display: flex;
    gap: 1cqw;
}

.heart-icon {
    width: 6cqw;
    height: auto;
}

.settings-btn {
    border-width: 0.3cqw;
    box-shadow: inset 0 0 0 0.2cqw var(--secondary-color);
    border-radius: 8px;
    padding: 0.8cqw;
    margin-bottom: 1cqw;
}

.settings-btn .icon-settings {
    display: block;
    width: 4cqw;
    height: 4cqw;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}


#game-area {
    position: absolute;
    top: 8cqw;
    left: -7cqw;
    width: 104cqw;
    bottom: -7.5%;
    padding: 0 4cqw 2cqw 4cqw;
    display: none;
}

#game-area.active {
    display: flex;
}

.lane {
    flex: 1;
    background-color: rgba(25, 222, 139, 0.09);
    border-right: 0.2cqw dashed rgba(47, 233, 249, 0.3);
    position: relative;
    overflow: hidden;
}

.lane:first-of-type {
    border-left: 0.4cqw solid rgba(151, 29, 29, 0.8);
}

.lane:last-of-type {
    border-right: 0.4cqw solid rgba(151, 29, 29, 0.8);
}

/* --- Navicella --- */
.player-ship {
    position: absolute;
    bottom: 4cqw;
    left: 50%;
    width: 7cqw;
    height: auto;
    z-index: 20;
}

/* Posizioni esatte calcolate in base alla larghezza delle 3 colonne */
.player-ship.lane-0 { transform: translateX(calc(-50% - 32cqw)); } /* Sinistra */

.player-ship.lane-1 { transform: translateX(-50%); }               /* Centro */

.player-ship.lane-2 { transform: translateX(calc(-50% + 32cqw)); } /* Destra */

/* --- Alieni --- */
.alien {
    position: absolute;
    top: -20cqw;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 9cqw;
    height: 9cqw;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 15;
    animation: fallDown var(--fall-speed, 15s) steps(30) forwards;
}

.alien-1 { background-image: url('../assets/images/aliens1.webp'); }
.alien-2 { background-image: url('../assets/images/aliens2.webp'); }
.alien-3 { background-image: url('../assets/images/aliens3.webp'); }
.alien-4 { background-image: url('../assets/images/aliens4.webp'); }

@keyframes fallDown {
    0% { top: -20cqw; }
    100% { top: 120%; }
}

@keyframes explodeEffect {
    0% {
        background-color: var(--neutral-light);
        box-shadow: 0 0 4cqw var(--neutral-light), 0 0 8cqw var(--tertiary-color);
    }
    100% {
        background-color: transparent;
        box-shadow: 0 0 4cqw transparent, 0 0 8cqw transparent;
    }
}

.alien.exploded {
    top: var(--freeze-top) !important;
    background-image: none !important;
    border-radius: 50%;
    animation: explodeEffect 0.3s ease-out forwards !important;
}

/* --- Proiettile --- */
.laser {
    position: absolute;
    bottom: 12cqw;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 1.5cqw;
    height: 5cqw;
    background-color: var(--tertiary-color);
    box-shadow: 0 0 2cqw var(--tertiary-color);
    border-radius: 1cqw;
    z-index: 10;
    animation: shootUp 0.9s linear forwards;
}

@keyframes shootUp {
    0% { bottom: 12cqw; }
    100% { bottom: 100vh; }
}

/* --- Schermata Game Over --- */
#game-over-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-family: var(--primary-font);
    color: var(--neutral-light);
    text-align: center;
}

#game-over-screen.active {
    display: flex;
}

.game-over-title {
    background: linear-gradient(to bottom, var(--tertiary-color) 40%, var(--secondary-color));
    -webkit-background-clip: text;
    color: transparent;
    font-size: 17cqw;
    -webkit-text-stroke: 0.1cqw #000;
    filter: drop-shadow(0 0 2cqw rgb(76, 49, 132));
    font-family: var(--secondary-font);
}

.final-score-text {
    font-size: 5cqw;
    color: var(--primary-color);
    font-family: var(--primary-font);
    margin-bottom: 4.5cqw;
}

.game-over-divider {
    width: 65cqw;
    border: none;
    border-bottom: 0.4cqw dashed var(--secondary-color);
    margin-bottom: 5.5cqw;
    opacity: 0.8;
}

.player-name-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5cqw;
    margin-bottom: 1cqw;
}

.player-name-container label {
    font-family: var(--primary-font);
    font-size: 2.5cqw;
    color: var(--neutral-light);
    text-transform: uppercase;
    text-shadow: 0 0 1cqw rgba(0, 0, 0, 1);
    margin-bottom: 0.5cqw;
}

#player-name {
    background-color: rgba(0, 0, 0, 0.6);
    border: 0.3cqw solid var(--primary-color);
    box-shadow: inset 0 0 1cqw rgba(47, 233, 249, 0.5), 0 0 2cqw rgba(47, 233, 249, 0.3);
    color: var(--neutral-light);
    font-family: var(--primary-font);
    font-size: 4.5cqw;
    text-align: center;
    width: 60cqw;
    padding: 1.5cqw;
    text-transform: uppercase;
    outline: none;
    border-radius: 6px;
    letter-spacing: 0.2cqw;
    transition: all 0.3s ease;
}

#player-name:focus {
    background-color: rgba(25, 222, 139, 0.15);
    border-color: var(--primary-color);
    box-shadow: inset 0 0 1cqw var(--primary-color), 0 0 3cqw var(--primary-color);
}

#save-score-btn {
    font-size: 2.8cqw;
    padding: 2cqw 4cqw;
    margin-top: 3cqw;
    line-height: 1.8;
    text-align: center;
    text-shadow: 0 0.5cqw 1cqw var(--secondary-color);
}

/* --- Classifica --- */
.leaderboard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 100%;
}

.leaderboard-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1cqw;
    margin-top: -2cqw;
    margin-bottom: 1cqw;
    width: 100%;
}

.leaderboard-logo {
    width: 40cqw;
    height: auto;
}

.leaderboard-title {
    font-size: 6cqw;
    margin-bottom: 1cqw;
    margin-top: -0.5cqw;
    text-shadow: 0 0 2cqw rgba(149, 149, 149, 0.3);
}

.leaderboard-divider {
    width: 80%;
    border: none;
    border-bottom: 0.4cqw dashed var(--secondary-color);
    margin-bottom: 2cqw;
    opacity: 0.8;
}

.leaderboard-filters {
    display: flex;
    gap: 2cqw;
    margin-bottom: 3cqw;
}

.filter-btn {
    font-size: 2.5cqw;
    padding: 1cqw 2cqw;
    opacity: 0.5;
    border-width: 0.3cqw;
}

.filter-btn.active {
    opacity: 1;
    background-color: rgba(47, 233, 249, 0.15);
    border-color: var(--primary-color);
}

.leaderboard-list {
    list-style: none;
    width: 80%;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(247, 247, 247, 0.05);
    padding: 1cqw 2cqw;
    margin-bottom: 0.5cqw;
    border-radius: 4px;
    font-family: var(--primary-font);
    font-size: 2.5cqw;
    color: var(--neutral-light);
    border-left: 0.3cqw solid transparent;
}

.leaderboard-row.highlight {
    background-color: rgba(47, 233, 249, 0.15);
    border-left: 0.3cqw solid var(--tertiary-color);
    color: var(--tertiary-color);
    text-shadow: 0 0 1cqw var(--neutral-dark);
}

.leaderboard-row .rank { width: 15%; text-align: left; color: var(--tertiary-color); }
.leaderboard-row .name { width: 55%; text-align: left; }
.leaderboard-row .score { width: 30%; text-align: right; color: var(--primary-color); }

.leaderboard-separator {
    text-align: center;
    color: var(--secondary-color);
    font-family: var(--primary-font);
    margin-bottom: 1cqw;
}

.leaderboard-actions {
    display: flex;
    gap: 3cqw;
    margin-top: auto;

}

.back-btn,
.play-again-btn {
    font-size: 3cqw;
    padding: 1.5cqw 3cqw;
}