Get a cloth or some kitchen roll, open the sunroof fully and thoroughly clean both the rubber seal and the underside of the glass. If it's not been used in a while, you can get moss growing around the edge of the sunroof. When you open it, this gets dislodged and then trapped between glass and seal when you close it again, preventing a full seal.