.leaderboard-card {
  text-align: left;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.leaderboard-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 6px;
  margin-bottom: 12px;
}

.leaderboard-field {
  display: contents;
}

.leaderboard-field label {
  display: block;
  grid-row: 1;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.leaderboard-select {
  grid-row: 2;
  position: relative;
}

.leaderboard-select-button {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fff;
  font-size: 14px;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.leaderboard-select-value {
  flex: 1;
}

.leaderboard-select-caret {
  font-size: 12px;
  color: var(--text-muted);
}

.leaderboard-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  z-index: 30;
  padding: 6px 0;
}

.leaderboard-select-option {
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  background: transparent;
  border: none;
  font-size: 14px;
  color: var(--text-main);
}

.leaderboard-select-option:hover,
.leaderboard-select-option:focus {
  background: var(--primary-light);
  color: var(--primary);
}

.leaderboard-select-option[aria-selected="true"] {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.leaderboard-select.is-disabled .leaderboard-select-button {
  background: #f3f4f6;
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.leaderboard-select.is-disabled .leaderboard-select-caret {
  color: var(--text-muted);
}

.leaderboard-table-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.leaderboard-table-body {
  overflow-y: auto;
  max-height: 420px;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  text-align: center;
  vertical-align: middle;
}

.leaderboard-table th {
  color: var(--text-muted);
  font-weight: 700;
}

.leaderboard-table th.name,
.leaderboard-table td.name {
  width: 42%;
  text-align: center;
}

.leaderboard-table th.rank,
.leaderboard-table td.rank {
  text-align: center;
}

.leaderboard-table td.rank {
  width: 54px;
  font-weight: 700;
  color: var(--text-main);
}

.leaderboard-table td.name {
  font-weight: 700;
  color: var(--text-main);
}

.leaderboard-table tr.leaderboard-row-me td {
  background: var(--secondary-light);
}

.leaderboard-table td.leaderboard-rank-new {
  color: var(--error);
  font-weight: 800;
}

.leaderboard-empty {
  margin-top: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.leaderboard-me {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--secondary-light);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
}

.leaderboard-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  padding: 16px;
}

.leaderboard-modal {
  width: 100%;
  max-width: 760px;
  max-height: min(80vh, 640px);
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.leaderboard-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--primary-light);
  position: relative;
}

.leaderboard-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: 100%;
  pointer-events: none;
}

.leaderboard-modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto;
  position: relative;
  z-index: 1;
}

.leaderboard-modal-body {
  padding: 16px 18px 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.leaderboard-modal-body .leaderboard-table-wrap {
  flex: 1;
}

.leaderboard-modal-body .leaderboard-table-body {
  flex: 1;
  max-height: none;
  min-height: 0;
}

html.leaderboard-modal-open,
body.leaderboard-modal-open {
  overflow: hidden;
  overscroll-behavior: none;
}
