JSFiddle - React, Tailwind, and code Playground
HTML
<main id="oceanTapApp" class="game-shell">
<header class="game-header">
<span class="eyebrow">BLUE WEEK CHALLENGE</span>
<h1>Ocean Tap Rush</h1>
<p>See it. Tap it. Beat your best score!</p>
</header>
<section class="game-card" aria-label="Ocean Tap Rush game">
<div class="hud">
<div class="hud-box">
<span class="hud-label">TIME</span>
<strong><span id="timeValue">30</span>s</strong>
</div>
<div class="hud-box score-box">
<span class="hud-label">SCORE</span>
<strong id="scoreValue">0</strong>
</div>
<div class="hud-box">
<span class="hud-label">STREAK</span>
<strong id="streakValue">0</strong>
</div>
<div id="speedBadge" class="speed-badge">
<span>SPEED</span>
<strong>CALM</strong>
</div>
</div>
<div class="time-track" aria-hidden="true">
<div id="timeFill" class="time-fill"></div>
</div>
<div id="oceanBoard" class="ocean-board">
<div class="sunbeam beam-one" aria-hidden="true"></div>
<div class="sunbeam beam-two" aria-hidden="true"></div>
<div id="targetGrid" class="target-grid" aria-label="Tap targets">
<button class="target-cell" type="button" data-cell="0"></button>
<button class="target-cell" type="button" data-cell="1"></button>
<button class="target-cell" type="button" data-cell="2"></button>
<button class="target-cell" type="button" data-cell="3"></button>
<button class="target-cell" type="button" data-cell="4"></button>
<button class="target-cell" type="button" data-cell="5"></button>
<button class="target-cell" type="button" data-cell="6"></button>
<button class="target-cell" type="button" data-cell="7"></button>
<button class="target-cell" type="button" data-cell="8"></button>
<button class="target-cell" type="button" data-cell="9"></button>
...
CSS
:root {
--navy: #113e6c;
--blue: #167fc4;
--sky: #63c8ef;
--ink: #163b5b;
--muted: #648096;
--yellow: #ffe36e;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-width: 300px;
color: var(--ink);
background:
radial-gradient(
circle at 14% 8%,
rgba(255, 255, 255, 0.9),
transparent 25%
),
linear-gradient(
145deg,
#ebfaff 0%,
#c6efff 50%,
#dcecff 100%
);
font-family:
Inter,
"Trebuchet MS",
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
sans-serif;
}
button {
font: inherit;
}
.game-shell {
width: min(760px, 100%);
margin: 0 auto;
padding: 22px 14px 28px;
}
.game-header {
margin-bottom: 14px;
text-align: center;
}
.eyebrow {
display: inline-block;
margin-bottom: 7px;
color: #277eb7;
font-size: 0.73rem;
font-weight: 900;
letter-spacing: 0.15em;
}
.game-header h1 {
margin: 0;
color: var(--navy);
font-size: clamp(1.8rem, 5vw, 2.7rem);
line-height: 1.05;
}
.game-header p {
margin: 8px 0 0;
color: var(--muted);
font-weight: 700;
}
.game-card {
overflow: hidden;
border: 1px solid rgba(17, 62, 108, 0.14);
border-radius: 24px;
background: rgba(255, 255, 255, 0.96);
box-shadow: 0 20px 55px rgba(27, 91, 143, 0.18);
}
.hud {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 8px;
padding: 12px;
background: #fffefa;
}
.hud-box,
.speed-badge {
display: flex;
min-height: 56px;
align-items: center;
justify-content: center;
flex-direction: column;
border: 1px solid #d8eaf5;
border-radius: 14px;
background: #f4fbff;
}
.hud-label,
.speed-badge span {
color: #70899b;
font-size: 0.61rem;
font-weight: 900;
letter-spacing: 0.09em;
}
.hud-box strong,
.speed-badge strong {
color: var(--navy);
font-size: 1.3rem;
}
.score-box strong {
color:...
JavaScript
(() => {
const GAME_SECONDS = 30;
const START_STAY_MS = 900;
const END_STAY_MS = 430;
const TARGETS = [
{
type: "bubble",
label: "Bubble",
points: 1,
weight: 55
},
{
type: "fish",
label: "Blue Fish",
points: 3,
weight: 25
},
{
type: "bottle",
label: "Plastic Bottle",
points: -2,
weight: 20
}
];
const app = document.querySelector("#oceanTapApp");
if (!app) {
return;
}
const cells = [
...app.querySelectorAll(".target-cell")
];
const startOverlay =
app.querySelector("#startOverlay");
const countdownOverlay =
app.querySelector("#countdownOverlay");
const countdownValue =
app.querySelector("#countdownValue");
const resultOverlay =
app.querySelector("#resultOverlay");
const startButton =
app.querySelector("#startButton");
const playAgainButton =
app.querySelector("#playAgainButton");
const copyButton =
app.querySelector("#copyButton");
const copyStatus =
app.querySelector("#copyStatus");
const feedbackLayer =
app.querySelector("#feedbackLayer");
const timeValue =
app.querySelector("#timeValue");
const timeFill =
app.querySelector("#timeFill");
const scoreValue =
app.querySelector("#scoreValue");
const streakValue =
app.querySelector("#streakValue");
const speedBadge =
app.querySelector("#speedBadge");
const resultRank =
app.querySelector("#resultRank");
const finalScore =
app.querySelector("#finalScore");
const finalHits =
app.querySelector("#finalHits");
const finalStreak =
app.querySelector("#finalStreak");
const resultMessage =
app.querySelector("#resultMessage");
let running = false;
let score = 0;
let timeLeft = GAME_SECONDS;
let streak = 0;
let bestStreak = 0;
let correctHits = 0;
let...