/* Leaderboard Pattern */
.leaderboard {
  max-width: 1000px;
  width: 100%;
}

.leaderboard-header {
  position: relative;
  border-radius: 0;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 30px;
  overflow: hidden;
}

.leaderboard-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(to bottom, rgb(29, 29, 29) 0%, transparent 100%);
  z-index: 1;
  pointer-events: none;
}

.leaderboard-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(to top, rgb(29, 29, 29) 0%, transparent 100%);
  z-index: 1;
  pointer-events: none;
}

.leaderboard-header .header-content {
  position: relative;
  z-index: 2;
  color: white;
  text-align: center;
}

.leaderboard-header h1 {
  color: rgb(242, 241, 237);
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 4px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  line-height: 1.2;
}

.leaderboard-header p {
  color: rgb(242, 241, 237);
  font-size: 18px;
  font-weight: 400;
  margin-bottom: 0;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  line-height: 1.3;
}

.leaderboard-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-bottom: 20px;
  position: relative;
}

.control-group {
  display: contents;
}

.control-item {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
  min-height: 80px;
  text-align: center;
  border: 1px solid rgb(65, 65, 65);
}

.control-item:first-child {
  border-right: none;
}

.control-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-icon {
  color: rgb(242, 241, 237);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.control-label {
  color: rgb(160, 160, 160);
  font-size: 0.9rem;
}

.control-value {
  color: rgb(242, 241, 237);
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.9rem;
}

.ranking-section {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.leader-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: rgb(242, 241, 237);
  margin-bottom: 8px;
  text-align: center;
}

.ranking-title {
  font-size: 1rem;
  font-weight: 400;
  color: rgb(242, 241, 237);
  margin-bottom: 4px;
  text-align: right;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ranking-separator-content {
  display: flex;
  align-items: center;
  gap: 15px;
  margin: 30px 0;
  color: rgb(102, 102, 102);
  font-size: 14px;
  font-weight: 500;
}

.ranking-separator-line {
  flex: 1;
  height: 1px;
  background: rgb(51, 51, 51);
}

.ranking-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
  transition: background-color 0.2s ease;
  border-left: 1px solid rgb(249, 237, 219);
  cursor: pointer;
}

.ranking-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.ranking-item:nth-child(1) {
  background-color: rgb(90, 85, 79);
}

.ranking-item:nth-child(2) {
  background-color: rgb(72, 68, 64);
}

.ranking-item:nth-child(3) {
  background-color: rgb(53, 51, 49);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: rgb(60, 60, 60);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgb(242, 241, 237);
}

.user-avatar.has-photo {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: transparent;
}

.user-avatar.placeholder {
  background-color: rgb(45, 45, 45);
  color: rgb(120, 120, 120);
}

.user-details {
  flex: 1;
}

.user-details h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgb(255, 255, 255);
  margin: 0 0 2px 0;
  line-height: 1.3;
}

.user-details p {
  font-size: 0.8rem;
  color: rgb(242, 241, 237);
  margin: 0;
  line-height: 1.2;
}

.ranking-number {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgb(249, 237, 219);
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgb(45, 45, 45);
}

/* Leaderboard Dropdowns */
.dropdown-trigger {
  cursor: pointer;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  background-color: rgb(29, 29, 29);
  border: 1px solid rgb(65, 65, 65);
  border-top: none;
  border-radius: 0;
  width: 50%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  margin-top: 0;
}

#timeline-dropdown,
#settings-dropdown {
  left: 50%;
}

.dropdown-menu.show {
  display: block !important;
  opacity: 1;
  visibility: visible;
}

.ranking-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #999;
  font-size: 16px;
}

.ranking-state.error {
  color: #e74c3c;
  text-align: center;
}

.load-more-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
  color: #999;
  font-size: 14px;
}

