:root {
  --navy: #071534;
  --navy-soft: #102958;
  --blue: #2f6df6;
  --blue-bright: #5c8cff;
  --cyan: #5bd4ff;
  --white: #fff;
  --muted: #aebeda;
  --line: rgba(185, 207, 247, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--white);
  background: var(--navy);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 86% 12%, rgba(54, 116, 255, 0.34), transparent 30%),
    radial-gradient(circle at 8% 86%, rgba(42, 213, 255, 0.15), transparent 34%),
    linear-gradient(145deg, #06122e, #091c42 56%, #06132f);
}

button,
input { font: inherit; }

button,
.closeButton {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

button { cursor: pointer; }

.authScreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #eef3fb;
  color: #101828;
}

body:not(.authLocked) .authScreen { display: none; }
body.authChecking .authScreen { opacity: 0; }

.authCard {
  display: grid;
  gap: 15px;
  width: min(420px, calc(100vw - 32px));
  border: 1px solid #d7e0ef;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 65px rgba(15, 40, 80, 0.18);
  padding: 30px;
}

.authCard h1 { margin: 0; }
.authCard label { display: grid; gap: 7px; font-weight: 700; }
.authCard input { min-height: 46px; border: 1px solid #cfd9e8; border-radius: 10px; padding: 0 12px; }
.authCard button { min-height: 48px; border: 0; background: var(--blue); font-weight: 800; }
.authMessage { min-height: 20px; color: #a32626; }

.brandMark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: linear-gradient(145deg, #0d1837, #172b58);
  color: #fff;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.leaderboardApp {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100vw;
  height: 100vh;
  min-height: 560px;
  padding: clamp(18px, 2vw, 34px) clamp(24px, 3.3vw, 64px) clamp(16px, 2vw, 30px);
}

.leaderboardHeader,
.leaderboardFooter {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.leaderboardBrand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  text-decoration: none;
}

.leaderboardBrand > span:last-child { display: grid; gap: 1px; }
.leaderboardBrand strong { font-size: clamp(17px, 1.35vw, 25px); }
.leaderboardBrand small { color: var(--muted); font-size: clamp(12px, 0.9vw, 16px); }

.leaderboardHeaderRight,
.leaderboardControls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.liveBadge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(92, 140, 255, 0.35);
  border-radius: 999px;
  background: rgba(47, 109, 246, 0.14);
  padding: 8px 13px;
  color: #c9d8ff;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.liveBadge i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #52e6a5;
  box-shadow: 0 0 0 5px rgba(82, 230, 165, 0.13);
}

#leaderboardClock {
  min-width: 95px;
  color: #dae5fa;
  font-size: clamp(15px, 1.1vw, 20px);
  font-weight: 750;
  text-align: center;
}

#fullscreenBtn,
.closeButton {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  text-decoration: none;
}

#fullscreenBtn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.closeButton { font-size: 29px; line-height: 1; }

.leaderboardStage {
  position: relative;
  min-height: 0;
  margin: clamp(14px, 2vh, 28px) 0 clamp(12px, 1.6vh, 22px);
  overflow: hidden;
}

.leaderboardSlide,
.loadingSlide {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: clamp(25px, 2.2vw, 42px);
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.02)),
    rgba(7, 20, 51, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 35px 90px rgba(0, 0, 0, 0.22);
  padding: clamp(28px, 4vw, 76px);
  opacity: 0;
  transform: translateX(5%) scale(0.985);
  transition: opacity 520ms ease, transform 620ms cubic-bezier(0.22, 1, 0.36, 1);
}

.leaderboardSlide.active { opacity: 1; transform: translateX(0) scale(1); }
.leaderboardSlide.leaving { opacity: 0; transform: translateX(-4%) scale(0.985); }

.loadingSlide {
  position: relative;
  place-items: center;
  align-content: center;
  gap: 18px;
  opacity: 1;
  transform: none;
  color: var(--muted);
  font-size: clamp(18px, 1.6vw, 28px);
}

.loadingSpinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--blue-bright);
  border-radius: 999px;
  animation: spin 850ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.slideEyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: clamp(10px, 1.2vh, 18px);
  color: #76a0ff;
  font-size: clamp(12px, 1vw, 18px);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.slideEyebrow::before {
  content: "";
  width: 34px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}

.slideTitle {
  max-width: 1200px;
  margin: 0;
  font-size: clamp(40px, 5.4vw, 94px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.slideSubtitle {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: clamp(15px, 1.5vw, 27px);
}

.teamBreakdownSlide {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  height: 100%;
}

.teamBreakdownHeader {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: clamp(14px, 2vh, 26px);
}

.teamBreakdownTitle {
  font-size: clamp(32px, 4vw, 68px);
}

.repCountBadge {
  flex: 0 0 auto;
  border: 1px solid rgba(92, 140, 255, 0.36);
  border-radius: 999px;
  background: rgba(47, 109, 246, 0.15);
  padding: 10px 16px;
  color: #cfddff;
  font-size: clamp(12px, 1vw, 17px);
  font-weight: 850;
}

.teamBreakdownGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(var(--breakdown-rows), minmax(0, 1fr));
  gap: clamp(8px, 1vh, 14px) clamp(12px, 1.2vw, 20px);
  min-height: 0;
}

.teamBreakdownCard {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) minmax(170px, 1.25fr) minmax(250px, 2fr);
  align-items: center;
  gap: clamp(10px, 1vw, 18px);
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: clamp(13px, 1.1vw, 19px);
  background: linear-gradient(145deg, rgba(41, 85, 173, 0.19), rgba(255, 255, 255, 0.035));
  padding: clamp(9px, 1vw, 15px);
}

.teamBreakdownName {
  overflow: hidden;
  font-size: clamp(15px, 1.35vw, 23px);
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teamBreakdownTimes,
.teamBreakdownMetrics {
  display: grid;
  min-width: 0;
}

.teamBreakdownTimes {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(7px, 0.8vw, 13px);
  padding-left: clamp(9px, 0.8vw, 14px);
  border-left: 1px solid var(--line);
}

.teamBreakdownMetrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(7px, 0.8vw, 13px);
  padding-left: clamp(9px, 0.8vw, 14px);
  border-left: 1px solid var(--line);
}

