.leaderboard-open-button {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 110;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid rgba(183, 239, 53, 0.58);
  border-radius: 999px;
  background: rgba(3, 8, 24, 0.9);
  color: #d4fb68;
  cursor: pointer;
  font-weight: 800;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.32),
    inset 0 0 18px rgba(183, 239, 53, 0.08);
}

.leaderboard-open-button:hover,
.leaderboard-open-button:focus-visible {
  outline: none;
  border-color: #b7ef35;
  box-shadow:
    0 0 0 3px rgba(183, 239, 53, 0.14),
    0 14px 34px rgba(0, 0, 0, 0.38);
}

.leaderboard-dialog {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: grid;
  place-items: center;
  padding:
    max(14px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  background: rgba(1, 3, 11, 0.78);
  backdrop-filter: blur(12px);
}

.leaderboard-dialog[hidden] {
  display: none;
}

.leaderboard-panel {
  width: min(620px, 100%);
  max-height: min(720px, calc(100dvh - 28px));
  overflow: hidden;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid rgba(37, 213, 255, 0.42);
  border-radius: 22px;
  background:
    radial-gradient(circle at 100% 0%, rgba(183, 239, 53, 0.1), transparent 34%),
    linear-gradient(180deg, rgba(8, 14, 37, 0.99), rgba(2, 6, 19, 0.995));
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.68),
    inset 0 0 42px rgba(37, 213, 255, 0.05);
  direction: rtl;
}

.leaderboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.leaderboard-kicker {
  margin: 0 0 7px;
  color: #8cecff;
  font-size: 13px;
  font-weight: 800;
}

.leaderboard-header h2 {
  margin: 0;
  color: #d4fb68;
  font-family: var(--display-font);
  font-size: clamp(29px, 6vw, 42px);
  line-height: 1;
  text-shadow: 0 0 22px rgba(183, 239, 53, 0.26);
}

.leaderboard-actions {
  display: flex;
  gap: 7px;
}

.leaderboard-icon-button {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 1px solid rgba(37, 213, 255, 0.32);
  border-radius: 10px;
  background: rgba(4, 11, 29, 0.86);
  color: #8cecff;
  cursor: pointer;
  font-size: 23px;
  line-height: 1;
}

.leaderboard-icon-button:hover,
.leaderboard-icon-button:focus-visible {
  outline: none;
  border-color: #b7ef35;
  color: #d4fb68;
}

.leaderboard-icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.leaderboard-copy {
  margin: 14px 0;
  color: #aebbd0;
  line-height: 1.4;
}

.leaderboard-scope {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.leaderboard-scope-chip {
  padding: 5px 10px;
  border: 1px solid rgba(37, 213, 255, 0.28);
  border-radius: 999px;
  background: rgba(37, 213, 255, 0.08);
  color: #9beeff;
  font-size: 12px;
  font-weight: 800;
}

.leaderboard-scope-chip.is-active {
  border-color: rgba(103, 240, 139, 0.54);
  background: rgba(103, 240, 139, 0.12);
  color: #9dffb5;
}

.leaderboard-scope-chip.is-unavailable {
  border-color: rgba(145, 162, 186, 0.26);
  background: rgba(145, 162, 186, 0.08);
  color: #91a2ba;
}

.leaderboard-player-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}

.leaderboard-player-summary > div {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid rgba(37, 213, 255, 0.18);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(16, 29, 61, 0.84), rgba(5, 12, 31, 0.9));
  text-align: center;
}

.leaderboard-player-summary > div.is-rank {
  border-color: rgba(255, 216, 74, 0.48);
  background: linear-gradient(180deg, rgba(255, 216, 74, 0.16), rgba(63, 35, 4, 0.3));
  box-shadow: inset 0 0 18px rgba(255, 216, 74, 0.06);
}

.leaderboard-player-summary span {
  display: block;
  overflow: hidden;
  color: #91a2ba;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-player-summary strong {
  display: block;
  margin-top: 2px;
  color: #f7fbff;
  font-family: var(--display-font);
  font-size: clamp(19px, 4vw, 25px);
  line-height: 1.1;
}

