Rect();
          if (
            sheepRect.left > penRect.left &&
            sheepRect.right < penRect.right &&
            sheepRect.top > penRect.top &&
            sheepRect.bottom < penRect.bottom
          ) {
            sheepInPen++;
          }
        }

        score = sheepInPen;
        updateScore();
        return sheepInPen >= levels[level - 1].numSheep * 0.8; // 80% win condition
      }
      //Updates the score
      function updateScore() {
        scoreDisplay.textContent = "Sheep: " 