:root {
  --bg: #0c0e11;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-strong: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e9ecef;
  --muted: #8b939c;
  --faint: #5d656e;
  --accent: #3ecf8e;
  --accent-soft: rgba(62, 207, 142, 0.12);
  --gold: #e6c36a;
  --silver: #c3cad2;
  --bronze: #d29a6b;
  --chroma: #b892ff;
  --radius: 12px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f6f8;
    --panel: rgba(255, 255, 255, 0.75);
    --panel-strong: #ffffff;
    --line: rgba(15, 20, 25, 0.08);
    --line-strong: rgba(15, 20, 25, 0.16);
    --text: #14181d;
    --muted: #5f6872;
    --faint: #98a0a8;
    --accent: #13a26a;
    --accent-soft: rgba(19, 162, 106, 0.1);
    --gold: #b88a12;
    --silver: #7c8691;
    --bronze: #a8652f;
    --chroma: #7a4fd6;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button { font: inherit; color: inherit; cursor: pointer; }

a { color: inherit; }

.num, .c-num, .money { font-variant-numeric: tabular-nums; }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.top-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 15px;
}

.brand span { color: var(--accent); margin-left: 4px; }

.tabs { display: flex; gap: 4px; }

.tab {
  background: none;
  border: 0;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
}

.tab:hover { color: var(--text); }

.tab.on { color: var(--text); background: var(--panel-strong); box-shadow: inset 0 0 0 1px var(--line); }

.seg {
  margin-left: auto;
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.seg button {
  background: none;
  border: 0;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.seg button.on { background: var(--accent-soft); color: var(--accent); }

.wrap {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 16px 40px;
  flex: 1;
}

.head { margin-bottom: 18px; }

.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.pick { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }

.pick select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background-color: var(--panel);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 8px 34px 8px 12px;
  min-width: 200px;
  cursor: pointer;
}

.pick select:focus { outline: 2px solid var(--accent-soft); outline-offset: 1px; border-color: var(--accent); }

.pick option { background: var(--bg); color: var(--text); }

h1 { font-size: 24px; letter-spacing: -0.01em; margin: 0; font-weight: 650; }

.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.board { width: 100%; border-collapse: collapse; }

.board th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.board td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }

.board tbody tr:last-child td { border-bottom: 0; }

.board tbody tr { cursor: pointer; transition: background 0.12s; }

.board tbody tr:hover { background: var(--panel-strong); }

.board .c-num { text-align: right; }

.c-rank { width: 48px; color: var(--faint); font-weight: 600; font-variant-numeric: tabular-nums; }

tr.r1 .c-rank { color: var(--gold); }
tr.r2 .c-rank { color: var(--silver); }
tr.r3 .c-rank { color: var(--bronze); }

.who { display: flex; align-items: center; gap: 12px; min-width: 0; }

.who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.who-meta { color: var(--faint); font-size: 12px; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex: none;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar.lg { width: 56px; height: 56px; border-radius: 12px; font-size: 20px; }

.money { font-weight: 600; }

.money-main { color: var(--accent); font-weight: 650; }

.money-sv { display: block; color: var(--faint); font-size: 12px; font-weight: 500; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }

.cards.three { grid-template-columns: repeat(3, 1fr); }
.cards.five { grid-template-columns: repeat(5, 1fr); }
.card-value.bad { color: #ef6b6b; }
.mm2-flag { margin-top: 6px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}

.card-label { font-size: 12px; color: var(--muted); font-weight: 500; }

.card-value { font-size: 24px; font-weight: 650; margin-top: 4px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }

.card-value.accent { color: var(--accent); }

.card-foot { font-size: 12px; color: var(--faint); margin-top: 2px; font-variant-numeric: tabular-nums; }

.split { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; align-items: start; }

.list { list-style: none; margin: 0; padding: 0; }

.list li { padding: 11px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }

.list li:last-child { border-bottom: 0; }

.grow { flex: 1; min-width: 0; }

.right { text-align: right; flex: none; }

.item-name { font-weight: 600; }

.chroma { color: var(--chroma); }

.rarity { font-size: 12px; color: var(--faint); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.chip {
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--muted);
  white-space: nowrap;
}

.trade-line { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }

.trade-line .from { color: var(--faint); font-size: 13px; }

.link { text-decoration: none; font-weight: 600; cursor: pointer; }

.link:hover { text-decoration: underline; text-underline-offset: 3px; }

.time { color: var(--faint); font-size: 12px; white-space: nowrap; }

.empty { padding: 28px 16px; text-align: center; color: var(--faint); font-size: 14px; }

.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: 14px; margin-bottom: 16px; }

.back:hover { color: var(--text); }

.user-head { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }

.foot {
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
  text-align: center;
  padding: 14px 16px;
}

@media (max-width: 820px) {
  .cards, .cards.five { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .top-inner { gap: 10px; }
  .seg { margin-left: 0; width: 100%; }
  .seg button { flex: 1; }
  .c-hide { display: none; }
  .board td, .board th { padding-left: 12px; padding-right: 12px; }
  .cards.three { grid-template-columns: 1fr; }
  .card-value { font-size: 20px; }
  h1 { font-size: 21px; }
}

.mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; }

.center-page { display: grid; place-items: center; padding: 16px; }

.gate {
  width: 100%;
  max-width: 380px;
  margin: 8vh auto 0;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.center-page .gate { margin-top: 0; }

.gate h1 { font-size: 21px; }

.gate .sub { margin: -6px 0 6px; }

.gate-brand { margin-bottom: 6px; }

.field {
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 10px 12px;
  width: 100%;
}

.field.mono { letter-spacing: 0.04em; text-transform: uppercase; font-size: 14px; }

.field:focus { outline: 2px solid var(--accent-soft); outline-offset: 1px; border-color: var(--accent); }

.btn {
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  border-radius: 9px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.btn:hover { border-color: var(--muted); }

.btn:disabled { opacity: 0.55; cursor: default; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #06130d; }

.btn.primary:hover { filter: brightness(1.06); }

.btn.small { padding: 6px 10px; font-size: 13px; font-weight: 500; }

.btn.ghost { background: none; }

.btn.danger { color: #ef6b6b; }

.btn.danger:hover { border-color: #ef6b6b; }

.form-error { margin: 0; color: #ef6b6b; font-size: 14px; }

[hidden] { display: none !important; }

.admin-section { margin-bottom: 16px; }

.table-scroll { overflow-x: auto; }

.admin-table { min-width: 880px; }

.admin-table tbody tr { cursor: default; }

.admin-table td { vertical-align: top; }

#updated { margin-left: auto; }

.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px currentColor;
}

.pill-good { color: var(--accent); background: var(--accent-soft); }

.pill-warn { color: var(--gold); background: rgba(230, 195, 106, 0.1); }

.pill-bad { color: #ef6b6b; background: rgba(239, 107, 107, 0.1); }

.pill-muted { color: var(--faint); background: var(--panel-strong); box-shadow: inset 0 0 0 1px var(--line); }
