init
Deploy to GitHub Pages / build-and-deploy (push) Failing after 8m31s

This commit is contained in:
MeghdadFadaee committed 2026-07-30 15:49:04 +03:30
commit b73adb9fe3
30 files changed
+3776

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
name: Deploy to GitHub Pages
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build-and-deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Check code quality
run: npm run lint
- name: Build application
run: npm run build
- name: Configure GitHub Pages
uses: actions/configure-pages@v5
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: dist
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
+7
View File
@@ -0,0 +1,7 @@
.idea/
node_modules/
dist/
*.tsbuildinfo
vite.config.js
vite.config.d.ts
.DS_Store
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Meghdad Fadaee
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+37
View File
@@ -0,0 +1,37 @@
# Heavy Metal
A modern browser adaptation of the classic heavy coin puzzle. Ten bags, one digital scale, and one chance to identify the heavy coins.
## Play
[Play on GitHub Pages](https://meghdadfadaee.github.io/heavy-metal/)
## Development
Requires Node.js 22 or newer.
```bash
npm install
npm run dev
```
Production checks:
```bash
npm run lint
npm run build
```
## Deployment
Every push to `main` runs the GitHub Pages workflow in `.github/workflows/deploy-pages.yml`. The workflow checks, builds, and publishes the `dist` artifact.
The Vite build uses relative asset paths, so the same output works at both:
- `https://meghdadfadaee.github.io/heavy-metal/`
To use a custom domain, enter it in the repository's **Settings → Pages → Custom domain** field and configure the DNS records GitHub provides. GitHub will manage the domain association and HTTPS certificate.
## License
[MIT](LICENSE)
+19
View File
@@ -0,0 +1,19 @@
import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: { ecmaVersion: 2022, globals: globals.browser },
plugins: { 'react-hooks': reactHooks, 'react-refresh': reactRefresh },
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
},
},
);
+29
View File
@@ -0,0 +1,29 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#f6f3ea" />
<meta name="description" content="Ten bags, one scale, one chance. Solve the classic heavy coin logic puzzle in your browser." />
<meta name="author" content="Meghdad Fadaee" />
<meta name="application-name" content="Heavy Metal" />
<meta name="color-scheme" content="light dark" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Heavy Metal — The One-Weigh Puzzle" />
<meta property="og:description" content="Ten bags, one scale, one chance. Can you identify the heavy coins?" />
<meta property="og:site_name" content="Heavy Metal" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="Heavy Metal — The One-Weigh Puzzle" />
<meta name="twitter:description" content="Ten bags, one scale, one chance. Can you identify the heavy coins?" />
<link rel="icon" href="./favicon.svg" type="image/svg+xml" />
<link rel="manifest" href="./site.webmanifest" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<title>Heavy Metal — The One-Weigh Puzzle</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
+2722
View File
File diff suppressed because it is too large. Load diff
+51
View File
@@ -0,0 +1,51 @@
{
"name": "heavy-metal",
"private": true,
"version": "1.0.0",
"description": "A modern one-weigh logic game inspired by the classic heavy coin puzzle.",
"author": "Meghdad Fadaee",
"license": "MIT",
"homepage": "https://meghdadfadaee.github.io/heavy-metal/",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/MeghdadFadaee/heavy-metal.git"
},
"bugs": {
"url": "https://github.com/MeghdadFadaee/heavy-metal/issues"
},
"keywords": [
"puzzle",
"browser-game",
"react",
"typescript",
"heavy-coin"
],
"type": "module",
"engines": {
"node": ">=22"
},
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@vitejs/plugin-react": "latest",
"vite": "latest",
"typescript": "latest",
"react": "latest",
"react-dom": "latest",
"lucide-react": "latest"
},
"devDependencies": {
"@eslint/js": "latest",
"@types/react": "latest",
"@types/react-dom": "latest",
"eslint": "latest",
"eslint-plugin-react-hooks": "latest",
"eslint-plugin-react-refresh": "latest",
"globals": "latest",
"typescript-eslint": "latest"
}
}
+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<rect width="64" height="64" rx="15" fill="#253046"/>
<path d="M20 9h24l-5 10c8 5 13 13 13 23 0 10-8 15-20 15S12 52 12 42c0-10 5-18 13-23L20 9Z" fill="#e9734d"/>
<path d="M22 20c6 3 14 3 20 0M25 16h14" fill="none" stroke="#f6f3ea" stroke-width="3" stroke-linecap="round"/>
<circle cx="32" cy="38" r="10" fill="#e4ad44" stroke="#f6f3ea" stroke-width="2"/>
<path d="M27 38h10M32 33v10" stroke="#253046" stroke-width="2.5" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 523 B

