:root {
  --bg: #0c0c0e;
  --bg-raised: #131316;
  --bg-card: #17171b;
  --bg-elevated: #1d1d22;
  --bg-input: #111114;
  --bg-hover: #24242a;

  --border: #232329;
  --border-strong: #32323a;

  --text: #f0f0f2;
  --text-muted: #9797a2;
  --text-faint: #65656f;

  --accent: #6d72f6;
  --accent-2: #a855f7;
  --accent-hover: #8388f8;
  --accent-soft: rgba(109, 114, 246, 0.13);

  --grad-accent: linear-gradient(135deg, #6d72f6 0%, #a855f7 100%);
  --grad-surface: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0) 100%);
  --grad-glow: radial-gradient(60% 120% at 50% 0%, rgba(109,114,246,0.16) 0%, rgba(109,114,246,0) 70%);

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.12);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', Consolas, 'Liberation Mono', monospace;

  --content-w: 880px;
}

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

body {
  background: var(--bg);
  background-image: var(--grad-glow);
  background-repeat: no-repeat;
  background-size: 100% 520px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-hover); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--text); }

::selection { background: var(--accent-soft); color: var(--text); }

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ---------- App shell ---------- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(12, 12, 14, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--grad-accent);
  box-shadow: 0 2px 12px rgba(109, 114, 246, 0.4);
}
.brand-dot { color: var(--text-faint); font-weight: 500; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-user-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-user-name {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border);
  color: var(--text);
}

.main {
  flex: 1;
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 32px 20px 120px;
}

/* ---------- Bottom tab bar ---------- */

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  justify-content: center;
  padding: 0 16px 20px;
  z-index: 50;
  pointer-events: none;
}
.tabbar-inner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px;
  background: rgba(23, 23, 27, 0.88);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 68px;
  padding: 9px 12px;
  border-radius: 12px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease;
}
.tab:hover { background: var(--bg-hover); color: var(--text-muted); }
.tab.active {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(109, 114, 246, 0.35);
}
.tab.active:hover { color: #fff; }
.tab .icon { width: 19px; height: 19px; }

.tab-sep {
  width: 1px;
  height: 28px;
  background: var(--border-strong);
  margin: 0 4px;
}

/* ---------- Page heading ---------- */

.page-title {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  text-align: center;
}
.page-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 26px;
}
.page-title + .card,
.page-title + .stat-grid,
.page-title + .subnav,
.page-title + .search-bar,
.page-title + .script-grid,
.page-title + .game-grid { margin-top: 26px; }

/* ---------- Sub navigation (admin) ---------- */

.subnav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 22px;
}
.subnav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.subnav a:hover { background: var(--bg-hover); color: var(--text); }
.subnav a.active { background: var(--accent-soft); color: var(--accent-hover); }
.subnav .icon { width: 15px; height: 15px; }

/* ---------- Cards ---------- */

