:root {
  --bg: #0f1218;
  --bg-2: #151a22;
  --card: #1a202a;
  --card-2: #212835;
  --border: #2a3242;
  --text: #e6e9ef;
  --muted: #8b95a7;
  --accent: #4ade80;
  --accent-2: #22c55e;
  --blue: #3fa7d9;
  --red: #e0565b;
  --yellow: #d9a53f;
  --purple: #a46cf0;
  --discord: #5865f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.2);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.6em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; background: var(--card-2); padding: 0.1em 0.35em; border-radius: 4px; }
pre { background: var(--bg-2); border: 1px solid var(--border); padding: 0.8em; border-radius: 8px; overflow-x: auto; }
pre code { background: none; padding: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.tiny { font-size: 0.78rem; margin: 0.4em 0 0; }
.strong { font-weight: 600; }
.pad { padding: 0 1.2rem 1rem; }
[hidden] { display: none !important; }

/* ---- Layout ---- */
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.25rem; }
main.container { flex: 1; }
.topbar { background: var(--bg-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0.6rem 1.25rem; display: flex; align-items: center; gap: 1.25rem; }
.brand { color: var(--text); font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 0.45rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 1.3rem; }
.brand-sub { font-size: 0.72rem; font-weight: 600; background: var(--accent); color: #062b14; padding: 0.1em 0.5em; border-radius: 99px; text-transform: uppercase; letter-spacing: 0.04em; }
.nav { display: flex; gap: 0.25rem; flex: 1; align-items: center; }
.nav a { color: var(--muted); padding: 0.4rem 0.7rem; border-radius: 7px; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--card); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--card-2); }
.nav .nav-sep { margin-left: auto; }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 0.25rem 0.6rem; font-size: 1.1rem; cursor: pointer; }
.userbox { display: flex; align-items: center; gap: 0.8rem; }
.userbox-name { display: flex; align-items: center; gap: 0.5rem; color: var(--text); font-weight: 500; }
.userbox form { margin: 0; }
.role-pill { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; background: var(--card-2); border: 1px solid var(--border); color: var(--muted); padding: 0.05em 0.5em; border-radius: 99px; font-weight: 600; vertical-align: middle; }
.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
.footer .container { padding-top: 1rem; padding-bottom: 1rem; }

/* ---- Components ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head.pad { padding: 1rem 1.2rem 0.2rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.card-head h2, .card-head h3 { margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; background: var(--card-2); color: var(--text); border: 1px solid var(--border); padding: 0.5rem 0.95rem; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: #3a4558; text-decoration: none; filter: brightness(1.1); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-success { background: var(--accent-2); border-color: var(--accent-2); color: #04210f; font-weight: 600; }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-ghost { background: transparent; }
.btn-ghost.active { background: var(--card-2); border-color: var(--blue); }
.btn-discord { background: var(--discord); border-color: var(--discord); color: #fff; }
.btn-small { padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn-block { width: 100%; margin-top: 0.75rem; }
.btn-icon { padding: 0.4rem 0.6rem; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }
.linklike { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.linklike:hover { color: var(--text); }

.badge { --c: var(--muted); display: inline-flex; align-items: center; gap: 0.35em; font-size: 0.78rem; font-weight: 600; padding: 0.15em 0.6em; border-radius: 99px; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); white-space: nowrap; text-transform: capitalize; }
.badge::before { content: ""; width: 0.5em; height: 0.5em; border-radius: 50%; background: var(--c); }
.chip { --c: var(--blue); display: inline-block; font-size: 0.75rem; padding: 0.1em 0.55em; border-radius: 6px; background: var(--card-2); border: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.chip-internal { --c: var(--purple); border-style: dashed; border-color: color-mix(in srgb, var(--c) 60%, transparent); color: color-mix(in srgb, var(--c) 70%, white); }
.chip-internal::before { content: "🔒 "; font-size: 0.85em; }
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.level-pill { --c: var(--blue); font-size: 0.78rem; font-weight: 600; color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 50%, transparent); padding: 0.05em 0.5em; border-radius: 6px; }

.avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; vertical-align: middle; background: var(--card-2); }
.avatar-fallback { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); font-size: 0.8em; }
.player-link { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text); }

.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-ok { background: rgba(74, 222, 128, 0.08); border-color: rgba(74, 222, 128, 0.35); color: #b7f5cd; }
.flash-err { background: rgba(224, 86, 91, 0.1); border-color: rgba(224, 86, 91, 0.4); color: #ffc2c4; }
.flash-warn { background: rgba(217, 165, 63, 0.1); border-color: rgba(217, 165, 63, 0.4); color: #f5dca8; }
.flash-info { background: rgba(63, 167, 217, 0.08); border-color: rgba(63, 167, 217, 0.35); color: #bfe4f7; }
.live-notice { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--blue); color: #fff; padding: 0.6rem 1.1rem; border-radius: 99px; box-shadow: var(--shadow); z-index: 20; font-weight: 500; }
.live-notice a { color: #fff; text-decoration: underline; margin-left: 0.4rem; }

/* ---- Forms ---- */
input[type="text"], input[type="search"], input[type="number"], input[type="url"], select, textarea {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.7rem; font: inherit; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; border-color: transparent; }
input[type="color"] { width: 2.6rem; height: 2.3rem; padding: 2px; border: 1px solid var(--border); background: var(--bg-2); border-radius: 8px; cursor: pointer; flex-shrink: 0; }
textarea { resize: vertical; }
label { display: block; font-size: 0.88rem; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 0.3rem; color: var(--text); }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.check { display: flex; align-items: flex-start; gap: 0.5rem; color: var(--text); font-size: 0.92rem; cursor: pointer; }
.check input { margin-top: 0.25em; }
.check-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 0.8rem 1rem; margin: 0; }
legend { padding: 0 0.4rem; color: var(--muted); font-size: 0.88rem; }
.row-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0; }
.row-form > input[type="text"], .row-form > input[type="number"], .row-form > select { width: auto; flex: 1 1 140px; }
.row-form .narrow { flex: 0 0 90px !important; }
.row-form .grow { flex: 3 1 220px !important; }
.row-form label { flex: 1 1 160px; }
.row-form label.grow { flex: 3 1 260px; }
.row-form .check { flex: 0 0 auto; }
.inline-form { display: flex; gap: 0.4rem; align-items: center; margin: 0; }
.inline-form input { width: 160px; }
.inline-search input { width: 220px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-2.tight { gap: 0.75rem; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--card-2); }
.table tr.archived td { opacity: 0.55; }
.rank { color: var(--muted); font-weight: 600; }
.bug-cell { min-width: 260px; }
.bug-title { color: var(--text); font-weight: 600; }
.bug-table .me { color: var(--accent); font-weight: 600; }
.sync-warn { color: var(--yellow); margin-left: 0.3rem; cursor: help; }
.settings-table td { padding: 0.5rem 0; }
.actions-cell { width: 1%; }
.files-table { margin: 0.6rem 0; font-size: 0.9rem; }
.files-table td, .files-table th { padding: 0.45rem 0.6rem; }
code.copy { cursor: copy; }

