A castle is defined as a private fortified residence built primarily during the Middle Ages (roughly 5th to 15th centuries) for the nobility and royalty. Unlike a "fort," which is a purely military structure, or a "palace," which is a grand unfortified residence, a castle combines defense and domesticity. Historically, castles served three main functions: a military stronghold to control territory, an administrative center for local government, and a home for a lord or knight. Their architectural hallmarks include stone curtain walls, defensive towers, battlements (crenellations), and the "keep" (or donjon), which was the most heavily fortified part of the building. The word itself comes from the Latin castellum, meaning "fortified place." By the late Middle Ages, as gunpowder and cannons made stone walls vulnerable, castles transitioned into "stately homes" where aesthetics and comfort took precedence over defense. Today, they are prized as historical monuments that reflect the social and political power of the feudal era.