.load-more-button {
  padding: 8px 16px;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.load-more-button.manual {
  margin-top: 10px;
  margin-right: 5px;
  background: #333;
  border: 1px solid #555;
}

.load-more-button.test-api {
  background: #555;
  border: 1px solid #777;
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgb(65, 65, 65);
}

.dropdown-header h3 {
  color: rgb(242, 241, 237);
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.dropdown-body {
  padding: 20px 0;
}

.area-options {
  margin-bottom: 20px;
}

.area-option {
  display: flex;
  align-items: center;
  padding: 14px 26px;
  color: rgb(242, 241, 237);
  cursor: pointer;
  transition: all 0.3s ease;
}

.area-option:last-child {
  margin-bottom: 0;
}

.area-option:hover {
  background-color: rgb(60, 60, 60);
  border-color: rgb(80, 80, 80);
}

.area-option.active {
  background-color: rgb(90, 85, 79);
  border-color: rgb(90, 85, 79);
  color: rgb(255, 255, 255);
}

.area-option span {
  font-size: 14px;
  font-weight: 500;
}

.timeline-options {
  padding: 0 20px;
}

.timeline-option {
  display: flex;
  align-items: center;
  padding: 14px 26px;
  color: rgb(242, 241, 237);
  border: 1px solid rgb(65, 65, 65);
  cursor: pointer;
  transition: background-color 0.2s ease;
  margin: 0 0 10px 0;
  box-sizing: border-box;
}

.timeline-option:hover {
  background-color: rgb(50, 50, 50);
}

.timeline-option.active {
  background-color: rgb(60, 60, 60);
}

.timeline-option span {
  font-size: 14px;
  font-weight: 500;
}

.timeline-option .setting-label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgb(242, 241, 237);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  padding: 4px 0;
  min-height: 44px;
}

.timeline-option .setting-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: rgb(249, 237, 219);
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.timeline-option:has(.setting-checkbox) {
  cursor: pointer;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.timeline-option:hover .setting-label {
  color: rgb(255, 255, 255);
}

.timeline-option:active {
  background-color: rgba(255, 255, 255, 0.05);
}

.postcode-section .mark-all-read-btn,
.postcode-section .save-settings-btn {
  width: 100%;
  padding: 12px 24px;
  border-radius: 2px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  background-color: rgb(249, 237, 219);
  color: rgb(29, 29, 29);
  font-weight: 500;
}

.postcode-section .mark-all-read-btn:hover,
.postcode-section .save-settings-btn:hover {
  background-color: rgb(255, 255, 255);
  box-shadow: 0 4px 12px rgba(249, 237, 219, 0.1);
}

.filter-options {
  padding: 0 20px;
}

.filter-option {
  display: flex;
  align-items: center;
  padding: 14px 26px;
  color: rgb(242, 241, 237);
  border: 1px solid rgb(65, 65, 65);
  cursor: pointer;
  transition: background-color 0.2s ease;
  margin: 0 0 10px 0;
  box-sizing: border-box;
}

.filter-option:hover {
  background-color: rgb(50, 50, 50);
}

.filter-option.active {
  background-color: rgb(60, 60, 60);
}

.filter-option span {
  font-size: 14px;
  font-weight: 500;
}

.dropdown-actions {
  padding: 20px 20px 0 20px;
  border-top: 1px solid rgb(65, 65, 65);
  margin-top: 20px;
}

.mark-all-read-btn,
.save-settings-btn {
  width: 100%;
  padding: 12px 24px;
  background-color: rgb(249, 237, 219);
  color: rgb(29, 29, 29);
  border: none;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.mark-all-read-btn:hover,
.save-settings-btn:hover {
  background-color: rgb(255, 255, 255);
  box-shadow: 0 4px 12px rgba(249, 237, 219, 0.1);
}

.settings-section {
  padding: 0 20px;
  margin-bottom: 20px;
}

.settings-section h4 {
  color: rgb(242, 241, 237);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px 0;
  padding: 0 6px;
}

.setting-item {
  padding: 10px 6px;
}

.setting-label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgb(242, 241, 237);
  font-size: 14px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  padding: 4px 0;
}

.setting-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: rgb(249, 237, 219);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.setting-label:hover {
  color: rgb(255, 255, 255);
}

.postcode-section {
  border-top: 1px solid rgb(65, 65, 65);
  padding-top: 20px;
  padding: 20px 20px 0 20px;
}

.postcode-input-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.postcode-input-group label {
  color: rgb(242, 241, 237);
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}

.postcode-input-group input {
  flex: 1;
  padding: 10px 12px;
  background-color: rgb(50, 50, 50);
  border: 1px solid rgb(65, 65, 65);
  border-radius: 2px;
  color: rgb(242, 241, 237);
  font-size: 13px;
  transition: all 0.3s ease;
}

.postcode-input-group input:focus {
  outline: none;
  border-color: rgb(249, 237, 219);
  box-shadow: 0 0 0 2px rgba(247, 63, 13, 0.1);
}

.postcode-input-group input::placeholder {
  color: rgb(120, 120, 120);
}

.apply-btn {
  padding: 10px 16px;
  background-color: rgb(249, 237, 219);
  color: rgb(29, 29, 29);
  border: none;
  border-radius: 2px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.apply-btn:hover {
  background-color: rgb(255, 255, 255);
  box-shadow: 0 2px 8px rgba(249, 237, 219, 0.3);
}

.apply-btn:active {
  transform: translateY(1px);
}

@media (max-width: 768px) {
  .ranking-section {
    padding: 0 15px;
  }

  .leaderboard {
    max-width: none;
    padding: 0 0px;
  }

  .leaderboard-header {
    padding: 10px;
  }

  .leaderboard-header h1 {
    font-size: 24px;
  }

  .leaderboard-header p {
    font-size: 14px;
  }

  .leaderboard-header .header-content {
    padding: 15px 0;
  }

  .leaderboard-controls {
    grid-template-columns: 1fr 1fr;
    gap: 0;
  }

  .control-item {
    padding: 18px;
    min-height: 70px;
  }

  .control-item:first-child {
    border-right: 1px solid rgb(65, 65, 65);
    border-left: none;
  }

  .control-item:last-child {
    border-right: none;
  }

  .ranking-item {
    padding: 12px;
  }

  .user-avatar {
    width: 40px;
    height: 40px;
    font-size: 0.8rem;
  }

  .user-details h3 {
    font-size: 0.9rem;
  }

  .user-details p {
    font-size: 0.75rem;
  }

  .ranking-number {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }

  .dropdown-menu {
    width: 100%;
    left: 0;
    right: 0;
  }

  #timeline-dropdown,
  #settings-dropdown {
    left: 0;
  }
}

@media (max-width: 480px) {
  .ranking-section {
    padding: 0 15px;
  }

  .leaderboard {
    padding: 0 0;
  }

  .leaderboard-header {
    padding: 10px;
  }

  .leaderboard-header h1 {
    font-size: 20px;
  }

  .leaderboard-header p {
    font-size: 12px;
  }

  .control-item {
    padding: 16px;
    padding-left: 32px;
    min-height: 60px;
    align-items: flex-start;
  }

  .ranking-item {
    padding: 12px;
  }

  .user-info {
    gap: 10px;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.75rem;
  }

  .user-details h3 {
    font-size: 0.85rem;
  }

  .user-details p {
    font-size: 0.7rem;
  }

  .ranking-number {
    width: 26px;
    height: 26px;
    font-size: 0.8rem;
  }

  .dropdown-menu {
    width: 100%;
    left: 0;
    right: 0;
  }

  #timeline-dropdown,
  #settings-dropdown {
    left: 0;
  }

  .dropdown-header {
    padding: 14px 16px;
  }

  .dropdown-header h3 {
    font-size: 14px;
  }

  .dropdown-body {
    padding: 16px;
  }

  .postcode-input-group {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .postcode-input-group label {
    align-self: flex-start;
  }

  .apply-btn {
    align-self: flex-end;
    padding: 10px 20px;
  }
}
