On the shore north of the cathedral stands ruined St. Andrews Castle, begun at the end of the 13th century. The remains include a rare example of a cold and gruesome bottle-shape dungeon, in which many prisoners spent their last hours. Even more atmospheric is the castle's mine and countermine. The former was a tunnel dug by besieging forces in the 16th century; the latter, a tunnel dug by castle defenders in order to meet and wage battle below ground. You can stoop and crawl into this narrow passageway—an eerie experience, despite the addition of electric light. The visitor center has a good audiovisual presentation on the castle's history. In the summer, the beach below is popular with sun bathers and rockpool investigators, weather permitting.