The Holy Roman Empire was technically an elective monarchy. A group of powerful feudal lords, known as electors - of which those of Brandenburg (Prussia) Bavaria and Saxony are likely the best known - would vote on the next Emperor during the reign of the current Emperor. The man who was elected would then become King of the Romans, which made him the heir apparent to the imperial throne in the same way that the Prince of Wales is the heir apparent to the British crown. In practice, however, the monarchy tended to become hereditary, even before the Hapsburgs seized permanent control of the throne.
The Holy Roman Emperor also technically possessed the right to deprive and grant feudal fiefs at will, a power that was exercised quite a bit in the early days of the Empire, with the emperors depriving too-powerful nobles - such as Albert "the Bear" of Saxony and Henry "the Lion" of Brandenburg - of their duchies and giving them to their allies, as well as the policy of some emperors of giving their own families fiefdoms, the idea being that they would retain those territories even if their family lost the next imperial election. Eventually, however, the fiefdoms, like the imperial crown, became hereditary. It was, in fact, repeatedly suggested that this hereditary succession be codified, but for some reason it was always defeated when it came to a vote.
There were also anomalies such as disputed elections, resulting in different factions supporting different "Kings of the Romans," papal interference in imperial elections - and vice-versa - which often resulted in more than one 'official' pope, Holy Roman Electors (and Emperors) who controlled more territory outside of the Empire's borders than within them - the Electors of Brandenburg were also the Kings of Prussia, the Hapsburgs obviously ruled Austria, Spain, Hungary, the Low Countries and swathes of the Balkans when most of those lands were outside of the Empire, the Kings of Saxony and Bohemia were periodically also Kings of Poland, etc. - and elections being won through huge bribes to the electors.
Then there's the Peace of Westphalia which ended the Thirty Years' War, which basically made the imperial title an empty one, long before Napoleon's assumption of the imperial title and redistribution of German lands led to Francis II's (Francis I of Austria) official renunciation of the title and assumption of the title 'Emperor of Austria.' The Holy Roman Empire is one of the more complex states - if one can even think of it as a single state, which it certainly wasn't - in world history. Part of why no game, including Europa Universalis, has even done even a passable job of embodying it.