this area, intermittently controlling it as the balance shifted. During the reign of King Emeric, the Dalmatian cities separated from Hungary by a treaty. A consistent period of Hungarian rule in Dalmatia was ended with the Mongol invasion of Hungary in 1241. The Mongols severely impaired the feudal state, so much so that that same year, King Béla IV had to take refuge in Dalmatia, as far south as the Fortress of Klis. The Mongols attacked the Dalmatian cities for the next few years but eventually withdrew without major success. At the beginning of the 14th century and until 1322, the Dalmatian cities were under the control of the Šubić noble family and held them until they were defeated at the Battle of Bliska by a coalition of nobles, Dalmatian cities and royal troops loyal to Charles I of Hungary. In the south, due to its protected location, Kotor became a major city for the salt trade. The area was prosperous during the 14th century under the rule of Emperor of the Serbs Dušan the Mighty, who encouraged law enforcement, which helped the Bay of Kotor to become a safe place for doing business. In 1389, Tvrtko I, the founder of the Kingdom of Bosnia, was able to control the Adriatic littoral between Kotor and Šibenik, and even claimed control over the northern coast up to Rijeka, and his own independent ally, Republic of Ragusa. This was only temporary, as Hungary and the Venetians continued their struggle over Dalmatia after Tvrtko's death in 1391. By this time, the whole Hungarian and Croatian Kingdom was facing increasing internal difficulties, as a 20-year civil war ensued between the Capetian House of Anjou from the Kingdom of Naples, and King Sigismund of the House of Luxembourg. During the war, the losing contender, Ladislaus of Naples, sold his "rights" on Dalmatia to the Republic of Venice for a mere 100,000 ducats. The much more centralized Republic came to control all of Dalmatia by the year 1420, it was to remain under Venetian rule for 377 years (1420–1797). Early modern period (1420–1815) From 1420 to 1797 the Republic of Venice controlled most of Dalmatia, calling it Esclavonia in the 15th century with the southern enclave, the Bay of Kotor, being called Albania Veneta. Venetian was the commercial lingua franca in the Mediterranean at that time, and it heavily influenced Dalmatian and to a lesser degree