:root {
  --bg: #0f0a1f;
  --bg-2: #16102b;
  --surface: #1c1638;
  --surface-2: #241c47;
  --border: #2a2250;
  --text: #f1efff;
  --text-dim: #9d95c2;
  --accent: #8b5cf6;
  --accent-2: #c084fc;
  --accent-glow: rgba(139, 92, 246, .35);
  --hot: #ef4444;
  --ok: #34d399;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 20px;
}
.logo-mark-img {
  width: 36px;
  height: 36px;
  display: block;
  border-radius: 9px;
}
.logo-text em { font-style: normal; color: var(--accent-2); font-weight: 500; }

.search { flex: 1; max-width: 560px; }
.search input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.search input:focus { border-color: var(--accent); }
.search input::placeholder { color: var(--text-dim); }

.topbar-actions { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--text-dim); }
.topbar-actions > a:hover { color: var(--text); }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform .1s, background .15s, border-color .15s, color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; padding: 12px 16px; font-size: 15px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform .1s, box-shadow .2s, filter .15s;
}
.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 22px rgba(139, 92, 246, 0.5);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }
.btn-danger {
  background: #3a1a1a;
  color: #ffb3b3;
  border-color: #5a2323;
}
.btn-danger:hover { background: #4a1f1f; color: #ffd1d1; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}
.link-btn:hover { text-decoration: underline; }

/* ── User menu ─────────────────────────────────────────── */
.user-menu { position: relative; }
.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s;
}
.user-menu-toggle:hover { border-color: var(--accent); }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.user-avatar.admin {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, .25);
}
.user-name { font-size: 13px; font-weight: 600; }
.caret { font-size: 10px; color: var(--text-dim); }

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
}
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-dropdown a,
.user-menu-dropdown .menu-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  background: none;
  border: none;
  cursor: pointer;
}
.user-menu-dropdown a:hover,
.user-menu-dropdown .menu-link:hover { background: var(--surface-2); }

/* ── Layout ────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 65px); }

.sidebar {
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  background: var(--bg-2);
}
.sidebar-link {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar-link:hover { background: var(--surface); color: var(--text); }
.sidebar-link.active { background: var(--surface-2); color: var(--text); }
.sidebar-divider { height: 1px; background: var(--border); margin: 12px 8px; }

.content { padding: 28px 32px; max-width: 1400px; }

/* ── Hero ──────────────────────────────────────────────── */
.hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 36px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 85% 15%, rgba(192, 132, 252, 0.25), transparent 55%),
    linear-gradient(135deg, #2d1b69 0%, #1a1144 100%);
  border: 1px solid rgba(192, 132, 252, 0.12);
  margin-bottom: 32px;
  box-shadow: var(--shadow), 0 0 60px rgba(139, 92, 246, 0.12);
  overflow: hidden;
}
.hero h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -0.01em; }
.hero h1 span {
  background: linear-gradient(135deg, var(--accent-2), #e9d5ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { margin: 0; color: var(--text-dim); }
.hero-wordmark { font-weight: 800; font-size: 44px; letter-spacing: -0.01em; line-height: 1; margin: 0; }
.hero-wordmark em { font-style: normal; color: var(--accent-2); font-weight: 500; }
.hero-stats { display: flex; gap: 32px; }
.stat { text-align: center; }
.stat strong { display: block; font-size: 26px; color: var(--text); }
.stat span { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; }

/* ── Grid ──────────────────────────────────────────────── */
.section-title { font-size: 20px; margin: 0 0 16px; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s, border-color .2s, box-shadow .25s;
  position: relative;
}
.game-card:hover {
  transform: translateY(-3px);
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 10px 30px rgba(139, 92, 246, 0.18);
}
.game-card img, .game-card .thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: linear-gradient(135deg, #3b2a6e, #1e1447);
  display: block;
}
.game-card .thumb {
  display: grid;
  place-items: center;
  font-size: 42px;
  font-weight: 800;
  color: rgba(255,255,255,.5);
}
.game-card .meta { padding: 10px 12px; }
.game-card .title { font-size: 14px; font-weight: 600; margin: 0 0 2px; }
.game-card .category { font-size: 12px; color: var(--text-dim); }

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--hot);
  color: white;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.game-card.locked img,
.game-card.locked .thumb {
  filter: brightness(.55) saturate(.75);
  transition: filter .2s;
}
.game-card.locked:hover img,
.game-card.locked:hover .thumb {
  filter: brightness(.7) saturate(.9);
}
.lock-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(15, 10, 31, 0.78);
  border: 1px solid rgba(139, 92, 246, 0.45);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  pointer-events: none;
  backdrop-filter: blur(2px);
}
.game-card.locked:hover .lock-overlay {
  border-color: var(--accent);
  background: rgba(28, 22, 56, 0.88);
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 40px 0;
  font-size: 14px;
}

/* ── About / Footer ────────────────────────────────────── */
.about { margin-top: 48px; }
.about p { color: var(--text-dim); max-width: 720px; line-height: 1.6; }

footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
}

/* ── Modal ─────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(139, 92, 246, 0.22), transparent 60%),
    rgba(5, 3, 15, .78);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal.open { display: flex; animation: modalFadeIn .25s ease-out; }
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background:
    radial-gradient(circle at 0% 0%, rgba(192, 132, 252, 0.12), transparent 55%),
    linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid rgba(192, 132, 252, 0.18);
  border-radius: 20px;
  box-shadow:
    var(--shadow-lg),
    0 0 80px rgba(139, 92, 246, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 32px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideUp .3s cubic-bezier(.16, 1, .3, 1);
}
@keyframes modalSlideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: none;
  color: var(--text-dim);
  border: none;
  font-size: 22px;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.modal-close:hover { color: var(--text); background: rgba(139, 92, 246, 0.15); }

.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 5px;
  background: rgba(15, 10, 31, 0.55);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 999px;
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1;
  padding: 9px 14px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s, color .2s, box-shadow .2s;
}
.auth-tab:hover:not(.active) { color: var(--text); }
.auth-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

.auth-pane h2 {
  margin: 0 0 6px;
  font-size: 24px;
  background: linear-gradient(135deg, #f1efff, #c4a0ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-sub { margin: 0 0 22px; color: var(--text-dim); font-size: 13px; }
.auth-fineprint { margin: 12px 0 0; color: var(--text-dim); font-size: 12px; line-height: 1.5; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form textarea,
.admin-form input[type="text"] {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(139, 92, 246, 0.22);
  background: rgba(15, 10, 31, 0.6);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
  font-family: inherit;
}
.auth-form input[type="text"]:hover,
.auth-form input[type="email"]:hover,
.auth-form input[type="password"]:hover,
.auth-form textarea:hover,
.admin-form input[type="text"]:hover {
  border-color: rgba(139, 92, 246, 0.4);
}
.auth-form textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.auth-form input:focus,
.auth-form textarea:focus,
.admin-form input:focus {
  border-color: var(--accent);
  background: rgba(22, 16, 43, 0.8);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

/* Kill Chrome's white autofill — keep the purple vibe */
.auth-form input:-webkit-autofill,
.auth-form input:-webkit-autofill:hover,
.auth-form input:-webkit-autofill:focus,
.auth-form input:-webkit-autofill:active,
.admin-form input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px rgba(15, 10, 31, 0.9) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  border-color: rgba(139, 92, 246, 0.35) !important;
  transition: background-color 5000s ease-in-out 0s;
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center !important;
  gap: 10px !important;
  color: var(--text) !important;
  font-size: 13px !important;
  font-weight: 400 !important;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.auth-row-between { display: flex; justify-content: flex-end; margin-top: -4px; }

.form-error {
  margin: 0;
  padding: 8px 12px;
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .4);
  color: #fca5a5;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ── Admin panel ───────────────────────────────────────── */
.admin-header { margin-bottom: 20px; }
.admin-sub { margin: 0; color: var(--text-dim); font-size: 14px; }

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.admin-card h3 { margin: 0 0 6px; font-size: 16px; }
.admin-note { margin: 0 0 14px; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.admin-note-inline { color: var(--text-dim); font-weight: 400; font-size: 13px; }

.admin-form { display: flex; flex-direction: column; gap: 14px; }
.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 28px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
}
.drop-zone strong { color: var(--text); font-size: 15px; }
.drop-zone.hover { border-color: var(--accent); background: rgba(139, 92, 246, .08); }
.drop-info { margin: 8px 0 0; font-size: 13px; color: var(--accent-2); }

.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}
.admin-row strong { display: block; font-size: 14px; margin-bottom: 2px; }
.admin-meta { color: var(--text-dim); font-size: 12px; }
.admin-empty { margin: 0; color: var(--text-dim); font-size: 13px; font-style: italic; }

.email-row {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}
.email-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.email-to { font-weight: 700; font-size: 13px; }
.email-meta { color: var(--text-dim); font-size: 12px; }
.email-subject { color: var(--accent-2); font-size: 13px; margin-bottom: 8px; }
.email-body {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 12px;
  white-space: pre-wrap;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  max-height: 220px;
  overflow-y: auto;
}

/* ── Play page ─────────────────────────────────────────── */
.play-body { background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.play-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 24px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.play-bar .logo-mark-img { width: 32px; height: 32px; }
.play-title { flex: 1; margin: 0; font-size: 16px; color: var(--text); }
.play-host { flex: 1; display: flex; }
.play-frame { flex: 1; width: 100%; border: none; background: black; }
.play-binary {
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
  max-width: 620px;
  margin: 0 auto;
  color: var(--text-dim);
}
.play-gate { text-align: center; padding: 40px; color: var(--text-dim); }

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .hero { flex-direction: column; align-items: flex-start; }
  .content { padding: 20px; }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar-actions > a { display: none; }
}
