@font-face {
  font-family: 'Pixelify Sans';
  src: url('../assets/fonts/pixelify-sans-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Pixelify Sans';
  src: url('../assets/fonts/pixelify-sans-latin-600-normal.woff2') format('woff2');
  font-weight: 500 600;
  font-display: swap;
}
@font-face {
  font-family: 'Pixelify Sans';
  src: url('../assets/fonts/pixelify-sans-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'VT323';
  src: url('../assets/fonts/vt323-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --page: #0b1016;
  --ink: #e9eef2;
  --ink-dim: #a9b6c2;
  --panel: #050608;
  --panel-line: #6f7277;
  --card: #18191b;
  --card-line: #172457;
  --card-line-hot: #3d8fd6;
  --purple: #7e549f;
  --purple-dark: #5f3971;
  --ball: #4dd5ea;
  --ball-dark: #3289d7;
  --coin: #f9c22b;
  --coin-dark: #f79617;
  --orange: #fb6b1d;
  --red: #e8433b;
  --green: #91db69;
  --font-pixel: 'Pixelify Sans', ui-monospace, monospace;
  --font-crt: 'VT323', ui-monospace, monospace;
  --radius: 10px;
  --gutter: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font: 400 1.375rem/1.3 var(--font-crt);
  background: var(--page) url('../assets/sprites/brick.png') repeat;
  background-size: 96px 48px;
  image-rendering: pixelated;
  overflow-x: hidden;
}

img,
canvas {
  display: block;
  max-width: 100%;
}

a {
  color: var(--ball);
}

h1,
h2,
h3 {
  font-family: var(--font-pixel);
  font-weight: 700;
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

:focus-visible {
  outline: 3px solid var(--ball);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 8px 14px;
  background: #000;
  color: #fff;
  font-family: var(--font-pixel);
  border: 2px solid var(--panel-line);
  border-radius: 6px;
}
.skip-link:focus {
  top: 16px;
}

.container {
  width: min(1120px, 100%);
  margin: 0 auto;
}

/* ---- buttons ------------------------------------------------------------ */

.btn {
  --a: #22b318;
  --b: #0a6a05;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.75em 1.4em;
  border: 0;
  border-radius: var(--radius);
  font: 600 1.25rem/1 var(--font-pixel);
  color: #fff;
  text-decoration: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
  background:
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 4px),
    linear-gradient(to bottom, var(--a), var(--b));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    inset 0 -4px 0 rgba(0, 0, 0, 0.35),
    0 4px 0 rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
}
.btn:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.2),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    0 1px 0 rgba(0, 0, 0, 0.55);
}
.btn-blue {
  --a: #2f5be0;
  --b: #14307f;
}
.btn-red {
  --a: #d8211a;
  --b: #7d0c08;
}
.btn-small {
  font-size: 1rem;
  padding: 0.6em 1em;
}
.btn-big {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  padding: 0.8em 1.6em;
  animation: glow 2.4s ease-in-out infinite;
}

@keyframes glow {
  50% {
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.28),
      inset 0 -4px 0 rgba(0, 0, 0, 0.35),
      0 4px 0 rgba(0, 0, 0, 0.55),
      0 0 32px rgba(70, 230, 60, 0.55);
  }
}

.sound-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--panel-line);
  border-radius: 8px;
  background: var(--panel);
  color: #fff;
  cursor: pointer;
}
.sound-toggle svg {
  width: 24px;
  height: 24px;
  shape-rendering: crispEdges;
}
.sound-toggle .spk,
.sound-toggle .wave {
  fill: currentColor;
}
.sound-toggle .cross {
  display: none;
  fill: none;
  stroke: var(--red);
  stroke-width: 1.6;
}
.sound-toggle.is-muted .wave {
  display: none;
}
.sound-toggle.is-muted .cross {
  display: inline;
}
.sound-toggle:hover {
  border-color: var(--card-line-hot);
}
html:not(.js) .sound-toggle {
  display: none;
}

/* ---- top bar ------------------------------------------------------------ */

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px var(--gutter);
  background: rgba(5, 6, 8, 0.94);
  border-bottom: 2px solid #1d2733;
  transform: translateY(-110%);
  transition: transform 0.3s ease;
}
.topbar.is-visible {
  transform: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  color: #fff;
  text-decoration: none;
  font: 700 1.3rem/1 var(--font-pixel);
}
.brand img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}
.topnav {
  display: flex;
  gap: 4px;
}
.topnav a {
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 1.3rem;
}
.topnav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}
.topbar .sound-toggle {
  width: 40px;
  height: 40px;
}

