/* Home-only design tokens. Rank colors are decorative, never payout rules. */
.home-screen { --leaderboard-max-width: 1000px; }
@media (min-width: 921px) {
  /* Keep desktop gutters and align the outer panel with the compact player rows. */
  .home-screen .home-inner { width: min(var(--leaderboard-max-width), calc(100% - 54px)); }
}
.home-screen .leaderboard-panel {
  --leaderboard-surface: #fffaf1;
  --leaderboard-ink: #202c3c;
  --leaderboard-muted: #64748b;
  --leaderboard-score-ink: #333333;
  --leaderboard-line: #e8edf4;
  --leaderboard-blue: #1768df;
  --leaderboard-row-height: 64px;
  --leaderboard-side-width: 112px;
  --leaderboard-rank-size: 46px;
  --leaderboard-row-max-width: 440px;
  --leaderboard-row-gap: 14px;
  --leaderboard-column-gap: 24px;
  --leaderboard-inline-space: 32px;
  --leaderboard-top-space: 28px;
  --leaderboard-bottom-space: 22px;
  /* Four complete rows: eight players in two columns, four on narrow screens. */
  --leaderboard-visible-rows: 4;
  --leaderboard-list-height: calc(var(--leaderboard-visible-rows) * var(--leaderboard-row-height) + (var(--leaderboard-visible-rows) - 1) * var(--leaderboard-row-gap) + 12px);
  width: min(var(--leaderboard-max-width), 100%) !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  grid-template-rows: auto auto auto;
  padding: var(--leaderboard-top-space) var(--leaderboard-inline-space) var(--leaderboard-bottom-space) !important;
  border-radius: 24px;
  background: var(--leaderboard-surface) !important;
  box-shadow: 0 14px 44px #263b5810;
}
.home-screen .leaderboard-header { margin-bottom: 22px; }
.home-screen .leaderboard-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.25rem);
  letter-spacing: -0.04em;
  line-height: 1.15;
}
.home-screen .leaderboard-header p {
  margin-top: 10px;
  color: #4e5d70;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
.home-screen .leaderboard-header #session-time {
  color: var(--leaderboard-ink);
  font-weight: 600;
}
.home-screen .leaderboard-header p::before {
  width: 6px;
  height: 6px;
  box-shadow: 0 0 0 4px #1976e815;
  animation: none;
}
.home-screen .leaderboard-summary {
  display: block;
  margin-top: 6px;
  color: var(--leaderboard-muted);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.5;
}
.home-screen .leaderboard-summary[hidden] { display: none; }
.home-screen .leaderboard-summary strong {
  color: inherit;
  font-weight: 500;
}
.home-screen .leaderboard-scroll {
  height: var(--leaderboard-list-height) !important;
  max-height: var(--leaderboard-list-height) !important;
  padding: 6px 8px 6px 4px !important;
  scrollbar-color: #b9cbe0 transparent;
  scrollbar-width: thin;
  scroll-behavior: auto;
}
.home-screen .leaderboard-scroll::-webkit-scrollbar { width: 5px; }
.home-screen .leaderboard-scroll::-webkit-scrollbar-track { background: transparent; }
.home-screen .leaderboard-scroll::-webkit-scrollbar-thumb { background: #b9cbe0; border-radius: 20px; }
.home-screen .leaderboard-scroll::-webkit-scrollbar-thumb:hover { background: #8da9cc; }
.home-screen .leaderboard-scroll::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.home-screen .leaderboard-scroll:focus-visible {
  outline: 2px solid #a8caff;
  outline-offset: 3px;
  border-radius: 16px;
}

.home-screen #leaderboard-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: min(100%, calc(2 * var(--leaderboard-row-max-width) + var(--leaderboard-column-gap))) !important;
  margin-inline: auto;
  gap: var(--leaderboard-row-gap) var(--leaderboard-column-gap) !important;
  padding: 0;
}

.home-screen #leaderboard-list > li {
  --rank-color: #e8eef8;
  --rank-light: #f6f8fc;
  --rank-ink: #435a78;
  --prize-color: #ffffff;
  --prize-ink: #245992;
  display: grid;
  grid-template-columns: var(--leaderboard-side-width) minmax(0, 1fr) var(--leaderboard-side-width);
  grid-template-areas: none;
  align-items: center;
  min-height: var(--leaderboard-row-height) !important;
  gap: 10px;
  padding: 8px 14px !important;
  border-radius: 999px;
  background: var(--rank-light) !important;
  border: 1px solid color-mix(in srgb, var(--rank-color) 16%, transparent);
  box-shadow: none;
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

/* Color only the top ten; later ranks keep the quiet neutral defaults. */
.home-screen #leaderboard-list > li:nth-child(-n + 10) {
  --rank-ink: #fff;
  --prize-color: var(--rank-color);
  --prize-ink: var(--rank-ink);
}
.home-screen #leaderboard-list > li:nth-child(1) {
  --rank-color: #ffc020;
  --rank-light: #fff5dd;
  --rank-ink: #664500;
}
.home-screen #leaderboard-list > li:nth-child(2) {
  --rank-color: #b6c2ce;
  --rank-light: #f0f3f6;
  --rank-ink: #344555;
}
.home-screen #leaderboard-list > li:nth-child(3) {
  --rank-color: #13815f;
  --rank-light: #e9f7f0;
}
.home-screen #leaderboard-list > li:nth-child(4) {
  --rank-color: #cf416a;
  --rank-light: #fff0f4;
}
.home-screen #leaderboard-list > li:nth-child(5) {
  --rank-color: #8047d7;
  --rank-light: #f4edfc;
}
.home-screen #leaderboard-list > li:nth-child(6) {
  --rank-color: #ef7922;
  --rank-light: #fff1e7;
  --rank-ink: #482100;
}
.home-screen #leaderboard-list > li:nth-child(7) {
  --rank-color: #1d70d4;
  --rank-light: #edf5ff;
}
.home-screen #leaderboard-list > li:nth-child(8) {
  --rank-color: #10b4c3;
  --rank-light: #eaf9fa;
  --rank-ink: #053e48;
}
/* Distinct lime and coral accents complete the ten-color palette. */
.home-screen #leaderboard-list > li:nth-child(9) {
  --rank-color: #d4e88b;
  --rank-light: #f5f9e7;
  --rank-ink: #34420f;
}
.home-screen #leaderboard-list > li:nth-child(10) {
  --rank-color: #c7473b;
  --rank-light: #fff0ec;
}

