At the end of the Carboniferous, shallow seas drained away leaving broad coastal plains covered in swampy forests in their stead. These lasted right through until the Permian period. Their vegetation was dense and lush and had evolved to cope with the shifting courses of rivers and the appearance and silting up of lakes. The coal forests resembled our flooded prone rainforests, mangrove swamps and cypress swamps, although the actual plants were quite different - dominated by giant relatives of horsetails and club mosses. When leaves, branches and whole trees toppled into the water, instead of decaying away they formed a layer of peat that would eventually become coal.