Inferior mirage: Hot ground heats air near surface, lowering its density and refractive index. Light curves upward, creating an inverted image below the horizon (desert, hot roads).
Superior mirage (Fata Morgana): Cold surface (ice, cold water) cools air below, creating an inversion layer. Light curves downward, making distant objects appear elevated or distorted.
Both effects arise because n decreases as temperature increases, and light bends toward denser (cooler) air.