The Allen-Cahn equation with dynamic boundary conditions and mass constraints