/* --- AD GRID INTEGRATION FIX --- */
.ad-tile-wrapper {
    grid-column: span 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white; 
    padding: 25px; 
    border-radius: 16px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    min-height: 450px;
    
    /* CRITICAL FIXES FOR OVERFLOW */
    width: 100%;
    min-width: 0;           /* Prevents ad content from pushing width out */
    overflow: hidden;        /* Clips any accidental ad bleed */
    box-sizing: border-box;  /* Ensures padding is included in width calculation */
}

/* Force AdSense to stay inside the container boundaries */
.ad-tile-wrapper ins.adsbygoogle {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important; /* Strictly limits ad to wrapper width */
    margin: 0 auto;
}

/* --- GRID BLOWOUT PREVENTION --- */
/* Add this to your MAIN CSS if the ads still push the grid out */
#main-editor-container {
    /* Changes 1fr to minmax(0, 1fr) to allow shrinking */
    grid-template-columns: repeat(2, minmax(0, 1fr)); 
}

@media (max-width: 900px) {
    #main-editor-container { grid-template-columns: minmax(0, 1fr); }
    .ad-tile-wrapper { min-height: 400px; padding: 15px; }
}