.compactBreakdownMetric {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.compactBreakdownMetric small {
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(8px, 0.64vw, 12px);
  font-weight: 800;
  letter-spacing: 0.045em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.compactBreakdownMetric strong {
  overflow: hidden;
  color: #fff;
  font-size: clamp(15px, 1.4vw, 24px);
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teamBreakdownSlide.dense .teamBreakdownCard,
.teamBreakdownSlide.veryDense .teamBreakdownCard {
  padding-top: 6px;
  padding-bottom: 6px;
}

.teamBreakdownSlide.veryDense .teamBreakdownHeader {
  margin-bottom: 10px;
}

.teamBreakdownSlide.veryDense .slideSubtitle {
  margin-top: 6px;
}

.breakdownStats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(10px, 1.3vw, 22px);
  margin-top: clamp(28px, 5vh, 62px);
}

.statTile,
.rankCard {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(41, 85, 173, 0.21), rgba(255, 255, 255, 0.035));
}

.statTile {
  min-width: 0;
  border-radius: clamp(16px, 1.4vw, 24px);
  padding: clamp(15px, 1.6vw, 25px);
}

.statTile span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: clamp(11px, 0.9vw, 16px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.statTile strong {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: clamp(27px, 3vw, 53px);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slideFootnote {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 26px;
  margin-top: clamp(20px, 3vh, 36px);
  color: #c0cee6;
  font-size: clamp(13px, 1.05vw, 19px);
}

.slideFootnote span { display: inline-flex; align-items: center; gap: 8px; }
.slideFootnote span::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: #5d89f7; }

.rankGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 32px);
  margin-top: clamp(28px, 5vh, 64px);
}

.rankCard {
  position: relative;
  min-width: 0;
  min-height: clamp(190px, 27vh, 330px);
  border-radius: clamp(20px, 2vw, 34px);
  padding: clamp(22px, 2.5vw, 42px);
  overflow: hidden;
}

.rankCard:first-child {
  border-color: rgba(255, 204, 84, 0.45);
  background: linear-gradient(145deg, rgba(255, 186, 46, 0.22), rgba(255, 255, 255, 0.04));
}

.rankNumber {
  display: grid;
  place-items: center;
  width: clamp(46px, 4.4vw, 74px);
  height: clamp(46px, 4.4vw, 74px);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  color: #dbe7ff;
  font-size: clamp(23px, 2.4vw, 40px);
  font-weight: 950;
}

.rankCard:first-child .rankNumber { background: #ffca52; color: #523500; }

.rankName {
  display: block;
  margin-top: clamp(18px, 2.4vh, 30px);
  overflow: hidden;
  font-size: clamp(25px, 2.8vw, 48px);
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rankValue {
  display: block;
  margin-top: 13px;
  color: #8fb0ff;
  font-size: clamp(21px, 2vw, 35px);
  font-weight: 850;
}

.rankDetail {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: clamp(13px, 1.1vw, 19px);
}

.emptyRanking {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 24px;
  color: var(--muted);
  font-size: clamp(18px, 1.7vw, 28px);
}

.leaderboardFooter {
  min-height: 54px;
}

.leaderboardFooter > div:first-child { display: grid; gap: 3px; min-width: 220px; }
.leaderboardFooter strong { font-size: 14px; }
.leaderboardFooter span { color: var(--muted); font-size: 12px; }

.slideProgress {
  flex: 1;
  height: 4px;
  max-width: 560px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}

.slideProgress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}

.slideProgress i.running { animation: progress var(--slide-duration, 12s) linear forwards; }
@keyframes progress { from { width: 0; } to { width: 100%; } }

.leaderboardControls button { min-width: 46px; min-height: 42px; font-weight: 800; }
#playPauseBtn { min-width: 82px; }

.leaderboardStatus {
  position: fixed;
  right: 24px;
  bottom: 76px;
  z-index: 10;
  max-width: 420px;
  border-radius: 12px;
  background: rgba(8, 18, 42, 0.88);
  color: #c7d5ee;
  padding: 10px 14px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.leaderboardStatus.visible { opacity: 1; }

@media (max-width: 900px) {
  .leaderboardApp { overflow: auto; height: auto; min-height: 100vh; }
  body { overflow: auto; }
  .leaderboardStage { min-height: 680px; }
  .breakdownStats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rankGrid { grid-template-columns: 1fr; }
  .rankCard { min-height: 0; }
  .teamBreakdownSlide { height: auto; }
  .teamBreakdownGrid { grid-template-columns: 1fr; grid-template-rows: none; overflow: auto; }
  .teamBreakdownCard { grid-template-columns: minmax(125px, 1fr) minmax(170px, 1.25fr) minmax(245px, 2fr); }
  .leaderboardFooter { flex-wrap: wrap; }
  .slideProgress { order: 3; flex-basis: 100%; max-width: none; }
}

@media (max-width: 620px) {
  .leaderboardApp { padding: 14px; }
  .leaderboardHeader { align-items: flex-start; }
  .leaderboardBrand small, .liveBadge, #leaderboardClock { display: none; }
  .leaderboardStage { min-height: 750px; }
  .leaderboardSlide { padding: 25px 20px; }
  .breakdownStats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .teamBreakdownHeader { align-items: flex-start; }
  .teamBreakdownCard { grid-template-columns: 1fr; gap: 8px; }
  .teamBreakdownTimes,
  .teamBreakdownMetrics { padding: 8px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .rankName { white-space: normal; }
  .leaderboardFooter > div:first-child { min-width: 0; }
}