.card {
  position: relative;
  background: var(--bg-card);
  background-image: var(--grad-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-faint); color: var(--text); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--grad-accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 14px rgba(109, 114, 246, 0.32);
}
.btn-primary:hover { filter: brightness(1.1); color: #fff; border-color: transparent; }

.btn-danger {
  background: transparent;
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }
.btn + .btn { margin-left: 6px; }

.btn-discord {
  background: #5865f2;
  border-color: #5865f2;
  color: #fff;
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 550;
  box-shadow: 0 3px 14px rgba(88, 101, 242, 0.3);
}
.btn-discord:hover { background: #4752c4; border-color: #4752c4; color: #fff; }

/* ---------- Forms ---------- */

input[type="text"],
input[type="search"],
input[type="password"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 13px;
  font-family: inherit;
  font-size: 13.5px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239797a2' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}

textarea { resize: vertical; min-height: 110px; }

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-row { display: flex; gap: 10px; align-items: flex-end; }
.form-row .form-group { flex: 1; margin-bottom: 0; }

/* ---------- Luau editor ---------- */

.editor {
  position: relative;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.editor.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor-body {
  position: relative;
  height: 300px;
  overflow: hidden;
}

.editor-highlight,
.editor-input {
  margin: 0;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
  word-wrap: normal;
  overflow-wrap: normal;
  border: 0;
  box-sizing: border-box;
}

.editor-highlight {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  color: var(--text);
  will-change: transform;
}

.editor-input {
  position: relative;
  width: 100%;
  height: 100%;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--accent-hover);
  outline: none;
  overflow: auto;
  display: block;
}
.editor-input:focus { box-shadow: none; border-color: transparent; }

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
  font-size: 11.5px;
  color: var(--text-faint);
}
.editor-hint { display: flex; align-items: center; gap: 6px; }
.editor-hint kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}
.editor-diag { display: flex; align-items: center; gap: 6px; }
.editor-diag.ok { color: var(--success); }
.editor-diag.bad { color: var(--danger); }

/* Luau syntax tokens */
.tok-key     { color: #c084fc; }
.tok-global  { color: #60a5fa; }
.tok-roblox  { color: #38bdf8; }
.tok-str     { color: #86efac; }
.tok-num     { color: #fbbf24; }
.tok-com     { color: #5f5f6b; font-style: italic; }
.tok-fn      { color: #f0abfc; }
.tok-op      { color: #9797a2; }
.tok-bool    { color: #fb923c; }
.ghost       { color: #4a4a55; }

.action-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- Status ---------- */

.status {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.status-ok   { background: var(--success-soft); border-color: rgba(74,222,128,0.3);  color: var(--success); }
.status-err  { background: var(--danger-soft);  border-color: rgba(248,113,113,0.3); color: var(--danger); }
.status-warn { background: var(--warning-soft); border-color: rgba(251,191,36,0.3);  color: var(--warning); }
.status-info { background: var(--info-soft);    border-color: rgba(96,165,250,0.3);  color: var(--info); }

/* ---------- Cooldown ---------- */

.cooldown-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  background-image: var(--grad-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.cooldown-track {
  flex: 1;
  height: 5px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
}
.cooldown-fill {
  height: 100%;
  background: var(--grad-accent);
  border-radius: 999px;
  transition: width 1s linear;
}
.cooldown-label {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.018); }

/* ---------- Stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  background-image: var(--grad-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-value {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }
.stat-card.accent .stat-value {
  background: var(--grad-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-card.warn .stat-value { color: var(--warning); }

/* ---------- Commands ---------- */

.cmd-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.cmd-item:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.cmd-name { font-weight: 550; font-size: 13.5px; }
.cmd-desc { flex: 1; font-size: 12.5px; color: var(--text-muted); }
.cmd-syntax { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }

/* ---------- Grids ---------- */

.script-grid, .game-grid { display: grid; gap: 14px; }
.script-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.game-grid   { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.script-card, .game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.script-card:hover, .game-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }

.script-thumb, .game-thumb {
  width: 100%;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 12px;
}
.script-thumb { height: 130px; }
.game-thumb { height: 150px; }
.script-thumb img, .game-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.script-info, .game-info { padding: 15px; }
.script-info h3, .game-info h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.script-info p, .game-info p { font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; }
.game-info p:last-child { margin-bottom: 0; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  text-transform: capitalize;
  border: 1px solid transparent;
}
.badge-basic    { background: var(--bg-hover);     border-color: var(--border-strong);   color: var(--text-muted); }
.badge-premium  { background: var(--accent-soft);  border-color: rgba(109,114,246,0.35); color: var(--accent-hover); }
.badge-elite    { background: var(--warning-soft); border-color: rgba(251,191,36,0.35);  color: var(--warning); }
.badge-pending  { background: var(--warning-soft); border-color: rgba(251,191,36,0.35);  color: var(--warning); }
.badge-approved { background: var(--success-soft); border-color: rgba(74,222,128,0.35);  color: var(--success); }
.badge-rejected { background: var(--danger-soft);  border-color: rgba(248,113,113,0.35); color: var(--danger); }

/* ---------- Search ---------- */

.search-bar { display: flex; justify-content: center; margin-bottom: 18px; }
.search-bar input { max-width: 380px; }

/* ---------- Subscription ---------- */

.sub-block {
  padding: 20px;
  background: var(--bg-elevated);
  background-image: var(--grad-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.sub-expires { font-size: 12.5px; color: var(--text-muted); margin-top: 8px; }

/* ---------- Login / activate ---------- */

.full-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  flex-direction: column;
  padding: 24px;
}
.login-box {
  background: var(--bg-card);
  background-image: var(--grad-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 34px;
  text-align: center;
  max-width: 380px;
  width: 100%;
}
.login-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--grad-accent);
  margin: 0 auto 18px;
  box-shadow: 0 6px 22px rgba(109, 114, 246, 0.42);
}
.login-box h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.025em; margin-bottom: 6px; }
.login-box p { color: var(--text-muted); font-size: 13.5px; margin-bottom: 28px; }

.activate-box { max-width: 480px; width: 100%; }

/* ---------- Pagination ---------- */

.pagination { display: flex; justify-content: center; gap: 5px; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 34px;
  padding: 6px 10px;
  text-align: center;
  font-size: 12.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.pagination a:hover { border-color: var(--border-strong); color: var(--text); }
.pagination .current {
  background: var(--accent-soft);
  border-color: rgba(109, 114, 246, 0.35);
  color: var(--accent-hover);
  font-weight: 600;
}

/* ---------- Output ---------- */

.output-block {
  margin-top: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--success);
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.empty { padding: 40px 20px; text-align: center; color: var(--text-faint); font-size: 13.5px; }

/* ---------- Utilities ---------- */

.mono { font-family: var(--font-mono); font-size: 12.5px; }
.dim { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.hidden { display: none; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Scrollbar ---------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .main { padding: 22px 14px 120px; }
  .tabbar { padding: 0 10px 14px; }
  .tab { min-width: 58px; padding: 8px 8px; font-size: 10px; }
  .tab-sep { margin: 0 2px; }
  .topbar-user-name { display: none; }
  .script-grid, .game-grid { grid-template-columns: 1fr; }
  .cmd-item { flex-wrap: wrap; gap: 6px; }
  .form-row { flex-direction: column; align-items: stretch; }
  .editor-scroll { height: 240px; }
}
