Here in Valencia, supermarkets, such as OpenCor are open til about 1am, but you can´t buy alcohol from 10pm, and is open on Sundays. Other places are Sprinter, which I think is open until 3am. Other than that, I´m sure there will be petrol stations open which sell food, if you are really desperate....
Hope this helps