Skip to content
Merged
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 @@ -83,6 +83,7 @@ The home page lists one **Games Hub** card (`games/`). Individual games live on
- **Color Clash** (`games/colors/`) — Stroop-style: tap the ink color, not the word; best streak
- **Odd One Out** (`games/odd/`) — four tiles, three match; tap the different shape or color; best streak
- **Higher or Lower** (`games/higher/`) — guess if the next number is higher or lower; best streak
- **Quick Math** (`games/math/`) — mental arithmetic; tap the right answer; 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
52 changes: 52 additions & 0 deletions assets/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,52 @@ body[data-tool="collab"] .site-footer { display: none; }
background: rgba(248, 113, 113, 0.12);
}


/* Quick Math */
.math-stage {
display: flex;
flex-direction: column;
align-items: center;
gap: 1.1rem;
width: min(100%, 360px);
margin: 0 auto;
}
.math-problem {
margin: 0;
font-size: clamp(2.2rem, 10vw, 3.2rem);
font-weight: 900;
line-height: 1.15;
letter-spacing: -0.02em;
color: var(--color-gold, #ffc300);
min-height: 1.2em;
text-align: center;
}
.math-problem.ok { color: #4ade80; }
.math-problem.err { color: #f87171; }
.math-choices {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0.7rem;
width: 100%;
}
.math-choice {
min-height: 64px;
font-size: 1.25rem;
font-weight: 800;
padding: 0.9rem 1rem;
border-radius: 14px;
}
.math-choice.is-correct {
border-color: rgba(74, 222, 128, 0.7);
background: rgba(74, 222, 128, 0.14);
color: #4ade80;
}
.math-choice.is-miss {
border-color: rgba(248, 113, 113, 0.7);
background: rgba(248, 113, 113, 0.12);
color: #f87171;
}

/* Higher or Lower */
.higher-stage {
display: flex;
Expand Down Expand Up @@ -1204,6 +1250,12 @@ body[data-tool="collab"] .site-footer { display: none; }
height: 42px;
}

.math-choice {
min-height: 60px;
font-size: 1.15rem;
padding: 0.8rem 0.85rem;
}

.higher-btn {
min-height: 56px;
font-size: 1rem;
Expand Down
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, 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, 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 @@ -53,6 +53,10 @@ <h3>Odd One Out</h3>
<h3>Higher or Lower</h3>
<p>A number from 1–99. Guess if the next is higher or lower. Best streak stays local.</p>
</a>
<a class="tool-card ai-card-accent" href="math/">
<h3>Quick Math</h3>
<p>Add or subtract small numbers. Tap the right answer from four choices. 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
204 changes: 204 additions & 0 deletions games/math/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quick Math | RMKR Toolkit</title>
<meta name="description" content="Solve simple addition and subtraction. Tap the right answer from four choices. 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="math">
<main class="wrap page-main" id="main">
<a class="game-back" href="../">← Focus Games</a>
<h1 class="page-title">Quick Math</h1>
<p class="page-lead">A simple add or subtract problem appears. Tap the <strong>correct</strong> answer from four choices. Keep a streak going.</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 right answer.</p>
<div class="game-board-wrap">
<div class="math-stage" id="stage" aria-live="polite" aria-label="Quick Math board">
<p class="math-problem" id="problem" hidden>—</p>
<div class="math-choices" id="choices" hidden aria-label="Answer choices"></div>
</div>
</div>
</main>
<script>
(function () {
var KEY = "rmkr-game-math-best";
var streak = 0;
var busy = false;
var playing = false;
var answer = null;
var problemEl = document.getElementById("problem");
var choicesEl = document.getElementById("choices");
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 makeProblem() {
var op = Math.random() < 0.5 ? "+" : "-";
var a, b, ans;
if (op === "+") {
a = randInt(1, 20);
b = randInt(1, 20);
ans = a + b;
} else {
a = randInt(2, 20);
b = randInt(1, a);
ans = a - b;
}
var wrongs = {};
var tries = 0;
while (Object.keys(wrongs).length < 3 && tries < 40) {
tries += 1;
var delta = randInt(1, 5);
var sign = Math.random() < 0.5 ? -1 : 1;
var w = ans + sign * delta;
if (w === ans || w < 0 || wrongs[w]) continue;
wrongs[w] = true;
}
while (Object.keys(wrongs).length < 3) {
var fill = ans + Object.keys(wrongs).length + 1;
if (fill !== ans && fill >= 0 && !wrongs[fill]) wrongs[fill] = true;
else wrongs[ans + 7 + Object.keys(wrongs).length] = true;
}
var choices = shuffle([ans].concat(Object.keys(wrongs).map(Number)));
return { text: a + " " + op + " " + b, answer: ans, choices: choices };
}
function setChoicesEnabled(on) {
var buttons = choicesEl.querySelectorAll("button");
for (var i = 0; i < buttons.length; i++) buttons[i].disabled = !on;
}
function showBoard() {
problemEl.hidden = false;
choicesEl.hidden = false;
}
function renderRound(p) {
answer = p.answer;
problemEl.textContent = p.text + " = ?";
problemEl.classList.remove("ok", "err");
choicesEl.innerHTML = "";
p.choices.forEach(function (n) {
var btn = document.createElement("button");
btn.type = "button";
btn.className = "btn math-choice";
btn.textContent = String(n);
btn.setAttribute("aria-label", "Answer " + n);
btn.addEventListener("click", function () { onPick(n, btn); });
choicesEl.appendChild(btn);
});
}
function onPick(picked, btn) {
if (!playing || busy || answer == null) return;
busy = true;
setChoicesEnabled(false);
var correct = picked === answer;
if (correct) {
streak += 1;
renderStreak();
var best = saveBest(streak);
renderBest();
problemEl.classList.add("ok");
btn.classList.add("is-correct");
setNote(
"Correct — " + problemEl.textContent.replace(" = ?", "") + " = " + answer +
". Streak " + streak + (best === streak ? " — new best!" : "."),
"ok"
);
setTimeout(function () {
if (!playing) return;
var next = makeProblem();
renderRound(next);
setNote("What is " + next.text + "?");
busy = false;
}, 450);
return;
}
problemEl.classList.add("err");
btn.classList.add("is-miss");
var buttons = choicesEl.querySelectorAll("button");
for (var i = 0; i < buttons.length; i++) {
if (Number(buttons[i].textContent) === answer) {
buttons[i].classList.add("is-correct");
}
}
var ended = streak;
streak = 0;
renderStreak();
setNote(
"Wrong — answer was " + answer +
(ended > 0 ? ". Streak reset from " + ended + "." : ". Press Start."),
"err"
);
startBtn.textContent = "Play again";
playing = false;
busy = false;
}
function startGame() {
playing = true;
busy = false;
streak = 0;
renderStreak();
renderBest();
startBtn.textContent = "Restart";
showBoard();
var p = makeProblem();
renderRound(p);
setNote("What is " + p.text + "?");
}
startBtn.addEventListener("click", startGame);
renderBest();
renderStreak();
})();
</script>
</body>
</html>
Loading