* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    background: #040406; 
    color: #fff; 
    font-family: 'Segoe UI', Roboto, sans-serif; 
    
    /* Cambiamos a flex vertical para ordenar juego y footer */
    display: flex; 
    flex-direction: column;
    min-height: 100vh; /* Alto mínimo adaptable */
    height: 100vh; /* Mantiene la ventana fija si no hay scroll */
    
    overflow: hidden;
    position: relative;
}

#starfield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.game-container { 
    background: rgba(18, 18, 24, 0.85); 
    backdrop-filter: blur(12px);
    padding: 35px 30px; 
    border-radius: 24px; 
    box-shadow: 0 25px 60px rgba(0,0,0,0.8); 
    text-align: center; 
    width: 380px; 
    border: 1px solid #2d2d3d; 
    z-index: 10;
}

.bote-box { font-size: 2.5rem; font-weight: 800; color: #ffcc00; text-shadow: 0 0 20px rgba(255,204,0,0.4); }
.bote-label { font-size: 0.75rem; color: #888; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 20px; }
.target-box { background: #1a1a24; padding: 8px 16px; border-radius: 20px; display: inline-block; font-size: 0.95rem; color: #00e5ff; font-weight: bold; margin-bottom: 15px; border: 1px solid rgba(0,229,255,0.3); }
.display-counter { font-size: 4.8rem; font-weight: 900; color: #fff; margin: 20px 0; font-family: 'Courier New', monospace; }
.balance-box { font-size: 1.1rem; color: #a2a2b0; margin-bottom: 20px; }
.balance-box span { color: #00ff88; font-weight: 700; }

.bet-section { margin-bottom: 20px; display: flex; justify-content: center; align-items: center; gap: 10px; }
.bet-section label { color: #888; font-size: 0.95rem; }
input[type="number"] { background: #1a1a24; border: 1px solid #3a3a4c; color: #fff; padding: 10px; border-radius: 8px; width: 90px; font-size: 1.1rem; text-align: center; outline: none; }

#action-btn { background: #ff0055; border: none; color: white; padding: 18px; font-size: 1.3rem; font-weight: bold; border-radius: 12px; cursor: pointer; width: 100%; box-shadow: 0 6px 20px rgba(255,0,85,0.3); transition: all 0.2s; }
#action-btn.stop-btn { background: #00ff88; color: #000; box-shadow: 0 6px 20px rgba(0,255,136,0.4); }

.monetization-links { display: flex; gap: 10px; justify-content: space-between; }
.btn-stripe { border: none; font-size: 0.85rem; padding: 12px; border-radius: 8px; font-weight: 600; width: 48%; transition: background 0.2s; cursor: pointer; }
.btn-buy { background: #635bff; color: white; }
.btn-cash { background: #2a2a36; color: #bbb; border: 1px solid #3e3e52; }
.btn-buy:hover { background: #7a73ff; }
.btn-cash:hover { background: #38384a; color: #fff; }

/* --- NUEVA PISTA HORIZONTAL DEL COHETE --- */
.space-runway-container {
    position: relative;
    background: rgba(10, 10, 15, 0.6);
    border: 1px dashed #3a3a52;
    height: 80px;
    border-radius: 12px;
    margin: 25px 0;
    padding: 10px;
    display: flex;
    align-items: center;
}

.rocket-sprite {
    position: absolute;
    left: 0%;
    font-size: 2.2rem;
    transition: left 0.05s linear, transform 0.1s ease;
    z-index: 5;
    will-change: left;
}

/* Efecto de vibración cuando los motores están encendidos */
.thrusters-on {
    animation: shakeRocket 0.08s infinite alternate;
    text-shadow: -10px 0px 12px #ff5500, -20px 0px 4px #ffcc00;
}

@keyframes shakeRocket {
    from { transform: translateY(-1px) scale(1.1); }
    to { transform: translateY(2px) scale(1.1); }
}

/* Efecto visual si se estrella o pasa */
.exploded-rocket {
    animation: explodeEffect 0.5s forwards;
}

@keyframes explodeEffect {
    0% { transform: scale(1.5); filter: hue-rotate(90deg) brightness(2); }
    100% { transform: scale(0); opacity: 0; }
}

/* Línea de radar guía inferior */
.radar-line {
    position: absolute;
    bottom: 12px;
    left: 4%;
    width: 92%;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.radar-marker {
    position: absolute;
    top: -5px;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 3px;
    transform: translateX(-50%);
}

.start-point { left: 0%; color: #666; }

/* La bandera de meta brillante */
.target-point {
    background: #00e5ff;
    color: #000;
    box-shadow: 0 0 10px #00e5ff;
    border-radius: 4px;
    top: -18px;
    transition: left 0.3s ease;
}

/* Telemetría digital superior */
.digital-telemetry {
    font-size: 1.4rem;
    color: #a2a2b0;
    font-weight: 500;
}
.digital-telemetry span {
    color: #00ff88;
    font-weight: bold;
    background: rgba(0,0,0,0.4);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid rgba(0,255,136,0.2);
}

/* --- NUEVA ENVOLTURA PARA EL CENTRADO DEL JUEGO --- */
.game-wrapper {
    flex: 1 0 auto; /* Empuja de forma elástica al footer hacia abajo */
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    z-index: 10; /* Por encima del canvas */
}

/* (Tu .game-container se queda igual, pero le quitamos el z-index ya que lo hereda del wrapper) */
.game-container { 
    background: rgba(18, 18, 24, 0.85); 
    backdrop-filter: blur(12px);
    padding: 35px 30px; 
    border-radius: 24px; 
    box-shadow: 0 25px 60px rgba(0,0,0,0.8); 
    text-align: center; 
    width: 380px; 
    border: 1px solid #2d2d3d; 
}

/* --- NUEVO FOOTER INTEGRADO INTERSTELAR --- */
.hud-footer {
    flex-shrink: 0; /* Evita que el footer se achique o aplaste */
    width: 100%;
    text-align: center;
    padding: 15px 10px;
    background: linear-gradient(to top, rgba(4, 4, 6, 0.95), rgba(4, 4, 6, 0.6));
    border-top: 1px dashed rgba(0, 229, 255, 0.15);
    backdrop-filter: blur(4px);
    z-index: 10;
}

.hud-footer span {
    color: #6c757d; 
    font-size: 0.8rem; 
    letter-spacing: 0.5px;
}

.hud-footer a {
    color: #ffd700; 
    text-decoration: none; 
    margin-left: 15px; 
    font-size: 0.8rem; 
    font-weight: 600; 
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.2); 
    transition: all 0.2s ease;
}

.hud-footer a:hover {
    color: #00e5ff;
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

/* --- OPTIMIZACIÓN RESPONSIVE PARA DISPOSITIVOS MÓVILES --- */
@media (max-width: 480px) {
    body {
        overflow-y: auto; /* Permite scroll en pantallas muy pequeñas para que nada quede oculto */
        height: auto;
    }
    .game-wrapper {
        padding: 20px 0; /* Espaciado de cortesía arriba y abajo en móviles */
    }
    .hud-footer {
        background: #040406; /* Fondo sólido en móvil para no interferir con la lectura */
        padding: 12px;
    }
    .hud-footer span, .hud-footer a {
        display: block; /* En móviles pequeños, apila el texto y el enlace */
        margin: 4px 0;
    }
    .hud-footer a {
        margin-left: 0;
    }
}

/* --- MODO CABINA LIMPIA TOTAL --- */
/* --- NUEVA ESTRUCTURA DE CABINA FLOTANTE --- */

/* Animación de desvanecimiento para el bloque viejo */
.game-container {
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.game-container.hidden-game {
    opacity: 0 !important;
    transform: scale(0.95);
    pointer-events: none;
}

/* Contenedor del HUD de vuelo */
#flight-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 30px 20px;
    box-sizing: border-box;
    z-index: 999;
    pointer-events: none; /* Deja pasar los clics al canvas de fondo */
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* Clase activa para mostrar el HUD con animación suave */
#flight-hud.hud-active {
    opacity: 1;
}

/* Zona Superior: Objetivo y Velocidad juntos */
#flight-hud .hud-top {
    text-align: center;
    margin-top: 10px;
}

#flight-hud .hud-target {
    display: inline-block;
    background: rgba(0, 229, 255, 0.15);
    color: #00e5ff;
    border: 1px solid #00e5ff;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    letter-spacing: 1px;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
    margin-bottom: 8px;
}

#flight-hud .hud-speed {
    font-size: 3.8rem;
    font-weight: 900;
    color: #ffffff;
    line-height: 1;
    text-shadow: 0 0 25px rgba(255, 255, 255, 0.6);
}

/* Zona Inferior: Botón de frenado abajo del todo */
#flight-hud .hud-bottom {
    width: 100%;
    max-width: 400px;
    margin: 0 auto 20px auto;
}

#flight-hud .btn-frenar-hud {
    pointer-events: auto; /* Permite hacer clic en el botón */
    width: 100%;
    background: #2ecc71;
    color: #000000;
    border: none;
    padding: 18px;
    font-size: 1.3rem;
    font-weight: bold;
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(46, 204, 113, 0.6);
    cursor: pointer;
    transition: transform 0.1s ease, background 0.2s ease;
}

#flight-hud .btn-frenar-hud:active {
    transform: scale(0.98);
    background: #27ae60;
}

/* Asegura que el HUD flotante flote por encima de cualquier elemento fijo o footer */
#flight-hud {
    position: fixed; /* Cambia a fixed para que flote sobre la pantalla y ignore el flujo normal */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999; /* Z-index altísimo para ganar siempre al footer */
    width: 90%;
    max-width: 420px;
}

/* Si tu footer tiene position fixed o absolute, asegúrate de que su z-index sea menor */
footer {
    z-index: 10;
}

.btn-back-floating {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 9999;
    background: #12141c;
    color: #00e5ff;
    border: 1px solid #00e5ff;
    border-left: none;
    padding: 10px 14px;
    border-radius: 0 8px 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-weight: bold;
    font-family: sans-serif;
    font-size: 0.9rem;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.3);
    transition: all 0.3s ease;
}

.btn-back-floating:hover {
    background: #00e5ff;
    color: #12141c;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.7);
    padding-left: 18px; /* Efecto de despliegue al pasar el cursor */
}

/* En pantallas pequeñas solo muestra el icono para no entorpecer el juego */
@media (max-width: 576px) {
    .btn-back-floating span {
        display: none;
    }
    .btn-back-floating {
        padding: 10px;
    }
}
