@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

:root {
  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --line: #28283c;
  --text: #e9e9f2;
  --dim: #9aa0b5;
  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;

  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --sans: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --text-base: clamp(1rem, 0.94rem + 0.3vw, 1.0625rem);
  --space-section: clamp(4rem, 3rem + 5vw, 8rem);

  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  --hud-height: 48px;
}

* { box-sizing: border-box; margin: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--text-base);
  line-height: 1.65;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); }
button { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(69, 240, 255, 0.22);
  border-radius: 2px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.hud {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  height: var(--hud-height);
  padding: 0 clamp(0.75rem, 3vw, 1.5rem);
  background: rgba(10, 10, 18, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-family: var(--pixel);
  font-size: 10px;
  line-height: 1;
}

.hud__player {
  display: inline-flex; align-items: center; height: 100%;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  text-shadow: 0 0 10px rgba(69, 240, 255, 0.25);
  transition: color var(--duration-fast) ease;
}

.hud__player:hover { color: var(--cyan); }
.hud__label { color: var(--cyan); }

.hud__stats { display: flex; align-items: center; gap: clamp(0.9rem, 3vw, 1.75rem); }
.hud__score { color: var(--dim); white-space: nowrap; }

.hud__score-value {
  display: inline-block;
  min-width: 6.4em;
  color: var(--text);
  text-align: right;
}

.hud__coins {
  display: flex;
  align-items: center;
  gap: 0.45em;
  color: var(--gold);
  white-space: nowrap;
}

.hud__coin-icon { display: block; }

.hero {
  position: relative;
  overflow: hidden;
  min-height: calc(100svh - var(--hud-height));
  display: grid;
  place-items: center;
  padding: var(--space-section) 1.25rem;
  text-align: center;
  background:
    radial-gradient(ellipse 70% 55% at 50% 42%, rgba(69, 240, 255, 0.06), transparent 70%),
    var(--bg);
}

.stars { position: absolute; inset: 0; pointer-events: none; }

.stars__layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: calc(100% + 360px);
  background-repeat: repeat;
  will-change: transform;
}

.stars__layer--far {
  background-image:
    radial-gradient(1px 1px at 23px 41px, rgba(233, 233, 242, 0.5) 50%, transparent 50%),
    radial-gradient(1px 1px at 97px 133px, rgba(233, 233, 242, 0.3) 50%, transparent 50%),
    radial-gradient(1px 1px at 171px 67px, rgba(154, 160, 181, 0.45) 50%, transparent 50%),
    radial-gradient(1px 1px at 64px 251px, rgba(233, 233, 242, 0.35) 50%, transparent 50%),
    radial-gradient(1px 1px at 219px 317px, rgba(154, 160, 181, 0.3) 50%, transparent 50%),
    radial-gradient(1px 1px at 141px 199px, rgba(233, 233, 242, 0.25) 50%, transparent 50%);
  background-size: 260px 360px;
  animation: star-drift 200s linear infinite;
}

.stars__layer--mid {
  background-image:
    radial-gradient(2px 2px at 51px 89px, rgba(69, 240, 255, 0.5) 50%, transparent 50%),
    radial-gradient(1px 1px at 187px 161px, rgba(233, 233, 242, 0.55) 50%, transparent 50%),
    radial-gradient(2px 2px at 119px 283px, rgba(233, 233, 242, 0.4) 50%, transparent 50%),
    radial-gradient(1px 1px at 251px 37px, rgba(69, 240, 255, 0.35) 50%, transparent 50%);
  background-size: 300px 360px;
  animation: star-drift 120s linear infinite;
}

.stars__layer--near {
  background-image:
    radial-gradient(2px 2px at 83px 53px, rgba(255, 200, 87, 0.6) 50%, transparent 50%),
    radial-gradient(2px 2px at 233px 227px, rgba(255, 61, 139, 0.45) 50%, transparent 50%),
    radial-gradient(2px 2px at 157px 331px, rgba(233, 233, 242, 0.6) 50%, transparent 50%);
  background-size: 340px 360px;
  animation: star-drift 75s linear infinite;
}

@keyframes star-drift { to { transform: translate3d(0, -360px, 0); } }

.hero__inner {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: clamp(1.4rem, 3.5vw, 2.25rem);
  max-width: 52rem;
}

.hero__kicker {
  font-family: var(--pixel);
  font-size: clamp(8px, 1.8vw, 11px);
  color: var(--magenta);
  letter-spacing: 0.18em;
  text-shadow: 0 0 12px rgba(255, 61, 139, 0.4);
}

.glitch {
  position: relative;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(2rem, 0.5rem + 7.5vw, 5.25rem);
  line-height: 1.15;
  letter-spacing: 0.02em;
  color: var(--text);
  text-shadow: 0 0 18px rgba(69, 240, 255, 0.4), 0 0 52px rgba(69, 240, 255, 0.18);
}

.glitch::before,
.glitch::after {
  content: attr(data-text) / "";
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  text-shadow: none;
}

.glitch::before { color: var(--cyan); }
.glitch::after { color: var(--magenta); }

.glitch:hover::before,
.glitch.glitching::before { animation: glitch-slice-a 0.42s steps(3, jump-none) 1; }

.glitch:hover::after,
.glitch.glitching::after { animation: glitch-slice-b 0.42s steps(3, jump-none) 1; }

@keyframes glitch-slice-a {
  0%   { opacity: 0.8; clip-path: inset(8% 0 72% 0);  transform: translate3d(-5px, -2px, 0); }
  33%  { opacity: 0.8; clip-path: inset(54% 0 22% 0); transform: translate3d(4px, 1px, 0); }
  66%  { opacity: 0.8; clip-path: inset(28% 0 50% 0); transform: translate3d(-3px, 2px, 0); }
  100% { opacity: 0;   clip-path: inset(45% 0 45% 0); transform: translate3d(0, 0, 0); }
}

@keyframes glitch-slice-b {
  0%   { opacity: 0.8; clip-path: inset(64% 0 16% 0); transform: translate3d(5px, 2px, 0); }
  33%  { opacity: 0.8; clip-path: inset(12% 0 70% 0); transform: translate3d(-4px, -1px, 0); }
  66%  { opacity: 0.8; clip-path: inset(42% 0 36% 0); transform: translate3d(3px, -2px, 0); }
  100% { opacity: 0;   clip-path: inset(45% 0 45% 0); transform: translate3d(0, 0, 0); }
}

.hero__sub {
  color: var(--dim);
  font-size: clamp(1rem, 0.9rem + 0.6vw, 1.2rem);
  max-width: 34rem;
}

.hero__insert { color: var(--gold); font-weight: 600; }

.press-start {
  font-family: var(--pixel);
  font-size: clamp(11px, 2.4vw, 14px);
  color: var(--bg);
  background: var(--cyan);
  border: 0;
  padding: 1.05rem 1.7rem;
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--cyan), 0 0 30px rgba(69, 240, 255, 0.45);
  transition: transform var(--duration-fast) var(--ease-out-expo),
    box-shadow var(--duration-fast) var(--ease-out-expo);
}

