It's okay - take a deep breath! Your seat isn't ruined. The "styrofoam" is actually EPS foam which isn't the most durable material in the world. I have cracked the EPS foam accidentally on some of my carseats over the years. As long as you're not missing chunks it's okay to repair it yourself. You can put a piece of tape (I use clear shipping tape) over the crack to make sure it doesn't continue to separate. As for gluing the EPS foam back onto the shell of the headrest- yup, you can do that. I just took apart my NextFit training seat and I can tell that the foam in the headrest is just glued on randomly with hot glue. If you have a glue gun - you can use that and it should be as good as new! HTH!
I will add that it is advisable to use a low-temp gun when gluing foam. When the foam was pulled out of my truefit when they were first released, it took an act of congress for learning curve to get me the foam. When the did, the engineers included a (very nice) cordless, dual-temp glue gun with instruction to use the low setting for the foam to avoid melting it.