JSFiddle - React, Tailwind, and code Playground

HTML

<div class="game-shell">
  <header class="game-header">
    <div>
      <span class="eyebrow">WEEKLY SMALL TALKS</span>
      <h1>Spare Part Express</h1>
      <p>Help the missing piece reach the workbench!</p>
    </div>
    <div class="brand-mark">ROBOTIME</div>
  </header>

  <section class="hud" aria-label="Game status">
    <div class="hud-item">
      <span>TIME</span>
      <strong id="timeValue">60</strong>
    </div>

    <div class="progress-area">
      <div class="progress-labels">
        <span id="sceneValue">Warehouse</span>
        <span id="distanceValue">0 / 1000 m</span>
      </div>
      <div class="progress-track">
        <div id="progressBar" class="progress-bar"></div>
      </div>
    </div>

    <div class="hud-item">
      <span>SCORE</span>
      <strong id="scoreValue">0</strong>
    </div>

    <div class="hud-item">
      <span>PACKAGE</span>
      <strong id="healthValue">♥ ♥ ♥</strong>
    </div>
  </section>

  <main class="game-stage">
    <canvas
      id="gameCanvas"
      width="960"
      height="540"
      tabindex="0"
      aria-label="Spare Part Express game"
    ></canvas>

    <div id="startScreen" class="overlay visible">
      <div class="panel">
        <div class="parcel-icon">📦</div>
        <h2>Ready for delivery?</h2>
        <p>
          Guide the spare-part package through four stops and reach the
          workbench within 60 seconds.
        </p>

        <div class="collision-guide">
  <div class="guide-card collect-card">
    <h3>✓ COLLECT THESE</h3>
    <p>The package can safely touch these items.</p>

    <ul>
      <li>
        <span class="guide-symbol order-symbol">TAG</span>
        <span>
          <b>Order Label</b>
          <small>Earn points and move forward</small>
        </span>
      </li>

      <li>
        <span class="guide-symbol heart-symbol">♥</span>
        <span>
          <b>Heart</b>
          <small>Repair...

CSS

:root {
  --cream: #fff8ea;
  --paper: #fffdf7;
  --brown: #533627;
  --orange: #f28b45;
  --orange-dark: #d9682c;
  --yellow: #ffd66b;
  --green: #62b89a;
  --blue: #72b9d6;
  --red: #e8665b;
  --shadow: 0 18px 45px rgba(83, 54, 39, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, #fff2c8 0, transparent 28%),
    linear-gradient(135deg, #f7ead4, #f7d9bd);
  color: var(--brown);
  font-family: Inter, "Trebuchet MS", Arial, sans-serif;
}

button {
  font: inherit;
}

.game-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
}

.game-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 8px 16px;
}

.eyebrow {
  color: var(--orange-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.game-header h1 {
  margin: 5px 0 2px;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1;
}

.game-header p {
  margin: 8px 0 0;
  color: #806353;
}

.brand-mark {
  padding: 10px 14px;
  border: 2px solid var(--brown);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.hud {
  display: grid;
  grid-template-columns: 82px minmax(160px, 1fr) 82px 125px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--paper);
  border: 3px solid var(--brown);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-item span,
.progress-labels {
  color: #927667;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.hud-item strong {
  margin-top: 3px;
  font-size: 20px;
}

#healthValue {
  color: var(--red);
  white-space: nowrap;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.progress-track {
  height:...

JavaScript

"use strict";

const canvas = document.getElementById("gameCanvas");
const ctx = canvas.getContext("2d");

const timeValue = document.getElementById("timeValue");
const scoreValue = document.getElementById("scoreValue");
const healthValue = document.getElementById("healthValue");
const sceneValue = document.getElementById("sceneValue");
const distanceValue = document.getElementById("distanceValue");
const progressBar = document.getElementById("progressBar");

const startScreen = document.getElementById("startScreen");
const resultScreen = document.getElementById("resultScreen");
const startButton = document.getElementById("startButton");
const restartButton = document.getElementById("restartButton");
const copyButton = document.getElementById("copyButton");
const toast = document.getElementById("toast");

const resultIcon = document.getElementById("resultIcon");
const resultTag = document.getElementById("resultTag");
const resultTitle = document.getElementById("resultTitle");
const resultMessage = document.getElementById("resultMessage");
const finalScore = document.getElementById("finalScore");

const W = canvas.width;
const H = canvas.height;
const TARGET_DISTANCE = 1000;
const GAME_DURATION = 60;

const scenes = [
  {
    name: "Robotime Warehouse",
    shortName: "Warehouse",
    sky: ["#f7d9a8", "#fff2d7"],
    road: "#d5b78e"
  },
  {
    name: "On the Way",
    shortName: "Transport",
    sky: ["#9ed7e8", "#eaf7fb"],
    road: "#89949a"
  },
  {
    name: "Almost Home",
    shortName: "Front Door",
    sky: ["#b9e5c8", "#f3f6d8"],
    road: "#c79e72"
  },
  {
    name: "The Crafting Room",
    shortName: "Workbench",
    sky: ["#f4c6ba", "#fff0d9"],
    road: "#b77b55"
  }
];

const player = {
  x: 150,
  y: 345,
  targetX: 150,
  targetY: 345,
  width: 82,
  height: 58,
  invincible: 0
};

let game = {};
let pointerStart = null;
let animationId = null;

function resetGame() {
  game =...