.press-start:hover {
  transform: translateY(-3px);
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--cyan), 0 0 44px rgba(69, 240, 255, 0.65);
}

.press-start:active { transform: translateY(1px); }
.press-start:focus-visible { outline: 3px solid var(--gold); outline-offset: 7px; }

.press-start__cursor {
  display: inline-block;
  animation: blink 1.1s steps(2, jump-none) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.hero__coin {
  position: absolute;
  top: clamp(0.75rem, 3vw, 2rem);
  right: clamp(0.75rem, 3vw, 2rem);
  z-index: 2;
}

.levels,
.quest { padding: var(--space-section) clamp(1rem, 4vw, 2rem); }

.levels {
  max-width: 72rem;
  margin-inline: auto;
  scroll-margin-top: calc(var(--hud-height) + 1rem);
}

.section-title {
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(14px, 3.4vw, 22px);
  text-align: center;
  letter-spacing: 0.06em;
  margin-bottom: clamp(2.25rem, 5vw, 3.5rem);
  text-shadow: 0 0 16px rgba(69, 240, 255, 0.3);
}

.section-title__deco {
  color: var(--magenta);
  text-shadow: 0 0 12px rgba(255, 61, 139, 0.5);
}

.grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: clamp(1rem, 2.5vw, 1.75rem);
  min-height: 18rem; /* reserve space — JS renders cards, avoid CLS */
}

.grid__cell { display: grid; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 16rem;
  padding: 2rem 1.3rem 1.3rem;
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 60%);
  border: 2px solid var(--line);
  border-radius: 8px;
}

.card::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  width: 46%;
  height: 10px;
  background: repeating-linear-gradient(180deg, var(--line) 0 2px, transparent 2px 4px);
  border-radius: 2px;
}

.card__top,
.card__bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.card__level {
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--cyan);
  letter-spacing: 0.08em;
}

.card__genre {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--magenta);
  border: 1px solid rgba(255, 61, 139, 0.45);
  border-radius: 3px;
  padding: 0.15rem 0.45rem;
}

