/**
 * Overlay загрузки - блокирует игру до завершения авторизации
 * Критическая защита от потери прогресса!
 */

#game-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(51, 144, 236, 0.15), rgba(96, 165, 250, 0.15));
    backdrop-filter: blur(20px) brightness(1.2);
    -webkit-backdrop-filter: blur(20px) brightness(1.2);
    z-index: 999999; /* Поверх ВСЕГО */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

#game-loading-overlay.loaded {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: #1a1a1a;
    max-width: 400px;
    padding: 40px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.loading-logo {
    width: 140px;
    height: 140px;
    margin: 0 auto 32px;
    display: block;
    object-fit: contain;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.loading-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 24px;
    border: 3px solid rgba(51, 144, 236, 0.2);
    border-top: 3px solid #3390ec;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #1a1a1a;
    text-shadow: 0 2px 8px rgba(255, 255, 255, 0.8);
}

.loading-subtitle {
    font-size: 16px;
    color: #3f3f46;
    margin-bottom: 8px;
}

.loading-status {
    font-size: 14px;
    color: #3390ec;
    font-weight: 600;
    margin-top: 16px;
    min-height: 20px;
    text-shadow: 0 1px 4px rgba(255, 255, 255, 0.5);
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Блокировка canvas игры */
#canvas.loading-blocked {
    pointer-events: none !important;
    filter: blur(5px);
    opacity: 0.5;
}

/* Прогресс-бар */
.loading-progress {
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin: 24px auto 0;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3390ec, #60a5fa);
    width: 0%;
    transition: width 0.3s ease;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -300px 0;
    }
    100% {
        background-position: 300px 0;
    }
}

/* Ошибка авторизации */
.loading-error {
    color: #dc2626;
    font-size: 16px;
    margin-top: 24px;
    padding: 16px;
    background: rgba(248, 113, 113, 0.15);
    border-radius: 12px;
    border: 1px solid rgba(248, 113, 113, 0.4);
}

.loading-error-title {
    font-weight: 700;
    margin-bottom: 8px;
}

.btn-retry {
    margin-top: 16px;
    padding: 12px 32px;
    background: #3390ec;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-retry:hover {
    background: #2b7fd6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(51, 144, 236, 0.4);
}

/* Адаптив */
@media (max-width: 768px) {
    .loading-logo {
        width: 80px;
        height: 80px;
    }
    
    .loading-title {
        font-size: 20px;
    }
    
    .loading-progress {
        width: 80%;
    }
}