+18
View File
@@ -0,0 +1,18 @@
{
"name": "Heavy Metal — The One-Weigh Puzzle",
"short_name": "Heavy Metal",
"description": "A one-weigh logic game inspired by the classic heavy coin puzzle.",
"start_url": ".",
"scope": ".",
"display": "standalone",
"background_color": "#f3f0e7",
"theme_color": "#253046",
"icons": [
{
"src": "favicon.svg",
"sizes": "any",
"type": "image/svg+xml",
"purpose": "any"
}
]
}
+51
View File
@@ -0,0 +1,51 @@
import { useEffect, useState } from 'react';
import { Moon, Sun } from 'lucide-react';
import { Game } from './components/Game';
import { StatsBar } from './components/StatsBar';
import { usePersistentStats } from './hooks/usePersistentStats';
import type { GameMode, Theme } from './types';
function getInitialTheme(): Theme {
const saved = localStorage.getItem('heavy-metal-theme');
if (saved === 'light' || saved === 'dark') return saved;
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
export default function App() {
const [theme, setTheme] = useState<Theme>(getInitialTheme);
const [mode, setMode] = useState<GameMode>('single');
const { stats, recordGame } = usePersistentStats();
useEffect(() => {
document.documentElement.dataset.theme = theme;
localStorage.setItem('heavy-metal-theme', theme);
}, [theme]);
return (
<div className="app-shell">
<header className="site-header">
<a className="brand" href="#top" aria-label="Heavy Metal home">
<span className="brand-mark"><i /><i /><i /></span>
<span><strong>HEAVY</strong> METAL<small>THE ONE-WEIGH PUZZLE</small></span>
</a>
<div className="header-rule" />
<button
className="theme-toggle"
type="button"
onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}
aria-label={`Switch to ${theme === 'light' ? 'dark' : 'light'} mode`}
>
{theme === 'light' ? <Moon size={18} /> : <Sun size={18} />}
</button>
</header>
<Game mode={mode} stats={stats} onRecordGame={recordGame} onModeChange={setMode} />
<StatsBar stats={stats} />
<footer>
<span>10g</span> normal coin <i /> <span>11g</span> heavy coin
<p>Built for curious minds · No coins were harmed</p>
</footer>
</div>
);
}
+62
View File
@@ -0,0 +1,62 @@
import { Minus, Plus } from 'lucide-react';
import type { BagVisual, GamePhase } from '../types';
interface BagProps {
index: number;
visual: BagVisual;
count: number;
phase: GamePhase;
selected: boolean;
onCountChange: (count: number) => void;
onSelect: () => void;
}
export function Bag({ index, visual, count, phase, selected, onCountChange, onSelect }: BagProps) {
const update = (next: number) => onCountChange(Math.max(0, Math.min(1000, next)));
const identifying = phase === 'identifying';
return (
<article
className={`bag-card ${identifying ? 'is-pickable' : ''} ${selected ? 'is-selected' : ''}`}
style={{ '--bag-color': visual.color } as React.CSSProperties}
onClick={identifying ? onSelect : undefined}
aria-label={`Bag ${index + 1}${selected ? ', selected as heavy' : ''}`}
>
<div className="bag-topline">
<span className="bag-number">{String(index + 1).padStart(2, '0')}</span>
<span className="bag-status">{selected ? 'HEAVY?' : '1,000 COINS'}</span>
</div>
<div className="bag-illustration" aria-hidden="true">
<span className="bag-knot" />
<span className="bag-body"><span>{visual.icon}</span></span>
</div>
{phase === 'selecting' ? (
<div className="stepper" onClick={(event) => event.stopPropagation()}>
<button type="button" onClick={() => update(count - 1)} aria-label={`Remove one coin from bag ${index + 1}`}>
<Minus size={14} strokeWidth={2.5} />
</button>
<label>
<span className="sr-only">Coins from bag {index + 1}</span>
<input
type="number"
min="0"
max="1000"
value={count}
onChange={(event) => update(Number(event.target.value) || 0)}
/>
<small>coins</small>
</label>
<button type="button" onClick={() => update(count + 1)} aria-label={`Add one coin from bag ${index + 1}`}>
<Plus size={14} strokeWidth={2.5} />
</button>
</div>
) : (
<div className="locked-count">
<span>{count.toLocaleString()}</span> coins weighed
</div>
)}
</article>
);
}
+30
View File
@@ -0,0 +1,30 @@
import { Bag } from './Bag';
import type { BagVisual, GamePhase } from '../types';
interface BagGridProps {
visuals: BagVisual[];
selections: number[];
phase: GamePhase;
guesses: number[];
onSelectionChange: (index: number, count: number) => void;
onGuessToggle: (index: number) => void;
}
export function BagGrid(props: BagGridProps) {
return (
<div className="bag-grid">
{props.visuals.map((visual, index) => (
<Bag
key={`${visual.color}-${index}`}
index={index}
visual={visual}
count={props.selections[index]}
phase={props.phase}
selected={props.guesses.includes(index)}
onCountChange={(count) => props.onSelectionChange(index, count)}
onSelect={() => props.onGuessToggle(index)}
/>
))}
</div>
);
}
+162
View File
@@ -0,0 +1,162 @@
import { useMemo, useState } from 'react';
import { ArrowRight, Lightbulb, RotateCcw, Sparkles } from 'lucide-react';
import { GameEngine } from '../engine/GameEngine';
import { Hints } from '../engine/Hints';
import { Scoring } from '../engine/Scoring';
import type { GameMode, GamePhase, GameResult, GameStats } from '../types';
import { BagGrid } from './BagGrid';
import { ResultModal } from './ResultModal';
import { Scale } from './Scale';
interface GameProps {
mode: GameMode;
stats: GameStats;
onRecordGame: (won: boolean, coins: number, score: number) => void;
onModeChange: (mode: GameMode) => void;
}
export function Game({ mode, stats, onRecordGame, onModeChange }: GameProps) {
const [game, setGame] = useState(() => GameEngine.createGame(mode));
const [selections, setSelections] = useState(() => Array(10).fill(0) as number[]);
const [guesses, setGuesses] = useState<number[]>([]);
const [phase, setPhase] = useState<GamePhase>('selecting');
const [weight, setWeight] = useState<number | null>(null);
const [weighing, setWeighing] = useState(false);
const [hintLevel, setHintLevel] = useState(0);
const [result, setResult] = useState<GameResult | null>(null);
const totalCoins = useMemo(() => selections.reduce((sum, value) => sum + value, 0), [selections]);
const expected = GameEngine.expectedWeight(selections);
const hints = Hints.for(mode);
const restart = (nextMode: GameMode = mode) => {
setGame(GameEngine.createGame(nextMode));
setSelections(Array(10).fill(0));
setGuesses([]);
setPhase('selecting');
setWeight(null);
setWeighing(false);
setHintLevel(0);
setResult(null);
};
const changeMode = (nextMode: GameMode) => {
onModeChange(nextMode);
restart(nextMode);
};
const updateSelection = (index: number, count: number) => {
setSelections((current) => current.map((value, i) => i === index ? count : value));
};
const fillStrategy = () => {
setSelections(GameEngine.suggestedSelection(mode));
};
const weigh = () => {
if (totalCoins === 0 || weighing) return;
setWeighing(true);
window.setTimeout(() => {
setWeight(GameEngine.weigh(selections, game.heavyBags));
setPhase('identifying');
setWeighing(false);
}, 850);
};
const toggleGuess = (index: number) => {
setGuesses((current) => {
if (current.includes(index)) return current.filter((bag) => bag !== index);
if (mode === 'single') return [index];
return [...current, index];
});
};
const submitGuess = () => {
const won = GameEngine.isCorrect(guesses, game.heavyBags);
const scoreEarned = Scoring.calculate(won, mode, totalCoins, hintLevel);
const finalResult = { won, scoreEarned, heavyBags: game.heavyBags, selectedBags: guesses };
setResult(finalResult);
setPhase('result');
onRecordGame(won, totalCoins, scoreEarned);
};
const showNextHint = () => setHintLevel((level) => Math.min(level + 1, hints.length));
return (
<main>
<section className="hero-copy">
<div>
<span className="eyebrow"><Sparkles size={14} /> ONE WEIGH. ONE ANSWER.</span>
<h1>Find the <em>heavy</em> coin.</h1>
<p>Ten identical bags. A tiny difference in weight. Outsmart the scale with a single measurement.</p>
</div>
<div className="mode-switch" role="group" aria-label="Game mode">
<button className={mode === 'single' ? 'active' : ''} onClick={() => changeMode('single')} type="button">
<span>01</span><strong>Single bag</strong><small>One heavy suspect</small>
</button>
<button className={mode === 'multiple' ? 'active' : ''} onClick={() => changeMode('multiple')} type="button">
<span>02</span><strong>Multiple bags</strong><small>Zero to ten suspects</small>
</button>
</div>
</section>
<section className="game-workspace">
<div className="workspace-heading">
<div>
<span className="step-badge">{phase === 'selecting' ? 'STEP 1 OF 2' : 'STEP 2 OF 2'}</span>
<h2>{phase === 'selecting' ? 'Choose your samples' : 'Name the heavy bag'}</h2>
<p>{phase === 'selecting'
? 'Enter how many coins to take from each bag.'
: mode === 'single' ? 'Select the one bag your measurement implicates.' : 'Select every heavy bag. Selecting none is allowed.'}</p>
</div>
<button type="button" className="restart-button" onClick={() => restart()}><RotateCcw size={16} /> New puzzle</button>
</div>
<div className="game-layout">
<div>
<BagGrid
visuals={game.bagVisuals}
selections={selections}
phase={phase}
guesses={guesses}
onSelectionChange={updateSelection}
onGuessToggle={toggleGuess}
/>
{phase === 'identifying' && (
<div className="guess-bar">
<span>{mode === 'multiple' && guesses.length === 0 ? 'No bags selected — submit if you suspect none' : `${guesses.length} bag${guesses.length === 1 ? '' : 's'} selected`}</span>
<button type="button" className="primary-action" onClick={submitGuess} disabled={mode === 'single' && guesses.length !== 1}>
LOCK ANSWER <ArrowRight size={17} />
</button>
</div>
)}
</div>
<div className="right-rail">
<Scale weight={weight} expected={expected} totalCoins={totalCoins} weighing={weighing} onWeigh={weigh} disabled={phase !== 'selecting' || totalCoins === 0} />
<section className="hint-card">
<div className="hint-heading"><span><Lightbulb size={17} /> FIELD NOTES</span><small>{hintLevel}/{hints.length}</small></div>
{hintLevel === 0 ? (
<p>Stuck? Reveal clues one at a time. Your score drops slightly with each hint.</p>
) : (
<p key={hintLevel} className="hint-text">{hints[hintLevel - 1]}</p>
)}
<div className="hint-actions">
<button type="button" onClick={showNextHint} disabled={hintLevel === hints.length}>
{hintLevel === 0 ? 'Reveal a hint' : hintLevel === hints.length ? 'All hints revealed' : 'Next hint'}
</button>
{hintLevel === hints.length && phase === 'selecting' && <button type="button" className="fill-button" onClick={fillStrategy}>Apply pattern</button>}
</div>
</section>
<div className="round-score"><span>SESSION SCORE</span><strong>{stats.score.toLocaleString()}</strong><small>pts</small></div>
</div>
</div>
</section>
{result && <ResultModal result={result} onRestart={() => restart()} onClose={() => setResult(null)} />}
</main>
);
}
+39
View File
@@ -0,0 +1,39 @@
import { RotateCcw, Trophy, X } from 'lucide-react';
import type { GameResult } from '../types';
interface ResultModalProps {
result: GameResult;
onRestart: () => void;
onClose: () => void;
}
const CONFETTI = Array.from({ length: 26 }, (_, i) => ({
left: `${(i * 37) % 100}%`,
delay: `${(i % 8) * 0.09}s`,
color: ['#f0b84b', '#e86d4d', '#6878e8', '#38a880'][i % 4],
}));
export function ResultModal({ result, onRestart, onClose }: ResultModalProps) {
const answer = result.heavyBags.length
? result.heavyBags.map((index) => `#${String(index + 1).padStart(2, '0')}`).join(', ')
: 'none of them';
return (
<div className="modal-backdrop" role="presentation">
{result.won && <div className="confetti" aria-hidden="true">{CONFETTI.map((piece, i) => <i key={i} style={{ '--x': piece.left, '--delay': piece.delay, '--confetti': piece.color } as React.CSSProperties} />)}</div>}
<section className={`result-modal ${result.won ? 'won' : 'lost'}`} role="dialog" aria-modal="true" aria-labelledby="result-title">
<button className="modal-close" type="button" onClick={onClose} aria-label="Close result"><X size={20} /></button>
<div className="result-emblem">{result.won ? <Trophy size={34} /> : <span>!</span>}</div>
<span className="eyebrow">{result.won ? 'CASE CLOSED' : 'MYSTERY REMAINS'}</span>
<h2 id="result-title">{result.won ? 'Brilliant deduction.' : 'Not quite this time.'}</h2>
<p>The heavy {result.heavyBags.length === 1 ? 'bag was' : 'bags were'} <strong>{answer}</strong>.</p>
{result.won ? (
<div className="score-award"><span>SCORE EARNED</span><strong>+{result.scoreEarned.toLocaleString()}</strong></div>
) : (
<p className="result-tip">Compare the extra grams with the coin counts you assigned to each bag.</p>
)}
<button className="primary-action" type="button" onClick={onRestart}><RotateCcw size={17} /> PLAY AGAIN</button>
</section>
</div>
);
}
+42
View File
@@ -0,0 +1,42 @@
import { Scale as ScaleIcon } from 'lucide-react';
interface ScaleProps {
weight: number | null;
expected: number;
totalCoins: number;
weighing: boolean;
onWeigh: () => void;
disabled: boolean;
}
export function Scale({ weight, expected, totalCoins, weighing, onWeigh, disabled }: ScaleProps) {
return (
<section className={`scale-panel ${weighing ? 'is-weighing' : ''}`} aria-label="Digital scale">
<div className="scale-platform">
{totalCoins > 0 && (
<div className="coin-stack" aria-hidden="true">
<i /><i /><i />
</div>
)}
</div>
<div className="scale-neck" />
<div className="scale-console">
<div className="scale-brand"><ScaleIcon size={16} /> HEAVY METAL <span>HM—10</span></div>
<div className="scale-readout" aria-live="polite">
<span className="readout-label">TOTAL WEIGHT</span>
<strong>{weight === null ? '———' : weight.toLocaleString()}</strong>
<span className="readout-unit">g</span>
<div className="readout-meta">
<span>{weight === null ? 'READY' : 'LOCKED'}</span>
<span>{weight === null ? `${totalCoins.toLocaleString()} COINS` : `BASE ${expected.toLocaleString()} g`}</span>
</div>
</div>
<button className="weigh-button" type="button" onClick={onWeigh} disabled={disabled}>
<span className="button-led" />
{weighing ? 'MEASURING…' : 'WEIGH ONCE'}
</button>
<p>One measurement. Make it count.</p>
</div>
</section>
);
}
+17
View File
@@ -0,0 +1,17 @@
import { ChartNoAxesColumnIncreasing, CheckCircle2, Coins, Target, Trophy } from 'lucide-react';
import type { GameStats } from '../types';
export function StatsBar({ stats }: { stats: GameStats }) {
const average = stats.gamesPlayed ? Math.round(stats.totalCoinsSelected / stats.gamesPlayed) : 0;
const winRate = stats.gamesPlayed ? Math.round((stats.gamesWon / stats.gamesPlayed) * 100) : 0;
return (
<aside className="stats-bar" aria-label="Player statistics">
<div className="stat-primary"><Trophy size={18} /><span><small>TOTAL SCORE</small><strong>{stats.score.toLocaleString()}</strong></span></div>
<div><ChartNoAxesColumnIncreasing size={17} /><span><small>PLAYED</small><strong>{stats.gamesPlayed}</strong></span></div>
<div><CheckCircle2 size={17} /><span><small>WON</small><strong>{stats.gamesWon}</strong></span></div>
<div><Target size={17} /><span><small>WIN RATE</small><strong>{winRate}%</strong></span></div>
<div><Coins size={17} /><span><small>AVG. COINS</small><strong>{average.toLocaleString()}</strong></span></div>
</aside>
);
}
+42
View File
@@ -0,0 +1,42 @@
import { RandomGenerator } from './RandomGenerator';
import type { GameMode, GameState } from '../types';
export const BAG_COUNT = 10;
export const COINS_PER_BAG = 1000;
export const NORMAL_WEIGHT = 10;
export const HEAVY_WEIGHT = 11;
export const GameEngine = {
createGame(mode: GameMode): GameState {
return {
mode,
heavyBags: RandomGenerator.heavyBags(mode),
bagVisuals: RandomGenerator.bagVisuals(),
};
},
weigh(selections: number[], heavyBags: number[]): number {
return selections.reduce((weight, coinCount, bagIndex) => {
const coinWeight = heavyBags.includes(bagIndex) ? HEAVY_WEIGHT : NORMAL_WEIGHT;
return weight + coinCount * coinWeight;
}, 0);
},
expectedWeight(selections: number[]): number {
return selections.reduce((sum, count) => sum + count, 0) * NORMAL_WEIGHT;
},
isCorrect(guess: number[], heavyBags: number[]): boolean {
if (guess.length !== heavyBags.length) return false;
const sortedGuess = [...guess].sort((a, b) => a - b);
const sortedAnswer = [...heavyBags].sort((a, b) => a - b);
return sortedGuess.every((bag, index) => bag === sortedAnswer[index]);
},
// Unique counts encode one heavy bag. Powers of two encode every possible subset.
suggestedSelection(mode: GameMode): number[] {
return Array.from({ length: BAG_COUNT }, (_, index) =>
mode === 'single' ? index + 1 : 2 ** index,
);
},
};
+25
View File
@@ -0,0 +1,25 @@
import type { GameMode } from '../types';
const shared = [
'The scale tells you more than a total. First calculate what the coins would weigh if every bag were normal.',
'If you take the same number from every bag, every suspect changes the reading by the same amount. That cannot identify a bag.',
];
const single = [
...shared,
'Give every bag a different “signature” by taking a different number of coins from each one.',
'Try 1 coin from Bag 01, 2 from Bag 02, and so on. The extra grams point directly to one bag.',
];
const multiple = [
...shared,
'Multiple bags can contribute extra grams at once, so ordinary consecutive counts can produce ambiguous sums.',
'You need counts where every combination has a unique sum. Think about how binary digits represent every number.',
'Use powers of two: 1, 2, 4, 8… The extra grams become a binary code for the complete set of heavy bags.',
];
export const Hints = {
for(mode: GameMode): string[] {
return mode === 'single' ? single : multiple;
},
};
+33
View File
@@ -0,0 +1,33 @@
import type { BagVisual, GameMode } from '../types';
const BAG_COLORS = [
'#E9734D', '#6878E8', '#38A880', '#D49A2F', '#AD63CC',
'#DD5A76', '#348DA8', '#839B3F', '#D06D36', '#5675A9',
];
const BAG_ICONS = ['◆', '✦', '●', '✹', '▲', '✿', '⬢', '✷', '◈', '✦'];
function shuffled<T>(values: T[]): T[] {
const copy = [...values];
for (let i = copy.length - 1; i > 0; i -= 1) {
const j = Math.floor(Math.random() * (i + 1));
[copy[i], copy[j]] = [copy[j], copy[i]];
}
return copy;
}
export const RandomGenerator = {
heavyBags(mode: GameMode): number[] {
if (mode === 'single') return [Math.floor(Math.random() * 10)];
return Array.from({ length: 10 }, (_, index) => index).filter(() => Math.random() < 0.5);
},
bagVisuals(): BagVisual[] {
const colors = shuffled(BAG_COLORS);
const icons = shuffled(BAG_ICONS);
return Array.from({ length: 10 }, (_, index) => ({
color: colors[index],
icon: icons[index],
}));
},
};
+11
View File
@@ -0,0 +1,11 @@
import type { GameMode } from '../types';
export const Scoring = {
calculate(won: boolean, mode: GameMode, totalCoins: number, hintsUsed: number): number {
if (!won) return 0;
const difficulty = mode === 'multiple' ? 750 : 400;
const efficiencyBonus = Math.max(0, 300 - Math.floor(totalCoins / 4));
const hintPenalty = hintsUsed * 75;
return Math.max(100, 500 + difficulty + efficiencyBonus - hintPenalty);
},
};
+33
View File
@@ -0,0 +1,33 @@
import { useCallback, useState } from 'react';
import type { GameStats } from '../types';
const STORAGE_KEY = 'heavy-metal-stats';
const EMPTY_STATS: GameStats = { gamesPlayed: 0, gamesWon: 0, totalCoinsSelected: 0, score: 0 };
function loadStats(): GameStats {
try {
const raw = localStorage.getItem(STORAGE_KEY);
return raw ? { ...EMPTY_STATS, ...JSON.parse(raw) } as GameStats : EMPTY_STATS;
} catch {
return EMPTY_STATS;
}
}
export function usePersistentStats() {
const [stats, setStats] = useState<GameStats>(loadStats);
const recordGame = useCallback((won: boolean, coins: number, score: number) => {
setStats((current) => {
const next = {
gamesPlayed: current.gamesPlayed + 1,
gamesWon: current.gamesWon + (won ? 1 : 0),
totalCoinsSelected: current.totalCoinsSelected + coins,
score: current.score + score,
};
localStorage.setItem(STORAGE_KEY, JSON.stringify(next));
return next;
});
}, []);
return { stats, recordGame };
}
+10
View File
@@ -0,0 +1,10 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
import './styles.css';
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
);
+180
View File
@@ -0,0 +1,180 @@
:root {
font-family: 'Manrope', system-ui, sans-serif;
color: #20221f;
background: #f3f0e7;
font-synthesis: none;
--bg: #f3f0e7;
--surface: #fbfaf5;
--surface-2: #ece9df;
--ink: #20221f;
--muted: #77776f;
--line: #d5d1c5;
--accent: #dc6040;
--accent-dark: #a53d26;
--navy: #253046;
--gold: #e4ad44;
--shadow: 0 20px 60px rgba(38, 34, 25, .10);
}
:root[data-theme='dark'] {
color: #eeece4;
background: #171a1c;
--bg: #171a1c;
--surface: #222628;
--surface-2: #2b3032;
--ink: #eeece4;
--muted: #a6a69f;
--line: #3a3f40;
--accent: #ef7958;
--accent-dark: #d05435;
--navy: #b7c5e7;
--shadow: 0 20px 60px rgba(0, 0, 0, .28);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.app-shell { min-height: 100vh; overflow: hidden; position: relative; }
.app-shell::before { content: ''; position: absolute; width: 520px; height: 520px; border: 1px solid color-mix(in srgb, var(--ink) 7%, transparent); border-radius: 50%; top: 90px; right: -210px; box-shadow: 0 0 0 80px color-mix(in srgb, var(--ink) 2%, transparent), 0 0 0 160px color-mix(in srgb, var(--ink) 1%, transparent); pointer-events: none; }
.site-header { max-width: 1440px; margin: auto; height: 82px; padding: 0 44px; display: flex; align-items: center; gap: 26px; position: relative; z-index: 2; }
.brand { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 12px; letter-spacing: .15em; font-size: 15px; }
.brand > span:last-child { display: flex; flex-wrap: wrap; width: 142px; line-height: 1; }
.brand strong { font-weight: 800; }
.brand small { display: block; width: 100%; color: var(--muted); font-size: 7px; letter-spacing: .19em; margin-top: 5px; }
.brand-mark { width: 35px; height: 35px; border: 2px solid var(--ink); border-radius: 50%; position: relative; display: block; }
.brand-mark i { position: absolute; width: 17px; height: 5px; border: 1px solid var(--ink); border-radius: 50%; background: var(--bg); left: 7px; }
.brand-mark i:nth-child(1) { top: 7px; }.brand-mark i:nth-child(2) { top: 13px; }.brand-mark i:nth-child(3) { top: 19px; }
.header-rule { height: 1px; background: var(--line); flex: 1; }
.theme-toggle, .restart-button { border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 75%, transparent); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: .2s ease; }
.theme-toggle { width: 42px; height: 42px; border-radius: 50%; }
.theme-toggle:hover, .restart-button:hover { border-color: var(--ink); transform: translateY(-1px); }
main { position: relative; z-index: 1; }
.hero-copy { max-width: 1352px; margin: 0 auto; min-height: 280px; padding: 46px 50px 38px; display: flex; align-items: flex-end; justify-content: space-between; gap: 50px; }
.hero-copy > div:first-child { max-width: 700px; }
.eyebrow { color: var(--accent); letter-spacing: .16em; font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; gap: 7px; }
h1 { font-size: clamp(44px, 6vw, 78px); line-height: .95; letter-spacing: -.065em; margin: 16px 0 18px; font-weight: 600; }
h1 em { color: var(--accent); font-style: italic; font-family: Georgia, serif; font-weight: 400; }
.hero-copy p { color: var(--muted); font-size: 15px; line-height: 1.7; max-width: 560px; margin: 0; }
.mode-switch { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 5px; display: flex; box-shadow: var(--shadow); flex: none; }
.mode-switch button { width: 176px; min-height: 78px; border: 0; background: transparent; border-radius: 7px; cursor: pointer; text-align: left; padding: 12px 15px 12px 43px; position: relative; transition: .2s ease; }
.mode-switch button > span { position: absolute; left: 14px; top: 14px; color: var(--muted); font: 500 10px 'DM Mono', monospace; }
.mode-switch strong, .mode-switch small { display: block; }.mode-switch strong { font-size: 13px; }.mode-switch small { color: var(--muted); font-size: 9px; margin-top: 5px; }
.mode-switch button.active { background: var(--navy); color: var(--bg); box-shadow: 0 7px 18px rgba(28, 39, 57, .2); }
.mode-switch button.active span, .mode-switch button.active small { color: color-mix(in srgb, var(--bg) 65%, transparent); }
.game-workspace { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 34px max(28px, calc((100vw - 1340px) / 2)) 48px; }
.workspace-heading { display: flex; justify-content: space-between; align-items: center; gap: 30px; margin-bottom: 24px; }
.step-badge { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); border-radius: 99px; padding: 5px 9px; font: 500 9px 'DM Mono', monospace; letter-spacing: .1em; }
.workspace-heading h2 { font-size: 25px; letter-spacing: -.035em; margin: 10px 0 3px; }
.workspace-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.restart-button { gap: 7px; border-radius: 99px; padding: 9px 13px; font-size: 11px; font-weight: 700; background: var(--surface); }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 292px; gap: 24px; align-items: start; }
.bag-grid { display: grid; grid-template-columns: repeat(5, minmax(118px, 1fr)); gap: 12px; }
.bag-card { --bag-color: #6878e8; min-width: 0; background: color-mix(in srgb, var(--bag-color) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bag-color) 23%, var(--line)); border-radius: 9px; padding: 11px; min-height: 205px; position: relative; overflow: hidden; transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease; animation: rise-in .45s both; }
.bag-card:nth-child(2) { animation-delay: .03s }.bag-card:nth-child(3) { animation-delay: .06s }.bag-card:nth-child(4) { animation-delay: .09s }.bag-card:nth-child(5) { animation-delay: .12s }.bag-card:nth-child(6) { animation-delay: .15s }.bag-card:nth-child(7) { animation-delay: .18s }.bag-card:nth-child(8) { animation-delay: .21s }.bag-card:nth-child(9) { animation-delay: .24s }.bag-card:nth-child(10) { animation-delay: .27s }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } }
.bag-topline { display: flex; justify-content: space-between; align-items: center; }
.bag-number { color: var(--bag-color); font: 500 12px 'DM Mono', monospace; }
.bag-status { font: 500 7px 'DM Mono', monospace; letter-spacing: .08em; color: var(--muted); }
.bag-illustration { height: 98px; display: flex; justify-content: center; align-items: center; position: relative; }
.bag-body { display: grid; place-items: center; position: absolute; bottom: 5px; width: 78px; height: 68px; border-radius: 27px 27px 22px 22px; color: #fff; background: var(--bag-color); box-shadow: inset -12px -8px 18px rgba(0,0,0,.1), 0 8px 14px color-mix(in srgb, var(--bag-color) 24%, transparent); clip-path: polygon(20% 0, 80% 0, 100% 100%, 0 100%); }
.bag-body::before { content: ''; position: absolute; width: 48px; height: 10px; top: 4px; border-top: 3px solid rgba(255,255,255,.7); border-radius: 50%; }
.bag-body span { font-size: 24px; filter: brightness(1.4); opacity: .8; transform: translateY(7px); }
.bag-knot { width: 44px; height: 22px; background: var(--bag-color); clip-path: polygon(15% 0, 48% 28%, 85% 0, 73% 100%, 25% 100%); position: absolute; top: 7px; }
.stepper { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; height: 43px; display: grid; grid-template-columns: 29px 1fr 29px; align-items: center; }
.stepper button { border: 0; background: transparent; color: var(--muted); cursor: pointer; height: 100%; display: grid; place-items: center; }
.stepper button:hover { color: var(--accent); }
.stepper label { min-width: 0; text-align: center; line-height: 1; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.stepper input { display: block; color: var(--ink); background: transparent; border: 0; outline: 0; width: 100%; text-align: center; font: 500 14px 'DM Mono', monospace; appearance: textfield; }
.stepper input::-webkit-inner-spin-button { appearance: none; }
.stepper small { font-size: 7px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.bag-card.is-pickable { cursor: pointer; }
.bag-card.is-pickable:hover { transform: translateY(-3px); box-shadow: 0 10px 25px color-mix(in srgb, var(--bag-color) 15%, transparent); }
.bag-card.is-selected { border: 2px solid var(--bag-color); background: color-mix(in srgb, var(--bag-color) 14%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bag-color) 12%, transparent); }
.locked-count { height: 43px; border-top: 1px solid var(--line); padding-top: 9px; text-align: center; font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.locked-count span { color: var(--ink); font: 500 13px 'DM Mono', monospace; display: block; }
.right-rail { display: grid; gap: 14px; }
.scale-panel { background: #c9c7be; padding: 16px 15px 15px; border-radius: 11px; box-shadow: inset 0 1px rgba(255,255,255,.8), 0 12px 30px rgba(30,30,25,.12); position: relative; }
:root[data-theme='dark'] .scale-panel { background: #444949; }
.scale-platform { width: 72%; height: 20px; margin: 4px auto 0; background: linear-gradient(#efeee9, #9c9d98); border-radius: 50%; box-shadow: 0 7px 0 #777a77, 0 9px 10px rgba(0,0,0,.3); position: relative; z-index: 2; }
.scale-neck { height: 22px; width: 56%; margin: 0 auto; background: linear-gradient(90deg, #8d8e88, #d8d7d1, #90928f); clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%); }
.coin-stack { position: absolute; left: 50%; transform: translateX(-50%); bottom: 13px; width: 48px; }
.coin-stack i { display: block; height: 9px; width: 48px; border-radius: 50%; margin-top: -4px; background: #e9ae36; border: 1px solid #ad781c; box-shadow: inset 0 2px #ffd76a; }
.scale-panel.is-weighing .scale-platform { animation: scale-bob .28s ease-in-out infinite alternate; }
@keyframes scale-bob { to { transform: translateY(2px); } }
.scale-console { background: #32363a; border-radius: 7px; padding: 10px; color: #f5f2e7; box-shadow: inset 0 1px rgba(255,255,255,.15); }
.scale-brand { font: 700 8px 'DM Mono', monospace; letter-spacing: .08em; display: flex; align-items: center; gap: 5px; margin: 0 2px 8px; color: #d9d8d2; }
.scale-brand span { margin-left: auto; color: #7f8587; }
.scale-readout { position: relative; background: #bdd0a9; color: #253329; min-height: 83px; border: 5px solid #1d2022; border-radius: 5px; padding: 8px 10px; font-family: 'DM Mono', monospace; box-shadow: inset 0 0 14px rgba(40,64,38,.2); }
.readout-label { font-size: 7px; letter-spacing: .12em; display: block; opacity: .65; }
.scale-readout strong { display: inline-block; max-width: 85%; overflow: hidden; font-size: clamp(24px, 2.4vw, 34px); line-height: 1.3; letter-spacing: -.08em; }
.readout-unit { font-size: 12px; margin-left: 4px; }
.readout-meta { display: flex; justify-content: space-between; border-top: 1px solid rgba(37,51,41,.25); padding-top: 4px; font-size: 6px; letter-spacing: .08em; }
.weigh-button { margin-top: 9px; width: 100%; border: 0; border-radius: 4px; height: 39px; background: var(--accent); color: #fff; font: 700 10px 'DM Mono', monospace; letter-spacing: .09em; cursor: pointer; box-shadow: inset 0 1px rgba(255,255,255,.25), 0 3px 0 var(--accent-dark); transition: .15s ease; }
.weigh-button:not(:disabled):hover { filter: brightness(1.08); transform: translateY(-1px); }
.weigh-button:disabled { background: #626669; box-shadow: inset 0 1px rgba(255,255,255,.1); color: #929697; cursor: not-allowed; }
.button-led { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; margin-right: 7px; }
.scale-console > p { color: #8c9091; margin: 9px 0 0; text-align: center; font-size: 7px; letter-spacing: .04em; }
.hint-card { background: color-mix(in srgb, var(--gold) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--gold) 35%, var(--line)); border-radius: 9px; padding: 14px; min-height: 132px; }
.hint-heading { display: flex; justify-content: space-between; color: #ba7e17; font: 700 9px 'DM Mono', monospace; letter-spacing: .1em; }
.hint-heading span { display: flex; align-items: center; gap: 6px; }.hint-heading small { font: inherit; opacity: .7; }
.hint-card p { color: var(--muted); font-size: 10px; line-height: 1.55; margin: 12px 0; min-height: 32px; }
.hint-card .hint-text { color: var(--ink); animation: hint-in .25s ease; }
@keyframes hint-in { from { opacity: 0; transform: translateY(3px); } }
.hint-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.hint-card button { border: 0; background: transparent; color: #b57811; padding: 0; font-size: 9px; font-weight: 800; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.hint-card button:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.hint-card .fill-button { color: var(--accent); }
.round-score { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; align-items: baseline; justify-content: flex-end; gap: 5px; }
.round-score span { margin-right: auto; color: var(--muted); font: 500 8px 'DM Mono', monospace; letter-spacing: .09em; }.round-score strong { font: 500 18px 'DM Mono', monospace; }.round-score small { color: var(--muted); font-size: 8px; }
.guess-bar { margin-top: 14px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px; min-height: 64px; padding: 10px 12px 10px 18px; display: flex; justify-content: space-between; align-items: center; gap: 15px; font-size: 11px; color: var(--muted); animation: rise-in .3s ease both; }
.primary-action { border: 0; background: var(--accent); color: white; padding: 12px 18px; border-radius: 5px; cursor: pointer; font: 800 10px 'DM Mono', monospace; letter-spacing: .08em; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 0 var(--accent-dark); }
.primary-action:hover { filter: brightness(1.05); transform: translateY(-1px); }.primary-action:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.stats-bar { max-width: 1050px; margin: 34px auto; display: grid; grid-template-columns: 1.35fr repeat(4, 1fr); border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 75%, transparent); border-radius: 10px; box-shadow: var(--shadow); }
.stats-bar > div { padding: 16px 23px; display: flex; align-items: center; gap: 12px; border-right: 1px solid var(--line); color: var(--muted); }.stats-bar > div:last-child { border: 0; }
.stats-bar .stat-primary { color: var(--accent); }
.stats-bar span, .stats-bar small, .stats-bar strong { display: block; }.stats-bar small { color: var(--muted); font: 500 7px 'DM Mono', monospace; letter-spacing: .1em; }.stats-bar strong { color: var(--ink); font: 500 17px 'DM Mono', monospace; margin-top: 3px; }
footer { max-width: 1352px; margin: auto; border-top: 1px solid var(--line); padding: 24px 8px 34px; color: var(--muted); font: 500 9px 'DM Mono', monospace; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; }
footer span { color: var(--ink); font-weight: 700; } footer i { width: 3px; height: 3px; background: var(--accent); border-radius: 50%; } footer p { margin: 0 0 0 auto; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(19, 21, 20, .64); backdrop-filter: blur(6px); padding: 20px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.result-modal { width: min(430px, 100%); background: var(--surface); color: var(--ink); border-radius: 14px; padding: 38px; text-align: center; position: relative; box-shadow: 0 30px 90px rgba(0,0,0,.35); animation: modal-in .35s cubic-bezier(.2,.8,.2,1.15); }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
.modal-close { position: absolute; right: 12px; top: 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.result-emblem { width: 68px; height: 68px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--accent); box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 12%, transparent); font-size: 30px; font-weight: 800; }
.result-modal.won .result-emblem { background: #3b9d78; box-shadow: 0 0 0 8px color-mix(in srgb, #3b9d78 12%, transparent); }
.result-modal h2 { margin: 9px 0 8px; font-size: 28px; letter-spacing: -.04em; }.result-modal > p { color: var(--muted); font-size: 13px; line-height: 1.6; }.result-modal > p strong { color: var(--ink); }
.score-award { margin: 22px 0; padding: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }.score-award span { color: var(--muted); font: 500 8px 'DM Mono', monospace; letter-spacing: .1em; display: block; }.score-award strong { color: #3b9d78; font: 500 26px 'DM Mono', monospace; }
.result-modal .primary-action { width: 100%; margin-top: 12px; }
.result-tip { background: var(--surface-2); padding: 12px; border-radius: 7px; }
.confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 21; }
.confetti i { position: absolute; left: var(--x); top: -20px; width: 9px; height: 16px; background: var(--confetti); animation: confetti-fall 2.1s var(--delay) ease-in forwards; }
@keyframes confetti-fall { to { transform: translate(calc((var(--x) - 50%) * -.15), 105vh) rotate(720deg); } }
@media (max-width: 1050px) {
.hero-copy { align-items: center; }.game-layout { grid-template-columns: 1fr; }.right-rail { grid-template-columns: 1fr 1fr; }.round-score { display: none; }.scale-panel { grid-row: span 2; }.bag-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 760px) {
.site-header { padding: 0 20px; height: 70px; }.hero-copy { padding: 35px 22px 30px; display: block; }.mode-switch { margin-top: 30px; width: 100%; }.mode-switch button { flex: 1; width: auto; }.game-workspace { padding: 28px 16px 38px; }.bag-grid { grid-template-columns: repeat(2, 1fr); }.game-layout { display: block; }.right-rail { display: grid; grid-template-columns: 1fr; margin-top: 18px; }.workspace-heading { align-items: flex-start; }.scale-panel { max-width: 420px; width: 100%; margin: auto; }.stats-bar { margin: 25px 16px; grid-template-columns: 1fr 1fr; }.stats-bar > div { border-bottom: 1px solid var(--line); }.stats-bar > div:nth-child(even) { border-right: 0; }.stats-bar > div:last-child { grid-column: 1 / -1; border-bottom: 0; } footer { margin: 0 16px; } footer p { display: none; }
}
@media (max-width: 430px) {
.brand > span:last-child { width: 126px; font-size: 13px; }.hero-copy { min-height: 0; }.mode-switch button { min-height: 70px; padding-left: 35px; padding-right: 7px; }.mode-switch button > span { left: 9px; }.mode-switch small { display: none; }.workspace-heading h2 { font-size: 22px; }.restart-button { font-size: 0; width: 37px; height: 37px; padding: 0; }.restart-button svg { width: 16px; }.bag-card { min-height: 192px; }.guess-bar { align-items: stretch; flex-direction: column; }.stats-bar > div { padding: 14px; }.result-modal { padding: 34px 22px; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
+28
View File
@@ -0,0 +1,28 @@
export type GameMode = 'single' | 'multiple';
export type GamePhase = 'selecting' | 'identifying' | 'result';
export type Theme = 'light' | 'dark';
export interface BagVisual {
color: string;
icon: string;
}
export interface GameState {
mode: GameMode;
heavyBags: number[];
bagVisuals: BagVisual[];
}
export interface GameStats {
gamesPlayed: number;
gamesWon: number;
totalCoinsSelected: number;
score: number;
}
export interface GameResult {
won: boolean;
scoreEarned: number;
heavyBags: number[];
selectedBags: number[];
}
+1
View File
@@ -0,0 +1 @@
/// <reference types="vite/client" />
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ES2022",
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"]
}
+7
View File
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
+11
View File
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true,
"allowImportingTsExtensions": true
},
"include": ["vite.config.ts"]
}
+9
View File
@@ -0,0 +1,9 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
// Relative asset URLs work both on GitHub's /heavy-metal/ path and on a
// custom domain mounted at the root, without requiring separate builds.
base: './',
});