There are almost no trains in the Balkans. You'll have to rely on buses (not included but cheap) from Split to Sofia.
One route with more trains would be Zagreb - Split - ferry to Italy - train down the Adriatic Coast - ferry to Albania or Greece - buses to Sofia - Sofia - Budapest - Bratislava/Vienna.
There are multiple night trains from Bucharest to Budapest.
Two options for adventure, but also lots of pleasure before that to figure out what the exact connections are:
Option 1:
Zagreb - Split
bus Split to Ploce
Ploce - Sarajevo - Tuzla
bus Tuzla to Brcko, then walk to Gunja in Croatia
Gunja to Tovarnik, see:
Sid - Beograd - Nis-Sofia see here: https://www.seat61.com/trains-and-routes/belgrade-to-sofia-by-train.htm
Sofia - Budapest - Bratislava - Vienna
Option 2 (without Bosnia):
Zagreb - Split
ferry to Ancona (Italy) and continue overland to Bari
In Bari, ferry to Bar (Montenegro)
Bar to Beograd via the famous route!
Beograd - Nis
bus Nis-Sofia see here: https://www.seat61.com/trains-and-routes/belgrade-to-sofia-by-train.htm
Sofia - Budapest - Bratislava - Vienna
(this option contours Bosnia so you will need to squeeze that in somehow, which is another challenge)
Wow I am jealous!