@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;700&family=Orbitron:wght@700&display=swap');

:root { 
    --laser: #00ff00; 
    --azul-espaco: #050c1a;
    --laranja: #ff8a3d;
    --btn-verde: #2ecc71;
    --btn-azul: #2196f3;
    --btn-vermelho: #ff7675;
    --btn-roxo: #a29bfe;
    --neon-azul: #00d2ff;
}

body { 
    margin: 0; 
    font-family: 'Fredoka', sans-serif; 
    background: var(--azul-espaco); 
    color: white; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    min-height: 100vh;
    height: 100dvh;
}

/* ESTRELAS NO FUNDO */
#estrelas{
    position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background-image:
        radial-gradient(rgba(255,255,255,0.60) 1px, transparent 1px),
        radial-gradient(rgba(0,210,255,0.12) 1px, transparent 1px);
    background-size: 360px 360px, 560px 560px;
    background-position: 0 0, 180px 220px;
    opacity: 0.38; transform: translate3d(0,0,0);
    animation: estrelasDrift 80s linear infinite;
}
#estrelas::after{
    content: ""; position: absolute; inset: 0;
    background-image: radial-gradient(rgba(255,255,255,0.85) 1px, transparent 1px);
    background-size: 820px 820px; background-position: 260px 140px;
    opacity: 0.10; animation: estrelasTwinkle 7.2s ease-in-out infinite;
}
@keyframes estrelasTwinkle{ 0%, 100% { opacity: 0.08; } 50% { opacity: 0.16; } }
@keyframes estrelasDrift{ from { transform: translate3d(0,0,0); } to { transform: translate3d(0,55px,0); } }

/* CABEÇALHO COM GRID PARA CENTRALIZAÇÃO PERFEITA */
header { 
    background: white; width: 100%; padding: 10px 20px; 
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; 
    z-index: 50; box-shadow: 0 4px 15px rgba(0,0,0,0.5); box-sizing: border-box; position: relative;
}

.grupo-botoes { display: flex; gap: 10px; align-items: center; justify-self: start; }
.status-topo { text-align: right; justify-self: end; }

