:root {
  --dash-cream: var(--ry-cream, #fff8f4);
  --dash-ink: var(--ry-ink, #163038);
  --dash-muted: var(--ry-muted, #3d5c66);
  --shell-max: 1440px;
  --shell-gutter: clamp(16px, 3.2vw, 36px);
  --shell-top: 0px;
  --dock-space: 84px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--dash-ink);
  font-family: Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--shell-top) var(--shell-gutter) calc(var(--dock-space) + env(safe-area-inset-bottom));
  overflow-x: clip;
}

.leaderboard-stage {
  position: relative;
  flex: 1 1 auto;
  width: min(100%, var(--shell-max));
  max-width: var(--shell-max);
}

.status-bar,
.top-brand,
.stat,
.race-meta,
.tabs-row,
.tabs,
.podium,
.standings-toolbar,
.rank-row,
.learner,
.badges,
.league-card,
.league-zero,
.bottom-dock,
.bottom-nav,
.bottom-nav a {
  display: flex;
  align-items: center;
}

.stat::before {
  content: "";
  display: block;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 8px;
  box-shadow: inset 0 -2px rgba(0, 0, 0, 0.16);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
}

.stat.fire::before {
  background-color: var(--ry-orange, #ff8a00);
  background-image: url("/assets/stat-icons/flame.svg");
}

.stat.gem::before {
  background-color: var(--ry-blue, #1cb0f6);
  background-image: url("/assets/stat-icons/gem.svg");
}

.stat.heart::before {
  background-color: var(--ry-red, #ff4b4b);
  background-image: url("/assets/stat-icons/heart.svg");
}

.cream-card,
body.room-league .league-arena,
body.room-league .standings {
  color: var(--dash-ink);
  background: var(--dash-cream);
  border-radius: 28px;
  box-shadow: 0 10px 28px rgba(22, 48, 56, 0.08);
}

body.room-league .league-arena,
body.room-league .standings {
  min-height: 0;
  padding: 26px 28px 20px;
}

.league-card {
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.league-copy,
.race-copy {
  display: grid;
  gap: 4px;
}

.ry-label,
.league-copy .ry-label,
.race-copy .ry-label,
.standings-toolbar .ry-label {
  margin: 0;
}

.league-card h1 {
  margin: 4px 0 2px;
  font-size: clamp(1.9rem, 3vw, 2.55rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 0.94;
}

.hero-copy {
  margin: 0;
  color: var(--dash-muted);
  font-weight: 700;
  line-height: 1.35;
}

.trophy-stack {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.trophy-cup {
  width: min(148px, 28vw);
  height: auto;
  filter: drop-shadow(0 8px 10px rgba(201, 137, 18, 0.22));
}

.mini-medals {
  display: flex;
  gap: 10px;
}

.mini-medal {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: inset 0 -2px rgba(0, 0, 0, 0.12);
}

.mini-medal::after {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  margin: 11px auto 0;
  border-radius: 2px;
  background: inherit;
  filter: brightness(0.86);
}

.mini-medal.gold { background: #ffc400; }
.mini-medal.silver { background: #c5d0d8; }
.mini-medal.coral { background: #fc5b62; }
.mini-medal.amber { background: #ffb020; }

.race-strip {
  display: grid;
  gap: 8px;
  margin: 18px 0 8px;
}

.race-copy strong {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.race-progress {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #efe4dc;
}

body.room-league .race-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #fc5b62;
}

.race-meta {
  justify-content: flex-start;
  gap: 8px;
  color: var(--dash-muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.chest-mark {
  width: 18px;
  height: 18px;
  border-radius: 4px 4px 2px 2px;
  background:
    linear-gradient(#ffc400, #f0a800);
  box-shadow: inset 0 -2px rgba(0, 0, 0, 0.12);
}

.league-zero {
  justify-content: flex-start;
  align-items: flex-end;
  gap: 10px;
  margin-top: auto;
  padding-top: 8px;
}

.zero-speech {
  position: relative;
  max-width: 16ch;
  margin: 0 0 28px;
  padding: 10px 12px;
  color: var(--dash-ink);
  border: 2px solid #d7e3e8;
  border-radius: 16px;
  background: #fff;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.3;
}

.zero-speech::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: 12px;
  width: 12px;
  height: 12px;
  border-right: 2px solid #d7e3e8;
  border-bottom: 2px solid #d7e3e8;
  background: #fff;
  transform: rotate(-45deg);
}

#leagueZero .zero-figure--dash .zero-sprite,
.zero-figure--dash .zero-sprite {
  width: 132px;
  filter: none;
}

.standings-toolbar {
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.standings-toolbar h2 {
  margin: 4px 0 0;
  font-size: clamp(1.55rem, 2.4vw, 2.05rem);
  font-weight: 900;
  letter-spacing: -0.04em;
}

.tabs-row {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.tabs {
  gap: 8px;
}

.tab,
.refresh-button {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 800;
}

.tab {
  padding: 8px 16px;
  color: var(--dash-ink);
  background: #fff;
  box-shadow: 0 4px 12px rgba(22, 48, 56, 0.05);
}

body.room-league .tab.active {
  color: #fff !important;
  background: #fc5b62 !important;
  box-shadow: 0 3px 0 #c4333b !important;
}

.refresh-button {
  padding: 8px 12px;
  color: var(--dash-muted);
  background: transparent;
  box-shadow: none;
  font-size: 0.72rem;
}

.podium {
  align-items: flex-end;
  gap: 12px;
  margin: 8px 0 18px;
}

.podium-card {
  display: grid;
  flex: 1;
  justify-items: center;
  gap: 6px;
  min-width: 0;
  padding: 16px 10px 14px;
  border: 0;
  border-radius: 22px;
  background: #eef7fb;
  box-shadow: none;
}

.podium-card.gold {
  padding-top: 22px;
  background: #fff6d2;
}

.podium-card.silver {
  background: #eef2f6;
}

.podium-card.bronze {
  background: #e7f4fb;
}

.medal {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #fff;
  border-radius: 50%;
  background: #3fa4b3;
  font-size: 0.78rem;
  font-weight: 900;
}

.podium-card.gold .medal {
  color: #7a5500;
  background: #ffc400;
}

.podium-card.gold .medal::before {
  content: "";
  position: absolute;
  top: -12px;
  width: 16px;
  height: 10px;
  background: #ffc400;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.podium-avatar {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  color: #fff;
  border-radius: 50%;
  background: #3fa4b3;
  font-weight: 900;
}

.podium-card.gold .podium-avatar {
  color: #7a5500;
  background: #ffe27a;
}

.podium-card strong {
  font-size: 1.05rem;
  font-weight: 900;
}

.podium-card small {
  color: var(--dash-muted);
  font-weight: 800;
}

.rank-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank-row {
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: #fff;
}

.rank-row.top-one,
.rank-row.top-two,
.rank-row.top-three,
.zone-label {
  display: none;
}

.rank-row.current {
  background: #fff;
  box-shadow: 0 0 0 2px #fc5b62;
}

.xp {
  color: var(--dash-ink);
  font-size: 0.95rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-transform: none;
}

.xp span {
  display: inline;
  margin-left: 4px;
  color: var(--dash-muted);
  font-size: 0.8rem;
}

.rank {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  color: #fff;
  border-radius: 50%;
  background: #3fa4b3;
  font-weight: 900;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  color: #fff;
  border-radius: 50%;
  background: #3fa4b3;
  font-size: 0.68rem;
  font-weight: 900;
}

.learner {
  flex: 1;
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.learner strong {
  max-width: 100%;
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badges {
  display: none;
}

body.room-league .dash-board--league {
  display: grid;
  gap: 20px;
  padding: 4px 12px 12px;
}

@media (min-width: 1100px) {
  body.room-league .dash-board--league {
    grid-template-columns: minmax(360px, 0.72fr) minmax(0, 1fr);
    align-items: stretch;
    min-height: calc(100dvh - 72px - var(--dock-space));
  }

  body.room-league .league-arena {
    display: grid;
    grid-template-rows: auto auto 1fr;
    align-content: start;
    gap: 8px;
  }

  body.room-league .standings {
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 8px;
  }

  .standings .rank-list {
    min-height: 0;
    overflow: auto;
  }
}

@media (max-width: 1099px) {
  .league-card {
    flex-wrap: wrap;
  }

  .standings-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 880px) {
  .app-shell {
    --shell-gutter: 12px;
    --dock-space: 92px;
    padding: 0 12px calc(var(--dock-space) + env(safe-area-inset-bottom));
  }
}

@media (max-width: 600px) {
  .podium {
    gap: 8px;
  }

  .podium-card {
    padding-inline: 6px;
  }

  .tabs-row {
    justify-content: stretch;
  }

  .tab {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
