*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --panel-bg: rgba(7, 8, 11, 0.95);
  --panel-fill: rgba(12, 14, 18, 0.94);
  --row-even: rgba(16, 18, 23, 0.94);
  --row-odd: rgba(13, 15, 20, 0.94);
  --row-top: rgba(22, 24, 29, 0.96);
  --accent: #d86b33;
  --accent-deep: #8d3417;
  --accent-soft: rgba(216, 107, 51, 0.18);
  --edge-light: rgba(255, 255, 255, 0.05);
  --separator: rgba(255, 255, 255, 0.06);
  --text-main: #f4f7fb;
  --text-dim: rgba(244, 247, 251, 0.7);
  --text-muted: rgba(244, 247, 251, 0.45);
  --points: #efb27f;
  --points-top: #f3c393;
}

body {
  background: transparent;
  color: var(--text-main);
  font-family: "Bahnschrift", "Segoe UI", Arial, sans-serif;
  overflow: hidden;
}

#leaderboard {
  --t-fast: 150ms;
  --t-normal: 240ms;
  --t-update: 220ms;
  --t-move: 280ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-snap: cubic-bezier(0.24, 0.76, 0.36, 1);
  --ease-smooth: cubic-bezier(0.22, 0.61, 0.36, 1);
  --vulcan-glow: rgba(216, 107, 51, 0.08);

  position: fixed;
  top: 120px;
  left: 40px;
  width: 284px;
  border: 1px solid transparent;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(9, 10, 13, 0.98), rgba(6, 7, 10, 0.98)) padding-box,
    linear-gradient(180deg, rgba(224, 124, 69, 0.5) 0%, rgba(141, 52, 23, 0.44) 100%) border-box;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 -1px 0 rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 255, 255, 0.015),
    0 14px 30px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(8px) saturate(82%);
  overflow: hidden;
  isolation: isolate;
  visibility: hidden;
  opacity: 0;
  transform: translateX(-100%);
  will-change: transform, opacity;
}

#leaderboard::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 26%);
  pointer-events: none;
  z-index: 0;
}

#leaderboard > * {
  position: relative;
  z-index: 2;
}

#leaderboard.idle-glow::after {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background:
    linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.05) 22%,
      rgba(216, 107, 51, 0.18) 48%,
      transparent 76%
    );
  background-size: 220% 100%;
  animation: panelEdgeScan 9s linear infinite;
  opacity: 0.28;
  pointer-events: none;
  z-index: 1;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

#leaderboard.popup-enter {
  animation: popInBroadcast var(--t-normal) var(--ease-out) both;
}

#leaderboard.popup-exit {
  animation: popOutBroadcast var(--t-fast) var(--ease-in) both;
}

#header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 12px;
  background: rgba(14, 16, 20, 0.92);
  border-bottom: 1px solid var(--separator);
}

#header::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(216, 107, 51, 0.36), rgba(216, 107, 51, 0));
}

.header-icon {
  flex-shrink: 0;
  color: rgba(216, 107, 51, 0.88);
  font-size: 8px;
  line-height: 1;
}

.header-title {
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.4px;
  text-transform: uppercase;
}

#rows-container {
  display: flex;
  flex-direction: column;
  padding: 4px 0 2px;
}

#loading {
  padding: 12px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-align: center;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 33px;
  padding: 6px 12px 6px 15px;
  background: var(--row-odd);
  border-bottom: 1px solid var(--separator);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.015);
  overflow: hidden;
  will-change: transform, opacity;
}

.row:last-child {
  border-bottom: none;
}

.row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 2px;
  background: linear-gradient(180deg, rgba(216, 107, 51, 0.82), rgba(141, 52, 23, 0.82));
  opacity: 0.24;
}

.row.even {
  background: var(--row-even);
}

.row.odd {
  background: var(--row-odd);
}

.row.top-1 {
  background: var(--row-top);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.02),
    inset 0 0 0 1px rgba(216, 107, 51, 0.08);
}

.row.top-1::before {
  width: 3px;
  opacity: 0.88;
}

.row.top-2::before,
.row.top-3::before {
  opacity: 0.42;
}

.rank {
  width: 32px;
  flex-shrink: 0;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  text-align: left;
}

.row.top-1 .rank,
.row.top-2 .rank,
.row.top-3 .rank {
  color: #ffffff;
}

.name {
  flex: 1;
  min-width: 0;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.points {
  min-width: 56px;
  margin-left: auto;
  flex-shrink: 0;
  color: var(--points);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  text-align: right;
}

.row.top-1 .points {
  color: var(--points-top);
}

#rows-container .row-update {
  animation: rowUpdateBroadcast var(--t-update) linear both;
}

#rows-container .row-update::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(216, 107, 51, 0.1), rgba(216, 107, 51, 0) 54%);
  animation: rowWashBroadcast var(--t-update) linear both;
  pointer-events: none;
}

#rows-container .row-update .rank-pulse,
#rows-container .rank-pulse {
  animation: rankPulseBroadcast 180ms linear;
}

@keyframes panelEdgeScan {
  from {
    background-position: 200% center;
  }

  to {
    background-position: -100% center;
  }
}

@keyframes popInBroadcast {
  from {
    opacity: 0;
    transform: translateX(-32px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes popOutBroadcast {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(-24px);
  }
}

@keyframes rowUpdateBroadcast {
  0% {
    filter: brightness(1);
  }

  40% {
    filter: brightness(1.06);
  }

  100% {
    filter: brightness(1);
  }
}

@keyframes rowWashBroadcast {
  from {
    opacity: 0.38;
  }

  to {
    opacity: 0;
  }
}

@keyframes rankPulseBroadcast {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.68;
  }

  100% {
    opacity: 1;
  }
}
