The mathematics of quantum entanglement via nonlocal games