(function() {
    // Watch for the listings container
    const container = document.querySelector(".ygl_listings_container");
    if (!container) return;

    const observer = new MutationObserver(() => {
        const items = container.querySelectorAll(".ygl_listing_item");
        if (!items.length) return;

        // Apply grid styles
        items.forEach(item => {
            item.style.flex = "0 0 25%";
            item.style.maxWidth = "25%";
            item.style.boxSizing = "border-box";
            item.style.marginBottom = "20px";
        });

        // Responsive adjustments
        function adjustGrid() {
            const width = window.innerWidth;
            items.forEach(item => {
                if (width &lt;= 768) {
                    item.style.flex = &quot;0 0 50%&quot;;
                    item.style.maxWidth = &quot;50%&quot;;
                } else if (width &lt;= 1024) {
                    item.style.flex = &quot;0 0 33.33%&quot;;
                    item.style.maxWidth = &quot;33.33%&quot;;
                } else {
                    item.style.flex = &quot;0 0 25%&quot;;
                    item.style.maxWidth = &quot;25%&quot;;
                }
            });
        }

        window.addEventListener(&quot;resize&quot;, adjustGrid);
        adjustGrid();

        // Stop observing once applied
        observer.disconnect();
    });

    observer.observe(container, { childList: true, subtree: true });
})();

