:root {
  --bg: #0d1220;
  --panel: #151c2e;
  --panel-2: #1c2540;
  --line: #2a3554;
  --text: #e8ebf3;
  --muted: #9aa4bf;
  --brass: #e2b765;
  --primary: #5865f2;
  --danger: #e5484d;
  --ok: #3fb950;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--brass); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
.muted { color: var(--muted); }

/* buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 8px; padding: 9px 14px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 60%, transparent); color: #ff8b8f; }
.btn-discord { background: var(--primary); border-color: var(--primary); color: #fff; font-size: 17px; padding: 13px 22px; }
select, input {
  width: 100%; min-width: 0; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font: inherit;
}
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }

/* landing */
.landing { display: grid; place-items: center; padding: 24px 16px; }
.hero { max-width: 560px; text-align: center; display: grid; gap: 18px; justify-items: center; }
.hero h1 { font-size: clamp(34px, 8vw, 52px); }
.hero h1 span { color: var(--brass); display: block; }
.eyebrow { margin: 0; color: var(--brass); letter-spacing: .14em; text-transform: uppercase; font-size: 13px; font-weight: 700; }
.lead { margin: 0; color: var(--muted); font-size: 17px; }
.fine { margin: 0; color: var(--muted); font-size: 13px; max-width: 420px; }
.notice { margin: 0; color: #ffb4b6; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 800; color: var(--text); text-decoration: none; }
.brand span { color: var(--brass); }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user img { width: 32px; height: 32px; border-radius: 50%; }
.user .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* pages */
.page { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; display: grid; gap: 16px; }
.page > h1 { font-size: 28px; }
.page > p { margin: 0; }
.back { color: var(--muted); text-decoration: none; font-weight: 600; }
.section-title { font-size: 13px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; margin-top: 12px; }

/* server list */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.server {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.server .info { min-width: 0; flex: 1; display: grid; gap: 6px; }
.server .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server.missing { opacity: .8; }
.icon {
  width: 48px; height: 48px; border-radius: 14px; flex: none; object-fit: cover;
  display: grid; place-items: center; background: var(--panel-2); color: var(--brass); font-weight: 800;
}

/* server page */
.server-head { display: flex; align-items: center; gap: 14px; }
.server-head h1 { font-size: 26px; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: grid; gap: 12px; align-content: start;
}
.card.wide { grid-column: 1 / -1; }
.card h3 { font-size: 17px; }
.card .desc { margin: 0; color: var(--muted); font-size: 14px; }
.status { margin: 0; font-size: 14px; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); }
.status.on { border-left: 3px solid var(--ok); }
.status.off { border-left: 3px solid var(--line); color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row > select, .row > input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px;
  border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 600;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.chip button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
  width: 24px; height: 24px; border-radius: 50%;
}
.chip button:hover { color: #ff8b8f; background: var(--bg); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}
.toast.error { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }

@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr; }
  .user .name { display: none; }
}

/* tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.tabs [role=tab] {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700;
  padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs [role=tab][aria-selected=true] { color: var(--text); border-bottom-color: var(--brass); }
.tab-panel { display: grid; gap: 16px; }

/* segmented control */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 3px; justify-self: start; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--panel-2); color: var(--text); }
textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; font: inherit; resize: vertical;
}

/* AoO events */
.event-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.event-head a { white-space: nowrap; font-size: 14px; }
.lists { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.players h4 { margin: 0 0 6px; font-size: 14px; }
.players ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }
.players li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--panel-2); border-radius: 6px; padding: 4px 6px 4px 10px; font-size: 14px;
}
.players li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .muted { margin: 0; font-size: 14px; }
.x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; width: 24px; height: 24px; border-radius: 50%; flex: none; }
.x:hover { color: #ff8b8f; background: var(--bg); }
@media (max-width: 520px) { .lists { grid-template-columns: 1fr; } }

/* MGE */
.row.wrap { flex-wrap: wrap; }
.status.caps { white-space: pre-line; }
.applicants { display: grid; gap: 8px; }
.applicant {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start;
  background: var(--panel-2); border-radius: 8px; padding: 10px 12px; border-left: 3px solid var(--line);
}
.applicant.ranked { border-left-color: var(--brass); }
.applicant .who { display: grid; gap: 4px; min-width: 0; }
.applicant .who a { font-size: 13px; }
.rank-edit { display: flex; gap: 6px; align-items: center; }
.rank-edit input[type=number] { width: 72px; }
.rank-edit input:not([type]) { width: 150px; }
.answers summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.answers dl { margin: 6px 0 0; display: grid; gap: 2px; font-size: 14px; }
.answers dt { color: var(--muted); font-size: 12px; margin-top: 6px; }
.answers dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .applicant { grid-template-columns: 1fr; }
  .rank-edit { flex-wrap: wrap; }
  .rank-edit input:not([type]) { flex: 1; width: auto; }
}

/* Events */
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel-2); border-radius: 8px; padding: 8px 10px 8px 12px;
}
.item-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.item-main strong { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.item-main .muted { font-size: 13px; overflow-wrap: anywhere; }
.item .btn { padding: 6px 12px; flex: none; }
.item .emoji { width: 28px; height: 28px; flex: none; display: grid; place-items: center; font-size: 22px; line-height: 1; }
.item.hidden-event { opacity: .65; }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px;
}
h4.sub { margin: 6px 0 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }

/* Owner tools */
code { background: var(--panel-2); border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.compose { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.preview { display: grid; gap: 6px; }
.preview-label { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.embed {
  background: var(--panel-2); border-left: 4px solid var(--brass); border-radius: 6px;
  padding: 10px 14px; display: grid; gap: 6px; min-height: 80px;
}
.embed-title { overflow-wrap: anywhere; }
.embed-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.status.error { border-left: 3px solid var(--danger); color: #ffb4b6; }
.server-rows { display: grid; gap: 8px; }
.server-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.server-row .info { min-width: 0; flex: 1; display: grid; gap: 4px; }
.server-row .name { font-weight: 700; overflow-wrap: anywhere; }
.server-row .meta { font-size: 13px; }
.server-row .chips { gap: 6px; }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.owner-link { padding: 7px 12px; }
@media (max-width: 720px) {
  .compose { grid-template-columns: 1fr; }
  .server-row { flex-wrap: wrap; }
  .server-row .btn { width: 100%; }
}

/* MGE posted results */
.results-edit { display: grid; gap: 10px; }
.results-edit summary { cursor: pointer; font-weight: 700; color: var(--brass); }
.results-edit[open] summary { margin-bottom: 10px; }
.results-edit .desc { margin-bottom: 10px; }
.placements { display: grid; grid-template-columns: auto minmax(0, 2fr) minmax(0, 1fr); gap: 6px 8px; align-items: center; margin-bottom: 12px; }
.rank-label { color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }
@media (max-width: 520px) {
  .placements { grid-template-columns: auto minmax(0, 1fr) 96px; }
}
