Queen Maria Theresa, after long insistence from the Croatian Diet, restored the towns of Karlovac and Rijeka (Fiume) to the Croatian crownland on August 9, 1776. Maria Theresa was also responsible for the founding of Gymnasium Karlovac, and later King Joseph II reaffirmed it as a free town with an official charter in 1781. This allowed the citizens to expand the city and exploit the potential of being at the crossroads of paths from the Pannonian plains to the Adriatic coast. The town blossomed in the 18th and 19th centuries with the development of roads to the seaside and waterways along the Kupa River. The construction of the Zidani Most-Zagreb-Sisak railway line in 1861, however, marked the end of the era of Karlovac as a major trade and transport center.