:root {
  --bg: #0b0d13;
  --panel: #12151d;
  --surface: #191d28;
  --surface-2: #212634;
  --stroke: #2a3040;
  --stroke-soft: rgba(42, 48, 64, 0.6);
  --text: #eaedf5;
  --muted: #8890a6;
  --faint: #585f74;
  --accent: #6c8cff;
  --accent-2: #966eff;
  --danger: #ff5c70;
  --success: #3dd68c;
  --warning: #ffb547;
  --role-0: #8a90a2;
  --role-1: #3dd68c;
  --role-2: #6c8cff;
  --role-3: #ffb547;
  --radius: 12px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

button, input, select { font: inherit; color: inherit; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: filter 0.12s, transform 0.06s, background 0.12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: rgba(255, 92, 112, 0.14); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface); color: var(--text); filter: none; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- inputs ---------- */

.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }

input, select {
  height: 38px;
  width: 100%;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 9px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.18); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); color: #fff; }

.form-error { color: var(--danger); font-size: 13px; }

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c, var(--muted));
  background: color-mix(in srgb, var(--c, var(--muted)) 15%, transparent);
}
.role-0 { --c: var(--role-0); }
.role-1 { --c: var(--role-1); }
.role-2 { --c: var(--role-2); }
.role-3 { --c: var(--role-3); }
.badge-warning { --c: var(--warning); }
.badge-info { --c: #6ec8ff; }
.badge-success { --c: var(--success); }
.badge-accent { --c: var(--accent); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--faint)); flex: none; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  object-fit: cover;
  flex: none;
}
.avatar-lg { width: 72px; height: 72px; }

/* ---------- login ---------- */

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(600px 400px at 20% 10%, rgba(108, 140, 255, 0.12), transparent 70%),
    radial-gradient(500px 400px at 85% 90%, rgba(150, 110, 255, 0.1), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  display: grid;
  gap: 16px;
  padding: 32px 28px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 22px; }

.logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 700;
  font-size: 19px;
  flex: none;
}
.logo-lg { width: 52px; height: 52px; font-size: 24px; border-radius: 14px; }

/* ---------- layout ---------- */

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100%;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 14px;
  border-right: 1px solid var(--stroke-soft);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { color: var(--muted); font-size: 12px; }

.nav { display: grid; gap: 4px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px 0 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: rgba(25, 29, 40, 0.6); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--text); font-weight: 600; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  bottom: 11px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.nav-count { font-size: 11px; font-weight: 700; color: var(--faint); }

.account {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--stroke-soft);
  border-radius: var(--radius);
}
.account-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.account-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-actions { display: flex; gap: 6px; }
.account-actions .btn { flex: 1; }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  margin: 8px 8px 8px 0;
  border: 1px solid var(--stroke-soft);
  border-radius: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 16px;
}
.topbar h2 { font-size: 20px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.page {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 24px;
  display: grid;
  align-content: start;
  gap: 16px;
}

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--stroke-soft);
  border-radius: var(--radius);
  padding: 16px;
}
.card-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 12px;
}

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--faint);
  border: 1px dashed var(--stroke);
  border-radius: var(--radius);
}
.empty strong { display: block; color: var(--muted); font-size: 15px; margin-bottom: 4px; }

/* ---------- servers ---------- */

.server { padding: 0; overflow: hidden; }
.server-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--stroke-soft);
}
.server-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.server-title strong { font-size: 14px; }
.server-id { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--faint); }
.server-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; padding: 10px; }
.player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
  min-width: 0;
}
.player:hover { background: var(--surface-2); }
.player.selected { background: var(--surface-2); border-color: rgba(108, 140, 255, 0.5); }
.player-names { min-width: 0; flex: 1; }
.player-display { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-user { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-empty { padding: 18px 16px; color: var(--faint); font-size: 13px; }

/* ---------- tables / rows ---------- */

.rows { display: grid; gap: 6px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
  min-width: 0;
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.row select { width: auto; height: 30px; font-size: 12px; padding: 0 8px; }

.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-row > input { flex: 1; min-width: 160px; }
.form-stack { display: grid; gap: 12px; }

.log {
  display: grid;
  grid-template-columns: 110px 160px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.log:nth-child(odd) { background: var(--surface); }
.log-time { color: var(--faint); font-variant-numeric: tabular-nums; }
.log-actor { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-text { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.perm-grid { display: grid; gap: 10px; }
.perm { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: start; font-size: 13px; color: var(--muted); }

/* ---------- drawer ---------- */

.drawer {
  position: fixed;
  top: 8px;
  right: 8px;
  bottom: 8px;
  width: 380px;
  max-width: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transform: translateX(calc(100% + 24px));
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.2, 1);
  z-index: 20;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; gap: 14px; align-items: center; padding: 20px; border-bottom: 1px solid var(--stroke-soft); }
.drawer-head .names { flex: 1; min-width: 0; }
.drawer-head h3 { font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 20px; display: grid; align-content: start; gap: 16px; }
.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.drawer .card { background: var(--surface); }
.drawer .notice { font-size: 12px; color: var(--faint); }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 40;
  animation: fade 0.15s ease-out;
}
.modal {
  width: 100%;
  max-width: 400px;
  display: grid;
  gap: 14px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: pop 0.22s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.modal h3 { font-size: 17px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100% - 32px));
  z-index: 60;
}
.toast {
  position: relative;
  padding: 12px 14px 12px 18px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: slide 0.22s ease-out;
}
.toast::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 2px;
  background: var(--c, var(--accent));
}
.toast.success { --c: var(--success); }
.toast.error { --c: var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: 0.25s; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.95); } }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .log { grid-template-columns: 70px 1fr; }
  .log-text { grid-column: 1 / -1; white-space: normal; }
  .log .badge { display: none; }
}

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-right: 0; }
  .brand-sub { display: none; }
  .nav { display: flex; overflow-x: auto; order: 3; width: 100%; }
  .nav-item { flex: none; gap: 8px; }
  .nav-item.active::before { display: none; }
  .account { margin: 0 0 0 auto; padding: 0; background: none; border: 0; grid-auto-flow: column; align-items: center; }
  .account-user > div { display: none; }
  .main { margin: 0 8px 8px; }
  .topbar { padding: 16px; flex-wrap: wrap; }
  .page { padding: 0 16px 16px; }
  .action-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- multi-game additions ---------- */

.small { font-size: 12px; }
a { color: var(--accent); }

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
}
.link:hover { color: var(--text); text-decoration: underline; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface); border-radius: 10px; }
.tab {
  height: 32px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.tab.active { background: var(--surface-2); color: var(--text); }

.code-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--stroke);
  border-radius: 10px;
}
.code-box code { flex: 1; font: 600 14px/1.4 ui-monospace, Consolas, monospace; color: var(--warning); word-break: break-word; }

pre.code {
  margin: 0;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  font: 13px/1.55 ui-monospace, Consolas, monospace;
  color: #c9d3ff;
  white-space: pre-wrap;
  word-break: break-all;
}
.code-wrap { position: relative; }
.code-wrap .btn { position: absolute; top: 8px; right: 8px; }

.game-picker { display: flex; gap: 6px; }
.game-picker select { height: 34px; font-size: 13px; font-weight: 600; }

.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); }
.steps strong { color: var(--text); }

.callout { padding: 12px 14px; border-radius: 10px; background: rgba(255, 181, 71, 0.1); color: var(--warning); font-size: 13px; }

.modal-wide { max-width: 560px; }

@media (max-width: 720px) {
  .game-picker { order: 2; width: 100%; }
}

.logo { overflow: hidden; }
.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
