:root {
  --bg: #0c1410;
  --bg-elev: #13201a;
  --ink: #e8f0ea;
  --muted: #8aa092;
  --line: rgba(184, 242, 85, 0.14);
  --accent: #b8f255;
  --accent-ink: #0d1f17;
  --warm: #ff8a4c;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --display: "Syne", "IBM Plex Sans", sans-serif;
  --bar-h: 52px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

/* —— Home —— */
.home-body { min-height: 100%; position: relative; overflow-x: hidden; }

.atmosphere {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(184, 242, 85, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(255, 138, 76, 0.12), transparent 50%),
    radial-gradient(ellipse 70% 60% at 50% 100%, rgba(19, 80, 60, 0.35), transparent 55%),
    linear-gradient(180deg, #0a120e 0%, #0c1410 40%, #0e1a14 100%);
}
.atmosphere::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  opacity: 0.4;
  mix-blend-mode: overlay;
}

.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  opacity: 0.5;
}

.topbar, .stage, .site-foot { position: relative; z-index: 1; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; gap: 16px;
}
.brand-lockup {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-ink);
  border: 2px solid var(--accent);
  box-shadow: inset 0 0 0 5px var(--accent-ink), inset 0 0 0 7px var(--accent);
  animation: pulse-ring 2.8s ease-in-out infinite;
}
.brand {
  font-family: var(--display); font-weight: 800; font-size: 1.25rem;
  letter-spacing: -0.04em;
}
.top-links { display: flex; gap: 18px; }
.top-links a {
  color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 500;
  transition: color 0.2s;
}
.top-links a:hover { color: var(--accent); }

.stage {
  max-width: 1100px; margin: 0 auto;
  padding: 8px 24px 72px;
}