.home-screen #leaderboard-list .leaderboard-standing {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0 !important;
  grid-area: auto !important;
  align-self: center !important;
  text-align: left;
}
.home-screen #leaderboard-list .leaderboard-rank,
.home-screen #leaderboard-list .leaderboard-prize {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  grid-area: auto;
  background: var(--rank-color);
  color: var(--rank-ink) !important;
  font-family: var(--font-body);
  font-weight: 600 !important;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 5px #263b5808;
}
.home-screen #leaderboard-list .leaderboard-rank {
  flex: 0 0 var(--leaderboard-rank-size);
  width: var(--leaderboard-rank-size);
  height: var(--leaderboard-rank-size);
  border-radius: 50%;
  font-size: 1rem;
  letter-spacing: -0.025em;
}
.home-screen #leaderboard-list .leaderboard-prize {
  min-width: 94px;
  min-height: 38px;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 1.04rem;
  justify-self: end;
  background: var(--prize-color);
  color: var(--prize-ink) !important;
  border: 1px solid #ffffff60;
}
.home-screen #leaderboard-list .leaderboard-prize b {
  font-weight: 600;
}
.home-screen #leaderboard-list .leaderboard-prize-coin {
  display: inline-grid;
  place-items: center;
  grid-area: auto;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffffd9;
  color: #466484 !important;
  font: 700 12px/1 Arial, sans-serif;
}
.home-screen #leaderboard-list .leaderboard-player {
  display: flex;
  min-width: 0;
  justify-self: stretch;
  align-items: center;
  justify-content: center;
  grid-area: auto;
  font-size: 0.94rem;
  font-weight: 600;
  text-align: center;
}
.home-screen #leaderboard-list .leaderboard-player-name {
  grid-area: auto;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #263542;
  font-size: inherit;
}
.home-screen #leaderboard-list .leaderboard-points {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  gap: 1px;
  color: var(--leaderboard-score-ink);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.home-screen #leaderboard-list .leaderboard-points > span {
  min-width: 0 !important;
  grid-area: auto !important;
  align-self: auto !important;
  color: inherit !important;
  font-weight: inherit !important;
  white-space: nowrap;
}
.home-screen #leaderboard-list .leaderboard-points-value {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: inherit !important;
}
.home-screen #leaderboard-list .leaderboard-points-label {
  font-size: 0.64rem !important;
}
.home-screen #leaderboard-list .leaderboard-placeholder-name {
  grid-area: auto;
  color: #687885 !important;
  letter-spacing: 0.12em;
  font-weight: 500;
  justify-self: stretch;
  text-align: center;
}
.home-screen #leaderboard-list > li.is-house-bot {
  --rank-color: #dce2e9;
  --rank-light: #f2f4f6;
  --rank-ink: #435364;
  --prize-color: #e7ecf2;
  --prize-ink: #435364;
}
/* Ranks 41–100 stay readable but visually quieter than the forty prize places. */
.home-screen #leaderboard-list > li.is-standard-rank {
  --rank-color: transparent;
  --rank-light: #faf9f6;
  --rank-ink: #596574;
  --prize-color: transparent;
  --prize-ink: #596574;
  border-color: #e8e6e2;
}
.home-screen #leaderboard-list > li.is-standard-rank .leaderboard-rank,
.home-screen #leaderboard-list > li.is-standard-rank .leaderboard-prize {
  box-shadow: none;
  border-color: transparent;
}
.home-screen #leaderboard-list > li.is-standard-rank .leaderboard-prize-coin {
  display: none;
}
.home-screen #leaderboard-list .leaderboard-prize-empty {
  grid-area: auto !important;
  align-self: center !important;
  min-width: 0 !important;
}
.home-screen #leaderboard-list > li.is-current-player {
  border-color: #91bafa;
  box-shadow: inset 0 0 0 1px #91bafa38;
}
@media (hover: hover) and (pointer: fine) {
  .home-screen #leaderboard-list > li:not(.is-placeholder):hover {
    transform: none;
    border-color: color-mix(in srgb, var(--rank-color) 50%, #cfdaea);
    box-shadow: 0 3px 12px #263b580a;
  }
}

