Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ The home page lists one **Games Hub** card (`games/`). Individual games live on
- **Quick Math** (`games/math/`) — mental arithmetic; tap the right answer; best streak
- **Find Number** (`games/find/`) — spot the target number in a 4×4 grid; best streak
- **Pop Light** (`games/pop/`) — tap the gold cell on a 3×3 grid before it fades; best streak
- **Sum Pair** (`games/sum/`) — tap the one pair of numbers that adds to the target; best streak
- **Casual Quiz** (`games/quiz/`) — multiple-choice on India, Tamil Nadu, science, technology, and more, plus a General mix. Switch topic or level anytime. Marks stay in `localStorage`. Questions live only in `games/quiz/questions.json`.

#### How to add or change quiz questions
Expand Down
79 changes: 79 additions & 0 deletions assets/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,78 @@ body[data-tool="collab"] .site-footer { display: none; }
transform: none;
}

/* Sum Pair */
.sum-stage {
display: flex;
flex-direction: column;
align-items: center;
gap: 1.1rem;
width: min(100%, 420px);
margin: 0 auto;
}
.sum-target {
margin: 0;
font-size: clamp(2.4rem, 10vw, 3.4rem);
font-weight: 900;
line-height: 1;
letter-spacing: -0.03em;
color: var(--color-gold, #ffc300);
min-height: 1.1em;
text-align: center;
font-variant-numeric: tabular-nums;
}
.sum-target.ok { color: #4ade80; }
.sum-target.err { color: #f87171; }
.sum-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 0.75rem;
width: 100%;
}
.sum-cell {
min-height: 88px;
min-width: 0;
padding: 0.65rem 0.35rem;
border-radius: 16px;
border: 1px solid var(--color-line);
background: linear-gradient(145deg, #1c2844, #121a2c);
color: var(--color-text);
font-family: inherit;
font-size: 1.65rem;
font-weight: 800;
font-variant-numeric: tabular-nums;
cursor: pointer;
user-select: none;
-webkit-tap-highlight-color: transparent;
transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.sum-cell:hover:not(:disabled) {
border-color: rgba(255, 195, 0, 0.55);
color: var(--color-accent);
}
.sum-cell:active:not(:disabled) {
transform: scale(0.97);
}
.sum-cell:disabled { cursor: default; }
.sum-cell.is-selected {
border-color: #ffc300;
color: var(--color-accent, #ffc300);
box-shadow: 0 0 0 3px rgba(255, 195, 0, 0.35);
background: linear-gradient(145deg, #2a2410, #1c2844);
}
.sum-cell.is-correct {
border-color: rgba(74, 222, 128, 0.7);
background: rgba(74, 222, 128, 0.14);
color: #4ade80;
box-shadow: none;
}
.sum-cell.is-miss {
border-color: rgba(248, 113, 113, 0.7);
background: rgba(248, 113, 113, 0.12);
color: #f87171;
box-shadow: none;
}


@media (max-width: 420px) {
.memory-grid,
Expand Down Expand Up @@ -1386,4 +1458,11 @@ body[data-tool="collab"] .site-footer { display: none; }
.pop-grid { gap: 0.55rem; }
.pop-cell { min-height: 84px; border-radius: 14px; }

.sum-grid { gap: 0.55rem; }
.sum-cell {
min-height: 76px;
font-size: 1.4rem;
border-radius: 14px;
}

}
6 changes: 5 additions & 1 deletion games/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Focus Games | RMKR Toolkit</title>
<meta name="description" content="Simple browser focus games — memory, sequence, number slide, word scramble, reaction tap, tap order, color clash, odd one out, higher or lower, quick math, find-the-number, pop light, and a casual quiz. No accounts, works offline after load.">
<meta name="description" content="Simple browser focus games — memory, sequence, number slide, word scramble, reaction tap, tap order, color clash, odd one out, higher or lower, quick math, find-the-number, pop light, sum pair, and a casual quiz. No accounts, works offline after load.">
<link rel="icon" type="image/svg+xml" href="../assets/favicon.svg">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&display=swap" rel="stylesheet">
Expand Down Expand Up @@ -65,6 +65,10 @@ <h3>Find Number</h3>
<h3>Pop Light</h3>
<p>One cell lights gold on a 3×3 grid. Tap it before it fades. Best streak stays local.</p>
</a>
<a class="tool-card ai-card-accent" href="sum/">
<h3>Sum Pair</h3>
<p>A target sum and six numbers. Tap the one pair that adds up. Best streak stays local.</p>
</a>
<a class="tool-card ai-card-accent" href="quiz/">
<h3>Casual Quiz</h3>
<p>Multiple-choice on India, Tamil Nadu, science, tech, and more. Switch topic or level anytime.</p>
Expand Down
263 changes: 263 additions & 0 deletions games/sum/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sum Pair | RMKR Toolkit</title>
<meta name="description" content="Tap the one pair of numbers that adds up to the target. Best streak saved locally.">
<link rel="icon" type="image/svg+xml" href="../../assets/favicon.svg">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../../assets/site.css">
<script src="../../assets/site.js" defer></script>
</head>
<body data-root="../../" data-tool="sum">
<main class="wrap page-main" id="main">
<a class="game-back" href="../">← Focus Games</a>
<h1 class="page-title">Sum Pair</h1>
<p class="page-lead">A target sum appears above six different numbers. Exactly one pair adds up to it. Tap those <strong>two</strong> tiles. A hit grows your streak; a miss resets it.</p>

<div class="game-hud">
<div class="game-hud-stats">
<span>Streak: <strong id="streak">0</strong></span>
<span>Best: <strong id="best">—</strong></span>
</div>
<div class="game-hud-actions">
<button type="button" class="btn btn-gold" id="startBtn">Start</button>
</div>
</div>
<p class="game-note" id="note" role="status">Press Start, then tap the pair that adds up.</p>
<div class="game-board-wrap">
<div class="sum-stage" id="stage" aria-live="polite" aria-label="Sum Pair board">
<p class="sum-target" id="target" hidden>—</p>
<div class="sum-grid" id="grid" hidden aria-label="Number tiles"></div>
</div>
</div>
</main>
<script>
(function () {
var KEY = "rmkr-game-sum-best";
var streak = 0;
var busy = false;
var playing = false;
var roundId = 0;
var target = null;
var pair = null;
var picked = [];
var targetEl = document.getElementById("target");
var gridEl = document.getElementById("grid");
var startBtn = document.getElementById("startBtn");

function loadBest() {
try {
var v = parseInt(localStorage.getItem(KEY) || "", 10);
return Number.isFinite(v) && v > 0 ? v : null;
} catch (e) { return null; }
}
function saveBest(n) {
var cur = loadBest();
if (cur == null || n > cur) {
try { localStorage.setItem(KEY, String(n)); } catch (e) {}
return n;
}
return cur;
}
function setNote(msg, kind) {
var el = document.getElementById("note");
el.textContent = msg || "";
el.className = "game-note" + (kind ? " " + kind : "");
}
function renderBest() {
var b = loadBest();
document.getElementById("best").textContent = b == null ? "—" : String(b);
}
function renderStreak() {
document.getElementById("streak").textContent = String(streak);
}
function randInt(min, max) {
return min + Math.floor(Math.random() * (max - min + 1));
}
function shuffle(arr) {
var a = arr.slice();
for (var i = a.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var t = a[i];
a[i] = a[j];
a[j] = t;
}
return a;
}
function splitPool(goal) {
var pairs = [];
var safe = [];
for (var n = 1; n <= 12; n++) {
var c = goal - n;
if (c === n || c < 1 || c > 12) safe.push(n);
else if (n < c) pairs.push([n, c]);
}
return { pairs: pairs, safe: safe };
}
function solutionCount(cells, goal) {
var count = 0;
var found = null;
for (var i = 0; i < cells.length; i++) {
for (var j = i + 1; j < cells.length; j++) {
if (cells[i] + cells[j] === goal) {
count += 1;
found = [cells[i], cells[j]];
}
}
}
return { count: count, pair: found };
}
function distinctOk(cells) {
var seen = {};
if (cells.length !== 6) return false;
for (var i = 0; i < cells.length; i++) {
if (cells[i] < 1 || cells[i] > 12 || seen[cells[i]]) return false;
seen[cells[i]] = true;
}
return true;
}
function makeRound() {
for (var attempt = 0; attempt < 40; attempt++) {
var goal = randInt(8, 18);
var pack = splitPool(goal);
if (!pack.pairs.length) continue;
var chosen = pack.pairs[randInt(0, pack.pairs.length - 1)];
var pool = pack.safe.slice();
for (var i = 0; i < pack.pairs.length; i++) {
var p = pack.pairs[i];
if (p[0] === chosen[0] && p[1] === chosen[1]) continue;
pool.push(Math.random() < 0.5 ? p[0] : p[1]);
}
if (pool.length < 4) continue;
var cells = shuffle([chosen[0], chosen[1]].concat(shuffle(pool).slice(0, 4)));
var check = solutionCount(cells, goal);
if (distinctOk(cells) && check.count === 1) {
return { target: goal, cells: cells, pair: check.pair };
}
}
return { target: 13, cells: shuffle([1, 2, 3, 4, 6, 7]), pair: [6, 7] };
}
function setCellsEnabled(on) {
var buttons = gridEl.querySelectorAll("button");
for (var i = 0; i < buttons.length; i++) buttons[i].disabled = !on;
}
function showBoard() {
targetEl.hidden = false;
gridEl.hidden = false;
}
function isSolution(n) {
return pair && (n === pair[0] || n === pair[1]);
}
function renderRound(round) {
target = round.target;
pair = round.pair.slice();
picked = [];
targetEl.textContent = String(round.target);
targetEl.setAttribute("aria-label", "Target sum " + round.target);
targetEl.classList.remove("ok", "err");
gridEl.innerHTML = "";
round.cells.forEach(function (n) {
var btn = document.createElement("button");
btn.type = "button";
btn.className = "sum-cell";
btn.textContent = String(n);
btn.setAttribute("aria-label", "Number " + n);
btn.setAttribute("aria-pressed", "false");
btn.addEventListener("click", function () { onTap(n, btn); });
gridEl.appendChild(btn);
});
}
function goNext(id, delay) {
setTimeout(function () {
if (!playing || id !== roundId) return;
var next = makeRound();
renderRound(next);
setCellsEnabled(true);
setNote("Tap two numbers that add to " + next.target + ".");
busy = false;
}, delay);
}
function onTap(n, btn) {
if (!playing || busy || target == null) return;
if (btn.classList.contains("is-selected")) {
btn.classList.remove("is-selected");
btn.setAttribute("aria-pressed", "false");
picked = picked.filter(function (item) { return item.btn !== btn; });
setNote("Tap two numbers that add to " + target + ".");
return;
}
btn.classList.add("is-selected");
btn.setAttribute("aria-pressed", "true");
picked.push({ n: n, btn: btn });
if (picked.length < 2) {
setNote("Pick a second number.");
return;
}
busy = true;
setCellsEnabled(false);
var id = roundId;
var a = picked[0];
var b = picked[1];
var correct = a.n + b.n === target;
var buttons = gridEl.querySelectorAll("button");
for (var i = 0; i < buttons.length; i++) {
buttons[i].classList.remove("is-selected");
var value = Number(buttons[i].textContent);
if (correct && (buttons[i] === a.btn || buttons[i] === b.btn)) {
buttons[i].classList.add("is-correct");
} else if (!correct && isSolution(value)) {
buttons[i].classList.add("is-correct");
} else if (!correct && (buttons[i] === a.btn || buttons[i] === b.btn)) {
buttons[i].classList.add("is-miss");
}
}
if (correct) {
streak += 1;
renderStreak();
var best = saveBest(streak);
renderBest();
targetEl.classList.add("ok");
setNote(
"Correct — " + a.n + " + " + b.n + ". Streak " + streak +
(best === streak ? " — new best!" : "."),
"ok"
);
goNext(id, 900);
return;
}
targetEl.classList.add("err");
var ended = streak;
streak = 0;
renderStreak();
setNote(
"Miss — " + a.n + " + " + b.n + " is not " + target +
(ended > 0 ? ". Streak reset from " + ended + "." : "."),
"err"
);
goNext(id, 1100);
}
function startGame() {
roundId += 1;
playing = true;
busy = false;
streak = 0;
picked = [];
renderStreak();
renderBest();
startBtn.textContent = "Restart";
showBoard();
var round = makeRound();
renderRound(round);
setCellsEnabled(true);
setNote("Tap two numbers that add to " + round.target + ".");
}
startBtn.addEventListener("click", startGame);
renderBest();
renderStreak();
})();
</script>
</body>
</html>
Loading