.hero {
  padding: clamp(28px, 7vh, 64px) 0 36px;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.hero-brand {
  margin: 0 0 12px;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(4.5rem, 14vw, 7.5rem);
  letter-spacing: -0.06em; line-height: 0.9;
  background: linear-gradient(135deg, #e8f0ea 20%, var(--accent) 90%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  animation: brand-sheen 4.5s ease-in-out infinite;
}
.lede {
  margin: 0 0 28px; max-width: 28rem;
  color: var(--muted); font-size: 1.1rem; line-height: 1.45;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.launch-form {
  display: flex; gap: 10px; max-width: 560px; width: 100%;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.14s both;
}
.launch-form input,
.player-nav input {
  flex: 1; min-width: 0; height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(19, 32, 26, 0.85); color: var(--ink);
  font: 500 1rem var(--font); outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.launch-form input:focus,
.player-nav input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 242, 85, 0.18);
}
.launch-form input::placeholder { color: #5f7366; }

.go {
  height: 48px; padding: 0 22px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font: 700 0.95rem var(--display); letter-spacing: -0.02em;
  cursor: pointer; transition: transform 0.15s, filter 0.15s;
}
.go:hover { filter: brightness(1.06); transform: translateY(-1px); }
.go:active { transform: translateY(0); }

.library { animation: rise 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.22s both; }
.library-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.section-title {
  margin: 0;
  font-family: var(--display); font-weight: 700; font-size: 0.95rem;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.game-count {
  margin: 0; color: var(--muted); font-size: 0.85rem; font-weight: 500;
}

.category-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 18px;
}
.cat-chip {
  appearance: none; border: 1px solid var(--line);
  background: rgba(19, 32, 26, 0.65); color: var(--muted);
  font: 600 0.82rem var(--font); letter-spacing: 0.01em;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.15s;
}
.cat-chip:hover {
  color: var(--ink); border-color: rgba(184, 242, 85, 0.35);
  transform: translateY(-1px);
}
.cat-chip.is-active {
  color: var(--accent-ink); background: var(--accent); border-color: var(--accent);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.game-tile {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 148px; padding: 18px;
  text-decoration: none; color: var(--ink);
  background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 14px;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.game-tile:hover {
  transform: translateY(-3px);
  border-color: rgba(184, 242, 85, 0.35);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.game-tile strong {
  position: relative; z-index: 1;
  font-family: var(--display); font-weight: 700; font-size: 1.15rem;
  letter-spacing: -0.03em; margin-bottom: 4px;
}
.game-tile > span:not(.tile-glow):not(.tile-cat) {
  position: relative; z-index: 1;
  color: var(--muted); font-size: 0.88rem; line-height: 1.35;
}
.tile-cat {
  position: relative; z-index: 1;
  align-self: flex-start;
  margin-bottom: auto;
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
  opacity: 0.75;
}
.tile-glow {
  position: absolute; inset: auto -20% -40% -20%; height: 70%;
  border-radius: 50%; filter: blur(28px); opacity: 0.55;
  pointer-events: none; transition: opacity 0.25s;
}
.game-tile:hover .tile-glow { opacity: 0.8; }
.tile-glow.cg { background: #b8f255; }
.tile-glow.pk { background: #4cc9f0; }
.tile-glow.lol { background: #ff8a4c; }
.tile-glow.ss { background: #f4d35e; }
.tile-glow.kr { background: #ff6b6b; }
.tile-glow.cm { background: #7bdff2; }
.tile-glow.ag { background: #c3f584; }
.tile-glow.io { background: #9b8cff; }
.tile-glow.warm { background: #ff8a4c; }

.library-empty {
  margin: 28px 0 0; color: var(--muted); font-size: 0.95rem;
}
.library-empty[hidden] { display: none; }

.site-foot {
  max-width: 1100px; margin: 0 auto;
  padding: 8px 24px 48px;
  color: var(--muted); font-size: 0.85rem;
}
.site-foot p { margin: 0; max-width: 36rem; line-height: 1.45; }

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-ring {
  0%, 100% { box-shadow: inset 0 0 0 5px var(--accent-ink), inset 0 0 0 7px var(--accent); }
  50% { box-shadow: inset 0 0 0 4px var(--accent-ink), inset 0 0 0 8px var(--accent); }
}
@keyframes brand-sheen {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}

/* —— Player —— */
.player-body {
  display: flex; flex-direction: column; height: 100%;
  background: #070b09;
}
.player-bar {
  flex: 0 0 var(--bar-h); height: var(--bar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: #0f1a14; border-bottom: 1px solid var(--line);
  z-index: 2;
}
.brand-lockup.compact .brand { font-size: 1.05rem; }
.brand-lockup.compact .brand-mark { width: 22px; height: 22px; border-radius: 6px; animation: none; }

.player-nav {
  flex: 1; display: flex; gap: 8px; min-width: 0; margin: 0;
}
.player-nav input { height: 36px; font-size: 0.9rem; border-radius: 8px; }
.player-nav .go { height: 36px; padding: 0 14px; border-radius: 8px; font-size: 0.85rem; }

.player-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: rgba(184, 242, 85, 0.1); color: var(--accent); }

.player-stage {
  flex: 1; position: relative; min-height: 0; background: #000;
}
.player-stage iframe {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; background: #000;
}
.player-empty {
  position: absolute; inset: 0; margin: 0;
  display: grid; place-items: center;
  color: var(--muted); font-size: 1rem;
}
.player-empty a { color: var(--accent); }
.player-empty[hidden] { display: none; }

.player-stage:fullscreen,
.player-stage:-webkit-full-screen {
  background: #000;
}

/* —— Errors —— */
.error-page {
  display: grid; place-items: center; min-height: 100%;
  padding: 2rem; background: var(--bg); color: var(--ink);
  font-family: var(--font);
}
.error-page main { max-width: 36rem; }
.error-page .brand {
  font-family: var(--display); color: var(--accent);
  margin: 0 0 0.5rem; font-size: 1.35rem; font-weight: 800;
}
.error-page h1 { margin: 0 0 0.75rem; font-family: var(--display); }
.muted { color: var(--muted); }
.break { word-break: break-all; font-size: 0.85rem; }
.back {
  display: inline-block; margin-top: 1.25rem;
  color: var(--accent); font-weight: 600; text-decoration: none;
}
.back:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .topbar { padding: 14px 16px; }
  .stage { padding: 4px 16px 40px; }
  .site-foot { padding: 0 16px 40px; }
  .hero-brand { font-size: clamp(3.5rem, 18vw, 5rem); }
  .launch-form { flex-direction: column; }
  .launch-form .go { width: 100%; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
  .game-tile { min-height: 132px; padding: 14px; }
  .player-bar .brand { display: none; }
}
