/* Leaderboard */
.lb-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* Sort as a joined segmented control (one pill, dividers between segments). */
.lb-sort {
  display: inline-flex;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.lb-sort-btn {
  flex: 1 1 0;
  padding: 8px 14px;
  border: none;
  border-left: 1.5px solid var(--outline);
  background: transparent;
  color: var(--on-surface-variant);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.lb-sort-btn:first-child { border-left: none; }

.lb-sort-btn:hover {
  color: var(--accent);
}

.lb-sort-btn.active {
  background: var(--accent);
  color: white;
}

/* Group-view sort: full-width segmented control under the count row */
.lb-group-sort {
  margin: 0 0 16px;
}
.lb-group-sort .lb-sort {
  display: flex;
  width: 100%;
}

/* Page head: breadcrumb + Create Group / Build Your Bracket */
.lb-pagehead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.lb-pagehead-actions {
  display: flex;
  gap: 8px;
}
.lb-head-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  padding: 10px 18px;
}
.lb-head-btn-secondary {
  background: var(--surface);
  color: var(--on-surface);
  border: 1.5px solid var(--outline);
}
.lb-head-btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* Sort is a single dropdown everywhere. In the group view it spans full width. */
.lb-group-sort .lb-sort-select { width: 100%; }

/* ---- Mobile: tidy the whole top into clean rows ---- */
@media (max-width: 600px) {
  /* CTAs: Build (primary) full-width on top, Create Group below */
  .lb-pagehead-actions {
    width: 100%;
    flex-direction: column-reverse;
  }
  .lb-head-btn { width: 100%; padding: 12px 18px; }

  /* Public controls: stack into full-width rows */
  .lb-controls { flex-direction: column; align-items: stretch; gap: 8px; }
  .lb-view-group { width: 100%; }
  .lb-sort-select { width: 100%; }

  /* Champion filter: removed on mobile (clutter) */
  .lb-controls .lb-filter { display: none; }

  /* Group header stacks: meta on top, actions full-width below */
  .lb-group-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .lb-group-actions { width: 100%; }
  .lb-group-actions .lb-group-btn { flex: 1 1 0; padding: 12px 16px; }
  /* Gear stays a fixed square at the end of the action row */
  .lb-group-actions .lb-group-gear { flex: 0 0 auto; }

  /* In the GROUP view on mobile, hide the page-head "Build Your Bracket" CTA —
     the group's own "Add Bracket" is the relevant action. */
  body.lb-in-group .lb-head-btn-primary { display: none; }
}

.lb-select {
  padding: 8px 12px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--on-surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.lb-view-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.lb-view-group-input {
  padding: 8px 12px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--on-surface);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, monospace);
  letter-spacing: 2px;
  width: 110px;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}

.lb-view-group-input::placeholder {
  letter-spacing: 0;
  font-weight: 500;
  color: var(--on-surface-variant);
  text-transform: none;
}

.lb-view-group-input:focus {
  border-color: var(--accent);
}

.lb-view-group-btn {
  padding: 8px 14px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.lb-view-group-btn:hover {
  opacity: 0.9;
}

.lb-count {
  font-size: 13px;
  color: var(--on-surface-variant);
  margin-bottom: 16px;
}

.lb-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.lb-count-row .lb-count {
  margin-bottom: 0;
}

.lb-scoring-link {
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Scoring-timing explainer banner (shown until the first results land). */
.lb-scoring-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--primary-container, rgba(12, 26, 61, 0.06));
  color: var(--on-surface-variant);
  font-size: 13px;
  line-height: 1.5;
}

.lb-scoring-note svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--primary);
}

.lb-scoring-link:hover {
  opacity: 0.8;
}

.lb-scoring-list {
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}

.lb-scoring-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--outline-variant);
  font-size: 14px;
  color: var(--on-surface);
}

.lb-scoring-row:last-child {
  border-bottom: none;
}

.lb-scoring-pts {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.lb-scoring-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface-variant);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  color: var(--on-surface);
}

.lb-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lb-card {
  background: var(--surface);
  border: 1.5px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}

.lb-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.lb-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lb-card-rank {
  font-size: 14px;
  font-weight: 800;
  color: var(--on-surface-variant);
  min-width: 28px;
}

