/* ============================================================
   COSMIC DRIFT WEB — ESTILOS E INTERFAZ RESPONSIVE (styles.css)
   Mantiene proporción 16:9 (1280 × 720 lógicos) e imagen espejo
   ============================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html,
body {
    width: 100%;
    height: 100%;
    background-color: #050508;
    color: rgb(245, 245, 255);
    font-family: "Cambria Math", "Segoe UI Symbol", "Segoe UI", sans-serif;
    overflow: hidden;
}

/* Contenedor centrado adaptable a cualquier pantalla manteniendo 16:9 */
#appWrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #110d1d 0%, #050508 100%);
    padding: 8px;
}

#gameContainer {
    position: relative;
    width: min(100%, calc((100vh - 16px) * (16 / 9)));
    aspect-ratio: 16 / 9;
    max-width: 1280px;
    max-height: 720px;
    background-color: rgb(5, 5, 8);
    border-radius: 12px;
    box-shadow:
        0 0 40px rgba(190, 160, 255, 0.18),
        0 16px 48px rgba(0, 0, 0, 0.85);
    overflow: hidden;
}

#gameContainer:fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #050508;
}

/* Canvas principal 1280 × 720 */
#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Video de cámara con efecto espejo (transform: scaleX(-1)) y Canvas de MediaPipe */
.vision-Offscreen {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    left: -9999px;
    top: -9999px;
}

#camera {
    transform: scaleX(-1);
}

/* Botón #startGame alineado con las coordenadas lógicas (x: 670, y: 430, w: 320, h: 62 sobre 1280x720) */
#startGame {
    position: absolute;
    left: calc((670 / 1280) * 100%);
    top: calc((430 / 720) * 100%);
    width: calc((320 / 1280) * 100%);
    height: calc((62 / 720) * 100%);
    opacity: 0;
    cursor: pointer;
    border: none;
    background: transparent;
    z-index: 5;
}

#startGame.hidden {
    display: none;
    pointer-events: none;
}

/* Botón de pantalla completa en la esquina superior derecha */
#fullscreenBtn {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1.5px solid rgba(190, 160, 255, 0.55);
    background: rgba(18, 18, 28, 0.72);
    color: rgb(245, 245, 255);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

#fullscreenBtn:hover {
    background: rgba(40, 28, 65, 0.92);
    border-color: rgb(245, 245, 255);
    transform: scale(1.06);
}

/* Pantalla de precarga ("Cargando Cosmic Drift...") */
#loadingOverlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #140f24 0%, #050508 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.35s ease;
}

#loadingOverlay.loaded {
    opacity: 0;
    pointer-events: none;
}

.loading-card {
    background: rgb(18, 18, 28);
    border: 2px solid rgb(190, 160, 255);
    border-radius: 24px;
    padding: 40px 56px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.75);
}

.loading-title {
    font-size: 42px;
    font-weight: normal;
    color: rgb(245, 245, 255);
    margin-bottom: 24px;
    letter-spacing: 1px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 22px;
    border: 4px solid rgba(190, 160, 255, 0.25);
    border-top-color: rgb(115, 220, 255);
    border-radius: 50%;
    animation: cosmicSpin 0.9s linear infinite;
}

.loading-text {
    font-size: 18px;
    color: rgb(220, 220, 235);
}

@keyframes cosmicSpin {
    to {
        transform: rotate(360deg);
    }
}
