/* ============================================================
   NEXUS GAMES — premium dark UI
   ============================================================ */
:root {
  --bg: #05060f;
  --bg-2: #0a0d1d;
  --card: #10142a;
  --card-hi: #161c3d;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef1ff;
  --muted: #8b93b8;
  --acc1: #7c5cff;
  --acc2: #38bdf8;
  --acc3: #4ade80;
  --danger: #f87171;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Inter", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  /* NOTE: overflow-x:hidden here breaks position:sticky (top bar vanishes on scroll).
     overflow-x:clip clips without creating a scroll container, so sticky keeps working. */
  overflow-x: clip;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { max-width: 100%; }
::selection { background: rgba(124, 92, 255, 0.45); }

/* ---------- animated background ---------- */
.bg-fx { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.32; }
.orb-a { width: 640px; height: 640px; background: #5b3df5; top: -220px; left: -120px; animation: drift 26s ease-in-out infinite alternate; }
.orb-b { width: 520px; height: 520px; background: #0ea5e9; bottom: -180px; right: -100px; animation: drift 32s ease-in-out infinite alternate-reverse; }
.orb-c { width: 400px; height: 400px; background: #22c55e; top: 40%; left: 55%; opacity: 0.14; animation: drift 40s ease-in-out infinite alternate; }
.grid-overlay {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 40%, transparent 100%);
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(90px, 60px) scale(1.12); }
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(5, 6, 15, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark { filter: drop-shadow(0 0 10px rgba(124, 92, 255, 0.6)); }
.brand-name { font-weight: 800; letter-spacing: 1.5px; font-size: 17px; }
.brand-name em { font-style: normal; background: linear-gradient(90deg, var(--acc1), var(--acc2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.search-wrap { flex: 1; max-width: 560px; position: relative; display: flex; align-items: center; }
.search-ic { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
#search {
  width: 100%; padding: 11px 42px 11px 42px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  color: var(--text); font-size: 14px; outline: none; transition: 0.2s;
}
#search::placeholder { color: var(--muted); }
#search:focus { border-color: rgba(124, 92, 255, 0.7); box-shadow: 0 0 0 3px rgba(124, 92, 265, 0.15); }
.search-kbd {
  position: absolute; right: 12px; font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px;
  background: rgba(255, 255, 255, 0.04);
}

.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--card);
  transition: 0.18s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: var(--card-hi); border-color: rgba(124, 92, 255, 0.5); transform: translateY(-1px); }
.icon-btn.on { background: linear-gradient(135deg, rgba(124,92,255,.25), rgba(56,189,248,.2)); border-color: rgba(124,92,255,.6); color: #fff; }

/* ---------- Google Classroom button ---------- */
.gc-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 13.5px;
  color: #fff; border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(135deg, #1a73e8, #4285f4);
  box-shadow: 0 6px 20px rgba(66, 133, 244, 0.35);
  transition: 0.18s;
}
.gc-btn svg { width: 18px; height: 18px; }
.gc-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(66, 133, 244, 0.5); filter: brightness(1.08); }
.gc-btn:active { transform: translateY(0); }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.2fr 0.8fr; align-items: center;
  gap: 30px;
  max-width: 1280px; margin: 0 auto;
  padding: clamp(40px, 7vw, 84px) clamp(16px, 4vw, 40px) 30px;
}
.hero-chip {
  display: inline-block; font-size: 12.5px; font-weight: 700; letter-spacing: 0.4px;
  color: #c9b8ff; border: 1px solid rgba(124, 92, 255, 0.35);
  background: rgba(124, 92, 255, 0.12);
  padding: 7px 14px; border-radius: 999px;
}
.hero h1 { font-size: clamp(38px, 5.5vw, 64px); line-height: 1.05; margin: 18px 0 14px; font-weight: 900; letter-spacing: -1px; }
.grad { background: linear-gradient(90deg, var(--acc1), var(--acc2), var(--acc3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--muted); font-size: clamp(15px, 1.4vw, 17.5px); line-height: 1.65; max-width: 52ch; margin: 0 0 26px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 24px; border-radius: 14px; font-weight: 700; font-size: 14.5px;
  transition: 0.18s;
}
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--acc1), #5b8cff); box-shadow: 0 10px 30px rgba(124, 92, 255, 0.4); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 38px rgba(124, 92, 255, 0.55); }
.btn-ghost { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); transform: translateY(-2px); }

.hero-stats { display: flex; gap: 34px; margin-top: 34px; }
.hero-stats b { display: block; font-size: 26px; font-weight: 900; background: linear-gradient(90deg, #fff, #9aa7ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-stats span { color: var(--muted); font-size: 12.5px; letter-spacing: 1px; text-transform: uppercase; }

.hero-art { position: relative; height: 360px; }
.hero-orb {
  position: absolute; inset: 8% 4%;
  border-radius: 32px;
  background:
    radial-gradient(circle at 30% 25%, rgba(124, 92, 255, 0.5), transparent 55%),
    radial-gradient(circle at 75% 70%, rgba(56, 189, 248, 0.4), transparent 55%),
    linear-gradient(160deg, #151a3a, #0a0d20);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: float 7s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-16px); } }
.float-card {
  position: absolute; display: flex; align-items: center; justify-content: center;
  width: 74px; height: 74px; border-radius: 20px; font-size: 34px;
  background: var(--card-hi); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: float 6s ease-in-out infinite;
}
.fc-1 { top: 4%; left: 0; animation-delay: -1s; }
.fc-2 { top: 30%; right: 2%; animation-delay: -3s; }
.fc-3 { bottom: 6%; left: 14%; animation-delay: -5s; }

/* ---------- filter bar ---------- */
.filterbar {
  max-width: 1280px; margin: 10px auto 8px;
  padding: 0 clamp(16px, 4vw, 40px);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.chip {
  padding: 9px 16px; border-radius: 999px; font-size: 13px; font-weight: 700;
  color: var(--muted); border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  transition: 0.16s; white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: rgba(124, 92, 255, 0.5); transform: translateY(-1px); }
.chip.on { color: #fff; background: linear-gradient(135deg, var(--acc1), #5b8cff); border-color: transparent; box-shadow: 0 6px 18px rgba(124, 92, 255, 0.35); }

.sort-wrap { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.sort-wrap select {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; font-size: 13px; outline: none; cursor: pointer;
}

/* ---------- game grid ---------- */
.grid-section { max-width: 1280px; margin: 0 auto; padding: 10px clamp(16px, 4vw, 40px) 80px; }
.grid-title { font-size: 20px; font-weight: 800; margin: 18px 0 16px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.card {
  position: relative; display: block;
  border-radius: var(--radius); overflow: hidden;
  background: var(--card); border: 1px solid var(--line);
  cursor: pointer; transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-5px); border-color: rgba(124, 92, 255, 0.55); box-shadow: 0 16px 38px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(124, 92, 255, 0.2); }
.card-thumb {
  position: relative; width: 100%; aspect-ratio: 4 / 3; display: block; overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, rgba(124, 92, 255, 0.28), transparent 60%),
    linear-gradient(140deg, #1a1f45, #0c1026);
}
.thumb-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 46px; font-weight: 900; letter-spacing: -1px;
  background: linear-gradient(135deg, var(--acc1), var(--acc2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  opacity: 0.85;
}
.card-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.card-body { padding: 10px 12px 12px; }
.card-title { font-size: 13.5px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.tag { font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); }
.card-fav {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 6, 15, 0.65); backdrop-filter: blur(4px);
  opacity: 0; transition: 0.15s;
}
.card:hover .card-fav, .card-fav.on { opacity: 1; }
.card-fav svg { width: 16px; height: 16px; }
.card-fav.on { color: #ff6d8d; }
.card-fav:hover { transform: scale(1.12); }

/* ---------- player overlay ---------- */
.player {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 4, 10, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; flex-direction: column;
}
.player-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px clamp(12px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(10, 13, 29, 0.8);
}
.player-title { flex: 1; font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-tools { display: flex; gap: 8px; }
#frame { flex: 1; width: 100%; border: 0; background: #000; }
.player[hidden] { display: none; }

/* ---------- empty state ---------- */
.empty { color: var(--muted); text-align: center; padding: 60px 0; font-size: 15px; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); background: rgba(5, 6, 15, 0.7); }
.footer-inner {
  max-width: 1280px; margin: 0 auto; padding: 34px clamp(16px, 4vw, 40px) 44px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px;
}
.foot-brand { font-weight: 800; letter-spacing: 1.5px; }
.foot-brand em { font-style: normal; background: linear-gradient(90deg, var(--acc1), var(--acc2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.footer p { margin: 0; color: var(--muted); font-size: 13px; flex: 1; min-width: 240px; }
.footer p a { color: #a9b4ff; }
.footer p a:hover { text-decoration: underline; }

/* ---------- proxy banner (shown only when the /g/ game server is unreachable) ---------- */
.proxy-banner {
  position: fixed; z-index: 130; left: 16px; bottom: 16px; max-width: 350px;
  background: var(--bg-2); border: 1px solid rgba(248, 113, 113, 0.45); border-radius: 16px;
  padding: 14px; box-shadow: var(--shadow); font-size: 13px; color: var(--text);
}
.proxy-banner b { display: block; margin-bottom: 6px; }
.proxy-banner code { background: rgba(255, 255, 255, 0.07); padding: 1px 5px; border-radius: 5px; }
.proxy-banner .cloak-row { margin-top: 10px; }

/* ---------- cloak menu ---------- */
.cloak-menu {
  position: fixed; z-index: 120; top: 64px; right: 16px;
  width: 260px; padding: 14px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow);
}
.cloak-menu h4 { margin: 2px 4px 10px; font-size: 13px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); }
.cloak-row { display: flex; gap: 8px; }
.cloak-menu select, .cloak-menu input {
  flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 9px 10px; font-size: 13px; outline: none;
}
.cloak-menu select:focus, .cloak-menu input:focus { border-color: rgba(124, 92, 255, 0.6); }
.cloak-menu small { display: block; margin-top: 8px; color: var(--muted); font-size: 11.5px; }
.cloak-menu small code { background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 5px; }

/* ---------- misc ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 46px; }
  .hero-art { display: none; }
  .hero-stats { gap: 24px; }
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .search-wrap { order: 3; min-width: 100%; }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .gc-btn span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .orb, .float-card, .hero-orb { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- credit gate (10s disclaimer) ---------- */
.credit-gate {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(3, 4, 10, 0.9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: gateIn 0.45s ease both;
}
.credit-gate.credit-gone { opacity: 0; transform: scale(1.04); transition: opacity 0.4s ease, transform 0.4s ease; }
@keyframes gateIn { from { opacity: 0; } }
.credit-card {
  max-width: 560px; width: 100%; text-align: center;
  background: linear-gradient(180deg, var(--bg-2), var(--card));
  border: 1px solid rgba(124, 92, 255, 0.4); border-radius: 24px;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.12), 0 40px 90px rgba(0, 0, 0, 0.6);
  padding: 34px clamp(22px, 5vw, 44px) 30px;
  animation: cardPop 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) 0.1s both;
}
@keyframes cardPop { from { opacity: 0; transform: translateY(26px) scale(0.92); } }
.credit-mark { margin-bottom: 10px; }
.credit-chip {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: 2.4px;
  color: #fca5a5; background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35); margin-bottom: 16px;
}
.credit-title {
  margin: 0 0 12px; font-size: clamp(21px, 4.2vw, 27px); line-height: 1.35; font-weight: 800;
}
.credit-name {
  background: linear-gradient(90deg, var(--acc1), var(--acc2), var(--acc3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.credit-name-small { font-size: 0.72em; font-weight: 700; color: var(--text); }
.credit-sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.credit-btn {
  padding: 13px 30px; border-radius: 14px; font-weight: 800; font-size: 15px;
  color: #eef1ff;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line); cursor: not-allowed;
  letter-spacing: 0.4px; min-width: 240px;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s, transform 0.15s;
}
.credit-btn-live {
  cursor: pointer; color: #fff;
  background: linear-gradient(90deg, var(--acc1), var(--acc2));
  border-color: transparent;
  box-shadow: 0 10px 32px rgba(124, 92, 255, 0.45);
}
.credit-btn-live:hover { transform: translateY(-1px); }

/* ---------- perf: let the browser skip offscreen game cards ---------- */
.grid .card { content-visibility: auto; contain-intrinsic-size: auto 460px; }

/* ---------- spin-the-wheel picker ---------- */
.wheel {
  position: fixed; inset: 0; z-index: 9500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: rgba(3, 4, 10, 0.88);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.wheel-gone { opacity: 0; transition: opacity 0.28s ease; pointer-events: none; }
.wheel-card {
  max-width: min(540px, 84vw); display: flex; align-items: center; justify-content: center;
  padding: 30px clamp(20px, 6vw, 52px); text-align: center;
  background: linear-gradient(135deg, var(--bg-2), var(--card));
  border: 1px solid rgba(124, 92, 255, 0.55); border-radius: 22px;
  box-shadow: 0 0 60px rgba(124, 92, 255, 0.35), var(--shadow);
}
.wheel-pop { animation: wheelPop 0.09s ease-out both; }
@keyframes wheelPop { from { transform: scale(1.06); border-color: rgba(56, 189, 248, 0.9); } }
.wheel-face { font-size: clamp(20px, 4.4vw, 30px); font-weight: 800; }
.wheel-label {
  color: var(--muted); font-size: 14px; font-weight: 700; letter-spacing: 2px; text-transform: lowercase;
  animation: labelPulse 0.7s ease-in-out infinite alternate;
}
@keyframes labelPulse { from { opacity: 0.45; } to { opacity: 1; } }

/* ---------- boss key: fake homework skin ---------- */
.boss-sheet {
  position: fixed; inset: 0; z-index: 9600;
  background: #f9f9f9; color: #202124;
  font-family: Arial, Helvetica, sans-serif;
  user-select: none; -webkit-user-select: none;
  display: flex; flex-direction: column;
  animation: bossIn 0.18s ease both;
}
@keyframes bossIn { from { opacity: 0; } }
.bs-topbar {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-bottom: 1px solid #e8eaed; padding: 10px 16px;
}
.bs-docname { color: #5f6368; font-size: 16px; }
.bs-tools { margin-left: auto; }
.bs-avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: #1a73e8; color: #fff; font-size: 13px; font-weight: 700;
}
.bs-menubar {
  display: flex; gap: 18px; padding: 7px 16px; background: #fff;
  border-bottom: 1px solid #e8eaed; color: #5f6368; font-size: 13px;
}
.bs-page-wrap { flex: 1; overflow: hidden; background: #f9f9f9; padding: 26px 0; }
.bs-page {
  width: min(794px, 92vw); min-height: 1056px; margin: 0 auto;
  background: #fff; box-shadow: 0 1px 6px rgba(60, 64, 67, 0.3);
  padding: 96px 96px 72px; font-size: 15px; line-height: 1.85;
  color: #202124; overflow: hidden;
}
.bs-h1 { text-align: center; font-size: 17pt; font-weight: 700; margin-bottom: 26px; }
.bs-p { text-indent: 2em; margin: 0 0 12px; }
.bs-cited { white-space: pre-line; font-size: 12.5pt; margin-top: 30px; }
.bs-foot { text-align: center; color: #5f6368; margin-top: 34px; font-size: 10.5pt; }
.bs-cursor {
  display: inline-block; width: 2px; height: 1.1em; background: #202124;
  animation: bsBlink 1s steps(1) infinite;
}
@keyframes bsBlink { 50% { opacity: 0; } }
.boss-hint {
  position: fixed; left: 12px; bottom: 10px; z-index: 9601;
  color: #5f6368; font-size: 11px; background: rgba(232, 234, 237, 0.85);
  padding: 5px 10px; border-radius: 999px;
}
body.boss-on header, body.boss-on main, body.boss-on footer { display: none !important; }