@media (max-width: 720px) {
  .topnav {
    display: none;
  }
}
@media (max-width: 400px) {
  .brand span {
    display: none;
  }
}

/* ---- hero: the living room ---------------------------------------------- */

.hero {
  position: relative;
  height: min(100svh, 118vw);
  min-height: 420px;
  overflow: hidden;
  background: #2b2226 url('../assets/screens/main-menu.webp') center / cover no-repeat;
  image-rendering: auto;
  display: grid;
  place-items: center;
}
.hero.is-live {
  display: block;
  background: #2b2226;
}
.room-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  visibility: hidden;
}
.hero.is-live .room-canvas {
  visibility: visible;
}

.tv {
  position: relative;
  width: min(92vw, 640px);
  aspect-ratio: 183 / 125;
  container-type: size;
  overflow: hidden;
  border-radius: 6%;
  background: radial-gradient(ellipse at 50% 45%, #10201a 0%, #050907 100%);
  box-shadow: 0 0 0 14px #3f4542, 0 20px 60px rgba(0, 0, 0, 0.6);
}
.hero.is-live .tv {
  position: absolute;
  width: auto;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
  -webkit-mask: url('../assets/room/tv-mask.png') center / 100% 100% no-repeat;
  mask: url('../assets/room/tv-mask.png') center / 100% 100% no-repeat;
}
.tv::before,
.tv::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.tv::before {
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px);
}
.tv::after {
  background:
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(165deg, rgba(255, 255, 255, 0.08), transparent 35%);
}

