:root {
    --bg-pos-x: 50%;
    --bg-pos-y: 0%;
    --bg-main: #020817;
    --bg-alt: #050c25;
    --accent: #4af2c5;
    --accent-soft: rgba(74, 242, 197, 0.18);
    --accent-2: #7b5cff;
    --accent-2-soft: rgba(123, 92, 255, 0.14);
    --danger: #ff4f81;
    --text-main: #e6f1ff;
    --muted: #7b88a6;
    --radius-pill: 999px;
    --radius-card: 18px;
    --shadow-soft: 0 14px 40px rgba(0,0,0,0.65);
    --transition-fast: 0.18s ease-out;
    --font-ui: 'Orbitron', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'Rajdhani', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Impostazioni di base per il corpo della pagina */
body {
    margin: 0;
    overflow: hidden;
    min-height: 100vh;
    background:
        radial-gradient(circle at top, #101b3f 0%, #050816 38%, #000000 100%);
    color: var(--text-main);
    font-family: var(--font-body);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle, rgba(74, 242, 197, 0.03) 1px, transparent 0),
        radial-gradient(circle, rgba(123, 92, 255, 0.02) 1px, transparent 0);
    background-size: 80px 80px, 140px 140px;
    mix-blend-mode: screen;
    opacity: 0.7;
    z-index: -3;
    pointer-events: none;
}

/* Stelle animate come sfondo */
#stars {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1; /* Dietro la finestra di benvenuto */
}

/* Singola stella */
.star {
    position: absolute;
    background-color: white;
    border-radius: 50%;
    opacity: 0.8;
    animation: twinkle 5s infinite alternate ease-in-out;
}

/* Effetto di "brillio" delle stelle */
@keyframes twinkle {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.8; }
}

/* Finestra di benvenuto */
#welcomeMessage { /* tech glass card */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    padding: 30px;
    background-color: rgba(255, 255, 255, 0.9); /* Colore di sfondo leggermente trasparente */
    color: #333333;
    border: 3px solid #444444;
    border-radius: 15px;
    line-height: 1.5;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.9);
    display: block;
    background: url('../img/blossom.png') no-repeat center; 
    background-size: cover; 
    width: 60%;
    max-width: 500px;
    height: auto;
    animation: fadeIn 2s ease-in-out; /* Animazione per il fade-in */
}

/* Animazione di fade-in per il welcomeMessage */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Titolo della finestra di benvenuto */
#welcomeMessage #title {
    font-weight: bold;
    font-size: 24px;
    margin-bottom: 20px;
    text-transform: uppercase;
    color: #444444;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

/* Icona del titolo della finestra di benvenuto */
#welcomeMessage #title i {
    color: #b8a92a; /* Verde brillante per l'icona */
}

/* Testo del messaggio di benvenuto */
#welcomeText {
    font-size: 18px;
    text-align: center;
    color: #333333;
}

/* Contatore in alto a destra */
#counter,
#worldNumber {
    color: #FFFFFF;
    font-size: 24px;
    z-index: 10;
    position: absolute;
}

#counter {
    top: 10px;
    right: 10px;
}

#worldNumber {
    top: 10px;
    left: 10px;
}

/* Messaggi di gioco */
#message,
#welcomeMessage,
#levelGoalMessage {
    position: absolute;
    color: #FFFFFF;
    text-align: center;
    z-index: 20;
    font-family: 'Arial', sans-serif;
}

#message {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    display: none;
}

/* Pulsanti per interagire (e.g. prova ancora, prossimo livello) */
#nextWorld,
#tryAgain {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 15px 30px;
    background-color: #FFFFFF;
    color: #000000;
    font-size: 20px;
    cursor: pointer;
    z-index: 20;
    display: none;
    border: none;
    border-radius: 5px;
}

#nextWorld,
#tryAgain {
    transition: all var(--transition-fast);
}

#nextWorld:hover,
#tryAgain:hover {
    transform: translate(-50%, -50%) scale(1.04);
    box-shadow:
        0 0 10px rgba(74, 242, 197, 0.9),
        0 0 22px rgba(123, 92, 255, 0.5);
}

#nextWorld:active,
#tryAgain:active {
    transform: translate(-50%, -50%) scale(0.98);
}


/* Immagine del bot */
#botImage {
    position: absolute;
    top: 25%;
    left: -40%;
    width: 50%;
    height: auto;
    transition: left 0.7s ease-in-out;
    z-index: 15;
    display: none;
    height: 50%;
    width: auto;
}

/* Immagine dell'alieno */
.alienImage {
    position: absolute;
    top: 25%;
    right: -40%;
    width: 30%;
    height: auto;
    transition: right 1s ease-in-out;
    z-index: 15;
    display: none;
    height: 30%;
    width: auto;
}

