I haven't added the days up (I speak three languages, didn't get the math gene!) but see if this works:
Munich - 3 full days (time for a day trip to castles, plus half day to Dachau and city sightseeing)
Train to Innsbruck (good scenery, only 2 and a bit hour journey if you take the scenic route, 1hr30 if you take the fast train)
Innsbruck - depending on what you plan to do here, you could spend anywhere from 1 to 3 full days. If you only want to see Innsbruck, then one full day is fine, but if you intend to go hiking, biking, etc then make it 2-3 full days.
Train to Vienna - takes around 4.5hrs
Vienna/Bratislava - 2-3 full days in Vienna, with perhaps a half day trip to Bratislava on the hovercraft down the Danube.
Train to Budapest - takes just under 3hrs direct.
Budapest - 2-3 days
Train to Sarajevo - it's a long trip, around 12 hours, and I belive there is only one train during the day, but no night train.
Sarajevo - 2-3 full days
Train or bus depending on where you decide to visit
Croatian Coast??? (Dubrovnik/Split/Hvar) - If you're travelling from Sarajevo, then travel to Dubrovnik is by bus as the closest train station is Ploce, I belive. (bus journey 5hrs, several busses daily so book departure day/time at station when you first arrive in Sarajevo). Sarajevo to Split can be by bus (under 6hrs) or train (Sarajevo to Ploce or Mostar then bus on to Split). You'll need to work out travel times between each place and see what suits your timetable, then you can choose places to visit. Dubrovnik to Split is around 4hours by bus.
Dubrovnik and Zadar are good, Zadar for a day between Split and Slovenia (I know you haven't included it, but through you might be interested) and Dubrovnik for 2-3 full days. Split for 1 full day seems to be the best as it's interesting if you're into Roman ruins, but if not then 1 night will be fine before or after you go to Hvar, depending on ferry schedules. Hvar for 2 full days minimum will allow for relaxing and a little sightseeing, but obviously spend longer if you can and if you need to chill.
To Slovenia - the method and journey time will depend on your itinerary, however iif travelling from Split, or even Zadar, you'll likely have to go through Zagreb for a train (around 8hrs, 5-ish hrs Split-Zagreb then around 2 to Ljubljana) and over 10 hours for a bus.
Ljubljana/Bled - definitely worth the trip, even for just one full day.
Bus to Trieste - a bus leaves twice a day I believe and takes 2hrs (website:
www.ap-ljubljana.si/eng ) and trains leave a few times a day and take just over 3hrs.
Trieste - pretty town 1-2 full days will allow for exploring
Train to Venice - takes 2hrs (going to Venezia Santa Lucia. Mestre station is on the mainland).
Venice - 2 full days in the city will allow time to wander, explore and enjoy the city in the evening.
Train to Rome - the Eurostar (Italia) takes around 3hrs45mins.
Rome - 4 full days will allow proper sightseeing, allow 5 days if you plan a day trip to Pompei.
Remember to carry your passport (securely) with you on all train journeys, especially when you are crossing borders as you'll be asked for your passport often, sometimes more than once on the same journey. You'll also need to look at booking ahead for some trains to ensure you get a seat, especially the sector from the beginning of your trip to at least Sarajevo. You can do this when you first arrive in Munich, at the international desk. The costs will vary for each leg with a reserved seat, but it beats sitting on your bag in the corridor of a train for 12 hours.
Also, for the long journeys, take snacks/water with you as you won't always be able to easily get food on some sectors, specifically the Hungary to Croatia part. You won't starve, but being organised will mean that you're not at the mercy of on-board food and train station or roadside prices. Oh, and in Serbia, you'll encounter the Cyrillic alphabet, so unless you know it, best to check the spelling of your destinations and key words so you can match them to signs and know what you're doing, where you're going and what you're eating!