Natural gas is a naturally occurring hydrocarbon gas mixture consisting primarily of methane , but commonly including varying amounts of other hydrocarbons, carbon dioxide , nitrogen , and hydrogen sulfide .