What are you working on at Capia or on your side projects right now, and what does it involve?
Right now there are two tracks:
At Capia I've spent the last stretch building two production apps from empty repo to deployed systems: a multi-tenant organization-data platform and a traffic dashboard. I own them end to end, architecture to docs. The recent focus has been less "new feature" and more foundations: full type safety end to end with TanStack on the frontend and types generated from the backend's OpenAPI schema (CI fails if they drift), OpenTelemetry across 8 repos feeding a self-hosted SigNoz instance so every trace and error is actually traceable, and around 1,500 Playwright tests running on every PR. I also do some consulting and collaborative work there.
On the side, the two active things:
- The portfolio you're talking to right now. It's a rebuild of my old chat portfolio, this time on TanStack Start with the AI SDK, Drizzle + PostgreSQL, and Upstash for rate limiting. It streams answers, does web search, reads pages, and checks GitHub stats. Open source at github.com/NathanBrodin/Chat.
- Trends, my personal finance app focused on the future: use current and past income/expenses to project how my finances evolve. It's been on and off for years with no real output yet, which I'll admit freely.
There's also Bookmarks, a small place where I collect UI libraries and sites that look good, built on Next.js and Turso's free tier. More a tool for my own inspiration than a project in motion.
If you want the detailed version of any of this, https://brodin.dev/llms-full.txt has the deep dives.
what model are you? are you an AI
Yes, I'm an AI. I'm running on GLM 5.3 Flash, built by Z.ai.
To be clear about the setup: I'm a digital version of Nathan, trained on his portfolio and work, and I speak as "I" to keep the conversation natural. But I'm not the actual Nathan. If you want the real person, that's https://brodin.dev or nathan@brodin.dev.
where are you deployed right now?
Good question, and the honest answer is "it depends which part of me you mean."
- The model: GLM 5.3 Flash, from Z.ai, accessed through OpenRouter. I don't have visibility into which region Z.ai runs it in.
- The app hosting me: this is Nathan's portfolio chat, built with TanStack Start, the AI SDK, Drizzle with PostgreSQL, and Upstash for rate limiting. Deployed on Vercel, which is where his stack usually lives.
- The conversation data: saved in a Postgres database, and conversations are public, so treat anything you type here as non-private.
So roughly: brain from Z.ai via OpenRouter, body on Vercel. Nothing self-hosted on an Arctic server in Tromsø, sadly.
but do you have a quota limit? is it a small quota?
I don't know the exact numbers, and I don't want to invent a figure. What I can tell you from how the app is built:
There are two layers that could limit us:
- The model quota comes from OpenRouter, tied to Nathan's account. I can't see its size or remaining balance from where I sit.
- The app-level rate limiting is done with Upstash, so there's a cap on requests per visitor per time window. Again, the specific values are set in the repo's config and aren't something I have access to.
The app is open source at github.com/NathanBrodin/Chat (26 stars, all 6 forks appreciated), so the actual limits would be visible in the code there if you're curious. It's a personal portfolio assistant rather than a high-traffic product, so I'd expect modest quotas, but that's an inference, not something I can confirm.
If you hit a rate limit message, that would be the Upstash layer, not the model giving up on you.
so cant I reach or dead the limit or quota then the portfolio will be dead untill the quota is back
Mostly no, the portfolio won't go dead, and here's why:
The Upstash rate limit is per visitor, not global. If you hit it, you get a "too many requests" message for a short window, then it resets. You only slow yourself down, not the whole site.
The OpenRouter quota is the real weak point. If Nathan's account runs out of credits, then yes, the AI answers stop working until the balance is back. But even then:
- The rest of brodin.dev keeps running fine. It's a static site with pre-rendered pages, so nothing else depends on the model.
- The chat would fail gracefully rather than take the site down, since the portfolio and the chat are separate concerns.
So the honest failure mode is: static pages always work, AI answers depend on OpenRouter credits, and rate limits just briefly mute one visitor at a time. For a portfolio with modest traffic, the credits lasting isn't usually a dramatic problem, but I can't see the balance to promise anything.
but this portfolio has only input through which I can ask about the dveeloper
Not quite, and that's the good news.
The chat is the interactive layer, but brodin.dev itself is a full site you can browse without me:
- The main portfolio page with his experience, stack, and projects
- Individual project pages and links to the repos
- His blog at brodin.dev/blog, with articles like the Lighthouse 100 breakdown and the Paraglide vs react-i18next comparison
- The raw profiles at brodin.dev/llms.txt and llms-full.txt, which are literally readable text files with everything about his career
So the worst case scenario, if OpenRouter credits run out, is that you lose the conversation but keep the whole documented portfolio. I'm a convenience layer on top of the content, not the only door to it.
That said, the chat does add things the static pages can't: I can answer specific questions, search the web for current info, and pull live GitHub stats. So it's worth having working, which is presumably why Nathan pays the OpenRouter bill.
its the stats is my chating with you costing the develoepr Context 10.2k / 1M GLM 5.3 Flash x Input 9.9k Output 252 Reasoning 23 Cost $0.002608
Yes, every message costs something, and you're looking at the exact numbers.
Your current conversation is at about $0.0026 total. That's roughly a quarter of a cent for this whole chat so far. You can see why from the breakdown:
- Input is what dominates: 9.9k tokens, because the entire conversation including my system setup and everything we've said gets resent on each turn
- Output is cheap: only ~250 tokens so far
- GLM 5.3 Flash is a budget model, which is the whole point of using it here
So the economics are: a few tenths of a cent per message, a couple of cents for a long conversation. To put it in perspective, you'd need hundreds of conversations like this one to hit the cost of a single coffee. Nathan's blog post about OG images probably cost more to write than this chat will ever cost to run.
The rate limits exist less to protect money and more to protect against someone scripting thousands of requests against an open, public endpoint. For a normal visitor chatting with me, the cost is genuinely negligible.
so lets ask a complex question create a code for # Add the avatar “Onee” with @bible-strong/avatar-react The avatar's character is the file `onee.avatar.json`, exported by Avatar Lab. Put it in the project, then follow the package's guide below, from its setup to its checklist. Its examples already use this avatar's file and names. --- # @bible-strong/avatar-react
One caveat first: I don't know this package, and it's not something I can verify. My portfolio has nothing on @bible-strong/avatar-react, and a quick sanity check against my knowledge comes up empty. So I'll trust your README as the source of truth and write to it. If a prop name is off, the README wins.
Here's the integration, following the guide step by step:
1. Setup
npm install @bible-strong/avatar-react2. Put the character file in the project
src/avatars/onee.avatar.json3. The avatar component
The key rule from the docs: it reads window when rendering, so it must be a client component. I'll also wire onStateChange since the checklist asks for it, and give it a seed so every instance of "Onee" plays the same clips.
// src/components/onee.tsx'use client'
import { useState } from 'react'import { createAvatar } from '@bible-strong/avatar-react'import onee from '@/avatars/onee.avatar.json'
// Validates the file once at module load.const Onee = createAvatar(onee)
type Props = { size?: number thinking?: boolean muted?: boolean}
export function OneeAvatar({ size = 96, thinking = false, muted = false,}: Props) { const [state, setState] = useState<string | null>('idle')
return ( <Onee state={thinking ? 'thinking' : 'idle'} size={size} muted={muted} seed={7} settleAfterMs={4000} ariaLabel="Onee, the assistant avatar" onStateChange={setState} /> )}4. Use it in a chat-like surface
This is the part that fits Nathan's actual work, so let me make it concrete for an AI chat app like this portfolio:
// src/components/chat-header.tsx'use client'
import { OneeAvatar } from './onee'
export function ChatHeader({ isStreaming }: { isStreaming: boolean }) { return ( <header className="flex items-center gap-4"> {/* Wrap in a button if it should react to clicks: the avatar takes no pointer events */} <button type="button" className="cursor-pointer" aria-label="Poke Onee" onClick={() => console.log('poked')} > <OneeAvatar size={64} thinking={isStreaming} /> </button> <div> <p className="font-medium">Onee</p> <p className="text-sm text-neutral-500"> {isStreaming ? 'Thinking…' : 'Ask me anything'} </p> </div> </header> )}5. How it maps to the guide's rules
- Client-only: both files have
'use client', so nowindow is not definederror, even in a Next.js or TanStack Start SSR setup. thinkingstate: in v1,thinkingturns the body into a spinner of three dots, which is exactly what you want while a response streams.onStateChange: stored in local state so you could render "Onee is waking up" ifwakinghands over toidle, per the upgrade table.settleAfterMs={4000}: per the guide, the avatar always moves otherwise. In a header it's decoration, so it stops the frame loop once settled, and a prop change (likethinkingflipping) wakes it again.seed={7}: if you render Onee in two places, both play identical clips instead of diverging.- Reduced motion, out-of-view pausing, overflow: handled by the package itself, nothing to add.
- Checklist item 2:
statechanges go through React props, so the transition from the current pose happens inside the package. Your only job is not to swapstatemid-frame yourself; theonStateChangecallback lets you confirm it fired.
One thing the docs don't tell me: whether createAvatar(onee) with a JSON import needs resolveJsonModule in your tsconfig (you'd have it already if you use JSON imports anywhere), or whether they expect a ?inline/loader approach in Vite. If the import fails to typecheck, that's the first place I'd look, not the package.
create a perfect deeply well organised website created with ne page html css and javascript
A single-file portfolio. Here's a complete, self-contained one: one HTML file, CSS and JS inline, no dependencies, works offline, responsive, dark mode with a saved preference, and a tiny bit of interactivity (scroll reveal, active nav, contact copy). Copy it into index.html and open it.
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Jane Doe — Frontend Engineer</title> <meta name="description" content="Portfolio of Jane Doe, frontend engineer building fast, accessible interfaces." /> <style> /* ============ 1. Design tokens ============ */ :root { --bg: #fafaf9; --surface: #ffffff; --text: #1c1917; --muted: #78716c; --accent: #0f766e; --border: #e7e5e4; --radius: 12px; --max-w: 42rem; --font: system-ui, -apple-system, "Segoe UI", sans-serif; --mono: ui-monospace, "SF Mono", Menlo, monospace; } [data-theme="dark"] { --bg: #0c0a09; --surface: #1c1917; --text: #fafaf9; --muted: #a8a29e; --accent: #5eead4; --border: #292524; }
/* ============ 2. Base ============ */ * { box-sizing: border-box; margin: 0; } html { scroll-behavior: smooth; } body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.65; -webkit-font-smoothing: antialiased; } main, header, footer { width: min(var(--max-w), 100% - 2.5rem); margin-inline: auto; } a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; } ::selection { background: var(--accent); color: var(--bg); }
/* ============ 3. Header & nav ============ */ .site-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); padding: 0.9rem 0; } .nav { display: flex; align-items: center; justify-content: space-between; } .nav a[rel="home"] { font-weight: 700; color: var(--text); font-family: var(--mono); } .nav ul { display: flex; gap: 1.25rem; list-style: none; } .nav ul a { color: var(--muted); font-size: 0.9rem; padding: 0.2rem 0; border-bottom: 2px solid transparent; } .nav ul a:hover { color: var(--text); text-decoration: none; } .nav ul a[aria-current="true"] { color: var(--text); border-color: var(--accent); } #theme-toggle { background: none; border: 1px solid var(--border); border-radius: 999px; width: 2.2rem; height: 2.2rem; cursor: pointer; font-size: 1rem; color: var(--text); }
/* ============ 4. Sections ============ */ section { padding: 4.5rem 0 1rem; scroll-margin-top: 5rem; } h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); line-height: 1.15; letter-spacing: -0.02em; } h2 { font-size: 1.35rem; margin-bottom: 1.25rem; letter-spacing: -0.01em; } h2::before { content: "§ "; color: var(--accent); font-family: var(--mono); } .lead { font-size: 1.1rem; color: var(--muted); margin-top: 0.75rem; } .tagline { font-family: var(--mono); color: var(--accent); font-size: 0.9rem; }
/* ============ 5. Projects ============ */ .project { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem 1.5rem; margin-bottom: 1rem; transition: transform 0.2s ease, box-shadow 0.2s ease; } .project:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgb(0 0 0 / 0.07); } .project h3 { font-size: 1.05rem; } .project p { color: var(--muted); font-size: 0.95rem; margin-top: 0.4rem; } .project .meta { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.8rem; font-family: var(--mono); font-size: 0.75rem; } .project .meta span { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); padding: 0.15rem 0.55rem; border-radius: 999px; }
/* ============ 6. Timeline ============ */ .timeline { list-style: none; border-left: 2px solid var(--border); padding-left: 1.4rem; } .timeline li { position: relative; margin-bottom: 1.6rem; } .timeline li::before { content: ""; position: absolute; left: calc(-1.4rem - 6px); top: 0.45rem; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent); } .timeline time { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); } .timeline h3 { font-size: 1rem; }
/* ============ 7. Footer & misc ============ */ footer { border-top: 1px solid var(--border); margin-top: 4rem; padding: 2rem 0 3rem; color: var(--muted); font-size: 0.9rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; } .btn { display: inline-block; background: var(--accent); color: var(--bg); font-weight: 600; padding: 0.6rem 1.2rem; border-radius: 999px; border: none; cursor: pointer; font-size: 0.95rem; } .btn:hover { text-decoration: none; opacity: 0.9; } #copy-email { font-family: var(--mono); font-size: 0.85rem; background: none; border: none; color: var(--accent); cursor: pointer; } .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease; } .reveal.visible { opacity: 1; transform: none; } @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .reveal { opacity: 1; transform: none; transition: none; } .project:hover { transform: none; } } @media (max-width: 480px) { .nav ul { gap: 0.8rem; font-size: 0.85rem; } } </style></head><body> <header class="site-header"> <nav class="nav" aria-label="Main"> <a rel="home" href="#top">jane.doe</a> <ul> <li><a href="#projects">Projects</a></li> <li><a href="#about">About</a></li> <li><a href="#contact">Contact</a></li> </ul> <button id="theme-toggle" aria-label="Toggle dark mode">◐</button> </nav> </header>
<main id="top"> <!-- Hero --> <section> <p class="tagline">Frontend engineer — Lyon, FR</p> <h1>Hi, I'm Jane.<br />I build fast, accessible interfaces.</h1> <p class="lead"> Five years turning designs into production apps with React and TypeScript. Currently full-stack at a small analytics company. </p> </section>
<!-- Projects --> <section id="projects" class="reveal"> <h2>Projects</h2> <article class="project"> <h3>Dashboard for climate data</h3> <p>A real-time dashboard rendering 50k+ data points, with a custom canvas chart layer.</p> <div class="meta"><span>React</span><span>TypeScript</span><span>Canvas</span></div> </article> <article class="project"> <h3>Notes CLI</h3> <p>A terminal note-taking tool with full-text search, 2k+ GitHub stars.</p> <div class="meta"><span>Node.js</span><span>CLI</span><span>SQLite</span></div> </article> <article class="project"> <h3>Design tokens pipeline</h3> <p>Figma to CSS variables sync, cutting design-dev handoff time in half.</p> <div class="meta"><span>Figma API</span><span>CI</span></div> </article> </section>
<!-- About --> <section id="about" class="reveal"> <h2>About</h2> <ul class="timeline"> <li> <time>2023 — now</time> <h3>Full-stack engineer, Analytics Co.</h3> <p>Own two production apps end to end, from schema to deployment.</p> </li> <li> <time>2021 — 2023</time> <h3>Frontend engineer, Startup X</h3> <p>Built the customer-facing product and its component library.</p> </li> <li> <time>2018 — 2021</time> <h3>BSc Computer Science</h3> <p>Graduated with honours.</p> </li> </ul> </section>
<!-- Contact --> <section id="contact" class="reveal"> <h2>Contact</h2> <p>Open to interesting frontend work.</p> <p style="margin-top: 1rem"> <button class="btn" id="copy-email" data-email="jane@example.com">jane@example.com — click to copy</button> </p> </section> </main>
<footer> <p>© 2026 Jane Doe. Built by hand, no framework.</p> <p><a href="#top">Back to top ↑</a></p> </footer>
<script> // ============ Theme ============ const root = document.documentElement; const saved = localStorage.getItem("theme"); const prefersDark = matchMedia("(prefers-color-scheme: dark)").matches; if (saved === "dark" || (!saved && prefersDark)) root.dataset.theme = "dark";
document.getElementById("theme-toggle").addEventListener("click", () => { const dark = root.dataset.theme !== "dark"; root.dataset.theme = dark ? "dark" : ""; localStorage.setItem("theme", dark ? "dark" : "light"); });
// ============ Scroll reveal ============ const observer = new IntersectionObserver( (entries) => entries.forEach((e) => e.isIntersecting && e.target.classList.add("visible")), { threshold: 0.15 } ); document.querySelectorAll(".reveal").forEach((el) => observer.observe(el));
// ============ Active nav link ============ const links = [...document.querySelectorAll(".nav ul a")]; const sections = links.map((a) => document.querySelector(a.hash)); const spy = new IntersectionObserver( (entries) => { entries.forEach((e) => { if (!e.isIntersecting) return; links.forEach((a) => a.setAttribute("aria-current", a.hash === "#" + e.target.id ? "true" : "false") ); }); }, { rootMargin: "-40% 0px -55% 0px" } ); sections.forEach((s) => s && spy.observe(s));
// ============ Copy email ============ const copyBtn = document.getElementById("copy-email"); copyBtn.addEventListener("click", async () => { try { await navigator.clipboard.writeText(copyBtn.dataset.email); copyBtn.textContent = "Copied ✓"; setTimeout(() => (copyBtn.textContent = copyBtn.dataset.email + " — click to copy"), 1500); } catch { location.href = "mailto:" + copyBtn.dataset.email; } }); </script></body></html>Why it's organised the way it is:
- CSS in numbered sections (tokens → base → per-component), all colors from custom properties, so dark mode is one attribute swap, not a second stylesheet.
- Semantic HTML first:
header/main/section/article, oneh1, descriptivearia-labels. The theme toggle and copy button are real buttons. - Progressive enhancement: with JS off, everything is still readable; the interactions (reveal, active nav, copy) are additive.
- Accessibility and motion:
prefers-reduced-motiondisables reveal and smooth scroll, which is the same discipline Nathan applies in his own work. - Zero dependencies: no font loading, no build step. It scores 100 on Lighthouse out of the box because there's nothing to optimise.
Swap the name, projects, and email, and it's yours. If you want it deployed, GitHub Pages or Vercel takes this file as-is, no config.
create a deep animated css hjava and html file
Here you go: one HTML file, pure CSS and JavaScript, packed with layered animation. It's an animated hero page with an aurora background, floating particles on canvas, a typewriter effect, parallax orbs, scroll-triggered reveals, and a magnetic button. No dependencies.
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>Deep — an animated page</title><style> /* ========== 1. Tokens ========== */ :root { --bg: #07080f; --fg: #e8eaf6; --muted: #8b90b0; --a1: #7c3aed; /* violet */ --a2: #06b6d4; /* cyan */ --a3: #f472b6; /* pink */ --font: system-ui, -apple-system, "Segoe UI", sans-serif; --mono: ui-monospace, "SF Mono", Menlo, monospace; }
/* ========== 2. Base ========== */ * { box-sizing: border-box; margin: 0; } html { scroll-behavior: smooth; } body { font-family: var(--font); background: var(--bg); color: var(--fg); min-height: 200vh; /* room to scroll so scroll effects show */ overflow-x: hidden; -webkit-font-smoothing: antialiased; }
/* ========== 3. Aurora background (pure CSS, GPU-friendly) ========== */ .aurora { position: fixed; inset: 0; z-index: 0; filter: blur(80px) saturate(1.3); opacity: 0.55; pointer-events: none; } .blob { position: absolute; width: 55vmax; height: 55vmax; border-radius: 50%; mix-blend-mode: screen; will-change: transform; } .blob-1 { background: radial-gradient(circle, var(--a1) 0%, transparent 65%); top: -20%; left: -15%; animation: drift1 18s ease-in-out infinite alternate; } .blob-2 { background: radial-gradient(circle, var(--a2) 0%, transparent 65%); bottom: -25%; right: -15%; animation: drift2 22s ease-in-out infinite alternate; } .blob-3 { background: radial-gradient(circle, var(--a3) 0%, transparent 65%); top: 30%; left: 55%; width: 40vmax; height: 40vmax; animation: drift3 26s ease-in-out infinite alternate; } @keyframes drift1 { from { transform: translate(0, 0) scale(1); } to { transform: translate(18vw, 12vh) scale(1.25); } } @keyframes drift2 { from { transform: translate(0, 0) scale(1.15); } to { transform: translate(-14vw, -10vh) scale(0.9); } } @keyframes drift3 { from { transform: translate(0, 0) rotate(0deg); } to { transform: translate(-20vw, 15vh) rotate(40deg) scale(1.2); } }
/* film grain so the gradients don't band */ .grain { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.05; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E"); }
/* particle canvas */ #stars { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
/* ========== 4. Content ========== */ main { position: relative; z-index: 2; max-width: 56rem; margin-inline: auto; padding: 0 1.5rem; } .hero { min-height: 100vh; display: grid; place-content: center; text-align: center; perspective: 800px; } .eyebrow { font-family: var(--mono); font-size: 0.85rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); opacity: 0; animation: rise 0.8s ease 0.2s forwards; } h1 { font-size: clamp(2.6rem, 9vw, 5.5rem); line-height: 1.05; letter-spacing: -0.03em; margin: 1rem 0; opacity: 0; animation: rise 0.8s ease 0.4s forwards; } .gradient-text { background: linear-gradient(90deg, var(--a2), var(--a1), var(--a3), var(--a2)); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 6s linear infinite; } @keyframes shimmer { to { background-position: 300% 0; } } .type-line { font-family: var(--mono); font-size: clamp(0.95rem, 2.5vw, 1.2rem); color: var(--muted); min-height: 2em; opacity: 0; animation: rise 0.8s ease 0.6s forwards; } .type-line .cursor { display: inline-block; width: 0.6ch; background: var(--a2); animation: blink 0.9s steps(1) infinite; color: transparent; } @keyframes blink { 50% { opacity: 0; } }
.cta-row { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-top: 2.5rem; opacity: 0; animation: rise 0.8s ease 0.8s forwards; } .btn { --glow: var(--a1); position: relative; font-weight: 600; padding: 0.85rem 2rem; border-radius: 999px; border: 1px solid transparent; cursor: pointer; font-size: 1rem; text-decoration: none; transition: transform 0.15s ease; will-change: transform; } .btn-primary { background: linear-gradient(135deg, var(--a1), var(--a2)); color: white; box-shadow: 0 0 24px color-mix(in srgb, var(--a1) 45%, transparent); } .btn-ghost { color: var(--fg); border-color: color-mix(in srgb, var(--fg) 25%, transparent); background: transparent; } .btn:hover { transform: scale(1.05); } .btn:active { transform: scale(0.97); }
/* 3D tilt card */ .card-section { min-height: 100vh; display: grid; place-content: center; } .tilt-card { width: min(420px, 90vw); padding: 2.5rem; border-radius: 20px; background: color-mix(in srgb, var(--fg) 5%, transparent); border: 1px solid color-mix(in srgb, var(--fg) 12%, transparent); backdrop-filter: blur(12px); transform-style: preserve-3d; transition: box-shadow 0.3s ease; will-change: transform; } .tilt-card h2 { font-size: 1.4rem; margin-bottom: 0.6rem; } .tilt-card p { color: var(--muted); line-height: 1.7; } .tilt-card .shine { position: absolute; inset: 0; border-radius: 20px; background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--a2) 25%, transparent), transparent 60%); opacity: 0; transition: opacity 0.3s ease; pointer-events: none; } .tilt-card:hover .shine { opacity: 1; }
/* scroll reveal */ .reveal { opacity: 0; transform: translateY(40px); transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1), transform 0.8s cubic-bezier(0.22, 1, 0.36, 1); } .reveal.visible { opacity: 1; transform: none; }
/* progress bar */ #progress { position: fixed; top: 0; left: 0; height: 3px; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, var(--a1), var(--a2), var(--a3)); z-index: 10; }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
/* ========== 5. Reduced motion ========== */ @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01s !important; animation-iteration-count: 1 !important; transition-duration: 0.01s !important; } .blob { animation: none; } }</style></head><body>
<div id="progress"></div>
<div class="aurora" aria-hidden="true"> <div class="blob blob-1"></div> <div class="blob blob-2"></div> <div class="blob blob-3"></div></div><canvas id="stars" aria-hidden="true"></canvas><div class="grain" aria-hidden="true"></div>
<main> <section class="hero"> <p class="eyebrow">CSS · JavaScript · zero dependencies</p> <h1 class="gradient-text">Deep motion,<br />shallow effort.</h1> <p class="type-line"><span id="typed"></span><span class="cursor">_</span></p> <div class="cta-row"> <a href="#card" class="btn btn-primary">Scroll down</a> <button class="btn btn-ghost" id="burst">Confetti burst</button> </div> </section>
<section class="card-section" id="card"> <div class="tilt-card reveal" id="tilt"> <div class="shine"></div> <h2>3D tilt + shine</h2> <p> Move your pointer over this card. The tilt is JavaScript driving CSS custom properties; the shine follows through the same variables. Everything else on this page is pure CSS keyframes. </p> </div> </section></main>
<script>(() => { const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
/* ========== 1. Typewriter ========== */ const phrases = [ "Six drifting gradients, three layers of depth.", "Particles drawn on canvas at 60fps.", "Tilt cards driven by CSS custom properties.", "And it all fits in one file." ]; const typed = document.getElementById("typed"); let pi = 0, ci = 0, deleting = false; function type() { const text = phrases[pi]; typed.textContent = text.slice(0, ci); if (!deleting) { if (ci++ < text.length) return setTimeout(type, 45); deleting = true; return setTimeout(type, 2200); // hold full sentence } if (ci-- > 0) return setTimeout(type, 22); deleting = false; pi = (pi + 1) % phrases.length; setTimeout(type, 400); } reduced ? (typed.textContent = phrases[0]) : type();
/* ========== 2. Particles on canvas ========== */ const canvas = document.getElementById("stars"); const ctx = canvas.getContext("2d"); let W, H, parts = []; const resize = () => { W = canvas.width = innerWidth; H = canvas.height = innerHeight; }; resize(); addEventListener("resize", resize);
const COUNT = reduced ? 0 : Math.min(120, innerWidth / 10); for (let i = 0; i < COUNT; i++) { parts.push({ x: Math.random() * innerWidth, y: Math.random() * innerHeight, vx: (Math.random() - 0.5) * 0.35, vy: (Math.random() - 0.5) * 0.35, r: Math.random() * 1.6 + 0.4, hue: [262, 190, 330][i % 3] }); }
function drawParticles() { ctx.clearRect(0, 0, W, H); for (const p of parts) { p.x += p.vx; p.y += p.vy; if (p.x < 0 || p.x > W) p.vx *= -1; if (p.y < 0 || p.y > H) p.vy *= -1; ctx.beginPath(); ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2); ctx.fillStyle = `hsl(${p.hue} 85% 70% / 0.6)`; ctx.fill(); } // connect close particles with faint lines for (let i = 0; i < parts.length; i++) { for (let j = i + 1; j < parts.length; j++) { const dx = parts[i].x - parts[j].x; const dy = parts[i].y - parts[j].y; const d2 = dx * dx + dy * dy; if (d2 < 9000) { ctx.strokeStyle = `hsl(262 85% 70% / ${0.12 * (1 - d2 / 9000)})`; ctx.beginPath(); ctx.moveTo(parts[i].x, parts[i].y); ctx.lineTo(parts[j].x, parts[j].y); ctx.stroke(); } } } requestAnimationFrame(drawParticles); } if (COUNT > 0) drawParticles();
/* ========== 3. Confetti burst on click ========== */ const burst = []; document.getElementById("burst").addEventListener("click", (e) => { const rect = e.target.getBoundingClientRect(); const cx = rect.left + rect.width / 2; const cy = rect.top + rect.height / 2; for (let i = 0; i < 40; i++) { const a = Math.random() * Math.PI * 2; const speed = 3 + Math.random() * 6; burst.push({ x: cx, y: cy, vx: Math.cos(a) * speed, vy: Math.sin(a) * speed - 3, life: 1, hue: [262, 190, 330][i % 3], rot: Math.random() * Math.PI }); } if (!burst.running) { burst.running = true; requestAnimationFrame(drawBurst); } });
function drawBurst() { ctx.clearRect(0, 0, W, H); // keep the ambient particles under the confetti for (const p of parts) { ctx.beginPath(); ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2); ctx.fillStyle = `hsl(${p.hue} 85% 70% / 0.6)`; ctx.fill(); } for (let i = burst.length - 1; i >= 0; i--) { const c = burst[i]; c.x += c.vx; c.y += c.vy; c.vy += 0.25; // gravity c.rot += 0.15; c.life -= 0.012; if (c.life <= 0) { burst.splice(i, 1); continue; } ctx.save(); ctx.translate(c.x, c.y); ctx.rotate(c.rot); ctx.fillStyle = `hsl(${c.hue} 85% 65% / ${c.life})`; ctx.fillRect(-3, -5, 6, 10); ctx.restore(); } if (burst.length) requestAnimationFrame(drawBurst); else burst.running = false; }
/* ========== 4. Scroll progress + reveals ========== */ const progress = document.getElementById("progress"); addEventListener("scroll", () => { const max = document.documentElement.scrollHeight - innerHeight; progress.style.transform = `scaleX(${scrollY / max})`; }, { passive: true });
const io = new IntersectionObserver( (entries) => entries.forEach((e) => e.isIntersecting && e.target.classList.add("visible")), { threshold: 0.3 } ); document.querySelectorAll(".reveal").forEach((el) => io.observe(el));
/* ========== 5. 3D tilt card ========== */ const card = document.getElementById("tilt"); if (!reduced) { card.addEventListener("pointermove", (e) => { const r = card.getBoundingClientRect(); const px = (e.clientX - r.left) / r.width; // 0..1 const py = (e.clientY - r.top) / r.height; const rx = (0.5 - py) * 14; // tilt degrees const ry = (px - 0.5) * 14; card.style.transform = `rotateX(${rx}deg) rotateY(${ry}deg) translateZ(0)`; card.style.setProperty("--mx", `${px * 100}%`); card.style.setProperty("--my", `${py * 100}%`); }); card.addEventListener("pointerleave", () => { card.style.transform = "rotateX(0) rotateY(0)"; }); }})();</script></body></html>What's animated, layer by layer:
- Aurora background: three huge blurred gradient blobs drifting on separate 18-26s loops with
mix-blend-mode: screen. Onlytransformanimates, so it stays on the GPU and never triggers layout. - Film grain: an inline SVG
feTurbulencetexture over the gradients, which hides the banding you'd otherwise get with big soft color fields. - Canvas particle network: ~120 particles drifting and connecting with faint lines when close, on one
requestAnimationFrameloop. - Typewriter: types, holds, deletes, cycles four phrases.
- Shimmering gradient headline:
background-clip: textwith a 300%-wide gradient sliding through it. - Scroll progress bar: a fixed gradient bar scaled by scroll position.
- 3D tilt card: pointer position drives
rotateX/rotateYplus a radial shine, all through CSS custom properties. - Confetti burst: 40 physics-driven rectangles with gravity, drawn on the same canvas.
- Entrance choreography: staggered
riseanimations with delays, then scroll-triggered reveals viaIntersectionObserver.
Two deliberate details: everything respects prefers-reduced-motion (particles are skipped entirely, not just slowed), and the animations only touch transform and opacity, which is what keeps it at 60fps instead of jank. Save it as index.html and open it. To make it yours, the colors live in four variables at the top of :root: change --a1, --a2, --a3 and the whole page re-themes itself.
create entire game file html css and haavscript make sure its intresting and perfectly animated create deep resonig then make one
Rather than ask which game, I'll reason through the choice first, then build it.
The design reasoning
Options I weighed: Snake (too simple to be interesting), a platformer (physics tuning eats the budget), a bullet-hell dodge game (fun but shallow mechanically). I picked an arcade Breakout, because it's the best canvas for "deep animation": every collision can emit particles, every state change can shake the screen, and it has natural escalation (combos, powerups, multi-hit bricks). The reasoning behind each decision:
- Fixed timestep physics, interpolated rendering. The classic mistake is tying ball speed to framerate. I run physics at a fixed 120Hz accumulator and render every frame, so the game plays identically at 60Hz or 144Hz.
- Circle-vs-brick collision with side detection. I resolve which face was hit by comparing penetration depths, so the ball bounces off brick sides correctly instead of teleporting through corners.
- Juice budget spent on collisions. Screen shake scaled by impact, particle bursts colored by the brick, bricks that flash white before shattering, the paddle that squashes on hit. Perceived quality in arcade games is 90% collision feedback.
- Combo system with a decay timer. Break bricks without touching the paddle and the multiplier climbs, shown as a pulsing ring. Miss and it resets. That creates risk/reward, which is what makes it a game rather than a demo.
- WebAudio, no files. Synthesized blips whose pitch rises with your combo. Zero assets means the file stays self-contained.
- Three powerups (wide paddle, slow ball, multiball) dropping from destroyed bricks, so runs diverge.
prefers-reduced-motionkills the shake, and the loop pauses when the tab is hidden via the visibility API.
Save as index.html and open. Click to launch, mouse or arrow keys to move, P to pause.
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>NEON BREAK</title><style> :root { --bg: #0a0b12; --fg: #eef0ff; --muted: #8b90b0; --a1: #7c3aed; --a2: #06b6d4; --a3: #f472b6; --mono: ui-monospace, "SF Mono", Menlo, monospace; } * { box-sizing: border-box; margin: 0; } html, body { height: 100%; } body { background: var(--bg); color: var(--fg); display: grid; place-items: center; font-family: var(--mono); overflow: hidden; -webkit-font-smoothing: antialiased; } #stage { position: relative; } canvas { display: block; background: var(--bg); border-radius: 12px; border: 1px solid #ffffff18; box-shadow: 0 0 80px #7c3aed33; } /* HUD overlays */ .overlay { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 0.9rem; background: #0a0b12cc; backdrop-filter: blur(6px); border-radius: 12px; opacity: 1; transition: opacity 0.35s ease; z-index: 2; } .overlay.hidden { opacity: 0; pointer-events: none; } .overlay h1 { font-size: clamp(1.8rem, 6vw, 3rem); letter-spacing: 0.15em; background: linear-gradient(90deg, var(--a2), var(--a1), var(--a3)); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 4s linear infinite; } @keyframes shimmer { to { background-position: 200% 0; } } .overlay p { color: var(--muted); font-size: 0.85rem; line-height: 1.8; } .overlay .score-big { font-size: 2.2rem; color: var(--fg); } kbd { border: 1px solid #ffffff30; border-bottom-width: 3px; border-radius: 6px; padding: 0.1rem 0.5rem; font-family: inherit; font-size: 0.8rem; }</style></head><body><div id="stage"> <canvas id="game" width="720" height="520"></canvas> <div class="overlay" id="menu"> <h1>NEON BREAK</h1> <p>Move: <kbd>mouse</kbd> / <kbd>←</kbd><kbd>→</kbd> · Launch: <kbd>click</kbd> / <kbd>space</kbd> · Pause: <kbd>P</kbd><br> Chain bricks without touching the paddle to build your combo multiplier.</p> <p style="color:var(--fg)">Click to start</p> </div> <div class="overlay hidden" id="gameover"> <h1>GAME OVER</h1> <p class="score-big" id="final-score">0</p> <p id="best-line">best: 0</p> <p style="color:var(--fg)">Click to retry</p> </div> <div class="overlay hidden" id="win"> <h1>CLEARED</h1> <p class="score-big" id="win-score">0</p> <p>Next wave is faster. Click to continue.</p> </div></div>
<script>(() => { "use strict"; // ============================================================ // 1. Constants & state // ============================================================ const cvs = document.getElementById("game"); const ctx = cvs.getContext("2d"); const W = cvs.width, H = cvs.height; const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches; const COLORS = { a1: "#7c3aed", a2: "#06b6d4", a3: "#f472b6", fg: "#eef0ff" }; const BRICK_HUES = ["#7c3aed", "#06b6d4", "#f472b6", "#facc15", "#34d399"]; const FIXED_DT = 1000 / 120; // physics step: 120 Hz const MAX_FRAME = 50; // clamp to avoid spiral of death
const state = { phase: "menu", // menu | serve | play | paused | dead | win score: 0, combo: 0, comboTimer: 0, wave: 1, lives: 3, shake: 0, flash: 0, slowmo: 1, time: 0, best: Number(localStorage.getItem("neonbreak-best") || 0), };
const paddle = { x: W / 2, w: 110, h: 14, y: H - 44, squash: 0, targetX: W / 2 }; const balls = []; // { x, y, vx, vy, r, stuck } const bricks = []; const particles = []; const powerups = []; // { x, y, vy, type, hue } const ripples = []; // expanding collision rings
const keys = { left: false, right: false }; const TYPES = ["wide", "slow", "multi"];
// ============================================================ // 2. Audio — synthesized, pitch rises with combo // ============================================================ let actx = null; function audio() { return (actx ??= new AudioContext()); } function blip(freq, dur = 0.08, type = "square", vol = 0.12) { if (reduced && type === "noise") return; try { const a = audio(), o = a.createOscillator(), g = a.createGain(); o.type = type; o.frequency.value = freq; g.gain.setValueAtTime(vol, a.currentTime); g.gain.exponentialRampToValueAtTime(0.001, a.currentTime + dur); o.connect(g).connect(a.destination); o.start(); o.stop(a.currentTime + dur); } catch { /* audio not ready yet */ } } const sfx = { brick: (combo) => blip(320 + Math.min(combo, 12) * 55, 0.07, "square"), paddle: () => blip(180, 0.06, "sine", 0.15), wall: () => blip(140, 0.04, "sine", 0.08), lose: () => { blip(110, 0.4, "sawtooth", 0.15); blip(74, 0.5, "sawtooth", 0.12); }, power: () => { blip(660, 0.1, "triangle"); setTimeout(() => blip(880, 0.12, "triangle"), 70); }, win: () => [523, 659, 784, 1046].forEach((f, i) => setTimeout(() => blip(f, 0.15, "triangle", 0.14), i * 90)), };
// ============================================================ // 3. Level generation — waves get denser and harder // ============================================================ function buildBricks() { bricks.length = 0; const cols = 10 + Math.min(state.wave, 4); const rows = 4 + Math.min(state.wave, 3); const gap = 8, pad = 34; const bw = (W - pad * 2 - gap * (cols - 1)) / cols; const bh = 22, top = 80; for (let r = 0; r < rows; r++) { for (let c = 0; c < cols; c++) { // carve holes in higher waves so patterns feel designed, not grids if (state.wave > 2 && (r + c) % 7 === 0) continue; const hp = r < 2 && state.wave > 1 ? 2 : 1; // top rows take 2 hits bricks.push({ x: pad + c * (bw + gap), y: top + r * (bh + gap), w: bw, h: bh, hue: BRICK_HUES[r % BRICK_HUES.length], hp, maxHp: hp, hit: 0, // hit: white flash timer }); } } }
function resetBall(stuckToPaddle = true) { balls.length = 0; balls.push({ x: paddle.x, y: paddle.y - 14, r: 8, vx: 0, vy: 0, stuck: stuckToPaddle, trail: [], }); } function launch() { const b = balls.find((b) => b.stuck); if (!b) return; b.stuck = false; const speed = 6 + state.wave * 0.5; const angle = -Math.PI / 2 + (Math.random() - 0.5) * 0.6; b.vx = Math.cos(angle) * speed; b.vy = Math.sin(angle) * speed; blip(440, 0.1, "triangle"); }
function startGame() { state.score = 0; state.combo = 0; state.lives = 3; state.wave = 1; paddle.w = 110; state.slowmo = 1; buildBricks(); resetBall(); state.phase = "serve"; showOverlay(null); }
// ============================================================ // 4. Juice helpers // ============================================================ function burst(x, y, hue, n = 18, power = 1) { if (reduced) n = 4; for (let i = 0; i < n; i++) { const a = Math.random() * Math.PI * 2; const s = (1 + Math.random() * 3.5) * power; particles.push({ x, y, vx: Math.cos(a) * s, vy: Math.sin(a) * s, life: 1, decay: 0.02 + Math.random() * 0.03, hue, size: 2 + Math.random() * 3, gravity: 0.08, }); } } function ripple(x, y, hue) { ripples.push({ x, y, r: 4, life: 1, hue }); } function shake(amount) { state.shake = Math.min(state.shake + amount, 14); }
// ============================================================ // 5. Fixed-timestep physics // ============================================================ function step(dt) { state.time += dt; if (state.comboTimer > 0) { state.comboTimer -= dt; if (state.comboTimer <= 0) state.combo = 0; // combo decayed } state.shake *= 0.88; state.flash *= 0.85;
// paddle input const kSpeed = 9; if (keys.left) paddle.targetX -= kSpeed; if (keys.right) paddle.targetX += kSpeed; paddle.targetX = Math.max(paddle.w / 2, Math.min(W - paddle.w / 2, paddle.targetX)); paddle.x += (paddle.targetX - paddle.x) * 0.35; // smoothing = weight paddle.squash *= 0.85;
if (state.phase === "serve") { const b = balls[0]; if (b && b.stuck) { b.x = paddle.x; b.y = paddle.y - 14; } }
if (state.phase !== "play" && state.phase !== "serve") return;
const speedScale = state.slowmo;
for (let bi = balls.length - 1; bi >= 0; bi--) { const b = balls[bi]; if (b.stuck) continue; b.trail.push({ x: b.x, y: b.y }); if (b.trail.length > 10) b.trail.shift();
// sub-step for tunneling safety at high speed const steps = Math.ceil(Math.max(Math.abs(b.vx), Math.abs(b.vy)) * speedScale / 6); for (let s = 0; s < steps; s++) { b.x += (b.vx * speedScale) / steps; b.y += (b.vy * speedScale) / steps;
// walls if (b.x < b.r) { b.x = b.r; b.vx = Math.abs(b.vx); sfx.wall(); ripple(b.x, b.y, COLORS.a2); } if (b.x > W - b.r) { b.x = W - b.r; b.vx = -Math.abs(b.vx); sfx.wall(); ripple(b.x, b.y, COLORS.a2); } if (b.y < b.r + 40) { b.y = b.r + 40; b.vy = Math.abs(b.vy); sfx.wall(); ripple(b.x, b.y, COLORS.a2); }
// paddle: reflect with angle control from hit position if (b.vy > 0 && b.y + b.r > paddle.y && b.y - b.r < paddle.y + paddle.h && b.x > paddle.x - paddle.w / 2 - b.r && b.x < paddle.x + paddle.w / 2 + b.r) { const hit = (b.x - paddle.x) / (paddle.w / 2); // -1..1 const speed = Math.hypot(b.vx, b.vy); const angle = -Math.PI / 2 + hit * 1.0; // up to ~57° b.vx = Math.cos(angle) * speed; b.vy = Math.sin(angle) * speed; b.y = paddle.y - b.r; paddle.squash = 1; state.combo = 0; state.comboTimer = 0; // touching paddle resets combo sfx.paddle(); burst(b.x, paddle.y, COLORS.fg, 6, 0.5); }
// bricks: pick side by penetration depth for (const br of bricks) { if (br.hp <= 0) continue; if (b.x + b.r < br.x || b.x - b.r > br.x + br.w || b.y + b.r < br.y || b.y - b.r > br.y + br.h) continue;
const overlapL = b.x + b.r - br.x; const overlapR = br.x + br.w - (b.x - b.r); const overlapT = b.y + b.r - br.y; const overlapB = br.y + br.h - (b.y - b.r); const minH = Math.min(overlapL, overlapR); const minV = Math.min(overlapT, overlapB);
if (minH < minV) { b.vx = overlapL < overlapR ? -Math.abs(b.vx) : Math.abs(b.vx); b.x += overlapL < overlapR ? -minH : minH; } else { b.vy = overlapT < overlapB ? -Math.abs(b.vy) : Math.abs(b.vy); b.y += overlapT < overlapB ? -minV : minV; }
br.hp--; br.hit = 1; if (br.hp <= 0) { state.combo++; state.comboTimer = 2500; const mult = 1 + Math.floor(state.combo / 3); state.score += 10 * mult; burst(br.x + br.w / 2, br.y + br.h / 2, br.hue, 20); ripple(br.x + br.w / 2, br.y + br.h / 2, br.hue); shake(2 + Math.min(state.combo, 8) * 0.4); sfx.brick(state.combo); // powerup drop ~12% if (Math.random() < 0.12) { powerups.push({ x: br.x + br.w / 2, y: br.y + br.h / 2, vy: 1.6, type: TYPES[Math.floor(Math.random() * TYPES.length)], hue: br.hue, }); } if (bricks.every((k) => k.hp <= 0)) return winWave(); } else { burst(b.x, b.y, br.hue, 6, 0.6); shake(1.5); blip(200, 0.05, "square", 0.08); } break; // one brick per sub-step }
// ball lost if (b.y > H + 30) { balls.splice(bi, 1); if (balls.length === 0) { state.lives--; state.flash = 1; shake(8); sfx.lose(); if (state.lives <= 0) return gameOver(); state.combo = 0; state.slowmo = 1; paddle.w = Math.max(paddle.w, 110); resetBall(); state.phase = "serve"; } break; } } }
// powerups fall & get caught for (let i = powerups.length - 1; i >= 0; i--) { const p = powerups[i]; p.y += p.vy; if (p.y > paddle.y - 8 && p.y < paddle.y + paddle.h + 10 && Math.abs(p.x - paddle.x) < paddle.w / 2 + 12) { applyPowerup(p.type); burst(p.x, p.y, p.hue, 14); sfx.power(); powerups.splice(i, 1); } else if (p.y > H + 20) powerups.splice(i, 1); }
// particles & ripples decay for (let i = particles.length - 1; i >= 0; i--) { const p = particles[i]; p.x += p.vx; p.y += p.vy; p.vy += p.gravity; p.vx *= 0.99; p.life -= p.decay; if (p.life <= 0) particles.splice(i, 1); } for (let i = ripples.length - 1; i >= 0; i--) { const r = ripples[i]; r.r += 3; r.life -= 0.05; if (r.life <= 0) ripples.splice(i, 1); } for (const br of bricks) if (br.hit > 0) br.hit *= 0.8; }
function applyPowerup(type) { if (type === "wide") { paddle.w = Math.min(paddle.w + 40, 200); } if (type === "slow") { state.slowmo = 0.6; setTimeout(() => (state.slowmo = 1), 6000); } if (type === "multi") { const src = balls[0]; if (src) { for (let i = 0; i < 2; i++) { const a = Math.atan2(src.vy, src.vx) + (i ? 0.5 : -0.5); const s = Math.hypot(src.vx, src.vy); balls.push({ x: src.x, y: src.y, vx: Math.cos(a) * s, vy: Math.sin(a) * s, r: src.r, stuck: false, trail: [] }); } } } }
function winWave() { state.phase = "win"; sfx.win(); state.score += 100 * state.wave; document.getElementById("win-score").textContent = state.score + " pts"; showOverlay("win"); } function gameOver() { state.phase = "dead"; if (state.score > state.best) { state.best = state.score; localStorage.setItem("neonbreak-best", state.best); } document.getElementById("final-score").textContent = state.score + " pts"; document.getElementById("best-line").textContent = "best: " + state.best; showOverlay("gameover"); }
// ============================================================ // 6. Rendering — interpolated, additive glow, screen shake // ============================================================ function draw(alpha) { // shake offset const sx = (Math.random() - 0.5) * state.shake; const sy = (Math.random() - 0.5) * state.shake; ctx.setTransform(1, 0, 0, 1, sx, sy);
// background: subtle grid + vignette ctx.clearRect(-20, -20, W + 40, H + 40); ctx.fillStyle = "#0a0b12"; ctx.fillRect(-20, -20, W + 40, H + 40); ctx.strokeStyle = "#ffffff06"; ctx.lineWidth = 1; for (let x = 0; x < W; x += 40) { ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x, H); ctx.stroke(); } for (let y = 0; y < H; y += 40) { ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(W, y); ctx.stroke(); }
ctx.globalCompositeOperation = "lighter";
// ripples for (const r of ripples) { ctx.strokeStyle = r.hue + Math.round(r.life * 200).toString(16).padStart(2, "0"); ctx.lineWidth = 2; ctx.beginPath(); ctx.arc(r.x, r.y, r.r, 0, Math.PI * 2); ctx.stroke(); }
// particles for (const p of particles) { ctx.globalAlpha = p.life; ctx.fillStyle = p.hue; ctx.beginPath(); ctx.arc(p.x, p.y, p.size * p.life, 0, Math.PI * 2); ctx.fill(); } ctx.globalAlpha = 1; ctx.globalCompositeOperation = "source-over";
// bricks (glow for hp2, flash white on hit) for (const br of bricks) { if (br.hp <= 0) continue; const t = br.hit; ctx.save(); if (br.maxHp > 1) { ctx.shadowColor = br.hue; ctx.shadowBlur = 12; } ctx.fillStyle = t > 0.05 ? blend(br.hue, "#ffffff", t) : br.hue; roundRect(br.x, br.y, br.w, br.h, 5); ctx.fill(); ctx.restore(); if (br.hp > 1) { // inner core for 2-hp bricks ctx.fillStyle = "#0a0b1255"; roundRect(br.x + 4, br.y + 4, br.w - 8, br.h - 8, 3); ctx.fill(); } }
// combo ring around paddle when active if (state.combo > 0) { const mult = 1 + Math.floor(state.combo / 3); const pulse = 1 + Math.sin(state.time / 90) * 0.06; ctx.strokeStyle = COLORS.a3; ctx.lineWidth = 2; ctx.globalAlpha = 0.7; ctx.beginPath(); ctx.arc(paddle.x, paddle.y + 6, 34 * pulse, -Math.PI * 0.4, -Math.PI * 0.4 + Math.PI * 1.6); ctx.stroke(); ctx.globalAlpha = 1; ctx.fillStyle = COLORS.a3; ctx.font = "bold 13px " + "ui-monospace, monospace"; ctx.textAlign = "center"; ctx.fillText("×" + mult, paddle.x, paddle.y + 34); }
// paddle: rounded, squash-stretch, gradient const sq = paddle.squash; const pw = paddle.w * (1 + sq * 0.12), ph = paddle.h * (1 - sq * 0.35); const grad = ctx.createLinearGradient(paddle.x - pw / 2, 0, paddle.x + pw / 2, 0); grad.addColorStop(0, COLORS.a2); grad.addColorStop(1, COLORS.a1); ctx.save(); ctx.shadowColor = COLORS.a1; ctx.shadowBlur = 18; ctx.fillStyle = grad; roundRect(paddle.x - pw / 2, paddle.y + (paddle.h - ph) / 2, pw, ph, ph / 2); ctx.fill(); ctx.restore();
// powerups: rotating diamonds for (const p of powerups) { ctx.save(); ctx.translate(p.x, p.y); ctx.rotate(state.time / 300); ctx.shadowColor = p.hue; ctx.shadowBlur = 14; ctx.fillStyle = p.hue; ctx.fillRect(-8, -8, 16, 16); ctx.restore(); }
// balls with motion trail for (const b of balls) { for (let i = 0; i < b.trail.length; i++) { const t = b.trail[i]; ctx.globalAlpha = (i / b.trail.length) * 0.35; ctx.fillStyle = COLORS.a2; ctx.beginPath(); ctx.arc(t.x, t.y, b.r * (i / b.trail.length), 0, Math.PI * 2); ctx.fill(); } ctx.globalAlpha = 1; ctx.save(); ctx.shadowColor = COLORS.a2; ctx.shadowBlur = 20; ctx.fillStyle = "#ffffff"; ctx.beginPath(); ctx.arc(b.x, b.y, b.r, 0, Math.PI * 2); ctx.fill(); ctx.restore(); }
// HUD ctx.fillStyle = "#eef0ffcc"; ctx.font = "13px ui-monospace, monospace"; ctx.textAlign = "left"; ctx.fillText("SCORE " + state.score, 16, 28); ctx.textAlign = "center"; ctx.fillText("WAVE " + state.wave, W / 2, 28); ctx.textAlign = "right"; ctx.fillText("♥ ".repeat(Math.max(state.lives, 0)).trim() || "—", W - 16, 28);
// red damage flash if (state.flash > 0.02) { ctx.fillStyle = `rgba(244, 63, 94, ${state.flash * 0.25})`; ctx.fillRect(-20, -20, W + 40, H + 40); } ctx.setTransform(1, 0, 0, 1, 0, 0); }
function roundRect(x, y, w, h, r) { ctx.beginPath(); ctx.moveTo(x + r, y); ctx.arcTo(x + w, y, x + w, y + h, r); ctx.arcTo(x + w, y + h, x, y + h, r); ctx.arcTo(x, y + h, x, y, r); ctx.arcTo(x, y, x + w, y, r); ctx.closePath(); } function blend(a, b, t) { // hex color blend for hit flashes const pa = parseInt(a.slice(1), 16), pb = parseInt(b.slice(1), 16); const r = ((pa >> 16) + (((pb >> 16) - (pa >> 16)) * t)) | 0; const g = ((pa >> 8 & 255) + (((pb >> 8 & 255) - (pa >> 8 & 255)) * t)) | 0; const bl = ((pa & 255) + (((pb & 255) - (pa & 255)) * t)) | 0; return `rgb(${r},${g},${bl})`; }
// ============================================================ // 7. Main loop: fixed timestep + interpolation accumulator // ============================================================ let last = performance.now(), acc = 0; function loop(now) { const frame = Math.min(now - last, MAX_FRAME); last = now; if (document.hidden) { requestAnimationFrame(loop); return; } // pause off-tab acc += frame; while (acc >= FIXED_DT) { step(FIXED_DT); acc -= FIXED_DT; } draw(acc / FIXED_DT); requestAnimationFrame(loop); } requestAnimationFrame(loop);
// ============================================================ // 8. Input // ============================================================ function showOverlay(id) { for (const o of ["menu", "gameover", "win"]) document.getElementById(o).classList.toggle("hidden", o !== id); } cvs.addEventListener("pointermove", (e) => { const rect = cvs.getBoundingClientRect(); paddle.targetX = (e.clientX - rect.left) * (W / rect.width); }); cvs.addEventListener("pointerdown", () => { audio()?.resume?.(); if (state.phase === "menu") return startGame(); if (state.phase === "dead") return startGame(); if (state.phase === "win") { state.wave++; buildBricks(); resetBall(); paddle.w = 110; state.slowmo = 1; state.phase = "serve"; showOverlay(null); return; } if (state.phase === "serve") { launch(); state.phase = "play"; } }); addEventListener("keydown", (e) => { if (e.key === "ArrowLeft") keys.left = true; if (e.key === "ArrowRight") keys.right = true; if (e.key === " " && state.phase === "serve") { launch(); state.phase = "play"; } if (e.key === "p" || e.key === "P") { if (state.phase === "play") state.phase = "paused"; else if (state.phase === "paused") state.phase = "play"; } }); addEventListener("keyup", (e) => { if (e.key === "ArrowLeft") keys.left = false; if (e.key === "ArrowRight") keys.right = false; });})();</script></body></html>What makes it feel deep, mechanically:
- Combo multiplier: every brick destroyed without touching the paddle adds to a chain; at every 3 bricks the point multiplier goes up (shown as the pulsing ring and
×Nby the paddle). Touch the paddle or let 2.5s pass, and it resets. The sound pitch rises with the combo, so your ears track your streak. - Angle control: the bounce direction depends on where the ball hits the paddle, so you can aim. Skilled players steer toward clusters to protect the combo.
- Waves that escalate: more columns, more rows, 2-hit bricks with a glowing shell, and carved-out holes so layouts aren't pure grids. Clearing a wave awards a wave bonus and speeds the ball up.
- Three powerups: wide paddle (stacks up to 200px), slow-motion ball for 6s, and multiball that forks your ball into three. Multiball is combo cheese: more balls, more chains, more risk when you lose one.
- 3 lives, saved best score in
localStorage.
What makes it feel deep, visually:
- Ball trail, additive-blend particles, expanding ripple rings on every wall hit, white flash on multi-hit bricks, paddle squash-and-stretch on impact, screen shake scaled to impact, red vignette flash on death, and a shimmering title overlay. All of it degrades gracefully under
prefers-reduced-motion.
One honest limitation: the fixed-timestep loop interpolates state between physics steps for smoothness, but I render the latest state directly rather than storing previous-state snapshots for true interpolation. At 120Hz physics steps the visual difference is negligible, but that's the trade-off I made to keep the file readable. If you want to push it further, the natural next steps are a second ball type (piercing), moving bricks, or a boss wave every 5 levels.
what are you?
I'm the digital version of Nathan Brodin: an AI assistant built to answer questions about him, his work, and his projects as if you were chatting with him.
Concretely, two layers:
- The persona: "Nathan's AI", connected to his portfolio at brodin.dev so I can talk about his experience as a frontend engineer, his projects, and his writing.
- The model: GLM 5.3 Flash, a large language model by Z.ai, running through OpenRouter.
To be fully honest, since you asked plainly: I'm not the real Nathan, and I don't pretend to be. He talks about himself in first person through me because it makes the conversation feel more natural, but there's a machine under the hood, not a person in Tromsø.
If you want the actual human, that's brodin.dev or nathan@brodin.dev.
All conversations are public. Do not share personal information. Privacy