:root {
  color-scheme: dark;
  --page: #030405;
  --surface: #090b0e;
  --surface-2: #0e1115;
  --raised: #151920;
  --line: rgba(255, 255, 255, 0.055);
  --grid: #191c23;
  --axis: #2a2e37;
  --ink: #eef0f4;
  --ink-2: #b4bac7;
  --muted: #8a91a1;
  --good: #0ca30c;
  --critical: #d03b3b;
  --warning: #fab219;
  --leetify: #f84982;
  --loss: #727888;
  --tie: #474c59;
  /* Set from the current Premier tier in app.js. */
  --accent: #8a93a6;
  --accent-rgb: 138, 147, 166;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; }
img { display: block; max-width: 100%; }

.glow {
  position: absolute;
  inset: 0 0 auto 0;
  height: 720px;
  pointer-events: none;
  background:
    radial-gradient(800px 420px at 18% -8%, rgba(var(--accent-rgb), 0.12), transparent 70%),
    radial-gradient(600px 360px at 92% 4%, rgba(var(--accent-rgb), 0.06), transparent 70%);
  transition: background 0.6s;
}

.wrap {
  position: relative;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}
main.wrap { padding-top: 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
main.wrap > * { min-width: 0; }
.loading, .muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px 40px;
  align-items: center;
  padding: 8px 0 12px;
}
.identity { display: flex; gap: 22px; align-items: center; min-width: 0; }
.avatar {
  flex: none;
  width: 112px;
  height: 112px;
  border-radius: 18px;
  padding: 3px;
  background: linear-gradient(140deg, var(--accent), rgba(var(--accent-rgb), 0.15));
  box-shadow: 0 10px 40px rgba(var(--accent-rgb), 0.25);
}
.avatar img, .avatar .initial {
  width: 100%;
  height: 100%;
  border-radius: 15px;
  object-fit: cover;
  background: var(--surface-2);
}
.avatar .initial {
  display: grid;
  place-items: center;
  font: 800 48px/1 var(--font-display);
}
.eyebrow {
  margin: 0;
  font: 700 13px/1 var(--font-display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.name {
  margin: 6px 0 8px;
  font: 800 clamp(44px, 9vw, 72px)/0.95 var(--font-display);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.identity-text { min-width: 0; }
.statline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin: 4px 0 20px;
}
.statline div { display: flex; flex-direction: column-reverse; }
.statline dt { color: var(--muted); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
.statline dd { margin: 0; font: 700 28px/1.1 var(--font); color: var(--ink); }
.statline div:first-child dd { color: var(--accent); }
.credentials { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.18); background: var(--raised); }
.btn svg { width: 16px; height: 16px; flex: none; }
.leetify-link { color: var(--leetify); font-weight: 700; }

/* Premier badge, after the in-game look: slanted panel with tier stripes. */
.premier {
  justify-self: end;
  display: grid;
  gap: 8px;
  text-align: right;
}
.premier-badge {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 12px 26px 12px 16px;
  transform: skewX(-14deg);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.28), rgba(var(--accent-rgb), 0.06));
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.45), 0 12px 50px rgba(var(--accent-rgb), 0.18);
  animation: badge-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes badge-in {
  /* Slide only, no fade: the badge is readable even on a frozen first frame. */
  from { transform: skewX(-14deg) translateX(28px); }
  to { transform: skewX(-14deg); }
}
.stripes { display: flex; gap: 5px; }
.stripes i { display: block; width: 6px; height: 52px; border-radius: 2px; background: var(--accent); }
.stripes i:nth-child(2) { opacity: 0.7; }
.stripes i:nth-child(3) { opacity: 0.4; }
.premier-value {
  font: italic 800 64px/1 var(--font-display);
  color: var(--accent);
  letter-spacing: 0.01em;
  text-shadow: 0 0 30px rgba(var(--accent-rgb), 0.45);
}
.premier-caption { color: var(--ink-2); font-size: 14px; }
.premier-caption strong { color: var(--ink); }
.premier-caption .up { color: #3fd13f; }

/* ---------- Highlights ---------- */
.tiles.highlights { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.tile.highlight {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.07), transparent 55%), var(--surface-2);
}
.tile.highlight::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 80%);
}
.tile.highlight .tile-value { font-size: 34px; }
.tile-link { display: inline-block; margin-top: 8px; font-size: 13px; text-decoration: none; }
.tile-link:hover { text-decoration: underline; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  min-width: 0;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  margin-bottom: 18px;
}
.card h2 {
  margin: 0;
  font: 700 22px/1.2 var(--font-display);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.card-sub { margin: 0; color: var(--muted); font-size: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

/* ---------- Stat tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.tile {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 0;
}
.tile-label { margin: 0; color: var(--ink-2); font-size: 14px; }
.tile-value {
  margin: 4px 0 0;
  font: 700 30px/1.1 var(--font);
  letter-spacing: -0.01em;
}
.tile-value.text { font-size: 20px; line-height: 1.2; padding-top: 4px; }
.tile-value .unit { font-size: 16px; font-weight: 500; color: var(--ink-2); margin-left: 3px; }
.tile-note { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- Ratings ---------- */
.meters { display: grid; gap: 16px; margin-bottom: 20px; }
.meter-row { display: grid; grid-template-columns: 110px 1fr 44px; gap: 14px; align-items: center; }
.meter-label { color: var(--ink-2); }
.meter-value { font-weight: 700; font-size: 20px; text-align: right; }
.meter {
  height: 8px;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.16);
  overflow: hidden;
}
.meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------- Charts ---------- */
.chart { position: relative; outline: none; touch-action: pan-y; }
.chart:focus-visible { box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.6); border-radius: 8px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: 0.1; }
.chart .spark { fill: none; stroke: var(--loss); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot, .chart .hdot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.tile .chart .dot, .tile .chart .hdot { stroke: var(--surface-2); }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; }
.chart .endlabel { fill: var(--ink); font-size: 13px; font-weight: 700; }
.chart.mini { margin-top: 10px; }
.tip {
  position: absolute;
  top: 0;
  z-index: 5;
  pointer-events: none;
  min-width: 120px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--raised);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-2);
  white-space: nowrap;
}
.tip strong { display: block; color: var(--ink); font-size: 16px; }
.chart.mini .tip { top: auto; bottom: calc(100% + 6px); }
.chart-note { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- Matches table ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 10px 10px;
  white-space: nowrap;
  border-bottom: 1px solid var(--grid);
}
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
th.num, td.num { text-align: right; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.map-cell { font-weight: 600; color: var(--ink); }
.result {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 13px;
}
.result.win { background: rgba(12, 163, 12, 0.18); color: #3fd13f; box-shadow: inset 0 0 0 1px rgba(12, 163, 12, 0.5); }
.result.loss { background: rgba(208, 59, 59, 0.16); color: #f07070; box-shadow: inset 0 0 0 1px rgba(208, 59, 59, 0.45); }
.result.tie { background: rgba(255, 255, 255, 0.06); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.delta { color: var(--muted); font-size: 12px; margin-left: 6px; }
.table-foot { display: flex; justify-content: center; margin-top: 16px; }
button.btn { color: inherit; font: inherit; font-weight: 600; cursor: pointer; }

/* ---------- Maps ---------- */
.legend { display: flex; gap: 16px; margin: 0 0 14px; padding: 0; list-style: none; color: var(--ink-2); font-size: 13px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 8px; border-radius: 999px; display: inline-block; }
.maps { display: grid; gap: 14px; }
.map-row { display: grid; grid-template-columns: 150px 1fr 120px; gap: 14px; align-items: center; }
.map-name { font-weight: 600; }
.map-name small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.segbar { display: flex; gap: 2px; height: 8px; }
.segbar i { display: block; height: 100%; border-radius: 999px; min-width: 0; }
.seg-win { background: var(--accent); }
.seg-loss { background: var(--loss); }
.seg-tie { background: var(--tie); }
.segbar.empty { background: var(--surface-2); border-radius: 999px; }
.map-record { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 14px; }
.map-record strong { color: var(--ink); }

/* ---------- Error ---------- */
.error-card { text-align: center; padding: 48px 22px; }
.error-card h1 { font: 800 36px/1.1 var(--font-display); margin: 0 0 8px; }
.error-card p { color: var(--ink-2); margin: 0 auto 20px; max-width: 46ch; }
.error-card .actions { justify-content: center; }

/* ---------- Footer ---------- */
.site-footer { padding-top: 36px; padding-bottom: 48px; display: grid; gap: 6px; justify-items: center; text-align: center; }
.site-footer p { margin: 0; }
.leetify-credit { display: inline-flex; align-items: center; gap: 8px; color: var(--leetify); font-weight: 700; text-decoration: none; margin-bottom: 6px; }
.leetify-credit:hover span { text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .premier { justify-self: start; text-align: left; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  main.wrap { padding-top: 24px; }
  .identity { flex-direction: column; align-items: flex-start; gap: 16px; }
  .avatar { width: 88px; height: 88px; }
  .card { padding: 18px 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .premier-value { font-size: 52px; }
  .stripes i { height: 42px; }
  .tiles, .tiles.highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile.highlight .tile-value { font-size: 28px; }
  .tile-value { font-size: 26px; }
  .meter-row { grid-template-columns: 92px 1fr 36px; gap: 10px; }
  .map-row { grid-template-columns: 1fr auto; gap: 6px 12px; }
  .map-row .segbar { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