.card__name {
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.4;
  color: var(--text);
}

.card__desc { color: var(--dim); font-size: 0.95rem; flex-grow: 1; }

.card__stars { display: inline-flex; gap: 3px; }
.star { display: block; fill: var(--line); }

.star--on {
  fill: var(--gold);
  filter: drop-shadow(0 0 4px rgba(255, 200, 87, 0.55));
}

.card__play {
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 200, 87, 0.35);
  white-space: nowrap;
}

.card__arrow {
  display: inline-block;
  transition: transform var(--duration-fast) var(--ease-out-expo);
}

.card--live {
  text-decoration: none;
  color: var(--text);
  border-color: rgba(69, 240, 255, 0.4);
  transition: transform var(--duration-fast) var(--ease-out-expo),
    box-shadow var(--duration-fast) var(--ease-out-expo),
    border-color var(--duration-fast) ease;
}

.card--live:hover,
.card--live:focus-visible {
  transform: translateY(-6px);
  border-color: var(--cyan);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), 0 0 26px rgba(69, 240, 255, 0.28);
}

.card--live:hover .card__arrow,
.card--live:focus-visible .card__arrow { transform: translate3d(5px, 0, 0); }

.card--locked { align-items: stretch; color: var(--dim); overflow: hidden; }
.card--locked .card__level { color: var(--dim); }
.card--locked .card__genre { color: var(--dim); border-color: var(--line); }
.card--locked .card__name { color: var(--dim); letter-spacing: 0.3em; }

.card__lock {
  display: block;
  margin: 0.4rem auto 0;
  color: var(--dim);
  opacity: 0.85;
}

.card__desc--locked {
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.2em;
  text-align: center;
  color: var(--dim);
}

.card__static {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.card__static::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -84px;
  height: calc(100% + 84px);
  background: repeating-linear-gradient(0deg,
    rgba(233, 233, 242, 0.05) 0 1px, transparent 1px 3px,
    rgba(69, 240, 255, 0.035) 3px 4px, transparent 4px 7px);
  animation: static-roll 1.5s linear infinite;
}

@keyframes static-roll { to { transform: translate3d(0, 84px, 0); } }

.card__coin { position: absolute; right: 10px; bottom: 8px; }

/* ---------- coin buttons ---------- */
.coin-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -7px; /* 44px touch target, same 30px layout footprint */
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out-expo);
}

.coin-btn:hover,
.coin-btn:focus-visible { opacity: 1; transform: scale(1.2); }

.coin-btn svg { display: block; width: 16px; height: 16px; }

.coin-btn--flip svg { animation: coin-flip 0.55s var(--ease-out-expo) both; }

@keyframes coin-flip {
  0%   { transform: rotateY(0deg) translateY(0); opacity: 1; }
  60%  { transform: rotateY(540deg) translateY(-16px); opacity: 1; }
  100% { transform: rotateY(720deg) translateY(0); opacity: 0; }
}

.coin-btn--got { opacity: 0.15; cursor: default; transform: none; }
.coin-btn--got svg { filter: grayscale(1); }

.coin-btn--got:hover,
.coin-btn--got:focus-visible { opacity: 0.15; transform: none; }

/* scroll-revealed coin dock */
.scroll-coin {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 90;
  opacity: 0;
  visibility: hidden; /* keeps the hidden coin out of the tab order */
  transform: translateY(16px);
  transition: opacity var(--duration-normal) var(--ease-out-expo),
    transform var(--duration-normal) var(--ease-out-expo),
    visibility 0s var(--duration-normal);
  pointer-events: none;
}

.scroll-coin--visible { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition-delay: 0s; }

/* ---------- quest strip ---------- */
.quest {
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.quest__copy { max-width: 38rem; margin: 0 auto 2rem; color: var(--dim); }

.quest__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1.25rem 2rem;
}

.quest__main {
  font-family: var(--pixel);
  font-size: clamp(10px, 2vw, 12px);
  color: var(--gold);
  text-decoration: none;
  border: 2px solid var(--gold);
  padding: 0.85rem 1.2rem;
  box-shadow: 0 0 18px rgba(255, 200, 87, 0.18);
  transition: transform var(--duration-fast) var(--ease-out-expo),
    background-color var(--duration-fast) ease,
    color var(--duration-fast) ease;
}

.quest__main:hover {
  background: var(--gold);
  color: var(--bg);
  transform: translateY(-2px);
}

.quest__gh {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--dim);
  text-decoration-color: var(--line);
  transition: color var(--duration-fast) ease;
}

