Mineral crystals form when magma