Fossil fuels such as coal, oil, and natural gas were formed from the remains of ancient plants and animals during the Carboniferous period. Coal is a hard, black, rock-like substance made of carbon, hydrogen, oxygen, and nitrogen. There are three main types of coal formations: anthracite, bituminous, and lignite. Fossil fuels are used to generate energy for buildings, factories, and transportation and are also used for heating and cooking. Refineries process and filter fossil fuels to produce usable fuels like gasoline, diesel, and heating oil. Major oil spills like the Exxon Valdez and Deepwater Horizon caused extensive environmental and economic damage.