History of Portugal (1640–1777) put to the test in 1762 when Spain invaded aided by France, during the Seven Years' War. Britain invoked its alliance with Portugal and sent troops. Several months later, the conflict was settled with comparatively little fighting. In 1777, Spain and Portugal signed the Treaty of San Ildefonso, which mainly resolved a number of border disputes between their South American colonies. During the Age of Enlightenment, Portugal was considered one of Europe's unenlightened backwaters; it was a country of three million with 200,000 people in 538 monasteries in 1750. Melo seems to have been deeply embarrassed by Portugal's much lamented
Castles in Portugal towers. By 1249 the Moors had been expelled from southern Portugal and the nation became the first in Europe to take on its modern borders. The focus of Portuguese castles during this period shifted from lines along east to west flowing rivers, to the towns along the long Portuguese border with rival Castile. The pinnacles of this period were the 13th-century castles built under King Denis, who rebuilt almost every major castle in the land. Until Denis, Portugal’s castles were usually just a three-story keep with one or two rings of walls. New tower keeps were built like the one