/* ============================================================
   NEONCADE — Design System Tokens
   "Midnight Arcade": graphite deep-space + per-game neon cells
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@400;600;800;900&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  /* ---- surfaces ---- */
  --bg-0: #07080c;
  --bg-1: #0e1018;
  --bg-2: #161927;
  --bg-3: #1f2336;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --grid-dot: rgba(255, 255, 255, 0.055);

  /* ---- text ---- */
  --text: #f3f4f8;
  --text-dim: #9aa0b4;
  --text-faint: #5c6178;

  /* ---- per-game neon signatures ---- */
  --lime: #b8ff3d;     /* Snake   */
  --gold: #ffc23d;     /* 2048    */
  --cyan: #3de0ff;     /* Flappy  */
  --magenta: #ff4db8;  /* Agar    */
  --coral: #ff6b4d;    /* brand / danger */

  /* default accent (overridden per page via --accent / --accent-rgb) */
  --accent: var(--cyan);
  --accent-rgb: 61, 224, 255;

  /* ---- type ---- */
  --font-display: 'Unbounded', system-ui, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, 'Courier New', monospace;

  /* ---- motion ---- */
  --pop: cubic-bezier(0.34, 1.56, 0.64, 1);   /* overshoot / arcade snap */
  --expo: cubic-bezier(0.22, 1, 0.36, 1);     /* smooth expo-out         */
  --t-fast: 140ms;
  --t-med: 280ms;
  --t-slow: 520ms;

  /* ---- shape ---- */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;

  /* ---- z ---- */
  --z-bg: 0;
  --z-grain: 60;
  --z-cursor: 9999;

  color-scheme: dark;
}

/* ============================================================
   RESET / BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-mono);
  background: var(--bg-1);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
canvas { display: block; touch-action: none; }
img, svg { display: block; }
::selection { background: rgba(var(--accent-rgb), 0.3); color: #fff; }

/* ============================================================
   ATMOSPHERE — dot grid, neon blobs, grain, vignette
   Reused on every page for a cohesive "living cabinet" feel.
   ============================================================ */
.atmos {
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(var(--accent-rgb), 0.10), transparent 55%),
    radial-gradient(100% 100% at 50% 120%, rgba(0, 0, 0, 0.55), transparent 60%),
    var(--bg-1);
}
/* drifting dot-grid */
.atmos::before {
  content: '';
  position: absolute;
  inset: -40px;
  background-image: radial-gradient(var(--grid-dot) 1.4px, transparent 1.6px);
  background-size: 26px 26px;
  animation: gridDrift 28s linear infinite;
  mask-image: radial-gradient(130% 100% at 50% 40%, #000 55%, transparent 92%);
}
/* vignette */
.atmos::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 220px 40px rgba(0, 0, 0, 0.6);
}
@keyframes gridDrift {
  to { background-position: 26px 26px; }
}

/* floating neon cells (agar.io nod) */
.blob {
  position: fixed;
  z-index: var(--z-bg);
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  pointer-events: none;
  will-change: transform;
}

/* film grain overlay */
.grain {
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  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='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   SHARED UI ATOMS — buttons, pills, chips
   ============================================================ */
.btn {
  --b: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding: 0.85em 1.6em;
  border-radius: var(--r-pill);
  color: var(--bg-0);
  background: var(--b);
  box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.5), 0 10px 30px -8px rgba(var(--accent-rgb), 0.6);
  transition: transform var(--t-fast) var(--pop), box-shadow var(--t-med) var(--expo);
}
.btn:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 0 0 5px rgba(var(--accent-rgb), 0.18), 0 16px 40px -10px rgba(var(--accent-rgb), 0.7); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn--ghost {
  color: var(--text);
  background: transparent;
  border: 1.5px solid var(--line-strong);
  box-shadow: none;
}
.btn--ghost:hover { border-color: rgba(var(--accent-rgb), 0.6); background: rgba(var(--accent-rgb), 0.06); box-shadow: none; transform: translateY(-2px); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.4em 0.8em;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.02);
}

/* focus-visible for keyboard users */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ============================================================
   CUSTOM CURSOR (desktop only, attached via JS)
   ============================================================ */
.neon-cursor {
  position: fixed;
  top: 0; left: 0;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px 3px rgba(var(--accent-rgb), 0.8);
  pointer-events: none;
  z-index: var(--z-cursor);
  mix-blend-mode: screen;
  transition: transform 90ms var(--expo), opacity 200ms;
  will-change: transform;
}
.neon-cursor.is-down { transform: scale(0.6); }
@media (hover: hover) and (pointer: fine) {
  body.cursor-ready, body.cursor-ready * { cursor: none; }
}

/* utility */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .atmos::before { animation: none; }
}