.btn-header { 
    color: white; text-decoration: none; padding: 8px 15px; border-radius: 12px; font-weight: bold; 
    font-size: 0.8rem; transition: 0.2s; border: none; cursor: pointer;
}
.btn-vermelho { background: var(--btn-vermelho); box-shadow: 0 4px 0 #d63031; }
.btn-laranja { background: var(--laranja); box-shadow: 0 4px 0 #e67e22; }
.btn-roxo { background: var(--btn-roxo); box-shadow: 0 4px 0 #6c5ce7; }

#vidas-display {
    justify-self: center; /* Centraliza no meio do Grid */
    font-size: 1.4rem; letter-spacing: 3px; text-shadow: 0 2px 4px rgba(0,0,0,0.2); white-space: nowrap;
}

.valor-recorde { font-size: 2.2rem; color: #f39c12; font-family: 'Orbitron', sans-serif; text-shadow: 1px 2px 0px rgba(0,0,0,0.15); line-height: 1; }

/* COMBO TOAST */
#combo-toast {
    position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%) translateY(-10px);
    opacity: 0; pointer-events: none; z-index: 120;
    background: rgba(0, 20, 40, 0.78); border: 1px solid rgba(0, 210, 255, 0.35); box-shadow: 0 0 18px rgba(0, 210, 255, 0.22);
    color: #fff; padding: 10px 14px; border-radius: 14px; font-family: 'Fredoka', sans-serif; font-weight: 900; letter-spacing: 0.6px;
    transition: opacity .18s ease, transform .18s ease;
}
#combo-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* METEOROS BASE */
.meteoro { 
    position: absolute; width: 80px; height: 80px; 
    background: #4a4a4a; border: 3px solid #2d2d2d; border-radius: 20px 40px 25px 35px;
    display: flex; justify-content: center; align-items: center; font-size: 1.4rem; font-weight: bold; color: white; 
    box-shadow: inset -5px -5px 0 rgba(0,0,0,0.5); z-index: 10; text-shadow: 2px 2px 4px black; will-change: transform, opacity;
    transition: transform 0.2s, width 0.2s, height 0.2s; 
}

/* TIPOS DE METEOROS */
.meteoro.boss { 
    width: 140px; height: 140px; background: #8e44ad; border-color: #5b2c6f; font-size: 2.2rem;
    box-shadow: inset -5px -5px 0 rgba(0,0,0,0.5), 0 0 20px rgba(142, 68, 173, 0.6);
    border-radius: 50% 40% 50% 40%;
}
.meteoro.fast { 
    width: 60px; height: 60px; background: #e74c3c; border-color: #c0392b; font-size: 1.1rem;
    box-shadow: inset -5px -5px 0 rgba(0,0,0,0.5), 0 0 15px rgba(231, 76, 60, 0.5);
    border-radius: 20px;
}
.meteoro.power { 
    background: #f1c40f; border-color: #f39c12; color: #fff; text-shadow: 1px 1px 2px #d35400;
    box-shadow: inset -5px -5px 0 rgba(211, 84, 0, 0.5), 0 0 25px #f1c40f;
    animation: brilhoPoder 1s infinite alternate;
}
@keyframes brilhoPoder { from { box-shadow: 0 0 10px #f1c40f; } to { box-shadow: 0 0 30px #f1c40f, inset -5px -5px 0 rgba(211, 84, 0, 0.5); } }

/* HUD INFERIOR */
#hud-inferior {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; justify-content: center; gap: 15px; z-index: 30; width: 95%; max-width: 600px; pointer-events: none; 
}

.painel-lateral {
    background: rgba(0, 20, 40, 0.9); border: 2px solid var(--neon-azul); border-radius: 12px;
    padding: 8px 15px; text-align: center; min-width: 70px; box-shadow: 0 0 10px rgba(0, 210, 255, 0.2); pointer-events: auto;
}
.painel-titulo { font-size: 0.65rem; color: var(--neon-azul); font-family: 'Orbitron', sans-serif; letter-spacing: 1px; margin-bottom: 2px; }
.painel-valor { font-size: 1.8rem; font-family: 'Orbitron', sans-serif; font-weight: bold; line-height: 1; }

/* SISTEMA DE MIRA (ARMA E AVISOS) */
#input-radar { 
    background: rgba(0, 20, 40, 0.9); padding: 10px 40px; border: 2px solid var(--neon-azul); border-radius: 5px 20px 5px 20px;
    box-shadow: 0 0 15px var(--neon-azul), inset 0 0 10px var(--neon-azul); text-align: center; position: relative; pointer-events: auto;
    transition: all 0.15s ease-out; 
}
#input-radar::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 2px; background: var(--neon-azul); opacity: 0.3; animation: scan 2s linear infinite; }
@keyframes scan { from { top: 0; } to { top: 100%; } }
#display-resposta { font-family: 'Orbitron', sans-serif; font-size: 3rem; color: #fff; text-shadow: 0 0 10px var(--neon-azul); transition: color 0.15s; }

/* AVISO DA BOMBA PISCANDO */
#aviso-bomba {
    position: absolute; top: -35px; left: 50%; transform: translateX(-50%);
    color: #f1c40f; font-family: 'Fredoka', sans-serif; font-size: 0.85rem; font-weight: bold;
    text-shadow: 0 0 10px #f39c12; white-space: nowrap;
    animation: piscaBomba 0.6s infinite alternate; display: none; pointer-events: none;
}
@keyframes piscaBomba { 
    from { opacity: 0.4; transform: translateX(-50%) scale(0.95); } 
    to { opacity: 1; transform: translateX(-50%) scale(1.05); } 
}

