/* Games list modal and the custom alert/confirm dialog it uses.
   Split out of quiz.css so the landing page can show the same modal without
   pulling in the whole quiz stylesheet, whose `*` and `body` rules would
   restyle the page underneath it. */

/* Mirrors the token block in quiz.css so this file stands alone on the landing
   page, which does not load quiz.css. Same values - keep them in step. */
:root {
    --gradient-main: linear-gradient(135deg, #FF6B35 0%, #F7931E 50%, #FDC500 100%);
    --gradient-cool: linear-gradient(135deg, #4ECDC4 0%, #5B5FFF 100%);
    --gradient-warm: linear-gradient(135deg, #FF5E78 0%, #9D4EDD 100%);

    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.2);

    --glow-orange: 0 0 30px rgba(255, 107, 53, 0.4);
    --glow-blue: 0 0 30px rgba(91, 95, 255, 0.4);
    --glow-purple: 0 0 30px rgba(157, 78, 221, 0.4);
    --glow-success: 0 0 30px rgba(78, 205, 196, 0.4);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes iconBounce {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    60% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* ========================================
   CUSTOM ALERT/CONFIRM DIALOG
   ======================================== */

.custom-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: modalFadeIn 0.3s ease-out;
}

.custom-dialog-overlay.active {
    display: flex;
}

.custom-dialog {
    background: white;
    padding: 40px;
    border-radius: 25px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: modalSlideUp 0.4s ease-out;
    border: 5px solid transparent;
    background-clip: padding-box;
    position: relative;
}

.custom-dialog::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: var(--gradient-main);
    border-radius: 25px;
    z-index: -1;
    opacity: 0.5;
}

.custom-dialog-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    animation: iconBounce 0.6s ease-out;
}

.custom-dialog-icon.alert {
    background: linear-gradient(135deg, #FDC500, #F7931E);
    color: white;
    box-shadow: var(--shadow-lg), 0 0 30px rgba(253, 197, 0, 0.5);
}

.custom-dialog-icon.confirm {
    background: var(--gradient-cool);
    color: white;
    box-shadow: var(--shadow-lg), var(--glow-blue);
}

.custom-dialog-icon.success {
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    color: white;
    box-shadow: var(--shadow-lg), var(--glow-success);
}

.custom-dialog-icon.error {
    background: var(--gradient-warm);
    color: white;
    box-shadow: var(--shadow-lg), var(--glow-purple);
}

.custom-dialog-title {
    font-family: 'Fredoka', sans-serif;
    color: transparent;
    background: var(--gradient-main);
    background-clip: text;
    -webkit-background-clip: text;
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 15px;
    text-align: center;
}

.custom-dialog-message {
    font-size: 1.1em;
    color: #555;
    text-align: center;
    margin-bottom: 30px;
    line-height: 1.6;
}

.custom-dialog-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.custom-dialog-btn {
    padding: 14px 32px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1em;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: var(--shadow-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 120px;
}

.custom-dialog-btn-primary {
    background: var(--gradient-main);
    color: white;
}

.custom-dialog-btn-primary:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-lg), var(--glow-orange);
}

.custom-dialog-btn-secondary {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
}

.custom-dialog-btn-secondary:hover {
    background: linear-gradient(135deg, #7f8c8d, #6c7a7b);
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-lg);
}

.custom-dialog-btn-success {
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    color: white;
}

.custom-dialog-btn-success:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-lg), var(--glow-success);
}

.custom-dialog-btn-danger {
    background: var(--gradient-warm);
    color: white;
}

.custom-dialog-btn-danger:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-lg), var(--glow-purple);
}

/* ========================================
   GAMES LIST MODAL
   ======================================== */

.games-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    padding: 20px;
}

.games-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.games-modal {
    background: linear-gradient(145deg, #ffffff 0%, #fef3e7 100%);
    border-radius: 32px;
    max-width: 900px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 24px 100px rgba(255, 107, 53, 0.35),
        0 12px 50px rgba(0, 0, 0, 0.25),
        inset 0 2px 0 rgba(255, 255, 255, 0.9);
    border: 4px solid transparent;
    background-image:
        linear-gradient(145deg, #ffffff, #fef3e7),
        linear-gradient(135deg, #FF6B35, #F7931E, #FDC500, #4ECDC4);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    transform: scale(0.85) translateY(-60px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.games-modal-overlay.active .games-modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.games-modal-header {
    padding: 4px 40px;
    border-bottom: 3px solid rgba(255, 107, 53, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.1), rgba(247, 147, 30, 0.1));
    border-radius: 28px 28px 0 0;
}

.games-modal-header h2 {
    font-family: 'Fredoka', sans-serif;
    font-size: 2em;
    font-weight: 700;
    background: linear-gradient(135deg, #FF6B35, #F7931E);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.games-modal-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ff5e78, #dc2626);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.games-modal-close svg {
    width: 24px;
    height: 24px;
}

.games-modal-close:hover {
    transform: rotate(90deg) scale(1.1);
    box-shadow:
        0 6px 20px rgba(220, 38, 38, 0.5),
        0 0 32px rgba(220, 38, 38, 0.3);
}

.games-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 40px;
}

.games-modal-content::-webkit-scrollbar {
    width: 10px;
}

.games-modal-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    margin: 10px 0;
}

.games-modal-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #FF6B35, #F7931E);
    border-radius: 10px;
}

.games-modal-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #F7931E, #FDC500);
}

/* Stagger animation for game list items */
.games-modal-content > div > div {
    animation: fadeInUp 0.5s ease backwards;
}

.games-modal-content > div > div:nth-child(1) { animation-delay: 0.05s; }
.games-modal-content > div > div:nth-child(2) { animation-delay: 0.1s; }
.games-modal-content > div > div:nth-child(3) { animation-delay: 0.15s; }
.games-modal-content > div > div:nth-child(4) { animation-delay: 0.2s; }
.games-modal-content > div > div:nth-child(5) { animation-delay: 0.25s; }
.games-modal-content > div > div:nth-child(6) { animation-delay: 0.3s; }

@media (max-width: 768px) {
    .games-modal {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 24px;
    }

    .games-modal-header {
        padding: 24px 20px;
    }

    .games-modal-header h2 {
        font-size: 1.5em;
    }

    .games-modal-content {
        padding: 20px;
    }
}
