:root {
  --bg: #0a0e17;
  --panel: #121927;
  --panel-2: #182132;
  --panel-3: #1f2a3f;
  --line: #243049;
  --text: #e6ebf5;
  --muted: #8a96ad;
  --faint: #5d6883;
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, .14);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, .13);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, .13);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, .14);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, .14);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[data-lucide] { width: 16px; height: 16px; stroke-width: 2; flex: none; }
.mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: #0d1320; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 800; font-size: 15px; letter-spacing: .2px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6d28d9, #2563eb); box-shadow: 0 6px 18px rgba(109, 40, 217, .35);
}
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--blue-soft); color: #93c5fd; }
.nav .section { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--faint); padding: 14px 12px 6px; font-weight: 700; }
.sidebar .spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.me img { width: 32px; height: 32px; border-radius: 50%; }
.me .who { flex: 1; min-width: 0; }
.me .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { padding: 22px 26px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 800; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

/* ---------- cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 14px; font-weight: 750; display: flex; align-items: center; gap: 8px; }
.card h2 .right { margin-left: auto; }
.sub { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat .v { font-size: 20px; font-weight: 800; margin-top: 2px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; }
.stat .s { font-size: 12px; color: var(--muted); }

/* ---------- badges, buttons, inputs ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 7px; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .4px; background: var(--panel-3); color: var(--muted); border: 1px solid var(--line); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.on { color: #4ade80; background: var(--green-soft); border-color: rgba(34, 197, 94, .3); }
.badge.off { color: var(--muted); }
.badge.admin { color: #fbbf24; background: var(--amber-soft); border-color: rgba(245, 158, 11, .3); }
.badge.purple { color: #c084fc; background: var(--purple-soft); border-color: rgba(168, 85, 247, .3); }
.pulse .dot { animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); } 70% { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); } 100% { box-shadow: none; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel-3); color: var(--text); font-weight: 650; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: #26324a; border-color: #33415f; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #2f6fe0; }
.btn.green { background: var(--green-soft); border-color: rgba(34, 197, 94, .35); color: #4ade80; }
.btn.green:hover { background: rgba(34, 197, 94, .22); }
.btn.red { background: var(--red-soft); border-color: rgba(239, 68, 68, .35); color: #f87171; }
.btn.red:hover { background: rgba(239, 68, 68, .22); }
.btn.purple { background: var(--purple-soft); border-color: rgba(168, 85, 247, .35); color: #c084fc; }
.btn.purple:hover { background: rgba(168, 85, 247, .22); }
.btn.amber { background: var(--amber-soft); border-color: rgba(245, 158, 11, .35); color: #fbbf24; }
.btn.ghost { background: transparent; }
.btn.icon { padding: 7px; }
.btn.chaos { flex-direction: column; gap: 3px; padding: 12px 8px; white-space: normal; text-align: center; }
.btn.chaos small { font-size: 11px; font-weight: 500; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; padding: 12px 20px; font-size: 15px; }
.btn.discord:hover { background: #4752c4; }

.input, select.input, textarea.input {
  width: 100%; background: #0e1522; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; outline: none; min-width: 0;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.input.num { width: 90px; text-align: center; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 12px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-3); color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--blue-soft); border-color: rgba(59, 130, 246, .5); color: #93c5fd; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; }
.chip.active { background: var(--purple-soft); border-color: rgba(168, 85, 247, .45); color: #d8b4fe; }

/* ---------- bars ---------- */
.bar { height: 8px; border-radius: 99px; background: #0d1422; overflow: hidden; border: 1px solid #1c2538; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--blue); transition: width .4s; }
.bar.green > i { background: linear-gradient(90deg, #16a34a, #84cc16); }
.bar.orange > i { background: linear-gradient(90deg, #ea580c, #f59e0b); }
.bar.purple > i { background: linear-gradient(90deg, #7c3aed, #c084fc); box-shadow: 0 0 12px rgba(168, 85, 247, .5); }
.bar.red > i { background: linear-gradient(90deg, #dc2626, #f87171); }
.bar.lg { height: 12px; }

.icons-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; font-size: 19px; line-height: 1; letter-spacing: -1px; }
.icons-row .empty { filter: grayscale(1) brightness(.45); }

/* ---------- player pieces ---------- */
.head { width: 40px; height: 40px; border-radius: 9px; image-rendering: pixelated; background: var(--panel-3); }
.head.lg { width: 76px; height: 76px; border-radius: 14px; }
.player-card { display: flex; gap: 12px; align-items: center; padding: 14px; cursor: pointer; transition: border-color .15s, transform .15s; }
.player-card:hover { border-color: #33415f; transform: translateY(-1px); }
.player-card .meta { flex: 1; min-width: 0; }
.player-card .meta b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.hero h1 { margin: 0; font-size: 26px; }
.body-render { width: 110px; image-rendering: pixelated; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .5)); }

.inv { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.slot {
  aspect-ratio: 1; border-radius: 8px; background: #0e1522; border: 1px solid #1d2739;
  position: relative; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; color: #cbd5e1; overflow: hidden;
}
.slot.has { border-color: #2b3854; }
.slot.ench { box-shadow: inset 0 0 12px rgba(168, 85, 247, .45); border-color: rgba(168, 85, 247, .5); }
.slot .cnt { position: absolute; right: 4px; bottom: 2px; font-size: 11px; text-shadow: 0 1px 2px #000; }
.slot .ab { padding: 2px; text-align: center; line-height: 1.05; }
.inv-extra { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; max-width: 280px; }

.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #1b2436; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.rankbar { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 70px; padding-top: 6px; }
.chart i { flex: 1; background: #1d2840; border-radius: 3px 3px 1px 1px; min-height: 3px; }
.chart i.on { background: linear-gradient(180deg, #60a5fa, #2563eb); }

/* ---------- feed & console ---------- */
.feed { height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
.ev { display: flex; gap: 8px; padding: 6px 9px; border-radius: 8px; background: var(--panel-2); font-size: 13px; }
.ev time { color: var(--faint); font-size: 11px; padding-top: 2px; flex: none; }
.ev.join { border-left: 3px solid var(--green); }
.ev.left { border-left: 3px solid var(--faint); }
.ev.death { border-left: 3px solid var(--red); }
.ev.advancement { border-left: 3px solid var(--amber); }
.ev.discord { border-left: 3px solid #5865f2; }
.ev.web { border-left: 3px solid var(--purple); }
.ev.chat { border-left: 3px solid var(--blue); }
.console { background: #070b12; border: 1px solid var(--line); border-radius: 12px; height: 60vh; overflow-y: auto; padding: 12px; white-space: pre-wrap; word-break: break-word; }
.console .l-warn { color: #fbbf24; }
.console .l-err { color: #f87171; }
.console .l-info { color: #cbd5e1; }
.console .l-dim { color: #64748b; }

.picker { min-height: 200px; max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: #0e1522; }
.pick { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid #172033; cursor: pointer; }
.pick:hover { background: var(--panel-2); }
.pick.active { background: var(--purple-soft); }
.pick small { margin-left: auto; color: var(--faint); font-size: 11px; }

/* ---------- modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(3, 6, 12, .7); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(880px, 100%); max-height: 88vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.modal.sm { width: min(440px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head .ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-soft); color: #93c5fd; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }
.attr-layout { display: grid; grid-template-columns: 190px 1fr; gap: 14px; }
.attr-tabs { display: flex; flex-direction: column; gap: 4px; }
.attr-tabs button { display: flex; justify-content: space-between; padding: 10px 12px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); font-weight: 650; cursor: pointer; text-align: left; }
.attr-tabs button.active { background: var(--blue-soft); color: #93c5fd; }
.attr-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 8px; }
.attr-row .grow { flex: 1; min-width: 0; }
.stepper { display: flex; align-items: center; background: #0e1522; border: 1px solid var(--line); border-radius: 9px; }
.stepper button { border: 0; background: transparent; padding: 6px 10px; cursor: pointer; color: var(--muted); font-size: 15px; }
.stepper button:hover { color: var(--text); }
.stepper input { width: 70px; text-align: center; border: 0; background: transparent; outline: none; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel-3); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 10px; padding: 10px 14px; max-width: 380px; box-shadow: var(--shadow); white-space: pre-wrap; font-size: 13px; animation: slide .2s; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(900px 500px at 20% 0%, rgba(109, 40, 217, .18), transparent), radial-gradient(800px 500px at 100% 100%, rgba(37, 99, 235, .15), transparent), var(--bg); }
.login { width: min(420px, 100%); text-align: center; padding: 34px 28px; }
.login .brand-mark { width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 16px; font-size: 26px; }
.login h1 { margin: 0 0 6px; font-size: 24px; }

.empty-state { text-align: center; color: var(--muted); padding: 30px 10px; }
.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 12px; gap: 6px; }
  .brand { padding: 0 8px 0 0; }
  .brand small, .nav .section, .sidebar .spacer, .me .who { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav a span { display: none; }
  .me { padding: 4px; margin-left: auto; }
  .main { padding: 16px 16px 60px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .attr-layout { grid-template-columns: 1fr; }
  .attr-tabs { flex-direction: row; overflow-x: auto; }
  .inv { gap: 3px; }
}