/* A quiet, readable personal-position footer, including the unranked state. */
.home-screen .leaderboard-self { gap: 10px; padding: 12px 4px 0; }
.home-screen .leaderboard-self-divider { width: 100%; background: var(--leaderboard-line); }
.home-screen #leaderboard-self-list { width: min(520px, 100%); }
.home-screen #leaderboard-self-list > li {
  grid-template-columns: 42px minmax(0, 1fr) max-content !important;
  gap: 12px !important;
  min-height: 62px !important;
  padding: 8px 14px !important;
  border: 1px solid #e0e9f7;
  border-radius: 18px;
  background: #f5f8fe !important;
  box-shadow: none;
}
.home-screen #leaderboard-self-list .leaderboard-self-position {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-width: 0 !important;
  align-self: center !important;
  border-radius: 13px;
  background: #e6eefc;
  color: #3a659e !important;
  font-size: 0.9rem !important;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.home-screen #leaderboard-self-list .leaderboard-self-player {
  display: grid;
  justify-self: stretch;
  gap: 2px;
  min-width: 0;
  text-align: left;
}
.home-screen #leaderboard-self-list .leaderboard-self-player > span {
  display: block;
  width: 100%;
  min-width: 0 !important;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.84rem !important;
  color: var(--leaderboard-ink);
  font-weight: 500;
}
.home-screen #leaderboard-self-list .leaderboard-self-score {
  display: grid;
  gap: 2px;
  color: #284a7a;
  font-weight: 600;
  font-size: 0.94rem !important;
  text-align: right;
}
.home-screen #leaderboard-self-list .leaderboard-self-score > span {
  font-size: 0.76rem !important;
  color: #4a5f7a;
}
.home-screen #leaderboard-self-list small {
  color: var(--leaderboard-muted);
  font-size: 0.65rem;
  font-weight: 400;
  line-height: 1.5;
}

/* Polling changes values, not the entrance animation or the user's scroll. */
.home-screen #leaderboard-list.is-live-refresh > li {
  animation: none;
}

@media (max-width: 920px) {
  .home-screen .leaderboard-panel {
    --leaderboard-inline-space: 24px;
    --leaderboard-column-gap: 16px;
    --leaderboard-side-width: 80px;
    --leaderboard-rank-size: 32px;
  }
  .home-screen #leaderboard-list > li { gap: 8px; padding-inline: 10px !important; }
  .home-screen #leaderboard-list .leaderboard-standing { gap: 6px; }
  .home-screen #leaderboard-list .leaderboard-rank { font-size: 0.85rem !important; }
  .home-screen #leaderboard-list .leaderboard-points-label { font-size: 0.6rem !important; }
  .home-screen #leaderboard-list .leaderboard-prize {
    min-width: 76px !important;
    min-height: 34px;
    padding-inline: 8px;
    gap: 4px;
    font-size: 0.9rem !important;
  }
  .home-screen #leaderboard-list .leaderboard-prize-coin {
    flex-basis: 14px;
    width: 14px;
    height: 14px;
    min-width: 14px !important;
    font-size: 10px !important;
  }
}
@media (max-width: 760px) {
  /* Replace the legacy two-line score layout, including its !important guards. */
  .home-screen .leaderboard-panel {
    --leaderboard-inline-space: 12px;
    --leaderboard-top-space: 24px;
    --leaderboard-bottom-space: 18px;
    --leaderboard-row-gap: 12px;
    border-radius: 22px;
  }
  .home-screen #leaderboard-list > li {
    grid-template-columns: var(--leaderboard-side-width) minmax(0, 1fr) var(--leaderboard-side-width) !important;
    grid-template-areas: none !important;
    gap: 8px !important;
  }
  .home-screen #leaderboard-list .leaderboard-rank,
  .home-screen #leaderboard-list .leaderboard-player,
  .home-screen #leaderboard-list .leaderboard-player-name,
  .home-screen #leaderboard-list .leaderboard-placeholder-name,
  .home-screen #leaderboard-list .leaderboard-prize,
  .home-screen #leaderboard-list .leaderboard-prize-coin {
    grid-area: auto !important;
    align-self: center !important;
  }
  .home-screen #leaderboard-list .leaderboard-player { font-size: 0.9rem !important; }
  .home-screen #leaderboard-list .leaderboard-player-name { min-width: 0 !important; }
  .home-screen #leaderboard-list .leaderboard-prize {
    justify-self: end !important;
  }
}
@media (max-width: 640px) {
  .home-screen #leaderboard-list { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (max-width: 360px) {
  .home-screen .leaderboard-panel { --leaderboard-inline-space: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .home-screen #leaderboard-list > li { animation: none; transition: none; transform: none; }
}
