At night we are liable to feel discomfort of one kind or another simply because we are not moving. As soon as we get up, move about, do a few stretching exercises, we feel better. I've had leg cramps as long as I can remember and discovered that making sure legs are warm helps to prevent the cramps. Throw an extra blanket around them.
Staying well hydrated is, as you say, so important. Even at night. Always have water nearby. Wishing you all the best.