* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Open Sans", sans-serif;
    background-color: #000000;
    overflow: hidden;
    color: white;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* =========================================
   1. CÉU ESTRELADO DINÂMICO EM CANVAS
   ========================================= */
#ceuEstrelas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000000;
    z-index: 1;
    pointer-events: none;
}

/* =========================================
   2. TOPO AUTÊNTICO (VOLTAR + TÍTULO)
   ========================================= */
.simulador-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    z-index: 1000;
    pointer-events: none;
    box-sizing: border-box;
}

.btn-voltar {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px;
    color: #e4d4b9;
    background-color: #4047764c;
    border: 4px solid rgba(0, 0, 0, 0.4);
    border-radius: 30px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.25s ease, background-color 0.25s ease;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.btn-voltar:hover {
    background-color: rgba(64, 71, 118, 0.6);
    transform: scale(1.05);
    color: #ffffff;
}

.btn-voltar svg {
    transition: transform 0.25s ease;
}

.btn-voltar:hover svg {
    transform: translateX(-3px);
}

.simulador-header h2 {
    margin: 0;
    font-family: "Open Sans", sans-serif;
    font-size: clamp(1.2rem, 3.2vw, 1.8rem);
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #ffffff;
    text-shadow: 0 -3px #ffe8bb7b;
    pointer-events: none;
    text-align: center;
    flex: 1;
    margin-right: 120px; /* Balanceia visualmente com o botão de voltar */
}

/* =========================================
   3. CAMADA DA LANTERNA E MÁSCARA PRETA
   ========================================= */
.luiz {
    position: fixed;
    top: 86%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10; /* Camada abaixo da interface e controles */
    width: clamp(140px, 36vw, 260px);
    aspect-ratio: 1 / 1;
    pointer-events: none;
}

/* Imagem da Lanterna */
.lantern {
    width: 60%;
    height: auto;
    position: absolute;
    left: 50%;
    bottom: 8%;
    transform: translateX(-50%);
    object-fit: contain;
    z-index: 3;
    pointer-events: auto;
    cursor: grab;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.8));
    transition: transform 0.1s ease;
}

.lantern:active {
    cursor: grabbing;
    transform: translateX(-50%) scale(1.04);
}

/* Feixe de Luz Cônico */
.light {
    position: absolute;
    left: 50%;
    top: -60%;
    transform: translateX(-50%);
    width: clamp(280px, 120vw, 900px);
    height: clamp(180px, 40vw, 260px);
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.42) 100%
    );
    clip-path: polygon(46% 98%, 28% 0%, 72% 0%, 54% 98%);
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.1s ease;
}

/* A BOLA PRETA: Opaca quando a 100% para bloquear totalmente as estrelas */
.fundo1 {
    position: absolute;
    left: 50%;
    top: -179%;
    transform: translateX(-50%);
    width: 800px;
    height: 600px;
    background-color: #000000;
    clip-path: ellipse(55% 50% at 50% 50%);
    z-index: 1;
    pointer-events: none;
    transition: opacity 0.1s ease;
}

/* =========================================
   4. GUIA DE INSTRUÇÕES
   ========================================= */
.guide {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 10px 22px;
    background: rgba(16, 18, 31, 0.88);
    border: 2px solid rgba(232, 201, 122, 0.35);
    border-radius: 999px;
    font-size: 0.9rem;
    color: #e4d4b9;
    text-align: center;
    max-width: 90vw;
    pointer-events: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* =========================================
   5. CONTROLES (JOYSTICK + BOTÕES AUTÊNTICOS)
   ========================================= */
.controles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
    display: none; /* Oculto no desktop; mostrado apenas no mobile */
}

.joystick {
    position: absolute;
    left: 24px;
    bottom: 24px;
    width: 110px;
    height: 110px;
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.joystick-base {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background-color: #4047764c;
    border: 4px solid rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

.joystick-stick {
    position: absolute;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-color: rgba(228, 212, 185, 0.65);
    border: 3px solid rgba(0, 0, 0, 0.4);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    transition: background-color 0.1s;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.joystick-stick.ativo {
    background-color: #e8c97a;
}

.botoes {
    position: absolute;
    right: 24px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: auto;
}

.btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #4047764c;
    border: 4px solid rgba(0, 0, 0, 0.4);
    color: #e4d4b9;
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
    transition: all 0.2s ease;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

.btn:active {
    background-color: rgba(232, 201, 122, 0.3);
    transform: scale(0.92);
}

/* =========================================
   6. RESPONSIVIDADE PRECISA PARA CELULAR
   ========================================= */
@media (max-width: 768px) {
    .simulador-header {
        padding: 10px 14px;
        align-items: center;
    }

    .btn-voltar {
        padding: 6px 14px;
        font-size: 12px;
        border-width: 3px;
        gap: 5px;
    }

    .simulador-header h2 {
        font-size: 0.95rem;
        letter-spacing: 1px;
        margin-right: 0;
        text-align: right;
    }

    /* Guia no topo para não disputar espaço com joystick e botões */
    .guide {
        top: 60px;
        bottom: auto;
        padding: 6px 14px;
        font-size: 0.74rem;
        width: 90%;
        max-width: 380px;
    }

    .luiz {
        width: 160px;
    }

    .light {
        width: 100vw;
        height: 220px;
        top: -104%;
        clip-path: polygon(45% 98%, 26% 0%, 74% 0%, 55% 98%);
    }

    .fundo1 {
        width: 92vw;
        max-width: 440px;
        height: 340px;
        top: -175%;
        clip-path: ellipse(50% 45% at 50% 50%);
    }

    .controles {
        display: block;
    }

    .joystick {
        left: 16px;
        bottom: 20px;
        width: 96px;
        height: 96px;
    }

    .joystick-stick {
        width: 44px;
        height: 44px;
    }

    .botoes {
        right: 16px;
        bottom: 20px;
        gap: 10px;
    }

    .btn {
        width: 50px;
        height: 50px;
        font-size: 22px;
        border-width: 3px;
    }
}

/* Telas com touch/coarse pointer (celulares e tablets) */
@media (hover: none) and (pointer: coarse) {
    .controles {
        display: block;
    }
}
