/* GameContainer - Estilos comunes para todos los juegos */

.game-container-custom {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.game-container-custom.visible {
    opacity: 1;
    transform: scale(1);
}

/* Desktop - contenedor centrado con tamaño fijo y bordes rectos */
@media (min-width: 768px) {
    .game-container-custom {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.95);
        width: 432px !important;
        height: 488px !important; /* 432px área de juego + 56px navbar */
        border-radius: 0; /* Bordes rectos */
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-sizing: border-box;
        background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%);
    }

    .game-container-custom.visible {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Móvil - centrar en la zona de apps (excluyendo el dock) */
@media (max-width: 767px) {
    .game-container-custom {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        flex-direction: column;
        background: transparent;
        pointer-events: none; /* Permitir que los clicks pasen a través del fondo transparente */
        /* Centrar en la zona de apps: desde 40px hasta (100vh - 120px) */
        /* Centro = 40px + (100vh - 40px - 120px) / 2 = 40px + (100vh - 160px) / 2 */
        padding-top: calc(40px + (100vh - 160px - 100vw) / 2);
    }

    /* Pero permitir clicks en el contenido del juego */
    .game-container-custom .game-inner-wrapper {
        pointer-events: auto;
    }
}

/* Navbar superior con fondo transparente del 70% */
.game-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 432px;
    margin: 0 auto;
    height: 56px;
    padding: 0 16px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 10;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .game-navbar {
        border-radius: 0; /* Bordes rectos */
    }
}

@media (max-width: 767px) {
    .game-navbar {
        width: 100%;
    }
}

.game-navbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-emoji {
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.game-name {
    color: white;
    font-size: 18px;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.game-scores {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

.score-label {
    font-weight: 500;
}

#current-score,
#best-score {
    font-weight: 700;
    color: #4CAF50;
}

.score-divider {
    color: rgba(255, 255, 255, 0.3);
}

.game-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.game-close-btn:hover {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.game-close-btn:active {
    transform: scale(0.95);
}

/* Área de juego - cuadrada que ocupa TODO el espacio disponible en el contenedor */
.game-area {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
}

/* Desktop - área de juego cuadrada que ocupa el espacio bajo la navbar */
@media (min-width: 768px) {
    .game-area {
        width: 432px;
        height: 432px;
        aspect-ratio: auto;
        border-radius: 0; /* Bordes rectos */
    }
}

/* Móvil - área de juego es cuadrada basada en el ancho de la pantalla */
@media (max-width: 768px) {
    .game-area {
        width: 100vw;
        height: 100vw;
        flex-shrink: 0;
    }
}

/* Contenedor interno para agrupar navbar + game-area en móvil */
.game-inner-wrapper {
    display: flex;
    flex-direction: column;
    width: 100vw;
    background: transparent;
}

@media (min-width: 768px) {
    .game-inner-wrapper {
        width: 432px;
        background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%);
    }
}

/* Animación de loading */
.game-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    z-index: 100;
}

.cart-animation {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: fadeIn 0.5s ease;
}

.cart-emoji {
    font-size: 80px;
    animation: cartBounce 1s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.loading-bar {
    width: 200px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 3px;
    width: 0%;
    transition: width 0.2s ease;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.loading-text {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes cartBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

/* Textos blancos y bordes blancos sutiles */
.game-container-custom,
.game-container-custom * {
    color: white !important;
}

.game-container-custom canvas {
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05) !important;
}

.game-container-custom button {
    color: white !important;
}

.game-container-custom .game-navbar {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Asegurar que todos los elementos dentro del juego sean blancos */
.game-area * {
    color: white !important;
}

.game-area canvas,
.game-area div,
.game-area span,
.game-area p,
.game-area h2,
.game-area h3 {
    border-color: rgba(255, 255, 255, 0.15) !important;
}

/* Responsive - ajustes para móvil */
@media (max-width: 768px) {
    .game-emoji {
        font-size: 20px;
    }

    .game-name {
        font-size: 16px;
    }

    .game-scores {
        font-size: 12px;
        gap: 8px;
    }

    .game-close-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .cart-emoji {
        font-size: 60px;
    }

    .loading-bar {
        width: 150px;
    }
}
