/* ============================================
   Enhanced Modal Styles - Game Container Ready
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    perspective: 1500px;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    animation: backdropFadeIn 400ms ease-out forwards;
}

.modal.closing .modal-backdrop {
    animation: backdropFadeOut 300ms ease-in forwards;
}

.modal-content {
    position: relative;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(232, 244, 245, 0.95));
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: var(--spacing-xl);
    max-width: 600px;
    width: 100%;
    box-shadow: 0 20px 60px var(--color-shadow-deep);
    border: 2px solid rgba(77, 184, 196, 0.4);
    opacity: 0;
    will-change: transform, opacity;
    animation: modalEnvelopeOpen 700ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.modal.closing .modal-content {
    animation: modalClose 300ms cubic-bezier(0.4, 0, 1, 1) forwards;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(77, 184, 196, 0.15) 50%,
        transparent 70%
    );
    animation: shimmer 3s infinite;
    pointer-events: none;
}

.modal-close {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    background: rgba(77, 184, 196, 0.15);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-secondary);
    transition: all 200ms var(--ease-smooth);
    z-index: 10;
}

.modal-close:hover {
    background: var(--color-primary);
    color: var(--color-text-light);
    transform: rotate(90deg) scale(1.1);
}

.modal-close:active {
    transform: rotate(90deg) scale(0.95);
}

.modal-close:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ============================================
   Game Container Styles
   ============================================ */

.modal-game-container {
    opacity: 0;
    animation: contentSlideUpBlur 500ms cubic-bezier(0.4, 0, 0.2, 1) 300ms forwards;
    position: relative;
    z-index: 1;
    min-height: 200px;
}

/* Game Loading State */
.game-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    font-size: 1.5rem;
    color: var(--color-text-dark);
}

/* Game Error State */
.game-error {
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--color-text-dark);
}

.game-error p {
    font-size: 1.125rem;
    margin-bottom: var(--spacing-sm);
}

.game-error small {
    color: #E74C3C;
    display: block;
}

/* Success Message */
.game-success-message {
    text-align: center;
    padding: var(--spacing-lg);
    animation: contentScaleFade 500ms ease-out forwards;
}

.game-success-message h3 {
    font-size: 1.5rem;
    color: var(--color-secondary);
    margin-bottom: var(--spacing-md);
}

.game-success-message p {
    font-size: 1rem;
    color: var(--color-text-dark);
    line-height: 1.6;
}

/* Game Success Animation */
.game-success {
    animation: gameSuccessPulse 600ms ease-out;
}

@keyframes gameSuccessPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Confetti Styles */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: confettiFloat 3s linear forwards;
    pointer-events: none;
}

@keyframes confettiFloat {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content {
        padding: var(--spacing-md);
        border-radius: 16px;
        max-width: 90vw;
    }

    .modal-game-container {
        min-height: 150px;
    }
}
