:root {
  --bg: #14110f;
  --bg-2: #1a1613;
  --panel: #201b17;
  --panel-2: #28221d;
  --line: #3a3129;
  --line-soft: #2d2620;
  --text: #efe7da;
  --muted: #a39686;
  --faint: #6f6458;
  --rust: #d4532b;
  --rust-hot: #ec6a3d;
  --rust-deep: #8f3418;
  --dust: #cdb68e;
  --gold: #e8b64c;
  --silver: #c7c2b8;
  --bronze: #c98552;
  --online: #8fcf6a;
  --radius: 10px;
  --wrap: 1180px;
  --font-display: "Oswald", "Arial Narrow", Impact, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 120px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .8 0 0 0 0 .7 0 0 0 0 .55 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

main, header, footer { position: relative; z-index: 1; }

a { color: inherit; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(20, 17, 15, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-inner { display: flex; align-items: center; gap: 24px; height: 60px; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }

.brand-mark {
  width: 26px; height: 26px; border-radius: 6px;
  background:
    radial-gradient(circle at 62% 46%, var(--rust) 0 3px, transparent 3.5px),
    linear-gradient(var(--bg), var(--bg)) 7px 6px / 10px 16px no-repeat,
    var(--rust);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.brand-name span { color: var(--rust); }

.nav { display: flex; gap: 22px; margin-left: 8px; }
.nav a {
  text-decoration: none; color: var(--muted); font-weight: 500; font-size: 14px;
  transition: color .15s;
}
.nav a:hover { color: var(--text); }

.status-chip {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  white-space: nowrap;
}
.status-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status-chip.is-online { color: var(--text); }
.status-chip.is-online .dot { background: var(--online); box-shadow: 0 0 0 4px rgba(143, 207, 106, .15); }
.status-chip.is-offline .dot { background: var(--rust); }

/* ---------- hero ---------- */

.hero {
  border-bottom: 1px solid var(--line-soft);
  background:
    radial-gradient(900px 380px at 85% -10%, rgba(212, 83, 43, .22), transparent 70%),
    radial-gradient(700px 300px at 0% 110%, rgba(205, 182, 142, .08), transparent 70%);
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 48px;
  padding-top: 64px;
  padding-bottom: 56px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--dust);
  font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(56px, 9vw, 112px);
  line-height: .9;
  letter-spacing: .01em;
  text-transform: uppercase;
}
.hero-title span { color: var(--rust); }

.hero-sub { margin: 20px 0 0; max-width: 520px; color: var(--muted); font-size: 16px; }
.hero-sub b { color: var(--text); font-weight: 600; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 22px;
  border-radius: 8px;
  font: 600 15px/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; fill: currentColor; flex: none; }

.btn-primary {
  background: var(--rust);
  color: #fff;
  font-family: var(--font-display);
  font-size: 18px; letter-spacing: .06em; text-transform: uppercase;
  box-shadow: 0 10px 30px -10px rgba(212, 83, 43, .7);
}
.btn-primary:hover { background: var(--rust-hot); }

.btn-ghost {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px; font-weight: 500;
}
.btn-ghost:hover { border-color: var(--dust); }
.btn-ghost svg { fill: none; }

.hero-steps {
  margin: 18px 0 0;
  padding: 0;
  max-width: 520px;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}
.hero-steps li { position: relative; padding-left: 34px; line-height: 24px; counter-increment: step; }
.hero-steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--dust);
  font: 600 12px/1 var(--font-body);
}
.hero-steps b { color: var(--text); font-weight: 600; }
kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--panel);
  color: var(--text);
  font: 600 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.facts {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.fact { background: var(--panel); padding: 18px 20px; }
.fact dt { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.fact dd {
  margin: 6px 0 0;
  font-family: var(--font-display); font-weight: 600; font-size: 26px; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.fact dd small { color: var(--faint); font-size: 18px; }

/* ---------- summary ---------- */

.summary { padding-top: 32px; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.sum {
  padding: 16px 18px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.sum-value {
  font-family: var(--font-display); font-weight: 600; font-size: 28px; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.sum-label { margin-top: 4px; color: var(--muted); font-size: 13px; }

/* ---------- period bar ---------- */

.period-bar {
  position: sticky; top: 60px; z-index: 15;
  margin-top: 32px;
  background: rgba(20, 17, 15, .86);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.period-inner { display: flex; align-items: center; gap: 16px; height: 58px; }

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.segmented button {
  height: 36px; padding: 0 16px;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--muted);
  font: 600 14px var(--font-body);
  cursor: pointer;
}
.segmented button[aria-selected="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

.online-now { margin: 0 0 0 auto; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-now b { color: var(--online); font-weight: 600; }

/* ---------- sections ---------- */

.section { padding-top: 56px; }
.section-head { margin-bottom: 20px; }
.section-head h2 {
  margin: 0;
  font-family: var(--font-display); font-weight: 600; font-size: 34px; letter-spacing: .02em; text-transform: uppercase;
}
.section-head p { margin: 4px 0 0; color: var(--muted); }
.section-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.group { margin-bottom: 36px; }
.group-title {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 14px;
  color: var(--dust);
  font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
}
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }

.top-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 16px 10px;
}

.card-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 10px;
  font-size: 14px; font-weight: 600;
}
.card-title .unit { margin-left: auto; color: var(--faint); font-size: 12px; font-weight: 500; }

.rank-list { list-style: none; margin: 0; padding: 0; }
.rank {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
}
.rank:first-child { border-top: 0; }
.rank:hover .rank-name { color: var(--rust-hot); }
.rank-pos { font-family: var(--font-display); font-weight: 600; color: var(--faint); font-size: 15px; text-align: center; }
.rank:nth-child(1) .rank-pos { color: var(--gold); }
.rank:nth-child(2) .rank-pos { color: var(--silver); }
.rank:nth-child(3) .rank-pos { color: var(--bronze); }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; transition: color .15s; }
.rank-value { font-variant-numeric: tabular-nums; font-weight: 600; }
.rank:nth-child(1) .rank-name { font-weight: 600; }
.rank-empty { padding: 10px 0 12px; color: var(--faint); font-size: 14px; }

/* ---------- insights ---------- */

.insight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.insight-grid .card { padding-bottom: 16px; }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; gap: 4px; }
.bar-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.bar-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-meta span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-track { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--rust); }

/* ---------- players table ---------- */

.search {
  display: flex; align-items: center; gap: 8px;
  width: 280px; max-width: 100%;
  height: 42px; padding: 0 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--dust); }
.search svg { width: 16px; height: 16px; flex: none; }
.search input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: var(--text); font: 14px var(--font-body);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
}