.tv-inner {
  position: absolute;
  inset: 6cqh 6cqw 5cqh;
  display: flex;
  flex-direction: column;
  gap: 3.5cqh;
  transform-origin: 50% 50%;
  animation: crt-flicker 5s infinite;
}
.tv-title {
  display: flex;
  align-items: center;
  gap: 3cqw;
}
.tv-logo {
  flex: none;
  width: 24cqh;
  height: 24cqh;
  border-radius: 3cqh;
  image-rendering: auto;
  box-shadow: 0 0 4cqh rgba(77, 213, 234, 0.35);
}
.tv-name {
  font-size: 14cqh;
  color: #fff;
  text-shadow:
    0 0 2.5cqh rgba(110, 220, 255, 0.55),
    0.5cqh 0 0 rgba(255, 40, 90, 0.35),
    -0.5cqh 0 0 rgba(40, 200, 255, 0.35);
}
.tv-tagline {
  margin-top: 1.4cqh;
  font: 6.6cqh/1 var(--font-crt);
  color: #c4f7d0;
  text-shadow: 0 0 1.5cqh rgba(120, 255, 150, 0.45);
}
.tv-menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2.4cqh;
}
.crt-btn {
  --a: #13a00a;
  --b: #0a6204;
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 2cqh;
  padding: 0;
  font: 500 7.2cqh/1 var(--font-pixel);
  color: #f1fff1;
  text-decoration: none;
  text-shadow: 0 0 1.2cqh rgba(255, 255, 255, 0.4);
  background:
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.09) 0 1px, transparent 1px 2.5px),
    linear-gradient(to bottom, var(--a) 0%, var(--b) 100%);
  box-shadow:
    inset 0 0.6cqh 0 rgba(255, 255, 255, 0.25),
    inset 0 -1cqh 0 rgba(0, 0, 0, 0.35),
    0 0 2cqh color-mix(in srgb, var(--a) 40%, transparent);
  cursor: pointer;
  transition: filter 0.12s, transform 0.12s;
}
.crt-blue {
  --a: #2852d1;
  --b: #142f86;
}
.crt-purple {
  --a: #8331b8;
  --b: #4f1b73;
}
.crt-red {
  --a: #cf150d;
  --b: #780a05;
}
.crt-btn::before,
.crt-btn::after {
  content: '';
  position: absolute;
  inset: -1.2cqh -1.4cqh;
  border: 0.9cqh solid #fff;
  border-radius: 3cqh;
  opacity: 0;
  pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) top left / 4cqh 4cqh, linear-gradient(#000 0 0) top right / 4cqh 4cqh,
    linear-gradient(#000 0 0) bottom left / 4cqh 4cqh, linear-gradient(#000 0 0) bottom right / 4cqh 4cqh;
  -webkit-mask-repeat: no-repeat;
  mask: linear-gradient(#000 0 0) top left / 4cqh 4cqh, linear-gradient(#000 0 0) top right / 4cqh 4cqh,
    linear-gradient(#000 0 0) bottom left / 4cqh 4cqh, linear-gradient(#000 0 0) bottom right / 4cqh 4cqh;
  mask-repeat: no-repeat;
  transition: opacity 0.1s, inset 0.15s;
}
.crt-btn:hover,
.crt-btn:focus-visible {
  filter: brightness(1.3) saturate(1.1);
  outline: none;
}
.crt-btn:hover::before,
.crt-btn:focus-visible::before {
  opacity: 1;
  inset: -0.6cqh -0.8cqh;
  animation: select-pulse 0.8s ease-in-out infinite;
}
.crt-btn:active {
  transform: scale(0.98);
}

@keyframes select-pulse {
  50% {
    inset: -1.4cqh -1.6cqh;
  }
}
@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  48% { opacity: 1; }
  49% { opacity: 0.93; }
  50% { opacity: 1; }
  80% { opacity: 0.97; }
}

.tv-toast {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 6%;
  z-index: 4;
  padding: 2cqh 3cqh;
  border-radius: 2cqh;
  background: rgba(0, 0, 0, 0.85);
  border: 0.6cqh solid #fff;
  font: 6cqh/1.1 var(--font-crt);
  color: #fff;
  text-align: center;
  opacity: 0;
  transform: translateY(20%);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.tv-toast.is-visible {
  opacity: 1;
  transform: none;
}

.tv.is-off .tv-inner {
  animation: crt-off 0.45s ease-in forwards;
}
.tv.is-off::after {
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.9) 0, rgba(255, 255, 255, 0) 3%, transparent 4%), #000;
  animation: crt-dot 1.3s ease-out forwards;
}
.tv:not(.is-off) .tv-inner {
  animation: crt-on 0.35s ease-out, crt-flicker 5s 0.35s infinite;
}

@keyframes crt-off {
  0% { transform: scale(1, 1); filter: brightness(1); }
  50% { transform: scale(1, 0.006); filter: brightness(3); }
  100% { transform: scale(0, 0.006); filter: brightness(5); opacity: 0; }
}
@keyframes crt-dot {
  0%, 30% { opacity: 0; }
  35% { opacity: 1; }
  100% { opacity: 1; }
}
@keyframes crt-on {
  0% { transform: scale(0.2, 0.006); filter: brightness(4); }
  45% { transform: scale(1, 0.01); filter: brightness(3); }
  100% { transform: scale(1, 1); filter: brightness(1); }
}

.room-tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 6;
  padding: 4px 10px;
  background: #000;
  border: 2px solid #fff;
  border-radius: 4px;
  font: 1.25rem/1 var(--font-crt);
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}
.room-tip.is-visible {
  opacity: 1;
}

.room-hint {
  position: absolute;
  left: 50%;
  bottom: 64px;
  z-index: 5;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 1.25rem;
  white-space: nowrap;
  transition: opacity 0.4s;
  display: none;
}
.hero.is-live .room-hint {
  display: block;
}
.room-hint::after {
  content: '_';
  animation: blink 1s steps(1) infinite;
}
.room-hint.is-hidden {
  opacity: 0;
}

.hero-sound {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 5;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  animation: bob 1.6s ease-in-out infinite;
}
.scroll-cue span {
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border-right: 4px solid #fff;
  border-bottom: 4px solid #fff;
  transform: rotate(45deg);
}

@keyframes blink {
  50% { opacity: 0; }
}
@keyframes bob {
  50% { transform: translateY(6px); }
}

@media (max-width: 600px) {
  .tv-logo,
  .tv-tagline {
    display: none;
  }
  .tv-name {
    font-size: 16cqh;
  }
  .crt-btn {
    font-size: 8cqh;
  }
  .room-hint {
    top: 18px;
    bottom: auto;
    left: 16px;
    transform: none;
    font-size: 1.1rem;
  }
}

/* ---- sections ----------------------------------------------------------- */

