JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shepherd's Dog</title>
<style>
body { margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; background: #87ceeb; }
canvas { border: 1px solid #000; }
#ui { position: absolute; top: 10px; left: 10px; color: white; font-family: Arial, sans-serif; }
.screen { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: white; }
button { padding: 10px 20px; margin: 5px; font-size: 16px; cursor: pointer; }
</style>
</head>
<body>
<div id="ui">
<p>Level: <span id="level">1</span></p>
<p>Sheep in Pen: <span id="sheepCount">0</span>/<span id="sheepGoal">40</span></p>
<p>Time to Nightfall: <span id="timer">300</span>s</p>
<p>Score: <span id="score">0</span></p>
</div>
<div id="startScreen" class="screen">
<h1>Shepherd's Dog</h1>
<p>Use mouse or touch to move the dog. Click/tap to bark.</p>
<p>Herd 80% of the sheep into the pen before nightfall!</p>
<button onclick="startGame()">Start Game</button>
</div>
<div id="gameOverScreen" class="screen" style="display: none;">
<h1>Game Over</h1>
<p>Time's up! Wolves scared the sheep.</p>
<button onclick="restartGame()">Restart</button>
<button onclick="backToStart()">Main Menu</button>
</div>
<div id="winScreen" class="screen" style="display: none;">
<h1>Level Complete!</h1>
<p>Sheep in Pen: <span id="winSheepCount">0</span></p>
<p>Score: <span id="winScore">0</span></p>
<button onclick="nextLevel()">Next Level</button>
<button onclick="backToStart()">Main Menu</button>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.2/p5.min.js"></script>
<script>
...