@font-face { font-family: 'Geist Pixel'; src: url('fonts/GeistPixel-Square.woff2') format('woff2'); font-weight: 400; font-display: swap; }
:root {
    --bg: #0f0f0f;
    --panel: #171717;
    --line: #262626;
    --fg: #efe9dc;
    --muted: #8d8a82;
    --accent: #efe9dc;
    --hit: 0, 0, 0;
    --pixel: 'Geist Pixel', 'Space Grotesk', monospace;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--fg); font-family: 'Space Grotesk', system-ui, sans-serif; font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; transition: background-color 0.8s ease; }
body.win { background: rgb(var(--hit)); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; border-radius: 6px; }
.num { font-family: var(--pixel); font-weight: 400; letter-spacing: 0; }

.game { max-width: 62rem; margin: 0 auto; padding: clamp(0.9rem, 2vw, 1.5rem) clamp(1rem, 3vw, 2rem); min-height: 100vh; display: flex; flex-direction: column; gap: 1rem; }
@media (min-height: 640px) and (min-width: 561px) { .game { height: 100vh; height: 100dvh; overflow: hidden; } }

/* top */
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 600; letter-spacing: -0.01em; }
.swatch { display: inline-grid; grid-auto-flow: column; gap: 2px; }
.swatch i { width: 0.55rem; height: 1rem; border-radius: 2px; background: #ff4d4d; }
.swatch i:nth-child(2) { background: #54d66a; } .swatch i:nth-child(3) { background: #4d8cff; }
.stats { display: flex; gap: 0.5rem; }
.stat { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.45rem 0.85rem; border: 1px solid var(--line); border-radius: 999px; background: rgba(23, 23, 23, 0.7); }
.stat-label { font-size: 0.75rem; color: var(--muted); }
.stat .num { font-size: 1.1rem; line-height: 1; }
body.win .stat, body.win .seg, body.win .pill, body.win .foot { border-color: rgba(255, 255, 255, 0.25); }

/* target */
.board { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: clamp(0.75rem, 2vh, 1.25rem); flex: 1; min-height: 0; padding-top: clamp(0.25rem, 2vh, 1.5rem); }
.target { text-align: center; }
.prompt { margin: 0; color: var(--muted); font-size: 0.95rem; }
body.win .prompt, body.win .stat-label, body.win .message, body.win .foot { color: rgba(255, 255, 255, 0.8); }
.value { margin: 0.15rem 0 0.6rem; font-size: clamp(2rem, min(6vw, 7vh), 4.2rem); line-height: 1; word-break: break-all; }
.lives { display: inline-flex; gap: 0.4rem; }
.lives i { width: 0.6rem; height: 0.6rem; border-radius: 999px; background: var(--fg); transition: transform 0.3s, opacity 0.3s; }
.lives i.lost { opacity: 0.25; transform: scale(0.7); }

/* controls */
.controls { display: flex; align-items: center; justify-content: center; gap: 0.75rem; flex-wrap: wrap; }
.seg { display: inline-flex; gap: 0.2rem; padding: 0.25rem; border: 1px solid var(--line); border-radius: 999px; background: rgba(23, 23, 23, 0.7); }
.seg-btn { padding: 0.45rem 0.9rem; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 0.85rem; font-weight: 500; transition: background-color 0.15s, color 0.15s; }
.seg-btn small { font-family: var(--pixel); font-size: 0.85rem; margin-left: 0.25rem; opacity: 0.8; }
.seg-btn:hover { color: var(--fg); }
.seg-btn.active { background: var(--fg); color: var(--bg); }
.pill { padding: 0.55rem 1.1rem; border-radius: 999px; border: 1px solid var(--fg); background: transparent; font-size: 0.85rem; font-weight: 500; transition: background-color 0.15s, color 0.15s; }
.pill:hover { background: var(--fg); color: var(--bg); }

/* grid */
/* The grid always reserves three rows, so changing difficulty never moves anything else. */
.grid { display: grid; gap: clamp(0.5rem, 1.2vh, 0.9rem); width: min(100%, 32rem, calc(100vh - 25rem)); aspect-ratio: 1; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); align-content: start; }
.sq { position: relative; aspect-ratio: 1; border-radius: 18%; border: 0; padding: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); transition: transform 0.35s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.35s, background-color 0.6s; }
.sq:hover { transform: translateY(-4px) scale(1.02); }
.sq::after { content: attr(data-key); position: absolute; left: 0.7rem; bottom: 0.5rem; font-family: var(--pixel); font-size: 0.95rem; color: rgba(255, 255, 255, 0.55); mix-blend-mode: difference; opacity: 0; transition: opacity 0.2s; }
.grid:hover .sq::after, .grid:focus-within .sq::after { opacity: 1; }
.sq.out { opacity: 0; transform: scale(0.6); pointer-events: none; }
.sq.in { animation: pop 0.45s cubic-bezier(0.19, 1, 0.22, 1) both; animation-delay: calc(var(--n) * 40ms); }
@keyframes pop { from { opacity: 0; transform: scale(0.85); } }
.sq.shake { animation: shake 0.35s ease; }
.sq.hit { transform: scale(1); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6); }
.grid.locked .sq { pointer-events: none; }
.grid[data-level="3"] .sq:nth-child(n+4), .grid[data-level="6"] .sq:nth-child(n+7) { visibility: hidden; pointer-events: none; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.message { margin: 0; min-height: 1.5em; color: var(--muted); font-size: 0.95rem; }
.message.good { color: var(--fg); }

/* footer */
.foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.9rem 0 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; }
.foot > span { margin-left: auto; }
.foot a:not(.made-by) { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 560px) {
    .grid { gap: 0.6rem; }
    .stats { width: 100%; }
    .stat { flex: 1; justify-content: center; }
    .foot > span { margin-left: 0; width: 100%; order: 3; }
    .grid { width: 100%; aspect-ratio: auto; grid-template-rows: none; }
    .grid[data-level="3"] .sq:nth-child(n+4), .grid[data-level="6"] .sq:nth-child(n+7) { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sq, body { transition: none; } .sq.shake, .sq.in { animation: none; } }

/* made-by badge (identical across every project; keep in sync). It lives in the page footer, never fixed, so it covers nothing. */
.made-by { display: inline-flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; border-radius: 999px; background: #0b0b0b; color: #f1ede4; border: 1px solid #262626; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 13px; font-weight: 400; line-height: 1; letter-spacing: 0; text-decoration: none; white-space: nowrap; flex: 0 0 auto; transition: background-color 0.2s, opacity 0.3s; }
.made-by b { font-weight: 600; color: inherit; }
.made-by-mark { display: block; border-radius: 6px; transition: transform 0.25s cubic-bezier(0.19, 1, 0.22, 1); }
.made-by:hover { background: #1c1c1c; color: #f1ede4; }
.made-by:hover .made-by-mark { transform: rotate(-8deg) scale(1.08); }
