Casimir effect on the lattice: U(1) gauge theory in two spatial dimensions