.section {
  position: relative;
  padding: clamp(64px, 10vw, 120px) var(--gutter);
  background: radial-gradient(ellipse at 50% 0%, rgba(11, 16, 22, 0.55), rgba(8, 12, 17, 0.9) 70%);
}
.section + .section {
  border-top: 2px solid #18212b;
}
.section-head {
  max-width: 760px;
  margin: 0 auto clamp(32px, 5vw, 56px);
  text-align: center;
}
.eyebrow {
  margin-bottom: 10px;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--coin);
}
.section-head h2 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.5);
}
.lede {
  margin-top: 16px;
  font-size: 1.55rem;
  color: var(--ink-dim);
}

.panel {
  background: var(--panel);
  border: 2px solid var(--panel-line);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

/* Sections stay visible at rest and only animate in once they scroll into view. */
[data-reveal].is-revealed {
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1.2) both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
}

/* ---- play --------------------------------------------------------------- */

.play {
  padding-top: clamp(48px, 7vw, 80px);
}
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 420px);
  grid-template-areas:
    'board head'
    'board howto';
  grid-template-rows: auto 1fr;
  justify-content: center;
  align-items: start;
  gap: 20px clamp(24px, 4vw, 48px);
}
.play-head {
  grid-area: head;
  margin: 0;
  text-align: left;
}
.play-head h2 {
  font-size: clamp(2rem, 4vw, 2.8rem);
}
.howto {
  grid-area: howto;
}
.board {
  grid-area: board;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.board-frame {
  position: relative;
  width: min(100%, 500px, calc((100svh - 140px) * 168 / 252));
  min-width: 280px;
  padding: 8px;
  border-radius: 14px;
  background: #000;
  border: 2px solid var(--panel-line);
  box-shadow: 0 0 0 6px #10151b, 0 20px 60px rgba(0, 0, 0, 0.6);
}
.board-frame::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 8px;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% 50%, transparent 65%, rgba(0, 0, 0, 0.35) 100%);
}
.board-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 168 / 252;
  border-radius: 8px;
  image-rendering: pixelated;
  touch-action: manipulation;
  background: #141a20;
}
.board-canvas:focus-visible {
  outline-offset: 6px;
}
.board-hint {
  min-height: 1.4em;
  text-align: center;
  color: var(--ink-dim);
}

.board-result {
  position: absolute;
  inset: 8px;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 8px;
  background: rgba(3, 5, 8, 0.72);
  animation: fade-in 0.3s ease;
}
.board-result[hidden] {
  display: none;
}
.result-card {
  width: 100%;
  max-width: 340px;
  padding: 20px 18px;
  text-align: center;
  background: #000;
  border: 2px solid var(--panel-line);
  border-radius: var(--radius);
  animation: pop-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
.result-title {
  font: 700 1.9rem/1 var(--font-pixel);
}
.result-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 14px 0 6px;
}
.star {
  width: 48px;
  height: 48px;
  background: url('../assets/sprites/star.png') 0 0 / 96px 48px;
  image-rendering: pixelated;
  filter: grayscale(1) brightness(0.35);
}
.star.is-earned {
  filter: none;
  animation: star-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.6) both;
}
.star.is-earned:nth-child(2) {
  animation-delay: 0.2s;
}
.star.is-earned:nth-child(3) {
  animation-delay: 0.4s;
}
.result-score {
  font-size: 1.6rem;
  color: var(--coin);
}
.result-text {
  margin: 8px 0 16px;
  color: var(--ink-dim);
  font-size: 1.25rem;
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.result-actions .btn {
  font-size: 1.05rem;
}

@keyframes fade-in {
  from { opacity: 0; }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.7); }
}
@keyframes star-pop {
  from { transform: scale(0) rotate(-40deg); }
}

