@@ -169,8 +169,8 @@
👫 Play Together
Build with family and friends, up to 4 players. There's no chat, just emoji, and the host lets each player in.
You are
-
-
+
+
🔒 Log in to play together. It keeps Play Together safe: only people with an account can make or join a game.
@@ -332,8 +332,8 @@🗂 My worlds
✨ Make a new world
-
-
+
+
@@ -408,7 +408,7 @@
diff --git a/src/a11y.js b/src/a11y.js
new file mode 100644
index 0000000..fc7d267
--- /dev/null
+++ b/src/a11y.js
@@ -0,0 +1,57 @@
+// Accessibility helpers (see docs/accessibility.md): pop-ups behave like proper dialogs
+// (named, keyboard focus moves in, Tab stays inside, Esc closes) and one place to ask
+// whether the player prefers reduced motion.
+export const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)');
+
+// Menu-level pop-ups: Esc presses their Back/Done button (in-game panels have their own Esc handling).
+const ESC_CLOSES = [['together', 'tg-close'], ['account', 'acc-done'], ['worlds', 'w-done'], ['news', 'news-done'], ['report', 'report-done'], ['gate', 'gate-cancel']];
+const FOCUSABLE = 'button, a[href], input:not([type=hidden]), select, summary, textarea, [tabindex="0"]';
+const shown = (el) => el.getClientRects().length > 0 && getComputedStyle(el).visibility !== 'hidden';
+
+/** Call once, after every overlay exists in the page. */
+export function initA11y(overlayIds) {
+ const $ = (id) => document.getElementById(id);
+ let n = 0;
+ for (const id of overlayIds) {
+ const ov = $(id);
+ const panel = ov?.querySelector('.panel');
+ if (!ov || !panel) continue;
+ const h = panel.querySelector('h1, h2');
+ if (h) { if (!h.id) h.id = `a11y-title-${++n}`; ov.setAttribute('aria-labelledby', h.id); }
+ if (!ov.getAttribute('role')) ov.setAttribute('role', 'dialog');
+ ov.setAttribute('aria-modal', 'true');
+ panel.tabIndex = -1;
+ let opener = null;
+ new MutationObserver(() => {
+ if (!ov.classList.contains('hidden')) {
+ // Opened: remember where the player was, then move keyboard focus into the pop-up.
+ const a = document.activeElement;
+ opener = a && a !== document.body && !ov.contains(a) ? a : null;
+ requestAnimationFrame(() => { if (!ov.classList.contains('hidden') && !ov.contains(document.activeElement)) panel.focus({ preventScroll: true }); });
+ } else if (opener) {
+ // Closed: hand focus back to the menu button that opened it (never to in-game controls).
+ if (opener.isConnected && $('menu').contains(opener) && shown(opener)) opener.focus({ preventScroll: true });
+ opener = null;
+ }
+ }).observe(ov, { attributes: true, attributeFilter: ['class'] });
+ }
+ // Long lists that scroll must be reachable by keyboard even when they hold no buttons.
+ for (const [id, label] of [['qb-list', 'Quests'], ['recipes', 'Recipes']]) { const el = $(id); if (el) { el.tabIndex = 0; el.setAttribute('role', 'region'); el.setAttribute('aria-label', label); } }
+ for (const id of ['tg-status', 'loading']) $(id)?.setAttribute('aria-live', 'polite');
+
+ document.addEventListener('keydown', (e) => {
+ const open = [...document.querySelectorAll('.overlay[aria-modal]:not(.hidden)')].pop();
+ if (!open) return;
+ if (e.key === 'Escape') {
+ const hit = ESC_CLOSES.find(([ov]) => ov === open.id);
+ if (hit) { e.preventDefault(); $(hit[1]).click(); }
+ } else if (e.key === 'Tab') {
+ const items = [...open.querySelectorAll(FOCUSABLE)].filter((el) => !el.disabled && shown(el));
+ if (!items.length) return;
+ const first = items[0], last = items[items.length - 1];
+ if (!open.contains(document.activeElement) || document.activeElement === open.querySelector('.panel')) { e.preventDefault(); (e.shiftKey ? last : first).focus(); }
+ else if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
+ else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
+ }
+ }, true);
+}
diff --git a/src/main.js b/src/main.js
index 37a22bc..6853865 100644
--- a/src/main.js
+++ b/src/main.js
@@ -30,6 +30,7 @@ import { Course, fmtTime } from './course.js';
import { PhotoMode, FRAMES, FILTERS, STICKERS } from './photo.js';
import { Insights, REPORTS } from './insights.js';
import { unseenNews, markNewsSeen } from './news.js';
+import { initA11y, reduceMotion } from './a11y.js';
const insights = new Insights(); // anonymous counts + error reports, online edition only
@@ -110,7 +111,7 @@ const course = new Course({
onRespawn() { sfx.whoosh?.(); },
onFinish(r) {
const p = player.pos;
- for (const tile of [TILE.WOOL_RED, TILE.WOOL_BLUE, TILE.WOOL_YELLOW, TILE.WOOL_GREEN, TILE.COIN]) particles.burst(Math.floor(p.x), Math.floor(p.y) + 1, Math.floor(p.z), tile);
+ if (!reduceMotion.matches) for (const tile of [TILE.WOOL_RED, TILE.WOOL_BLUE, TILE.WOOL_YELLOW, TILE.WOOL_GREEN, TILE.COIN]) particles.burst(Math.floor(p.x), Math.floor(p.y) + 1, Math.floor(p.z), tile);
sfx.fanfare?.(); sfx.yay?.();
const coins = r.total ? ` · 🪙 ${r.coins}/${r.total}` : '';
hint(`🏁 Finished in ${fmtTime(r.time)}${coins}${r.newBest ? (r.beatOld ? ' · 🏆 New best time!' : '') : ` · Best ${fmtTime(r.best)}`}`, 4500);
@@ -495,15 +496,21 @@ function renderHotbar() {
}
}
+/** Screen-reader text for a row of icons (hearts, bubbles, food); nothing when the row is empty. */
+function speak(el, text) {
+ if (text) { el.setAttribute('role', 'img'); el.setAttribute('aria-label', text); } else { el.removeAttribute('role'); el.removeAttribute('aria-label'); }
+}
+
function renderStatus() {
$('status').classList.toggle('hidden', !isSurvival());
if (!isSurvival()) return;
let h = '';
for (let i = 0; i < MAX_HEALTH / 2; i++) {
const v = survival.health - i * 2;
- h += `♥`;
+ h += `${v >= 1 ? '♥' : '♡'}`;
}
$('hearts').innerHTML = h;
+ speak($('hearts'), `Health: ${Math.max(0, Math.ceil(survival.health / 2))} of ${MAX_HEALTH / 2} hearts`);
const showAir = player?.headInWater || survival.air < MAX_AIR;
$('bubbles').innerHTML = showAir ? '●'.repeat(Math.ceil(survival.air)) : '';
let f = '';
@@ -512,6 +519,8 @@ function renderStatus() {
f += `🍗`;
}
$('hunger').innerHTML = f;
+ speak($('hunger'), isAdventure() ? `Food: ${Math.ceil(survival.hunger / 2)} of ${MAX_HUNGER / 2}` : '');
+ speak($('bubbles'), showAir ? `Air: ${Math.ceil(survival.air)}` : '');
const armor = isAdventure() && adv.armor ? ITEMS.get(adv.armor) : null;
$('armor-ind').textContent = armor ? `🛡️ ${itemName(adv.armor)} (−${Math.round(armor.armor * 100)}%)` : '';
renderXp();
@@ -1058,7 +1067,12 @@ function renderProfilePicker() {
for (const [label, color] of items) {
const b = document.createElement('button');
b.type = 'button'; b.className = 'chip' + (label === current ? ' on' : ''); b.textContent = label;
- if (color) b.style.setProperty('--chip', color);
+ if (color) {
+ b.style.setProperty('--chip', color);
+ // Readable label on any player colour: dark ink on light colours, white on dark ones.
+ const [r, g, bl] = [1, 3, 5].map((i) => parseInt(color.slice(i, i + 2), 16) / 255).map((c) => (c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4));
+ b.style.setProperty('--chip-ink', 0.2126 * r + 0.7152 * g + 0.0722 * bl > 0.3 ? '#10131c' : '#fff');
+ }
b.disabled = together.active || together.role === 'waiting' || together.role === 'connecting';
b.addEventListener('click', () => { together.profile = { ...together.profile, [key]: label }; saveProfile(together.profile); renderTogether(); });
box.appendChild(b);
@@ -1280,6 +1294,8 @@ for (const [overlay, done] of [['inventory', 'inv-done'], ['craft', 'craft-done'
ov.addEventListener('click', (e) => { if (e.target === ov) $(done).click(); });
}
+initA11y(['together', 'account', 'worlds', 'news', 'report', 'gate', 'inventory', 'craft', 'pet', 'trade', 'questbook', 'photo', 'rotate', 'death']);
+
// Bit's side panel is not a pop-up (taps inside it must not close it), so it only gets the ✕.
{
const x = document.createElement('button');
@@ -1452,7 +1468,7 @@ survival.onDamage = () => {
sfx.hurt();
const f = $('damage-flash');
f.classList.add('on');
- setTimeout(() => f.classList.remove('on'), 120);
+ setTimeout(() => f.classList.remove('on'), reduceMotion.matches ? 60 : 120);
};
survival.onDeath = (reason) => {
state = 'dead';
@@ -1910,7 +1926,7 @@ function foundStar(now) {
const { x, y, z } = target;
world.setBlock(x, y, z, B.AIR);
world.flushDirty();
- for (const tile of [TILE.STAR, TILE.WOOL_RED, TILE.WOOL_BLUE, TILE.WOOL_YELLOW, TILE.WOOL_GREEN]) particles.burst(x, y, z, tile);
+ if (!reduceMotion.matches) for (const tile of [TILE.STAR, TILE.WOOL_RED, TILE.WOOL_BLUE, TILE.WOOL_YELLOW, TILE.WOOL_GREEN]) particles.burst(x, y, z, tile);
sfx.fanfare?.(); sfx.yay?.();
hint('⭐ You found the Hidden Star! ⭐', 3500);
if (isSurvival()) { inv.add(B.STAR, 1); renderHotbar(); }
diff --git a/style.css b/style.css
index 5eb81a1..a73259d 100644
--- a/style.css
+++ b/style.css
@@ -65,7 +65,7 @@ table.controls td:first-child { color: #e6c35c; white-space: nowrap; font-weight
#hearts, #bubbles { display: flex; gap: 1px; font-size: 19px; line-height: 1; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.heart { color: #e0302a; }
.heart.half { background: linear-gradient(90deg, #e0302a 50%, #3a1010 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
-.heart.empty { color: #3a1010; }
+.heart.empty { color: #ffd0cd; }
.bubble { color: #8fd3ff; }
#damage-flash { position: fixed; inset: 0; pointer-events: none; z-index: 6; background: radial-gradient(circle, transparent 40%, rgba(220, 0, 0, .55)); opacity: 0; transition: opacity .4s; }
#damage-flash.on { opacity: 1; transition: none; }
@@ -161,7 +161,7 @@ body.touch .qt-key { display: none; }
.qb-item .qb-stars { white-space: nowrap; font-size: 1.05rem; }
.qb-item.done { border-color: #66b043; }
.qb-item.active { border-color: #ffd45a; }
-.qb-item.off { opacity: .45; }
+.qb-item.off { opacity: .72; }
.qb-item .tag { font-size: .7rem; padding: 1px 6px; border-radius: 4px; background: #3a4255; margin-left: 6px; font-weight: 400; }
/* Robot panel (docked so you can watch Bit work) */
@@ -329,7 +329,7 @@ select { width: 100%; }
.tg-me { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: rgba(255, 255, 255, .04); border: 1px solid #2c3446; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { padding: 4px 10px; border-radius: 999px; font-size: .85rem; background: #1b2030; border-color: var(--chip, #4b556b); }
-.chip.on { background: var(--chip, #3f7d2a); border-color: #fff; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
+.chip.on { background: var(--chip, #3f7d2a); border-color: #fff; color: var(--chip-ink, #fff); text-shadow: none; }
.chip:disabled { opacity: .55; cursor: default; }
.tg-start { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
@media (max-width: 560px) { .tg-start { grid-template-columns: 1fr; } }
@@ -507,3 +507,36 @@ body.touch #quest-tracker { right: calc(max(10px, env(safe-area-inset-right)) +
.pet-panel .slot-grid { grid-template-columns: repeat(9, minmax(0, 50px)); }
.pet-panel .slot-grid .slot { width: auto; height: auto; aspect-ratio: 1; }
.pet-panel .slot-grid .slot img { width: 68%; height: auto; }
+
+/* ---------- Accessibility baseline (docs/accessibility.md) ---------- */
+/* A clear keyboard focus ring everywhere (the browser's own is a thin 1px line on our dark panels). */
+:focus-visible { outline: 3px solid #ffd45a; outline-offset: 2px; }
+.panel:focus-visible, .overlay > .panel[tabindex="-1"]:focus { outline: none; }
+input[type=range] { min-height: 24px; }
+
+/* HUD text sits over any sky, even a bright one: give it a dark backing so it stays above 4.5:1. */
+#hint, #toast, #armor-ind { background: rgba(8, 12, 22, .74); padding: 3px 12px; border-radius: 8px; }
+#armor-ind:empty { display: none; }
+#mode-badge { background: rgba(8, 12, 22, .78); }
+#xp-level { background: rgba(8, 12, 22, .74); padding: 0 7px; border-radius: 8px; }
+#hotbar { background: rgba(0, 0, 0, .62); }
+.slot .num { font-size: 11px; color: #fff; }
+.qb-item .tag { color: #e6ebf5; }
+
+/* Phones and tablets: every button, field and tab is at least 44px to tap. */
+body.touch button:not(.tbtn) { min-width: 44px; }
+body.touch button:not(.tbtn), body.touch select, body.touch summary,
+body.touch input[type=text], body.touch input[type=password], body.touch input[type=number], body.touch input[type=range] { min-height: 44px; }
+body.touch .x-close { width: 44px; height: 44px; }
+body.touch .legal-links a, body.touch .acc-privacy a, body.touch #news a, body.touch .install-help a { display: inline-block; padding: 14px 4px; }
+body.touch details.fold > summary { padding-top: 12px; padding-bottom: 12px; }
+body.touch #hud #hotbar .slot { width: 44px; height: 44px; }
+body.touch #hud #hotbar .slot img { width: 30px; height: 30px; }
+@media (max-height: 520px) { body.touch #xpbar { bottom: 66px; } body.touch #status { bottom: 74px; } }
+
+/* Reduced motion: no pop-in zoom for celebrations, no fades or slides, a gentler damage flash. */
+@media (prefers-reduced-motion: reduce) {
+ *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
+ #celebrate { transform: translate(-50%, -50%); }
+ #damage-flash { background: radial-gradient(circle, transparent 55%, rgba(220, 0, 0, .3)); }
+}
diff --git a/sw.js b/sw.js
index ec5b616..d29673c 100644
--- a/sw.js
+++ b/sw.js
@@ -1,10 +1,11 @@
// Service worker: caches the whole game so it works offline once loaded.
// Bump VERSION whenever files change so players get the update.
-const VERSION = 'minicrafter-v31';
+const VERSION = 'minicrafter-v33';
const CORE = [
'./', './index.html', './style.css', './privacy.html', './terms.html', './legal.css', './features.html', './features.css', './manifest.webmanifest', './site-config.json',
'./icons/icon-192.png', './icons/icon-512.png', './icons/icon-maskable-512.png', './icons/apple-touch-icon.png', './icons/favicon-32.png',
'./vendor/three.module.js', './vendor/blockly.min.js', './vendor/media/sprites.png',
+ './src/a11y.js',
'./src/adventure.js',
'./src/audio.js',
'./src/blocks.js',
Turn your phone sideways
⚔️ Adventure mode is for older players
It has night creatures that fight back, hunger, tougher falls and losing your things when you faint. Grown-ups, please answer:
- +