What is this movie called

0

It’s an anime movie I watched as a kid so I cant describe it accurately (like at all its just images in my head I remember) :
The Movie is about some kind of supernatural contest where you have to solve riddles or solve quests or something idk. I think the winner would get a wish and can wish for anything ( it was something crazy )
A new misterious guy turns shows up at the school of the protagonist he’s loved and admired by everyone ( I think he had a Tragic backstory something with his sister but it could also be the protagonists sister where something happened) I think the new guy knew about the contest and he wanted to win for some deep reason. He participates and wants to win and It looks like he will win but new guy dies at the end
The Protagonist doesnt know about the contest at first I dont know how he (I’m pretty sure its a guy) got involved. I think when new guy shows up they kinda become friends but he doesnt know about new guy’s secrets. I’m pretty sure something tragic happened to the Protagonist too but I’m not sure (It would explain why he wants to win the contest). In the end after solving riddles and crazy tasks the protagonist ends up at the final task of the contest where he meets new guy again who arrived earlier than him. In the ending the new guy dies in the protagonists arms and the protagonist wins the contest

I know these informations are very vague but I watched it as a kid (even though now I remember it being not that kid friendly) and I just can’t get it out of my head.
Please someone help me find this movie

Asked question