.howto {
  padding: 24px;
}
.howto h3 {
  font-size: 1.6rem;
  margin-bottom: 16px;
}
.howto-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 14px;
}
.howto-list li {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
}
.howto-list strong {
  color: #fff;
  font-weight: 400;
  text-decoration: underline 2px var(--purple);
  text-underline-offset: 3px;
}
.howto-list p {
  color: var(--ink-dim);
}
.howto-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #141a20;
  border: 2px solid var(--card-line);
  overflow: hidden;
}
.howto-extra {
  margin-bottom: 18px;
  color: var(--ink-dim);
}
.t-green { color: #6fe08c; }
.t-yellow { color: #fad640; }
.t-red { color: #ff7a6e; }

@media (max-width: 900px) {
  .play-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'head' 'board' 'howto';
  }
  .play-head {
    text-align: center;
  }
  .board-frame {
    min-width: 0;
  }
  .howto {
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
  }
}

/* ---- sprites ------------------------------------------------------------ */

.spr {
  display: block;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.spr-emitter {
  width: 48px;
  height: 48px;
  background: url('../assets/sprites/emitter.png') -144px 0 / 288px 48px;
}
.spr-flipper-loaded,
.spr-flipper-empty,
.spr-flipper-tool {
  width: 48px;
  height: 48px;
  background: url('../assets/sprites/flipper.png') 0 0 / 240px 48px;
}
.spr-flipper-empty {
  background-position: -192px 0;
}
.spr-flipper-tool {
  background-position: -96px 0;
}
.spr-flipper-loaded {
  position: relative;
}
.spr-flipper-loaded::after {
  content: '';
  position: absolute;
  left: 0;
  top: -6px;
  width: 24px;
  height: 24px;
  background: url('../assets/sprites/ball.png') 0 0 / 96px 24px;
  image-rendering: pixelated;
}
.spr-collector {
  position: relative;
  width: 48px;
  height: 48px;
}
.spr-collector::before,
.spr-collector::after {
  content: '';
  position: absolute;
  left: 12px;
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}
.spr-collector::before {
  top: 0;
  background: url('../assets/sprites/collector.png') 0 0 / 96px 24px;
}
.spr-collector::after {
  top: 24px;
  background: url('../assets/sprites/collector-number.png') -48px 0 / 120px 24px;
}
.spr-merge {
  width: 32px;
  height: 32px;
  background: url('../assets/sprites/ball-green.png') 0 0 / 128px 32px;
}
.spr-ball {
  width: 32px;
  height: 32px;
  background: url('../assets/sprites/ball.png') 0 0 / 128px 32px;
}
.spr-teleporter {
  width: 48px;
  height: 48px;
  background: url('../assets/sprites/teleporter.png') 0 0 / 192px 48px;
}
.spr-number {
  width: 48px;
  height: 48px;
  background: url('../assets/sprites/collector-number.png') -96px 0 / 240px 48px;
}
.spr-edge {
  width: 48px;
  height: 48px;
  background: url('../assets/sprites/edge.png') 0 0 / 48px 48px;
}

/* ---- feature cards ------------------------------------------------------ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 20px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 14px 22px;
  background: var(--card);
  border: 3px solid var(--card-line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: border-color 0.15s, transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1.4);
}
.card:hover {
  border-color: var(--card-line-hot);
  transform: translateY(-6px);
}
.card h3 {
  padding: 0 6px;
  font-size: 1.5rem;
}
.card p {
  padding: 0 6px;
  color: var(--ink-dim);
}

.card-art {
  position: relative;
  height: 208px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  overflow: hidden;
  background: #0c1117;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.7);
}
.mini-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

/* bonus ball: the window lights up, opens, and the ball inside gets placed */
.art-window {
  background: #141a20 url('../assets/sprites/brick.png') repeat;
  background-size: 64px 32px;
}
.art-window > span {
  position: absolute;
}
.window-glow {
  left: calc(50% - 138px);
  top: 24px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 106, 0.55), transparent 65%);
  opacity: 0;
  animation: window-glow 5s infinite;
}
.window {
  left: calc(50% - 90px);
  top: 56px;
  width: 64px;
  height: 96px;
}
.window > span {
  position: absolute;
  inset: 0;
}
.window-back {
  background: radial-gradient(circle at 50% 58%, #22313b, #06090c 70%);
  -webkit-mask: url('../assets/sprites/window-back.png') 0 0 / 320px 96px no-repeat;
  mask: url('../assets/sprites/window-back.png') 0 0 / 320px 96px no-repeat;
}
.window-ball {
  position: absolute;
  left: 16px;
  top: 40px;
  animation: window-ball 5s steps(1) infinite;
}
.window-glass {
  background: #4f6b7d;
  -webkit-mask: url('../assets/sprites/window-glass.png') 0 0 / 320px 96px no-repeat;
  mask: url('../assets/sprites/window-glass.png') 0 0 / 320px 96px no-repeat;
  animation: glass-light 5s infinite, window-open-mask 5s steps(1) infinite;
}
.window-frame {
  background: url('../assets/sprites/window.png') 0 0 / 320px 96px no-repeat;
  image-rendering: pixelated;
  animation: window-open 5s steps(1) infinite;
}
.window-target {
  left: calc(50% + 30px);
  top: 96px;
  width: 64px;
  height: 64px;
  background-size: 320px 64px;
  background-position: -256px 0;
}
.place-spot {
  left: calc(50% + 60px);
  top: 90px;
  width: 36px;
  height: 36px;
  border: 2px dashed #fff;
  border-radius: 50%;
  opacity: 0;
  animation: place-spot 5s infinite;
}
.placed-ball {
  left: calc(50% - 74px);
  top: 96px;
  opacity: 0;
  animation: placed-ball 5s infinite;
}

@keyframes window-glow {
  0%, 12% { opacity: 0; }
  20% { opacity: 1; }
  23% { opacity: 0.6; }
  26%, 40% { opacity: 1; }
  60%, 100% { opacity: 0; }
}
@keyframes glass-light {
  0%, 12% { background-color: #4f6b7d; }
  20%, 30% { background-color: #ffd76a; }
  23% { background-color: #ffe9a8; }
  46% { background-color: #ffd76a; }
  92%, 100% { background-color: #4f6b7d; }
}
@keyframes window-open {
  0% { background-position: 0 0; }
  32% { background-position: -64px 0; }
  36% { background-position: -128px 0; }
  40% { background-position: -192px 0; }
  44% { background-position: -256px 0; }
  96% { background-position: -192px 0; }
  97% { background-position: -128px 0; }
  98% { background-position: -64px 0; }
  99%, 100% { background-position: 0 0; }
}
@keyframes window-open-mask {
  0% { -webkit-mask-position: 0 0; mask-position: 0 0; }
  32% { -webkit-mask-position: -64px 0; mask-position: -64px 0; }
  36% { -webkit-mask-position: -128px 0; mask-position: -128px 0; }
  40% { -webkit-mask-position: -192px 0; mask-position: -192px 0; }
  44% { -webkit-mask-position: -256px 0; mask-position: -256px 0; }
  96% { -webkit-mask-position: -192px 0; mask-position: -192px 0; }
  97% { -webkit-mask-position: -128px 0; mask-position: -128px 0; }
  98% { -webkit-mask-position: -64px 0; mask-position: -64px 0; }
  99%, 100% { -webkit-mask-position: 0 0; mask-position: 0 0; }
}
@keyframes window-ball {
  0% { visibility: visible; }
  60%, 99% { visibility: hidden; }
}
@keyframes placed-ball {
  0%, 59.9% { opacity: 0; transform: translate(0, 0); }
  60% { opacity: 1; transform: translate(0, 0); }
  69% { transform: translate(68px, -48px); }
  78%, 90% { opacity: 1; transform: translate(136px, -4px); }
  81% { transform: translate(136px, -8px); }
  96%, 100% { opacity: 0; transform: translate(136px, -4px); }
}
@keyframes place-spot {
  0%, 48% { opacity: 0; transform: scale(1.3); }
  54%, 70% { opacity: 1; transform: scale(1); }
  62% { opacity: 0.5; transform: scale(1.1); }
  78%, 100% { opacity: 0; transform: scale(0.8); }
}

/* editor: the level editor toolbar, cycling through tools */
.art-editor {
  background: #141a20 url('../assets/sprites/brick.png') repeat;
  background-size: 64px 32px;
}
.toolbar {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  background: #0b0d10;
  border: 2px solid #2b2f36;
}
.tool {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #3a3f4a;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.35);
  animation: tool-select 5s steps(1) infinite;
}
.tool:nth-child(2) { animation-delay: 1s; }
.tool:nth-child(3) { animation-delay: 2s; }
.tool:nth-child(4) { animation-delay: 3s; }
.tool:nth-child(5) { animation-delay: 4s; }
@keyframes tool-select {
  0% { background: #3d64c9; transform: translateY(-4px); }
  20%, 100% { background: #3a3f4a; transform: none; }
}
@media (max-width: 380px) {
  .toolbar {
    gap: 3px;
    padding: 5px;
  }
  .tool {
    width: 46px;
    height: 46px;
  }
}

/* ---- screenshots -------------------------------------------------------- */

.gallery-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(8px, 2vw, 24px);
}
.crt {
  padding: clamp(12px, 2.4vw, 28px);
  padding-bottom: clamp(14px, 2.4vw, 22px);
  border-radius: clamp(18px, 3vw, 36px);
  background: linear-gradient(180deg, #4c524f, #333835);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.12),
    inset 0 -6px 0 rgba(0, 0, 0, 0.35),
    0 24px 60px rgba(0, 0, 0, 0.6);
}
.crt-screen {
  position: relative;
  overflow: hidden;
  border-radius: clamp(10px, 2vw, 22px) / clamp(12px, 2.4vw, 26px);
  background: #000;
  box-shadow: 0 0 0 4px #1d2120;
}
.crt-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.5) 100%),
    linear-gradient(165deg, rgba(255, 255, 255, 0.07), transparent 35%);
}
.crt-screen img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  image-rendering: auto;
}
.crt-noise {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 0.08s;
}
.crt-noise.is-active {
  opacity: 0.85;
}
.crt-osd {
  position: absolute;
  top: 6%;
  right: 5%;
  z-index: 2;
  font: clamp(1.4rem, 3.6vw, 2.6rem)/1 var(--font-crt);
  color: #6dff7a;
  text-shadow: 0 0 10px rgba(80, 255, 100, 0.7), 2px 2px 0 #000;
  opacity: 0;
}
.crt-osd.is-flash {
  animation: osd 2s steps(1) forwards;
}
@keyframes osd {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
.crt-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 1.3rem;
  color: #d9dfdb;
}
.crt-caption::after {
  content: '';
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3c413e;
  box-shadow: inset 0 0 0 3px #222;
}

.channel-btn {
  width: 48px;
  height: 64px;
  padding: 0;
  border: 2px solid var(--panel-line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  position: relative;
}
.channel-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  border-left: 5px solid #fff;
  border-bottom: 5px solid #fff;
  transform: translate(-30%, -50%) rotate(45deg);
}
.channel-btn.next::after {
  transform: translate(-70%, -50%) rotate(-135deg);
}
.channel-btn:hover {
  border-color: var(--card-line-hot);
}
.channel-btn:active {
  transform: scale(0.94);
}

.thumbs {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 22px auto 0;
  padding: 0;
  max-width: 900px;
}
.thumbs button {
  display: block;
  width: 100%;
  padding: 0;
  border: 3px solid var(--card-line);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.thumbs img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  image-rendering: auto;
}
.thumbs button:hover {
  transform: translateY(-3px);
}
.thumbs button[aria-current='true'] {
  border-color: var(--card-line-hot);
  box-shadow: 0 0 18px rgba(61, 143, 214, 0.45);
}

@media (max-width: 640px) {
  .gallery-stage {
    grid-template-columns: minmax(0, 1fr);
  }
  .channel-btn {
    display: none;
  }
  .thumbs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---- call to action ----------------------------------------------------- */

.cta {
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 120, 160, 0.25), rgba(8, 12, 17, 0.92) 70%);
}
.cta-card {
  display: grid;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(20px, 4vw, 48px);
  padding: clamp(20px, 4vw, 44px);
}
.cta-logo {
  width: 100%;
  height: auto;
  border-radius: 20px;
  image-rendering: auto;
  box-shadow: 0 0 60px rgba(77, 213, 234, 0.25);
  animation: float 4s ease-in-out infinite;
}
.cta-body {
  display: grid;
  gap: 16px;
  justify-items: start;
}
.cta-body h2 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
}
.cta-body > p:not(.eyebrow) {
  color: var(--ink-dim);
  font-size: 1.45rem;
}
.cta-body .eyebrow {
  margin: 0;
}
.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
  padding: 0;
}
.chips li {
  padding: 4px 10px;
  border-radius: 6px;
  background: #11161c;
  border: 2px solid #23303e;
  color: var(--ink-dim);
  font-size: 1.15rem;
}
@keyframes float {
  50% { transform: translateY(-8px) rotate(-1.5deg); }
}
@media (max-width: 700px) {
  .cta-card {
    grid-template-columns: minmax(0, 1fr);
    text-align: center;
  }
  .cta-logo {
    width: min(200px, 60%);
    margin: 0 auto;
  }
  .cta-body {
    justify-items: center;
  }
  .chips {
    justify-content: center;
  }
}

.footer {
  padding: 28px var(--gutter) 40px;
  text-align: center;
  color: #7d8a96;
  background: rgba(5, 7, 10, 0.95);
  border-top: 2px solid #18212b;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