/* FEEDBACKS DA MIRA */
.radar-acerto { border-color: var(--laser) !important; box-shadow: 0 0 25px var(--laser), inset 0 0 15px var(--laser) !important; transform: scale(1.12) !important; }
.radar-acerto::before { background: var(--laser) !important; opacity: 0.8 !important; }
.radar-acerto #display-resposta { color: var(--laser); text-shadow: 0 0 15px var(--laser); }

.radar-erro { border-color: var(--btn-vermelho) !important; box-shadow: 0 0 25px var(--btn-vermelho), inset 0 0 15px var(--btn-vermelho) !important; animation: shakeErro 0.3s cubic-bezier(.36,.07,.19,.97) both !important; }
.radar-erro #display-resposta { color: var(--btn-vermelho); text-shadow: 0 0 15px var(--btn-vermelho); }
@keyframes shakeErro { 10%, 90% { transform: translate3d(-4px, 0, 0); } 20%, 80% { transform: translate3d(4px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-8px, 0, 0); } 40%, 60% { transform: translate3d(8px, 0, 0); } }

/* CANO E BASE DA ARMA */
#base-arma { position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); width: 60px; height: 40px; background: #2c3e50; border-radius: 10px 10px 0 0; border-top: 4px solid var(--neon-azul); z-index: 25; transition: left 0.15s ease-out; }
#cano { position: absolute; bottom: 20px; left: 50%; width: 10px; height: 50px; background: linear-gradient(to top, #34495e, #7f8c8d); transform-origin: bottom center; transform: translateX(-50%) rotate(0deg); border-radius: 5px; z-index: 24; transition: left 0.15s ease-out; }

/* LASER E EXPLOSÃO */
.laser { position: absolute; bottom: 30px; left: 50%; width: 6px; background: var(--laser); box-shadow: 0 0 20px var(--laser); transform-origin: bottom center; z-index: 5; border-radius: 10px; }
.particula { position: absolute; width: 6px; height: 6px; background: var(--laranja); border-radius: 50%; pointer-events: none; z-index: 15; animation: explodirParticula 0.6s ease-out forwards; }
@keyframes explodirParticula { to { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; } }

/* FLASH DA BOMBA */
#flash-bomba { position: fixed; inset: 0; background: white; opacity: 0; pointer-events: none; z-index: 999; transition: opacity 0.1s; }

/* MENUS & OVERLAYS */
.tela-blur { position: fixed; inset: 0; background: rgba(5, 12, 26, 0.95); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); display: flex; justify-content: center; align-items: center; z-index: 100; }
.caixa-menu { background: white; padding: 25px; border-radius: 30px; border: 8px solid var(--laranja); width: 340px; text-align: center; box-shadow: 0 15px 0 rgba(0,0,0,0.2); }
.lista-niveis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 15px 0; }
.btn-nivel { padding: 12px; border-radius: 12px; border: none; cursor: pointer; color: white; font-family: 'Fredoka', sans-serif; font-weight: bold; box-shadow: 0 4px 0 rgba(0,0,0,0.1); font-size: 0.95rem; transition: 0.1s; }
.btn-nivel small { display: block; font-size: 0.7rem; opacity: 0.9; }
.btn-acao-menu { width: 100%; padding: 12px; border-radius: 12px; border: none; font-weight: bold; cursor: pointer; margin-top: 8px; color: white; }
.instrucoes-texto { text-align: left; color: #333; font-size: 0.85rem; background: #f9f9f9; padding: 15px; border-radius: 15px; margin-bottom: 15px; }

.controles { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); right: calc(20px + env(safe-area-inset-right)); display: flex; flex-direction: column; gap: 10px; z-index: 110; }
.botao-acao { width: 50px; height: 50px; border-radius: 50%; border: 3px solid white; cursor: pointer; display: flex; align-items: center; justify-content: center; background: white; font-size: 1.2rem; }
.botao-acao.ativo { background: var(--btn-verde) !important; color: white; }
.botao-acao.bomba-ready { background: #f1c40f !important; border-color: #f39c12; box-shadow: 0 0 20px #f1c40f; animation: pulseSpace 1s infinite alternate; }

/* TUTORIAL ANIMADO */
#tutorial-container { position: fixed; inset: 0; pointer-events: none; z-index: 60; display: none; }
.tut-box { position: absolute; background: rgba(0,0,0,0.8); color: white; padding: 10px 15px; border-radius: 10px; border: 2px solid var(--neon-azul); font-size: 1rem; font-weight: bold; animation: pulseBox 1.5s infinite; }
.tut-top { top: 20%; left: 50%; transform: translateX(-50%); }
.tut-bottom { bottom: 120px; left: 50%; transform: translateX(-50%); }
@keyframes pulseBox { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.1); } }

