Yep. This perfectly describes our situation too. In the case of my daughter, it is definitely anxiety related. Literally the act of going to sleep is anxiety producing for her (what if I can't fall asleep? I will be tired and have a terrible day at school, practice, etc...). Some nights it takes 1+ hour to get to her to sleep. And if she wakes up in the middle of the night (2-3 nights per week when things are bad), she can be up for an hour or more. She is also highly dependent upon me to provide comfort at bedtime / middle of the night.
She takes melatonin gummies, uses an essential oil diffuser, and plays either white noise or meditation all night long. We have her psychiatrist and pediatrician involved.
One thing that I have definitely noticed is that my reactions have a substantial impact on the entire situation.... Not gonna lie, waking up at 3 am multiple nights per week for a non-infant child (she is 12 yrs old!) can sometimes make me more than a little grumpy. But if I express my own stress and frustration about the situation, it usually gets worse.
We start bedtime as early as possible (not always easy with a school+gym+homework+bath schedule). Also we try to avoid electronics right before bed (again not easy given my DD's age and that fact that school/social interactions all take place virtually now).
Big picture, we are working on providing DD with self-soothing and coping skills for getting and staying asleep. We created a list of self soothing ideas that she has above her bed. And, on nights where we have nothing the next day, I make her put herself to bed.
When she starts to get overtired, she does get leg cramps too. Motrin helps that.
Good luck. I know the struggle is real!