The game
Handball is played by two teams of seven, who score by throwing the ball into the other team's goal. This article covers the rules our match engine actually plays by, and says plainly where we simplify.
The court
A handball court is 40 metres long and 20 metres wide. Two lines matter more than the rest: the 6 metre goal area in front of each goal, and the 9 metre free throw line further out.
The teams
Each side fields seven: a goalkeeper plus six outfield players, split into two wings, two backs, a centre back and a pivot. Every outfield role also has a spot to defend when the other team attacks. The rest of the squad are substitutes.
The match
A match lasts two halves of 30 minutes, played in real time. The clock stops for free throws, penalties, the restart after a goal and injuries, so a match takes a little over an hour.
Scoring a goal
A goal counts when the ball fully crosses the goal line, inside the posts and under the crossbar. Shots that hit the frame can rebound back into play, and a rebound is a live ball that either team can collect. A goalkeeper can also deflect a shot away rather than catch it, which leaves the ball loose in front of goal.
The 6 metre area
The 6 metre area belongs to the goalkeeper. Outfield players may not step inside it, and the engine enforces this strictly: an outfield player can never end a move inside the area. An attacker may jump and shoot over the area, but he must land outside it. When the ball is loose inside the area, only the goalkeeper may pick it up. An attacker who steps into the area with the ball loses it: the goalkeeper restarts with a goal throw.
Fouls and free throws
A foul is contact that stops an opponent unfairly. The team that wins the foul restarts with a free throw from the 9 metre line, with the defenders holding their ground and the attackers taking up positions outside the line. During a free throw the clock is stopped, so the pause costs you nothing.
Technical faults
The player with the ball can also lose it without any defender winning it: too many steps (travelling), running into a defender who holds his ground (charging) or bouncing the ball again after catching it (double dribble). Travelling is the most common, charging only happens with a defender right in front of him, and a double dribble is rare. The other side gets a free throw.
Passive play
An attack may not just keep the ball. After about 35 seconds of a set attack without a shot, the referee raises his arm as a warning. The attack then has four passes to get a shot away. A free throw's pass doesn't count. On the fifth pass, the ball goes to the other side. A shot on goal resets the count; a blocked shot doesn't.
The 7 metre penalty
When a defender illegally denies a clear chance at goal, the attacker gets a penalty throw from 7 metres, one on one with the goalkeeper. It is the best chance in the game, and the engine plays it separately from normal shots.
Suspensions
A foul can be punished with a yellow card, a 2-minute exclusion or a red card. An excluded player leaves his side a player short for two minutes. Only a straight red card carries over: the player misses his club's next match, and sometimes the next two or three. The Match article has the details.
Restarts
Three ways to bring the ball back into play. A kickoff from the middle after a goal. A throw in from the sideline when the ball leaves the court over a touchline. And a goal throw by the goalkeeper, from his goal area, when the ball crosses the back line. A throw in is taken from the spot where the ball left the court.
Where we simplify
The engine runs on a simplified court measured in proportional units rather than centimetres, so distances are right in relation to each other but not exact. Substitutions happen automatically; you choose the lineup before a match, not during it. Handball has no offside rule, so there is none here either. And no referee makes judgement calls, so there is no advantage rule: every foul the engine detects is given.