.players { width: 100%; border-collapse: collapse; font-size: 14px; }
.players th, .players td { padding: 11px 14px; text-align: right; white-space: nowrap; }
.players th:first-child, .players td:first-child { text-align: left; }
.players th {
  position: relative;
  color: var(--muted);
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
.players th:hover { color: var(--text); }
.players th[aria-sort="descending"] { color: var(--rust-hot); }
.players th[aria-sort="descending"]::after { content: " ↓"; }
.players td { border-top: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
.players tbody tr { cursor: pointer; }
.players tbody tr:hover td { background: var(--panel-2); }
.players tbody tr:first-child td { border-top: 0; }

.who { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.avatar {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  font-family: var(--font-display); font-weight: 600; font-size: 14px; color: #14110f;
}
.who-name { font-weight: 600; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.pill-online { width: 8px; height: 8px; border-radius: 50%; background: var(--online); flex: none; }

.empty-row td { text-align: center !important; color: var(--faint); padding: 28px; }

/* ---------- modal ---------- */

.modal {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-2);
  color: var(--text);
}
.modal::backdrop { background: rgba(8, 6, 5, .72); backdrop-filter: blur(3px); }
.modal-inner { position: relative; padding: 24px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.modal-close:hover { color: var(--text); }

.p-head { display: flex; align-items: center; gap: 14px; padding-right: 44px; }
.p-head .avatar { width: 52px; height: 52px; border-radius: 10px; font-size: 22px; }
.p-name { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 28px; line-height: 1.1; overflow-wrap: anywhere; }
.p-meta { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.p-meta a { color: var(--dust); }

.p-highlights { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.p-hl { padding: 12px 14px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 9px; }
.p-hl b { display: block; font-family: var(--font-display); font-weight: 600; font-size: 24px; font-variant-numeric: tabular-nums; }
.p-hl span { color: var(--muted); font-size: 12px; }

.p-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; margin-top: 20px; }
.p-group h4 { margin: 10px 0 6px; color: var(--dust); font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.p-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line-soft); font-size: 14px; }
.p-row span:first-child { color: var(--muted); }
.p-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.p-row .rank-badge { margin-left: 6px; color: var(--gold); font-size: 12px; font-weight: 600; }

/* ---------- footer, toast ---------- */

.footer { margin-top: 72px; border-top: 1px solid var(--line-soft); }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 22px; padding-bottom: 28px; color: var(--faint); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */

@media (max-width: 1000px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .insight-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .hero-inner { grid-template-columns: 1fr; gap: 32px; padding-top: 40px; padding-bottom: 40px; }
  .nav { display: none; }
}

@media (max-width: 560px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fact { padding: 14px 16px; }
  .fact dd { font-size: 22px; }
  .btn { width: 100%; justify-content: center; }
  .btn-ghost { font-size: 12px; }
  .period-inner { height: auto; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
  .online-now { margin-left: 0; width: 100%; }
  .p-highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .p-groups { grid-template-columns: 1fr; }
  .modal-inner { padding: 18px; }
  .section-head h2 { font-size: 28px; }
  .search { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