/* ---- Public pages ---- */
.hero { text-align: center; padding: 2rem 1rem 1.25rem; }
.hero h1 { font-size: 2.2rem; }
.hero-small { padding-top: 1rem; }
.lead { color: var(--muted); font-size: 1.08rem; max-width: 620px; margin: 0 auto 1rem; }
.stats { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; margin: 1.25rem 0; }
.stats-left { justify-content: flex-start; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1.3rem; min-width: 140px; text-align: center; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.82rem; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; align-items: end; }
.podium-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1rem; text-align: center; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 0.35rem; box-shadow: var(--shadow); }
.podium-card:hover { text-decoration: none; border-color: #3a4558; }
.podium-1 { order: 2; border-color: rgba(250, 204, 21, 0.5); background: linear-gradient(180deg, rgba(250, 204, 21, 0.09), var(--card) 60%); padding-top: 1.75rem; }
.podium-2 { order: 1; }
.podium-3 { order: 3; }
.podium-rank { font-size: 1.8rem; line-height: 1; }
.podium-name { font-weight: 700; font-size: 1.05rem; }
.podium-points { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.podium-points span { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.level-card { --c: var(--blue); border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 8px; padding: 0.75rem 0.9rem; background: var(--bg-2); }
.level-name { font-weight: 700; color: var(--c); }
.level-points { font-size: 1.25rem; font-weight: 700; }
.profile { display: flex; gap: 1.5rem; align-items: center; margin: 1rem 0 1.5rem; }
.profile h1 { margin-bottom: 0.2rem; }
.profile .stats { margin: 0.75rem 0; }
.ledger, .report-list, .activity, .comments, .changelog-pick { list-style: none; margin: 0; padding: 0; }
.ledger li, .report-list li { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
.ledger li:last-child, .report-list li:last-child { border-bottom: 0; }
.ledger-amount { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.5rem; text-align: right; }
.ledger-amount.pos { color: var(--accent); }
.ledger-amount.neg { color: var(--red); }
.ledger-what, .report-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pts { color: var(--accent); font-weight: 700; font-size: 0.88rem; }
.kind { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.reward-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.reward-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; }
.reward-card.affordable { border-color: rgba(74, 222, 128, 0.5); }
.reward-cost { font-size: 1.5rem; font-weight: 700; color: var(--yellow); }
.reward-cost span { font-size: 0.85rem; color: var(--muted); }
.reward-name { font-weight: 700; font-size: 1.05rem; margin: 0.2rem 0; }
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-icon { font-size: 2.5rem; }
.changelog-post + .changelog-post { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.card.changelog-post + .card.changelog-post { border-top: 1px solid var(--border); padding-top: 1.2rem; }
.rich { white-space: pre-wrap; overflow-wrap: anywhere; }
.rich pre { white-space: pre; }

/* ---- Dashboard ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.quick-filters { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; }
.tab { --c: var(--blue); color: var(--muted); padding: 0.55rem 0.85rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; align-items: center; gap: 0.4rem; font-weight: 500; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--c); }
.tab .dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--c); }
.tab .count { background: var(--card-2); border-radius: 99px; padding: 0 0.5em; font-size: 0.78rem; color: var(--muted); }
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type="search"] { flex: 2 1 240px; width: auto; }
.filters select { flex: 1 1 130px; width: auto; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.back { display: inline-block; margin-bottom: 0.75rem; color: var(--muted); }
.bug-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.bug-head h1 { margin-bottom: 0.4rem; overflow-wrap: anywhere; }
.bug-meta { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.detail-side { position: sticky; top: 4.5rem; }
.side-card { padding: 1rem; margin-bottom: 1rem; }
.side-card h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.6rem; }
.status-form { margin: 0; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.status-btn { --c: var(--muted); background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 0.4rem 0.5rem; font: inherit; font-size: 0.86rem; cursor: pointer; display: flex; align-items: center; gap: 0.4rem; }
.status-btn::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.status-btn:hover:not(:disabled) { border-color: var(--c); }
.status-btn.current { background: color-mix(in srgb, var(--c) 18%, transparent); border-color: var(--c); font-weight: 600; opacity: 1; cursor: default; }
.claimer { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.assign-form { display: flex; gap: 0.4rem; margin-top: 0.6rem; }
.tag-checks { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.6rem; }
.tag-check { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.bounty-total { font-size: 0.95rem; margin-bottom: 0.4rem; }
.bounty-points { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.attachments { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.attachment-img img { max-width: 260px; max-height: 200px; border-radius: 8px; border: 1px solid var(--border); display: block; }
.attachment-video { max-width: 100%; max-height: 320px; border-radius: 8px; }
.attachment-file { background: var(--card-2); border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.8rem; }
.fix-report { border-left: 3px solid var(--accent-2); }
.fix-form-card { border-color: rgba(74, 222, 128, 0.45); }
.file-rows { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.6rem; }
.file-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 0.8fr) minmax(0, 1.6fr) auto; gap: 0.4rem; }
.comment { display: flex; gap: 0.7rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.comment > div { flex: 1; min-width: 0; }
.comment-head { margin-bottom: 0.15rem; }
.comments + form { margin-top: 0.75rem; }
.activity li { padding: 0.4rem 0; font-size: 0.9rem; border-bottom: 1px dashed var(--border); }
.activity li:last-child { border-bottom: 0; }
.activity-src { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.05em 0.45em; border-radius: 4px; margin-right: 0.35rem; background: var(--card-2); color: var(--muted); }
.activity-src.src-discord { background: rgba(88, 101, 242, 0.2); color: #b4bbff; }
.changelog-pick li { border-bottom: 1px solid var(--border); padding: 0.5rem 0; }
.changelog-pick label { display: flex; gap: 0.7rem; align-items: flex-start; color: var(--text); font-size: 0.95rem; cursor: pointer; }
.changelog-pick input { margin-top: 0.35em; }
.preview summary { cursor: pointer; color: var(--muted); }
.chip-form { display: inline-flex; align-items: center; gap: 0.25rem; margin: 0; }

/* ---- Responsive ---- */
@media (max-width: 980px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-side { position: static; order: -1; }
  .hide-md { display: none; }
}
@media (max-width: 720px) {
  .container { padding: 1rem; }
  .topbar-inner { flex-wrap: wrap; padding: 0.6rem 1rem; gap: 0.6rem; }
  .nav-toggle { display: block; margin-left: auto; }
  .nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; order: 3; }
  .nav.open { display: flex; }
  .nav .nav-sep { margin-left: 0; }
  .userbox { order: 2; }
  .userbox-name span:not(.role-pill) { display: none; }
  .hide-sm { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .podium { grid-template-columns: 1fr; }
  .podium-card { order: 0 !important; }
  .profile { flex-direction: column; text-align: center; }
  .profile .stats { justify-content: center; }
  .hero h1 { font-size: 1.7rem; }
  .file-row { grid-template-columns: 1fr 1fr; }
  .file-row input:first-child { grid-column: 1 / -1; }
  .inline-form { flex-wrap: wrap; }
  .inline-search input { width: 100%; }
}
.card > h3:not(:first-child), .card > form + h3 { margin-top: 1.5rem; }
.error-text { color: #ffc2c4; }
.fix-list { list-style: none; margin: 0; padding: 0; }
.fix-list li { display: flex; gap: 0.8rem; padding: 0.65rem 0; border-bottom: 1px solid var(--border); }
.fix-list li:last-child { border-bottom: 0; }
.fix-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--accent); margin-top: 0.5rem; flex-shrink: 0; }
.fix-note { font-weight: 600; }
.commit + .commit { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.commit-head { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
