The first law of magic system design
The foundational principle of hard fantasy magic system design is what Brandon Sanderson calls the First Law: an author's ability to solve plot problems with magic is proportional to how well the reader understands the magic. A magic system the reader does not understand can provide atmosphere and wonder, but it cannot provide narrative solutions that feel satisfying rather than arbitrary. The deus ex machina is always a magic system the reader did not understand clearly enough to anticipate. Conversely, the magic system whose rules the reader knows can produce climaxes that feel both surprising and inevitable: the solution the reader could not predict but can immediately recognize as the logical extension of rules they already understood. The hard fantasy writer builds toward these satisfying solutions by establishing the rules clearly enough that the solution retroactively makes sense.