Hannover's Sebastian Ernst scored deep into stoppage time to settle a seven-goal thriller in blow to Hamburg's hopes of automatic promotion.