:root {
  --bg: #0d0e11;
  --surface: #15171c;
  --surface-2: #1c1f26;
  --border: #272b33;
  --text: #e9e6e1;
  --muted: #979ca6;
  --accent: #e5484d;
  --accent-ink: #fff;
  --gold: #d9b45a;
  --ok: #3fb950;
  --warn: #d29922;
  --radius: 10px;
  --display: 'Cinzel', Georgia, serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  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.5 var(--body); }
a { color: var(--text); text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent); text-underline-offset: 3px; }
a:hover { color: #fff; }
code { font: 0.9em ui-monospace, 'SF Mono', Menlo, monospace; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
h1, h2, h4 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 60px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--accent); }
.brand span { font: 700 20px var(--display); letter-spacing: 0.08em; color: var(--text); }
.mark { width: 26px; height: 26px; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav a { padding: 7px 12px; border-radius: 7px; text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.me { display: flex; align-items: center; gap: 10px; font-size: 14px; white-space: nowrap; }
.me img { border-radius: 50%; }
.me form { margin: 0; }

/* ---------- layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; }
.pagehead { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.pagehead h1 { font: 700 28px var(--display); letter-spacing: 0.02em; }
.pagehead p { margin: 0; }
h2 { font-size: 16px; font-weight: 600; }
h2.section { margin: 28px 0 12px; display: flex; gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; margin-bottom: 16px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.grid2 .panel { margin: 0; }
.panel h2 { margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.panel-head a { font-size: 13px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .sub { font-size: 12px; color: var(--muted); }

.notice { background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border)); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 14px; }
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.flash.err { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.empty { color: var(--muted); padding: 18px 0; margin: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.list li:first-child { border-top: 0; }
.kills li { padding: 6px 0 6px 12px; border-left: 3px solid var(--ok); margin-bottom: 6px; border-top: 0; }
.kills li.death { border-left-color: var(--accent); }
.kills a { text-decoration: none; }

.silver { font-variant-numeric: tabular-nums; color: var(--gold); font-weight: 500; }
.silver.neg { color: var(--accent); }

.badge { font-style: normal; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.warn, .badge.denied { color: #ffb4b4; border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.badge.pending { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 50%, var(--border)); }
.badge.approved { color: #9be9a8; border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel .table-wrap { border: 0; background: none; margin: 0 -8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td form { margin: 0; }
.me-row td { background: color-mix(in srgb, var(--gold) 6%, transparent); }
.who { display: inline-flex; align-items: center; gap: 8px; }
.who img { border-radius: 50%; }
.filter { margin-bottom: 12px; }
.filter input { max-width: 320px; }

/* ---------- forms ---------- */
input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 0; border-color: transparent; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
form.inline { display: flex; gap: 10px; }
form.inline input:not([type="hidden"]) { flex: 1; }
fieldset.picks { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow-y: auto; margin: 0; }
fieldset.picks legend { font-size: 13px; color: var(--muted); padding: 0 6px; }
.pick { flex-direction: row; align-items: center; gap: 6px; }
.pick input { width: auto; accent-color: var(--accent); }
.pick span { color: var(--text); font-size: 14px; padding: 4px 10px 4px 0; }
.preview { margin: 0; font-variant-numeric: tabular-nums; }
.preview strong { color: var(--gold); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 14px var(--body); padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.ok { background: color-mix(in srgb, var(--ok) 20%, var(--surface-2)); border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.btn.danger { color: #ffb4b4; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { color: var(--text); }
button.link.danger:hover { color: var(--accent); }

/* ---------- events ---------- */
details.event { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; }
details.event.cancelled { opacity: 0.6; }
details.event summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
details.event summary::-webkit-details-marker { display: none; }
details.event[open] summary { border-bottom: 1px solid var(--border); }
details.event > *:not(summary) { margin-left: 18px; margin-right: 18px; }
details.event form { margin-bottom: 16px; }
.desc { white-space: pre-wrap; }
.roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 14px 18px; }
.roles h4 { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.roles ul { margin: 0; padding: 0; list-style: none; font-size: 14px; }

/* ---------- regears ---------- */
.regear { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px; }
.regear.approved { border-left-color: var(--ok); }
.regear.denied { border-left-color: var(--accent); }
.regear-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.regear p { margin: 6px 0; }
.items { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.items figure { margin: 0; position: relative; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; width: 56px; height: 56px; display: grid; place-items: center; }
.items figcaption { position: absolute; right: 3px; bottom: 1px; font-size: 10px; font-weight: 600; color: var(--muted); }
.note { font-style: italic; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.actions form { margin: 0; }
.actions .deny { display: flex; gap: 8px; }
.actions .deny input:not([type="hidden"]) { width: 220px; padding: 6px 10px; }

/* ---------- landing ---------- */
.landing { background:
  radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
  var(--bg); min-height: 100vh; }
.hero { min-height: 100vh; display: grid; place-items: center; padding: 48px 16px; }
.hero-inner { max-width: 760px; text-align: center; }
.crest { color: var(--accent); display: inline-block; }
.crest .mark { width: 64px; height: 64px; }
.hero h1 { font: 700 clamp(56px, 12vw, 96px)/1 var(--display); letter-spacing: 0.12em; margin: 12px 0 6px; }
.hero h1.sm { font-size: 36px; letter-spacing: 0.04em; }
.tag { font: 600 14px var(--display); letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold); margin: 0 0 20px; }
.lead { font-size: 18px; color: var(--muted); margin: 0 auto 28px; max-width: 540px; }
.cta { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 44px; }
.cta .btn { padding: 12px 22px; font-size: 15px; }
.hint { color: var(--muted); font-size: 14px; }
.features { list-style: none; padding: 0; margin: 0 0 28px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; text-align: left; }
.features li { background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.features strong { font-family: var(--display); letter-spacing: 0.04em; }
.features span { color: var(--muted); font-size: 14px; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px 0; gap: 8px 16px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 0 12px 8px; }
  .me { margin-left: auto; }
  .me span { display: none; }
  .wrap { padding: 20px 16px 48px; }
  .pagehead { flex-direction: column; gap: 2px; }
  form.inline { flex-direction: column; }
  .actions .deny { flex: 1; }
  .actions .deny input:not([type="hidden"]) { width: 100%; }
}

/* ---------- party builder ---------- */
.comp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 12px; margin-bottom: 14px; }
.comp-card { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; }
.comp-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.comp-card strong { font-size: 16px; }
.comp-meta { font-size: 13px; color: var(--gold); font-variant-numeric: tabular-nums; }
.comp-editor { display: flex; flex-direction: column; gap: 14px; }
.slots-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.slots-head h2 { margin: 0; }
[data-summary].over { color: var(--accent); }
.slots-wrap { background: var(--bg); }
table.slots td { padding: 6px 8px; vertical-align: middle; }
table.slots th { padding: 8px; }
table.slots input, table.slots select { padding: 7px 9px; font-size: 14px; }
table.slots .idx { color: var(--muted); font-variant-numeric: tabular-nums; width: 32px; text-align: right; }
table.slots .party-in { width: 64px; }
table.slots select { min-width: 140px; }
.weapon-in { display: flex; align-items: center; gap: 8px; min-width: 220px; }
.weapon-in img { width: 32px; height: 32px; border-radius: 6px; background: var(--surface-2); flex: none; }
.weapon-in img:not([src]) { visibility: hidden; }
table.slots td:nth-child(5) input { min-width: 180px; }
.row-actions { white-space: nowrap; text-align: right; }
.icon-btn { background: none; border: 1px solid transparent; color: var(--muted); border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font-size: 14px; }
.icon-btn:hover { border-color: var(--border); color: var(--text); background: var(--surface-2); }
.icon-btn.danger:hover { color: var(--accent); }
.add-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.save-bar { position: sticky; bottom: 0; padding: 12px 0 2px; background: linear-gradient(transparent, var(--surface) 35%); }
.comp-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.comp-actions form { margin: 0; }

.party-title { font-size: 14px; font-weight: 600; margin: 16px 0 8px; display: flex; gap: 8px; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 8px; }
.slot { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px 10px 14px; background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--role, var(--border)); border-radius: 8px; min-width: 0; }
.slot img { width: 40px; height: 40px; flex: none; }
.slot > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.slot strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-no { position: absolute; top: 4px; right: 8px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.slot.filled { background: color-mix(in srgb, var(--role, var(--surface-2)) 7%, var(--bg)); }
.slot.mine { outline: 2px solid color-mix(in srgb, var(--gold) 70%, transparent); outline-offset: -1px; }
.slot .player { font-weight: 600; color: var(--gold); }
.slot form { margin: 4px 0 0; }
.slot .assign select { padding: 5px 8px; font-size: 13px; }
.role-tank { --role: #5b8def; }
.role-healer { --role: #3fb950; }
.role-support { --role: #b083f0; }
.role-melee { --role: #e5484d; }
.role-ranged { --role: #d9b45a; }
.role-scout { --role: #6cc4c4; }
.board { margin: 4px 18px 16px; }
.board-me { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 0; }
.board-me form { margin: 0; }
.bench-title { font-size: 13px; margin: 16px 0 4px; }
.bench { margin: 0; font-size: 14px; }
.comp-pill { color: var(--gold); }
.event-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; padding: 12px 0 16px; border-top: 1px solid var(--border); }
.event-tools form { margin: 0; }
.inline-small { display: flex; gap: 8px; align-items: center; }
.inline-small select { width: auto; max-width: 260px; padding: 6px 10px; }
details.event > .event-tools { margin-top: 8px; }

/* ---------- Discord login ---------- */
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.btn.discord:hover { background: #4752c4; border-color: #4752c4; color: #fff; }
.discord-icon { width: 20px; height: 20px; }