.leaderboard-player-summary .is-rank strong {
  color: #ffd84a;
  text-shadow: 0 0 14px rgba(255, 216, 74, 0.28);
}

.leaderboard-list {
  display: grid;
  gap: 7px;
  max-height: min(430px, 52dvh);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-gutter: stable;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid rgba(37, 213, 255, 0.16);
  border-radius: 12px;
  background: rgba(8, 17, 38, 0.72);
}

.leaderboard-list li:nth-child(-n + 3) {
  border-color: rgba(183, 239, 53, 0.34);
  background: rgba(183, 239, 53, 0.07);
}

.leaderboard-list li.is-current-player {
  border-color: rgba(255, 216, 74, 0.72);
  background:
    linear-gradient(90deg, rgba(255, 216, 74, 0.16), rgba(37, 213, 255, 0.08)),
    rgba(8, 17, 38, 0.9);
  box-shadow: inset 0 0 20px rgba(255, 216, 74, 0.08), 0 0 0 1px rgba(255, 216, 74, 0.08);
}

.leaderboard-list li.is-current-player .leaderboard-rank,
.leaderboard-list li.is-current-player .leaderboard-score {
  color: #ffd84a;
}

.leaderboard-rank {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 1px solid rgba(183, 239, 53, 0.36);
  border-radius: 8px;
  color: #d4fb68;
  font-family: var(--display-font);
  font-weight: 700;
}

.leaderboard-player {
  min-width: 0;
  color: #f7fbff;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-player small {
  display: block;
  margin-top: 2px;
  color: #91a2ba;
  font-size: 11px;
  font-weight: 700;
}

.leaderboard-score {
  color: #67f08b;
  font-family: var(--display-font);
  font-size: 19px;
  white-space: nowrap;
}

.leaderboard-placeholder {
  display: block !important;
  min-height: 68px !important;
  padding: 22px 12px !important;
  color: #91a2ba;
  text-align: center;
}

.leaderboard-status,
.publish-score-status {
  min-height: 18px;
  margin: 10px 0 0;
  color: #91a2ba;
  font-size: 13px;
  line-height: 1.3;
}

.publish-score-panel {
  margin: 4px 0 18px;
  padding: 15px 0;
  border-block: 1px solid rgba(183, 239, 53, 0.24);
}

.publish-score-panel.is-disabled {
  border-block-color: rgba(145, 162, 186, 0.28);
}

.publish-score-panel[hidden] {
  display: none;
}

.publish-score-panel > strong {
  display: block;
  margin-bottom: 7px;
  color: #d4fb68;
  font-size: 17px;
}

.publish-score-panel > p:not(.publish-score-status) {
  margin: 0 0 13px;
  color: #91a2ba;
  line-height: 1.4;
}

.publish-score-panel.is-disabled > strong {
  color: #d7e4f5;
}

.publish-score-panel.is-disabled .secondary-button {
  border-color: rgba(145, 162, 186, 0.32);
  background: rgba(145, 162, 186, 0.12);
  color: #d7e4f5;
  cursor: not-allowed;
}

.secondary-button {
  min-width: min(230px, 100%);
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid rgba(183, 239, 53, 0.56);
  border-radius: 12px;
  background: rgba(183, 239, 53, 0.12);
  color: #d4fb68;
  cursor: pointer;
  font-family: var(--display-font);
  font-weight: 700;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  outline: none;
  border-color: #b7ef35;
  background: rgba(183, 239, 53, 0.18);
}

.secondary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

@media (max-width: 600px) {
  .leaderboard-open-button {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    min-height: 36px;
    padding-inline: 11px;
    font-size: 12px;
  }

  .leaderboard-dialog {
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  }

  .leaderboard-panel {
    max-height: calc(100dvh - 16px);
    padding: 16px 12px;
    border-radius: 17px;
  }

  .leaderboard-copy {
    margin: 11px 0;
    font-size: 13px;
  }

  .leaderboard-player-summary {
    gap: 5px;
    margin-bottom: 10px;
  }

  .leaderboard-player-summary > div {
    padding: 8px 4px;
  }

  .leaderboard-player-summary span {
    font-size: 9px;
  }

  .leaderboard-list {
    max-height: 46dvh;
  }
}
