How is "sea level" defined on the moon, mars, etc?

How is elevation determined on other rocky planets? How can they claim that a mountain is 10,000 feet high on Mars or they are orbiting 60 miles above the surface of the moon? What is the reference point?

They set a datum level that’s roughly the average altitude of the planet.

A datum level could be set at any elevation, really. It wouldn’t have to be the average altitude.

You’d have some long level loops if you did all the surveying on the ground.

OP: You can use surveying instruments to get the relative height of something, without referencing it to any particular datum. You’d set a temporary benchmark and call it zero, or 100, or whatever you wanted to. Then take a shot on the top of the thing, get out your calculator, and Bob’s your uncle.