.quest__gh:hover { color: var(--cyan); }

/* ---------- footer ---------- */
.footer {
  padding: clamp(2.5rem, 5vw, 4rem) 1.25rem 2.5rem;
  text-align: center;
  display: grid;
  gap: 1.1rem;
  justify-items: center;
}

.footer__copy {
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--dim);
  line-height: 2;
}

.footer__flavor {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--gold);
  letter-spacing: 0.18em;
}

.footer__blink {
  display: inline-block;
  animation: blink 2.2s steps(2, jump-none) infinite;
}

.footer__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
}

.footer__link { font-family: var(--mono); font-size: 0.85rem; color: var(--dim); }
.footer__link:hover { color: var(--cyan); }

.footer__crt {
  font-family: var(--pixel);
  font-size: 8px;
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.85rem 0.9rem;
  cursor: pointer;
  transition: color var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}

.footer__crt:hover { color: var(--cyan); border-color: var(--cyan); }

.footer__crt[aria-pressed="true"] {
  color: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 12px rgba(65, 255, 139, 0.35);
}

.footer__reset {
  background: transparent; border: 0; padding: 0.65rem 0.5rem;
  font-family: var(--mono); font-size: 0.78rem; color: var(--dim);
  text-decoration: underline; text-decoration-color: var(--line); cursor: pointer;
}

.footer__reset:hover { color: var(--red); }

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: min(20rem, calc(100vw - 28px));
  pointer-events: none;
}

.toast {
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1.8;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--gold);
  border-left: 4px solid var(--gold);
  padding: 0.7rem 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 14px rgba(255, 200, 87, 0.18);
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  transition: opacity var(--duration-normal) var(--ease-out-expo),
    transform var(--duration-normal) var(--ease-out-expo);
}

.toast--in { opacity: 1; transform: none; }
.toast--out { opacity: 0; transform: translate3d(0, -10px, 0); }

/* ---------- confetti ---------- */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  overflow: hidden;
}

.confetti__piece {
  position: absolute;
  top: -20px;
  width: 7px;
  height: 11px;
  will-change: transform, opacity;
}

/* ---------- CRT mode ---------- */
body.crt::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
}

body.crt::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 56%, rgba(0, 0, 0, 0.4) 100%);
  box-shadow: inset 0 0 130px rgba(69, 240, 255, 0.07),
    inset 6px 0 30px rgba(255, 61, 139, 0.05),
    inset -6px 0 30px rgba(69, 240, 255, 0.06);
}

/* ---------- noscript ---------- */
.noscript-note { text-align: center; color: var(--dim); margin-bottom: 0.75rem; }
.noscript-link { display: block; text-align: center; font-family: var(--mono); }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .hud { font-size: 8px; }
  .hud__label { display: none; }
  .hud__score-value { min-width: 6.2em; }
}

@media (max-width: 360px) {
  .hud__stats { gap: 0.7rem; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .stars__layer,
  .press-start__cursor,
  .footer__blink,
  .card__static::before,
  .coin-btn--flip svg { animation: none !important; }

  .glitch:hover::before,
  .glitch.glitching::before,
  .glitch:hover::after,
  .glitch.glitching::after { animation: none !important; opacity: 0 !important; }

  .card--live,
  .card--live:hover,
  .card--live:focus-visible,
  .press-start:hover,
  .quest__main:hover,
  .coin-btn:hover,
  .coin-btn:focus-visible { transform: none; }
}

/* ---------- filter rack ---------- */
.filter-rack { display: flex; justify-content: center; gap: 0.6rem; flex-wrap: wrap; margin: 0 0 2rem; }
.filter-chip {
  font-family: var(--font-pixel, 'Press Start 2P', monospace); font-size: 0.55rem;
  letter-spacing: 0.08em; color: var(--dim); background: var(--surface);
  border: 1px solid var(--line); padding: 0.7rem 1rem; min-height: 40px;
  cursor: pointer; transition: color 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.filter-chip:hover { color: var(--text); border-color: var(--cyan); transform: translateY(-2px); }
.filter-chip:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.filter-chip[aria-pressed='true'] { color: var(--cyan); border-color: var(--cyan); background: var(--surface-2); box-shadow: 0 0 12px rgba(69, 240, 255, 0.18); }
.filter-chip__count { color: var(--gold); margin-left: 0.25rem; }
.grid__cell--hidden { display: none; }
@media (prefers-reduced-motion: reduce) { .filter-chip { transition: none; } .filter-chip:hover { transform: none; } }