/* ===== MELHORIAS MOBILE ===== */
html, body { height: 100%; }
#tela-contagem .wrap-contagem { text-align: center; }
#tela-contagem .titulo-contagem { font-family: 'Orbitron', sans-serif; letter-spacing: 3px; color: var(--neon-azul); opacity: 0.9; margin-bottom: 10px; font-size: 1rem; }
#contagem-numero { font-family: 'Orbitron', sans-serif; font-size: clamp(90px, 22vw, 220px); color: #fff; text-shadow: 0 0 25px var(--neon-azul); line-height: 1; }

#teclado-virtual { position: fixed; left: calc(12px + env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom)); display: none; grid-template-columns: repeat(5, 1fr); gap: 6px; z-index: 95; background: rgba(0, 20, 40, 0.55); border: 1px solid rgba(0, 210, 255, 0.35); box-shadow: 0 0 12px rgba(0, 210, 255, 0.25); border-radius: 14px; padding: 8px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); touch-action: manipulation; user-select: none; }
#teclado-virtual button { width: 34px; height: 34px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.12); color: #fff; font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 0.98rem; cursor: pointer; display: flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
#teclado-virtual button:active { transform: translateY(1px) scale(0.98); background: rgba(255,255,255,0.18); }
#teclado-virtual .tv-del { grid-column: 1 / -1; height: 30px; width: auto; font-size: 0.88rem; letter-spacing: 0.6px; background: rgba(255, 118, 117, 0.20); border-color: rgba(255, 118, 117, 0.35); }

@media (max-width: 900px), (pointer: coarse) {
    #teclado-virtual { display: grid; }
    #hud-inferior { bottom: 92px; gap: 8px; }
    .painel-lateral { min-width: 50px; padding: 5px 8px; }
    .painel-valor { font-size: 1.3rem; }
    #input-radar { padding: 8px 20px; } 
    #display-resposta { font-size: 2.4rem; }
    #vidas-display { font-size: 1.1rem; }
    .tut-bottom { bottom: 170px; }
    #aviso-bomba { top: -25px; font-size: 0.75rem; }
    /* Ajuste para mobile no cabeçalho */
    header { grid-template-columns: 1fr; gap: 10px; }
    .grupo-botoes, .status-topo { justify-self: center; text-align: center; }
}

#decor-meteoros { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.meteoro-fundo { position: absolute; top: -120px; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.30), rgba(255,255,255,0.10) 55%, rgba(0,210,255,0.08) 100%); border: 1px solid rgba(255,255,255,0.22); border-radius: 40% 60% 35% 65%; box-shadow: 0 0 16px rgba(0, 210, 255, 0.16); animation-name: fundoCair; animation-timing-function: linear; animation-iteration-count: 1; will-change: transform, opacity; transform: translate3d(0,0,0); }
@keyframes fundoCair { from { transform: translate3d(0, 0, 0) rotate(var(--rot)); opacity: 0; } 12% { opacity: 1; } to { transform: translate3d(var(--dx), var(--fall), 0) rotate(calc(var(--rot) + 130deg)); opacity: 0; } }
#espaco { position: relative; z-index: 5; }