/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Content */
.modal-content {
    background: rgba(20, 20, 35, 0.85);
    backdrop-filter: blur(15px);
    border: 1px solid var(--card-border);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    /* Keep as is */
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 2rem;
    /* Reduced from 2.5rem */
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* Modal Header */
.modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
    /* Reduced from 2rem */
}

.modal-icon {
    font-size: 3rem;
    /* Reduced from 4rem */
    margin-bottom: 0.5rem;
    /* Reduced from 1rem */
    display: block;
}

.modal-title {
    font-size: 1.8rem;
    /* Reduced from 2rem */
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #b4b4b4);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}


.modal-tag {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-color);
    /* Cyan text */
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(125, 95, 255, 0.3);
    box-shadow: 0 0 15px rgba(125, 95, 255, 0.15);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

/* Modal Body */
.modal-body {
    margin-bottom: 1.5rem;
    /* Reduced from 2rem */
}

.section-title {
    font-size: 1rem;
    /* Reduced from 1.1rem */
    color: var(--accent-color);
    margin-bottom: 0.8rem;
    /* Reduced from 1rem */
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.rule-list {
    list-style: none;
    color: #e0e0e0;
}

.rule-list li {
    margin-bottom: 0.8rem;
    /* Reduced from 0.8rem */
    padding-left: 1.5rem;
    position: relative;
    font-size: 1.1rem;
    /* Increased for readability */
    /* Slightly smaller text */
    line-height: 1.6;
}

/* ... list item before ... */

.tips-box {
    background: rgba(255, 215, 0, 0.1);
    border-left: 3px solid #ffd700;
    padding: 0.8rem;
    /* Reduced from 1rem */
    margin-top: 1rem;
    /* Reduced from 1.5rem */
    border-radius: 0 8px 8px 0;
    color: #fff;
    font-size: 0.9rem;
    /* Reduced from 0.95rem */
}

/* Close Button */
.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Scrollbar for modal */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        padding: 1.2rem 1rem;
        /* More compact padding */
        max-height: 90vh;
        /* Allow it to be taller */
        border-radius: 20px;
        display: flex;
        flex-direction: column;
    }

    .modal-header {
        margin-bottom: 1rem;
        flex-shrink: 0;
    }

    .modal-body {
        margin-bottom: 1rem;
        overflow-y: auto;
        /* Internal scroll only if absolutely needed */
        flex-grow: 1;
    }

    .modal-title {
        font-size: 1.8rem;
        /* Increased from 1.4rem */
    }

    .modal-icon {
        font-size: 2.5rem;
        /* Smaller icon */
        margin-bottom: 0.2rem;
    }

    .rule-list li {
        font-size: 1.15rem;
        padding-left: 0;
        /* Removing extra padding-left */
        margin-left: 1.2rem;
        /* Using margin for bullet spacing instead */
        line-height: 1.6;
        margin-bottom: 0.8rem;
    }

    .section-title {
        font-size: 1.1rem;
        margin-bottom: 0.8rem;
    }

    .tips-box {
        font-size: 0.95rem;
        /* Slightly smaller for 'hint' feel */
        padding: 0.8rem;
        /* Compact padding */
        margin-top: 1rem;
    }

    .modal-footer {
        margin-top: 1rem;
        padding-top: 1rem;
        flex-shrink: 0;
        width: 100%;
        /* Full width container */
    }

    .btn-reroll {
        width: 100%;
        /* Full width button */
        justify-content: center;
        padding: 1rem;
        /* Larger touch target */
        font-size: 1.1rem;
    }
}

/* Game List Grid Styles */
.list-modal-content {
    max-width: 800px;
    padding: 2.5rem;
}

.game-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1.5rem;
    padding: 0.5rem;
}

.game-list-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1.2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.game-list-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.list-icon {
    font-size: 2.5rem;
    transition: transform 0.3s ease;
}

.game-list-item:hover .list-icon {
    transform: scale(1.1);
}

.list-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.list-close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.list-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

@media (max-width: 480px) {
    .game-list-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .game-list-item {
        padding: 1rem;
    }

    .list-icon {
        font-size: 2rem;
    }

    .list-title {
        font-size: 0.9rem;
    }
}