We bought our tickets 2-3 days before the trip at the train station itself. They were sleeper berths, 6 to a compartment, there were 4 of us and they blocked the other two for us, making it private. It was reasonable, unforyunately, I don't remember the cost.
When we arrived at Venice, before leaving the station, we bought ticktes to Rome, for a couple of days later.