The layered prisoners' dilemma: Ingroup versus macro-efficiency