/* Testo dell'alieno */
.alienText {
    position: absolute;
    top: 60%;
    right: -50%;
    height: auto;
    transition: right 1.2s ease-in-out;
    z-index: 15;
    display: none;
    width: auto;
    font-size: 18px;
    padding: 20px;
    background-color: #FFFFFF;
    color: #000000;
    border: 2px solid #444444;
    border-radius: 8px;
    max-width: 400px;
    line-height: 1.5;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
    z-index: 14;
    transform: translate(-50%, -50%);
}

/* Messaggio obiettivo del livello */
#levelGoalMessage {
    position: absolute;
    top: 50%;
    left: -50%;
    height: auto;
    transition: left 1.2s ease-in-out;
    z-index: 15;
    display: none;
    width: auto;
    font-size: 18px;
    padding: 20px;
    background-color: #FFFFFF;
    color: #000000;
    border: 2px solid #444444;
    border-radius: 8px;
    max-width: 400px;
    line-height: 1.5;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
    z-index: 14;
    transform: translate(-50%, -50%);
}

/* Canvas per le animazioni o il gioco */
canvas {
    display: block;
}

/* RIB */
#rib{
    float: right;
    position: relative;
    bottom: 1%;

}

/* TECH BUTTONS */
button,
.btn,
#startButton,
#infoButton,
#closeInfo,
#nextWorld,
#tryAgain,
#finalButton,
.control-button {
    font-family: var(--font-ui);
    text-transform: uppercase;
    padding: 10px 26px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(74, 242, 197, 0.6);
    background:
        radial-gradient(circle at top left, var(--accent-soft), transparent),
        radial-gradient(circle at bottom right, var(--accent-2-soft), transparent),
        rgba(0, 6, 18, 0.96);
    color: var(--text-main);
    letter-spacing: 0.12em;
    font-size: 13px;
    box-shadow:
        0 0 10px rgba(74, 242, 197, 0.4),
        0 0 26px rgba(123, 92, 255, 0.26);
    cursor: pointer;
    outline: none;
    transition:
        transform var(--transition-fast),
        box-shadow var(--transition-fast),
        border-color var(--transition-fast),
        background var(--transition-fast),
        color var(--transition-fast);
}

button:hover,
.btn:hover,
#startButton:hover,
#infoButton:hover,
#closeInfo:hover,
#finalButton:hover,
.control-button:hover {
    transform: translateY(-2px);
    box-shadow:
        0 0 14px rgba(74, 242, 197, 0.7),
        0 0 40px rgba(123, 92, 255, 0.35);
    border-color: rgba(123, 92, 255, 0.85);
    background:
        radial-gradient(circle at top, rgba(74, 242, 197, 0.22), transparent),
        radial-gradient(circle at bottom, rgba(123, 92, 255, 0.22), transparent),
        rgba(1, 9, 26, 1);
}

button:active,
.btn:active,
#startButton:active,
#infoButton:active,
#closeInfo:active,
#finalButton:active,
.control-button:active {
    transform: translateY(1px) scale(0.98);
    box-shadow:
        0 0 6px rgba(74, 242, 197, 0.5),
        0 0 14px rgba(123, 92, 255, 0.22);
}


/* World-specific dynamic backgrounds */
body.world-1 {
    background:
        radial-gradient(circle at var(--bg-pos-x) var(--bg-pos-y), #0b1020 0%, #050816 40%, #000000 100%);
}

body.world-2 {
    background:
        radial-gradient(circle at var(--bg-pos-x) var(--bg-pos-y), #1b0433 0%, #3c0b5d 40%, #05010c 100%);
}

body.world-3 {
    background:
        radial-gradient(circle at var(--bg-pos-x) var(--bg-pos-y), #001f17 0%, #014434 40%, #000806 100%);
}

body.world-4 {
    background:
        radial-gradient(circle at var(--bg-pos-x) var(--bg-pos-y), #2b0500 0%, #6a1400 40%, #000000 100%);
}

body.world-5 {
    background:
        radial-gradient(circle at var(--bg-pos-x) var(--bg-pos-y), #001826 0%, #004f7a 40%, #000000 100%);
}

body.world-6 {
    background:
        radial-gradient(circle at var(--bg-pos-x) var(--bg-pos-y), #111111 0%, #262626 40%, #000000 100%);
}

/* Mantieni il layer di particelle ma adattalo ai mondi con priorità di default */
body.world-1::before,
body.world-2::before,
body.world-3::before,
body.world-4::before,
body.world-5::before,
body.world-6::before {
    opacity: 0.18;
}
