I had this problem. When you say you can move it up and down do you mean the glass or the plastic trim piece that goes around it? If its the plastic trim piece then firmly push up on it in the middle of all 4 sides. One of the sides should pop into place, its almost like snapping legos together.
I have the rattle as well. Everything seems solid but if you push up around the edges you can make it stop. There is no rattle when closed. Dealership looked at it once but couldnt fix it. I've had it in several times for other issues and just haven't got around to the sunroof issue again.