You will have noted there is also a sea in between and alas, in these 3 baltic states INTernational trains are very, very sparse or non-existent.
IF you really do not want to fly, then its MUCH better to use a direct BUS from Tallinn-in fact most of these buses run onward to Poland and via Riga-Kaunas. Pre-covid pandemic there wer several different ferry links and also at least 3 different BUScompanies doing these trips-use google to find out current situation.
To go by train will take at least 1,5 full day longer, 3 or 4 changes and cannot be done every day. Also in some places a HTL will be needed en-route.
You will hence also understand that any rail pass is simply a waste of time and money for this