.lb-card-info {
  flex: 1;
  min-width: 0;
}

.lb-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-card-meta {
  font-size: 12px;
  color: var(--on-surface-variant);
  margin-top: 2px;
}

.lb-card-champion {
  font-size: 28px;
  flex-shrink: 0;
}

.lb-card-champ-name {
  font-size: 12px;
  color: var(--on-surface-variant);
  margin: 6px 0 0 40px;
}

.lb-card-score {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 0 40px;
}

.lb-score-points {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
}

.lb-score-correct {
  font-size: 12px;
  color: var(--on-surface-variant);
}

.lb-score-pending {
  font-size: 12px;
  color: var(--on-surface-variant);
  font-style: italic;
}

.lb-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--outline-variant);
}

.lb-vote-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--on-surface-variant);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.lb-vote-btn:hover {
  border-color: #F59E0B;
  color: #F59E0B;
}

.lb-vote-btn.voted {
  background: #FFFBEB;
  border-color: #F59E0B;
  color: #D97706;
}

.lb-view-btn {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.lb-view-btn:hover {
  text-decoration: underline;
}

.lb-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--on-surface-variant);
}

.lb-cta-btn {
  display: inline-block;
  margin-top: 16px;
  padding: 12px 24px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  transition: transform 0.15s;
}

.lb-cta-btn:hover {
  transform: translateY(-1px);
}

/* Desktop: name/code on the left, actions (Add Bracket / Copy Invite / gear) on the right. */
.lb-group-header {
  background: var(--surface);
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.lb-group-meta { min-width: 0; }
.lb-group-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--on-surface);
  line-height: 1.2;
  word-break: break-word;
}
.lb-group-code {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--on-surface-variant);
  margin-top: 4px;
}
.lb-group-code span {
  color: var(--primary);
  font-weight: 800;
  letter-spacing: 1px;
}
.lb-group-gear {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: all 0.15s;
}
.lb-group-gear:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Desktop: actions sit inline on the right at natural width. */
.lb-group-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lb-group-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 16px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--on-surface-variant);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  font-family: inherit;
}

.lb-group-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lb-group-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.lb-group-btn.primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.lb-group-btn.copied {
  background: #ECFDF5;
  border-color: #10B981;
  color: #059669;
}

/* Add Bracket modal */
.lb-add-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lb-add-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 26, 61, 0.55);
  backdrop-filter: blur(4px);
}

.lb-add-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  max-height: 90vh;
  overflow-y: auto;
}

.lb-add-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--on-surface-variant);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lb-add-close:hover {
  background: var(--surface-variant);
  color: var(--on-surface);
}

.lb-add-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
  padding-right: 32px;
}

.lb-add-sub {
  font-size: 13px;
  color: var(--on-surface-variant);
  margin-bottom: 20px;
  line-height: 1.5;
}

.lb-add-section {
  margin-bottom: 4px;
}

.lb-add-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--on-surface-variant);
  margin-bottom: 10px;
}

.lb-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.lb-add-input {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
  color: var(--on-surface);
  background: var(--surface);
  min-width: 0;
}

.lb-add-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.lb-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--on-surface);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  font-family: inherit;
  width: 100%;
  text-align: center;
}

.lb-add-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.lb-add-btn.primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.lb-add-btn.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lb-add-result {
  margin-top: 10px;
  min-height: 20px;
}

.lb-add-divider {
  position: relative;
  text-align: center;
  margin: 22px 0;
}

.lb-add-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--outline-variant);
}

.lb-add-divider span {
  position: relative;
  background: var(--surface);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--on-surface-variant);
}

/* Group owner management — member list */
.lb-manage-members {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.lb-manage-member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-variant, rgba(0,0,0,0.03));
  border-radius: 8px;
}
.lb-manage-member-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-manage-owner-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  margin-left: 6px;
}
.lb-manage-member-locked {
  color: var(--on-surface-variant);
  font-weight: 700;
  padding: 0 8px;
}
.lb-manage-remove {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--error, #dc2626);
  color: var(--error, #dc2626);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lb-manage-remove:hover {
  background: var(--error, #dc2626);
  color: #fff;
}
