I'm not sure if this is a Swedish movie or not, but anyway...

I remember we were watching some sort of moral animated horror movie back in the early 90s at school, which was very creepy for our age (7-8).
It was about a group of kids that were often up to some sort of mischief, and they were often taken to a scary judge who had a skull on his table - and everytime he laughed (because obviously he was rather pleased with punishing the kids), the skull laughed as well.
In the end of the movie one of the girls was blindfold and forced to pick his boyfriend from the rest of the children, and if she failed, they would all die.
The film ended with a house burning down, and I think the judge was burned inside.
Everything had a very dark and creepy atmosphere, almost like a nightmare.

What is the name of this movie?
I can't find it anywhere no matter what I search for on Google.