﻿/* Overlay to dim the background */
#popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5); /* Semi-transparent black */
    /* Above .hint-floating-button (30050) so dimmer covers full screen */
    z-index: 40000;
}

/* Popup container */
#end-game-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Center the popup */
    background: #ffffff00;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    /* Above overlay + floating hint */
    z-index: 40001;
    max-width: 500px;
    width: 90%;
    max-height: calc(100dvh - 28px);
    text-align: center;
}

/* Icon styling */
.popup-icon {
    width: 100px; /* Adjust as needed */
    height: auto;
    margin-bottom: 15px;
}

/* Content inside the popup */
/* === Restyled Popup Content === */
.popup-content {
  background: #000;
  border: 1px solid var(--theme-gold-base);
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(var(--theme-gold-rgb), 0.2);
  padding: 20px;
  color: var(--theme-gold-base);
  font-family: inherit;
  text-align: center;
}

#end-game-popup .popup-content {
  max-height: calc(100dvh - 68px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.popup-content h2 {
  margin: 0 0 10px;
  font-size: 26px;
  color: var(--theme-gold-base);
}

.popup-content h1 {
  margin: 10px 0;
  font-size: 32px;
  color: #fff;
  text-shadow: 0 0 4px rgba(255,255,255,0.2);
}

.popup-content p {
  font-size: 15px;
  color: #ccc;
  margin: 10px 0;
  line-height: 1.5;
}

.popup-content strong {
  color: var(--theme-gold-base);
}

.score-distribution-loading,
.score-distribution-empty {
  margin: 10px 0 14px;
  color: #a9a9a9;
  font-size: 14px;
}

.score-distribution {
  margin: 14px 0 18px;
  padding: 14px 14px 16px;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  position: relative;
}

.score-distribution-title {
  margin: 0;
  color: #e7e7e7;
  font-size: 28px;
  line-height: 1.1;
}

.score-distribution-subtitle {
  margin: 4px 0 0;
  color: #bababa;
  font-style: italic;
  font-size: 17px;
}

.score-distribution-meta {
  margin-top: 5px;
  color: #848484;
  font-size: 13px;
}

.score-distribution-toggle {
  margin-top: 12px;
  display: inline-flex;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.35);
  border-radius: 999px;
  overflow: hidden;
}

.score-distribution-view-btn {
  background: transparent;
  color: #c9c9c9;
  border: 0;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.score-distribution-view-btn.is-active {
  background: rgba(var(--theme-gold-rgb), 0.16);
  color: var(--theme-gold-soft);
}

.score-distribution-metrics {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.score-metric {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-metric .k {
  color: #a8a8a8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.score-metric .v {
  color: #f0f0f0;
  font-weight: 700;
  font-size: 17px;
}

.score-distribution-insight {
  margin: 10px 0 0;
  color: #9bd4d8;
  font-size: 13px;
}

.score-distribution-view-panel {
  display: none;
}

.score-distribution-view-panel.is-active {
  display: block;
}

.score-distribution-curve-chart {
  margin-top: 12px;
  height: 190px;
  width: 100%;
  border: 1px solid rgba(200, 200, 200, 0.2);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  position: relative;
  overflow: hidden;
}

.score-distribution-curve-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.curve-axis {
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 1;
}

.curve-area {
  fill: url(#curve-fill-gradient);
}

.curve-line {
  fill: none;
  stroke: #7dd6dd;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke-dashoffset 650ms ease-out;
}

.score-distribution-curve-marker {
  position: absolute;
  top: 10px;
  bottom: 22px;
  width: 0;
  border-left: 2px dashed rgba(255, 116, 96, 0.95);
  transform: translateX(-1px);
  pointer-events: none;
}

.score-distribution-curve-marker span {
  position: absolute;
  top: 4px;
  left: -15px;
  background: var(--theme-red-base);
  color: #fff;
  font-size: 10px;
  border-radius: 999px;
  padding: 2px 6px;
}

.score-distribution-hover-zones {
  position: absolute;
  inset: 0;
  z-index: 5;
}

.score-hover-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: crosshair;
}

.score-distribution-x-label {
  margin-top: 7px;
  color: #9f9f9f;
  font-size: 12px;
}

.score-distribution-axis-ticks {
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  color: #9bb3ba;
  font-size: 11px;
  opacity: 0.92;
}

.score-distribution-tooltip {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  background: rgba(33, 33, 33, 0.95);
  color: #f3f3f3;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  white-space: nowrap;
  z-index: 20;
}

.score-distribution-tooltip.visible {
  opacity: 1;
}

.score-distribution-reference-marker {
  position: absolute;
  top: 12px;
  bottom: 24px;
  width: 0;
  border-left: 1px solid rgba(160, 190, 210, 0.55);
  transform: translateX(-1px);
  pointer-events: none;
  z-index: 3;
}

.score-distribution-reference-marker span {
  position: absolute;
  top: -10px;
  left: -16px;
  font-size: 9px;
  color: #bdd4dc;
  background: rgba(0, 0, 0, 0.6);
  padding: 1px 4px;
  border-radius: 999px;
  white-space: nowrap;
}

.score-distribution-reference-marker.cutoff {
  border-left-color: rgba(var(--theme-gold-rgb), 0.7);
}

.score-distribution-reference-marker.cutoff span {
  color: var(--theme-gold-muted);
}

.score-percentile-track {
  margin-top: 12px;
  height: 70px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
}

.score-percentile-track .band {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: rgba(255, 255, 255, 0.92);
  font-size: 12px;
  line-height: 1.1;
}

.score-percentile-track .band small {
  font-size: 10px;
  opacity: 0.85;
}

.score-percentile-track .b1 { width: 40%; background: rgba(130, 85, 45, 0.72); }
.score-percentile-track .b2 { width: 30%; background: rgba(120, 120, 120, 0.72); }
.score-percentile-track .b3 { width: 20%; background: rgba(166, 139, 46, 0.72); }
.score-percentile-track .b4 { width: 10%; background: rgba(43, 156, 146, 0.72); }

.score-percentile-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 0;
  border-left: 3px solid #ff6347;
  box-shadow: 0 0 8px rgba(255, 99, 71, 0.5);
  transform: translateX(-1px);
}

.score-percentile-caption {
  margin-top: 8px;
  color: #d6d6d6;
  font-size: 12px;
}

.reward-totals {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.economy-level-track {
  margin-top: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.economy-level-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--theme-gold-base), #7dd6dd);
  transition: width 700ms ease-out;
}

.economy-level-caption {
  margin-top: 6px;
  color: #cfcfcf;
  font-size: 12px;
}

.economy-breakdowns {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  text-align: left;
}

.economy-breakdowns h4 {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--theme-gold-muted);
}

.economy-breakdowns ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.economy-breakdowns li {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #d5d5d5;
  margin: 3px 0;
}

.economy-breakdowns li.economy-no-gain {
  justify-content: flex-start;
  color: #9a9a9a;
}

@media (max-width: 640px) {
  .reward-totals,
  .economy-breakdowns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .score-distribution-metrics {
    grid-template-columns: 1fr;
  }
}

/* === Buttons container === */
.popup-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 25px;
}

.popup-buttons button {
  padding: 10px 18px;
  font-size: 16px;
  border: 1px solid var(--theme-gold-base);
  background-color: #1a1a1a;
  color: var(--theme-gold-base);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
    box-shadow: 0 0 8px rgba(var(--theme-gold-rgb), 0.1);
}

.popup-buttons button:hover {
  background-color: #2a2a2a;
    box-shadow: 0 0 12px rgba(var(--theme-gold-rgb), 0.3);
}



#player-name {
    padding: 5px;
    font-size: 16px;
    border: 1px solid var(--theme-gold-base);
    border-radius: 5px;
    background-color: #2c2c2c;
    color: #ffffff;
}

#save-name {
    padding: 5px 10px;
    background-color: var(--theme-red-base);
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-left: 10px;
}

#save-name:hover {
    background-color: var(--theme-red-deep);
}
#leaderboard {
  margin-top: 20px;
  text-align: center;
}

#leaderboard h2 {
  font-size: 22px;
  color: var(--theme-gold-base);
  margin-bottom: 10px;
}

#filter-display {
  color: var(--theme-gold-base);
  margin: 8px auto 12px auto;
  max-width: 920px;
}

.leaderboard-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.leaderboard-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--theme-gold-base);
  border-radius: 999px;
  background: rgba(26, 26, 26, 0.75);
  color: var(--theme-gold-base);
  font-size: 13px;
}

.leaderboard-filter-key {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--theme-gold-soft);
}

.leaderboard-filter-value {
  color: #ffffff;
}

.leaderboard-filter-chip-groups {
  border-radius: 14px;
  max-width: 100%;
}

.leaderboard-filter-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.leaderboard-filter-group-chip {
  background: rgba(var(--theme-red-deep-rgb), 0.65);
  border: 1px solid var(--theme-gold-base);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  color: #ffffff;
}

.leaderboard-score-note {
  color: #ffffff;
  font-style: normal;
  margin: 0;
}

.leaderboard-login-row {
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
}

.leaderboard-filter-buttons {
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

#leaderboard label {
  font-size: 16px;
  margin-right: 10px;
}

/* Default styles */
.table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  /* Enables scrolling on larger screens if needed */
  box-sizing: border-box;
  margin: 0 auto;
  max-height: 50VH;
  overflow-y: auto;
  --leaderboard-header-offset: 44px;
}

#leaderboard .table-wrapper::-webkit-scrollbar {
  width: 8px;
}

#leaderboard .table-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

#leaderboard table {
  width: 100%;
  max-width: 80%;
  margin: 0 auto;
  background-color: #2c2c2c;
  border: 1px solid var(--theme-gold-base);
  border-collapse: collapse;
}

#leaderboard th,
#leaderboard td {
  padding: 10px;
  border: none;
  font-size: 16px;
    white-space: normal;
      /* Allow text to wrap to a new line */
      word-wrap: break-word;
      /* Legacy support for older browsers */
      overflow-wrap: break-word;
      /* Standard property for breaking long words */
}

#leaderboard th {
  background-color: var(--theme-red-deep);
  color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 3;
}

#leaderboard td {
  color: #ffffff;
}

.leaderboard-loading-row td {
  padding: 8px 10px;
}

.leaderboard-loading-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leaderboard-loading-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
}

.leaderboard-loading-track {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.35);
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.leaderboard-loading-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(var(--theme-gold-rgb), 0.82), rgba(var(--theme-red-rgb), 0.9));
  box-shadow: 0 0 10px rgba(var(--theme-gold-rgb), 0.32);
  transition: width 0.14s linear;
}

#leaderboard tbody tr.leaderboard-self-row td {
  position: sticky;
  top: var(--leaderboard-header-offset);
  z-index: 2;
}

/* Media query for small screens */
@media (max-width: 768px) {
  .leaderboard-filters {
    justify-content: flex-start;
  }

  .leaderboard-filter-chip {
    font-size: 12px;
    padding: 6px 8px;
  }

  .leaderboard-filter-chip-groups {
    width: 100%;
    justify-content: flex-start;
    border-radius: 10px;
  }

  .leaderboard-score-note {
    font-size: 13px;
  }

  .table-wrapper {
    overflow-x: hidden;
    /* Disable horizontal scrolling */
  }

  #leaderboard table {
    width: 100%;
    /* Use full available width */
    max-width: none;
    /* Remove the 80% limitation */
    table-layout: fixed;
    /* Evenly distributes columns */
    font-size: 10px;
    /* Optional: reduce font size for better fit */
    margin: 0;
    /* Align table with the container edge */
  }

  #leaderboard th,
  #leaderboard td {
    padding: 3px;
    /* Reduce padding for a more compact layout */
  }

  /* Keep names readable on small screens (no per-letter wrapping). */
  #leaderboard th:nth-child(2),
  #leaderboard td:nth-child(2) {
    width: 40%;
    max-width: 0;
    overflow-wrap: normal;
    word-wrap: normal;
    word-break: normal;
  }

  .leaderboard-name-cell {
    gap: 6px;
    min-width: 0;
  }

  .leaderboard-name-text {
    min-width: 0;
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .leaderboard-name-text a,
  .leaderboard-name-text span {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: normal;
    word-break: normal;
  }
}
#options-container {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 20px 0;
  box-sizing: border-box;
    max-width: 100%;
}

#ethnos-column, #difficulty-column, #more-options-column {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#ethnos-column h2, #difficulty-column h2, #more-options-column h2 {
  font-size: 20px;
  color: var(--theme-gold-base);
  margin-bottom: 10px;
}

@media (max-width: 768px) {
  #options-container {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 0 10px;
  }

  #ethnos-column,
  #difficulty-column,
  #more-options-column {
    width: 100%;
    max-width: 400px;
    padding: 0 5px;
    box-sizing: border-box;
  }

  .difficulty-btn-wrapper {
    width: 100%;
  }

  #racial-group-selector, #continent-selector {
    width: 100%;
  }

  /* Stack mode buttons vertically on mobile */
  .mode-toggle {
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    width: 100%;
    max-width: 100%;
  }

  .mode-toggle label {
    font-size: 16px;
    padding: 10px 14px;
    width: 100%;
    justify-content: center;
  }

  .mode-toggle span {
    padding: 10px 14px;
    width: 100%;
    text-align: center;
  }

  .mode-toggle input[type="radio"]:checked + span {
    padding: 10px 14px;
  }

  /* Keep columns side-by-side on mobile, but smaller */
  .ethnos-content-wrapper {
    gap: 10px;
    max-width: 100%;
  }

  .checkboxes-column {
    flex: 1;
  }

  .settings-info-panel {
    flex: 1;
    padding: 8px;
    font-size: 11px;
  }

  .info-line {
    font-size: 11px;
    margin: 4px 0;
    line-height: 1.3;
  }

  .info-line strong {
    display: block;
    margin-bottom: 2px;
  }

  .info-line span {
    display: block;
  }

  .tooltip {
    max-width: 90vw;
    font-size: 12px;
  }

  /* Adjust difficulty panel for mobile */
  #difficulty-buttons {
    width: 100%;
    max-width: 300px;
  }

  .difficulty-info-panel {
    width: 100%;
    max-width: 300px;
    padding: 10px;
    font-size: 12px;
    min-height: 70px;
    max-height: 70px;
  }
}

@media (max-width: 480px) {
  #leaderboard table {
    font-size: 14px;
  }

  #leaderboard th,
  #leaderboard td {
    padding: 8px;
  }

  /* Keep vertical stack, adjust sizing for smaller screens */
  .mode-toggle {
    gap: 6px;
    padding: 6px;
  }

  .mode-toggle label {
    font-size: 15px;
    padding: 9px 12px;
  }

  .mode-toggle span {
    padding: 9px 12px;
  }

  .mode-toggle input[type="radio"]:checked + span {
    padding: 9px 12px;
  }

  /* Even more compact on very small screens, but keep side-by-side */
  .ethnos-content-wrapper {
    gap: 8px;
  }

  .settings-info-panel {
    padding: 6px;
  }

  .info-line {
    font-size: 10px;
    margin: 3px 0;
    line-height: 1.25;
  }

  .info-line strong {
    font-size: 10px;
  }

  .tooltip {
    max-width: 95vw;
    font-size: 11px;
    padding: 6px 10px;
  }

  /* Even more compact difficulty panel on very small screens */
  #difficulty-buttons {
    width: 100%;
    max-width: 250px;
  }

  .difficulty-info-panel {
    width: 100%;
    max-width: 250px;
    padding: 8px;
    font-size: 11px;
    line-height: 1.3;
    min-height: 60px;
    max-height: 60px;
  }
}

#login-twitter, #open-leaderboard-filters {
  padding: 10px 20px;
  background-color: #1a1a1a;

  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s ease;
}

#login-twitter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 118px;
  min-width: 118px;
  height: 44px;
  white-space: nowrap;
  max-width: 118px;
  text-align: center;
  line-height: 1.25;
  padding: 10px 12px;
}

#login-twitter.connected {
  border: 2px solid var(--theme-gold-base);
  background-color: black;
  color: var(--theme-gold-base);
  box-shadow: 0 0 10px var(--theme-gold-base), 0 0 20px var(--theme-gold-base) inset;
  animation: pulse-gold 1.2s infinite ease-in-out;
  transform: scale(1.05);
  cursor: default;
}

#open-leaderboard-filters:hover {
  border: 2px solid var(--theme-gold-base);
  background-color: black;
  color: var(--theme-gold-base);
  box-shadow: 0 0 10px var(--theme-gold-base), 0 0 20px var(--theme-gold-base) inset;
  transform: scale(1.02);
}
.twitter-name {
  color: #a84a4a;
  font-weight: bold;
}

.leaderboard-name-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.leaderboard-name-text {
  min-width: 0;
}

.leaderboard-name-level {
  margin-left: auto;
  white-space: nowrap;
  font-weight: 700;
  color: var(--theme-gold-base);
}

.moderated-term {
  color: var(--theme-red-base) !important;
  font-weight: 700;
}

.twitter-name:hover {
  color: #c15b5b;
  text-decoration: underline;
}
#open-leaderboard-filters {
  min-width: 136px;
}

.leaderboard-filters-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 10025;
  overflow-y: auto;
}

.leaderboard-filters-modal.hidden {
  display: none;
}

.leaderboard-filters-modal-panel {
  width: min(700px, 100%);
  max-height: min(92vh, 860px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.45);
  background: linear-gradient(165deg, rgba(16, 16, 20, 0.98), rgba(24, 24, 28, 0.96));
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  color: #fff;
  margin: auto;
}

.leaderboard-filters-modal-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 4px 12px;
  border-bottom: none;
  background: transparent;
}

.leaderboard-filters-modal-header h3 {
  margin: 0;
  color: var(--theme-gold-base);
}

.leaderboard-filters-modal-body {
  padding: 12px 14px 10px 14px;
  display: grid;
  gap: 10px;
  justify-items: center;
  overflow-y: auto;
  overflow-x: hidden;
}

.leaderboard-filters-section {
  width: 100%;
  border: none;
  border-radius: 0;
  padding: 6px 2px;
  background: transparent;
  text-align: center;
}

.leaderboard-filters-section.hidden {
  display: none;
}

.leaderboard-filters-section h4 {
  margin: 0 0 6px 0;
  color: var(--theme-gold-soft);
  text-align: center;
}

.lb-filter-reversed-row {
  margin-top: 10px;
  justify-content: center !important;
}

.lb-filter-reversed-hint {
  opacity: 0.72;
  font-size: 0.82em;
  font-weight: normal;
}

.leaderboard-filters-section > label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  margin: 3px auto;
  max-width: 320px;
  width: 100%;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.leaderboard-filters-section > label:hover {
  background: rgba(var(--theme-red-deep-rgb), 0.14);
}

.leaderboard-filter-grid label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 2px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.leaderboard-filter-grid label:hover {
  background: rgba(var(--theme-red-deep-rgb), 0.12);
}

.leaderboard-filters-section input[type="checkbox"],
.leaderboard-filters-section input[type="radio"] {
  accent-color: var(--theme-red-base);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.leaderboard-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 5px 8px;
  align-items: center;
  justify-items: stretch;
}

.leaderboard-filters-scope {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.leaderboard-filters-scope > label.lb-toggle {
  margin: 0;
  width: auto;
  max-width: none;
  padding: 0;
  background: transparent;
}

.leaderboard-filters-scope > label:not(.lb-toggle) {
  margin: 0;
  width: min(240px, 100%);
  max-width: 100%;
  padding: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.leaderboard-filters-scope select {
  max-width: 100%;
}

#lb-filter-playlist {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--theme-gold-base);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(22, 24, 28, 0.96) 0%, rgba(13, 15, 18, 0.98) 100%);
  background-color: #14171c;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.1;
  padding: 8px 42px 8px 12px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.86) 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.86) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 0 0 1px rgba(0, 0, 0, 0.22) inset,
    0 2px 8px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: filter 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

#lb-filter-playlist:hover {
  filter: brightness(1.07) saturate(1.04);
  border-color: rgba(var(--theme-gold-rgb), 0.8);
}

#lb-filter-playlist:focus-visible {
  outline: 2px solid rgba(var(--theme-gold-rgb), 0.96);
  outline-offset: 1px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 0 0 1px rgba(var(--theme-gold-rgb), 0.35),
    0 0 14px rgba(var(--theme-gold-rgb), 0.24);
}

#lb-filter-playlist option {
  background: #5a211f;
  color: #fff;
}

#lb-filter-playlist option:checked {
  background: var(--theme-red-hover);
  color: #fff;
}

.leaderboard-filters-scope .lb-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.leaderboard-filters-scope .lb-toggle input[type="checkbox"]::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.leaderboard-filters-scope .lb-toggle input[type="checkbox"]:checked {
  background: var(--theme-red-base);
}

.leaderboard-filters-scope .lb-toggle input[type="checkbox"]:checked::before {
  transform: translateX(18px);
}

.lb-difficulty-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.lb-difficulty-grid label {
  white-space: nowrap;
  font-size: 16px;
}

.lb-mode-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.leaderboard-filters-split {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  align-items: start;
}

.leaderboard-groups-stack {
  display: grid;
  gap: 8px;
}

.lb-options-vertical {
  text-align: left;
}

.lb-options-vertical h4 {
  text-align: left;
}

.lb-options-vertical > label {
  margin: 0 0 6px 0;
  justify-content: flex-start;
  max-width: none;
}

.lb-disabled-by-daily {
  opacity: 0.45;
}

@media (max-width: 760px) {
  .leaderboard-filters-modal {
    padding: 10px;
    align-items: flex-start;
  }

  .leaderboard-filters-modal-panel {
    max-height: calc(100vh - 20px);
  }

  .lb-difficulty-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .leaderboard-filters-split {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .lb-options-vertical,
  .lb-options-vertical h4 {
    text-align: center;
  }

  .lb-options-vertical > label {
    margin: 0 auto 6px auto;
    justify-content: center;
  }

  .leaderboard-filters-scope {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 10px;
  }

  .leaderboard-filters-scope > label {
    width: 100%;
    max-width: none;
    margin: 0;
  }
}

@media (max-width: 520px) {
  .lb-difficulty-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lb-mode-grid {
    grid-template-columns: 1fr;
  }

  .lb-difficulty-grid label,
  .lb-mode-grid label {
    white-space: normal;
    line-height: 1.2;
  }
}

#difficulty-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 200px;
}

.difficulty-info-panel {
  margin-top: 15px;
  padding: 12px;
  background: linear-gradient(145deg, #2c2c2c, #1a1a1a);
  border: 2px solid var(--theme-gold-base);
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(var(--theme-gold-rgb), 0.2);
  box-sizing: border-box;
  color: #cccccc;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  width: 200px;
  min-height: 80px;
  max-height: 80px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Hide scrollbar for difficulty info panel */
.difficulty-info-panel::-webkit-scrollbar {
  width: 0;
  display: none;
}

.difficulty-info-panel {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.difficulty-btn {
  padding: 10px 20px;
  background-color: var(--theme-red-deep); /* Match Play Custom Game button */
  color: #ffffff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  width: 100%; /* Makes buttons fill the container */
  box-sizing: border-box; /* Keeps padding inside the width */
  transition: background-color 0.3s ease;
  position: relative;
  padding-right: 86px;
}

.difficulty-btn .lock-chip {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 0;
  z-index: 1;
  pointer-events: none;
}

.difficulty-btn.locked {
  background-color: #555;
  cursor: not-allowed;
}

.difficulty-btn.selected {
  border: 2px solid var(--theme-gold-base);
  background-color: black;
  color: var(--theme-gold-base);
  box-shadow: 0 0 10px var(--theme-gold-base), 0 0 20px var(--theme-gold-base) inset;
  animation: pulse-gold 1.2s infinite ease-in-out;
  transform: scale(1.05);
}

.unlock-all-mode-wrapper {
  margin-top: 6px;
}

.unlock-all-mode-btn {
  background: linear-gradient(145deg, #f7cf62, #d09a1c);
  color: #111111;
  font-weight: 700;
  border: 1px solid rgba(0, 0, 0, 0.45);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.2s ease, transform 0.2s ease, filter 0.2s ease;
}

.unlock-all-mode-btn:hover {
  box-shadow:
    0 0 14px rgba(var(--theme-gold-rgb), 0.85),
    0 0 24px rgba(var(--theme-gold-rgb), 0.5);
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.unlock-all-mode-btn.is-active {
  background: linear-gradient(145deg, #818181, #585858);
  color: #e8e8e8;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
}

.unlock-all-mode-tooltip {
  width: min(280px, 84vw);
}

.custom-game-wizard-unlock-all-wrap {
  margin-top: 8px;
}

.custom-game-wizard-unlock-all-btn {
  background: linear-gradient(145deg, #f7cf62, #d09a1c);
  color: #111111;
  font-weight: 700;
  font-family: var(--home-display-font);
  border: 1px solid rgba(0, 0, 0, 0.45);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.custom-game-wizard-unlock-all-btn:hover {
  box-shadow:
    0 0 14px rgba(var(--theme-gold-rgb), 0.85),
    0 0 24px rgba(var(--theme-gold-rgb), 0.5);
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.custom-game-wizard-unlock-all-btn.is-active {
  background: linear-gradient(145deg, #818181, #585858);
  color: #e8e8e8;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
}

@keyframes pulse-gold {
  0% {
    box-shadow: 0 0 5px var(--theme-gold-base), 0 0 10px var(--theme-gold-base) inset;
  }
  50% {
    box-shadow: 0 0 15px var(--theme-gold-accent-bright), 0 0 25px var(--theme-gold-accent-bright) inset;
  }
  100% {
    box-shadow: 0 0 5px var(--theme-gold-base), 0 0 10px var(--theme-gold-base) inset;
  }
}

@keyframes pulse-white {
  0% {
    box-shadow: 0 0 5px rgb(208, 208, 208), 0 0 10px rgb(208, 208, 208) inset;
  }
  50% {
    box-shadow: 0 0 15px white, 0 0 25px white inset;
  }
  100% {
    box-shadow: 0 0 5px rgb(208, 208, 208), 0 0 10px rgb(208, 208, 208) inset;
  }
}

#racial-group-selector, #continent-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

#racial-group-selector label, #continent-selector label {
  display: flex;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  gap: 5px;
  cursor: pointer;
  color: var(--theme-gold-base);
  font-size: 16px;
}

#racial-group-selector input[type="checkbox"], #continent-selector input[type="checkbox"], #no-timer-toggle, #disallow-hints-toggle {
  accent-color: var(--theme-red-base);
  width: 16px;
  height: 16px;
}

/* Align timer and hints checkboxes */
.checkboxes-column > .difficulty-btn-wrapper {
  width: 100%;
}

.checkboxes-column > .difficulty-btn-wrapper > label {
  display: flex;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  gap: 5px;
  cursor: pointer;
  color: var(--theme-gold-base);
  font-size: 16px;
}

.checkboxes-column > .difficulty-btn-wrapper input[type="checkbox"] {
  order: 2;
  margin-left: auto;
  accent-color: var(--theme-red-base);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.checkboxes-column > .difficulty-btn-wrapper.option-lock-row {
  white-space: nowrap;
}

.checkboxes-column > .difficulty-btn-wrapper.option-lock-row > label .lock-chip {
  order: 3;
  margin-left: 8px;
  pointer-events: none;
}

/* Tooltip Styles */
.tooltip {
  position: absolute;
  background-color: #1a1a1a;
  color: var(--theme-gold-base);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  white-space: normal;
  word-break: break-word;
  max-width: 80vw;
  z-index: 100;
  opacity: 0;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  margin-bottom: 10px;
}

.difficulty-btn-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
  box-sizing: border-box;
}


.difficulty-btn-wrapper:hover .tooltip,
.difficulty-btn-wrapper.show-tooltip .tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.unlocked-animate {
  animation: unlockPulse 0.6s ease-out;
}

@keyframes unlockPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

#compatibility-warning {
  font-size: 14px;
  margin-top: 10px;
  color: #ccc;
  text-align: center;
  padding: 5px 15px;
}

/* Toggle How-To Button */
.toggle-how-to-btn {
  width: auto;
  max-width: none;
  min-height: 44px;
  padding: 12px 20px;
  background-color: #1a1a1a;
  color: var(--theme-gold-base);
  border: 2px solid var(--theme-gold-base);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s ease;
}

.toggle-how-to-btn:hover {
  background-color: #2a2a2a;
  transform: scale(1.02);
  box-shadow: 0 0 15px rgba(var(--theme-gold-rgb), 0.3);
}

#toggle-icon {
  font-size: 16px;
  transition: transform 0.3s ease;
}

/* How-To Sections Container */
.how-to-sections-container {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease-out, opacity 0.3s ease;
  opacity: 0;
}

.how-to-sections-container.open {
  max-height: 2000px;
  opacity: 1;
  transition: max-height 0.5s ease-in, opacity 0.3s ease;
}

.how-to-section {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 20px;
  margin: 15px auto;
  max-width: 900px; /* Ensures consistent total width */
  width: 100%;
}

.how-to-play {
  flex: 1;
  background: linear-gradient(145deg, #2c2c2c, #1a1a1a);
  border: 1px solid var(--theme-gold-base);
  border-radius: 12px;
  padding: 5px 8px;
  color: #fff;
  font-size: 15px;
  text-align: left;
  line-height: 1.5;
}
.double-line {
  width: 75%;
  height: 5px; /* thin line height */
  border-top: 2px solid #eec266;
  border-bottom: 4px solid var(--theme-gold-base);
  margin: 1.5em 0 2em 0; /* spacing above and below */
}


.disclaimer {
  flex: 1;
  background: linear-gradient(145deg, #2c2c2c, #1a1a1a);
  border: 0px solid var(--theme-gold-base);
  border-radius: 12px;
  padding: 15px;
  color: var(--theme-gold-base);
  font-size: 12px;
  line-height: 1.5;
  font-style: italic;


  /* Centering styles */
  display: flex;
  flex-direction: column;
  justify-content: center;  /* vertical centering */
  align-items: center;      /* horizontal centering */
  text-align: center;       /* text center */
}


.showcase-icon {
  flex-shrink: 0;
  width: 300px;
  height: auto;
  border-radius: 8px;
}

@media (max-width: 768px) {
  .how-to-section {
    flex-direction: column;
    align-items: center;
  }

  #contribute-message {
    width: 90%;
  }

  .showcase-icon {
    width: 90%;
    max-width: 300px;
  }

  .how-to-play {
    width: 90%;
    max-width: none;
    text-align: center;
  }
}

#how-to-play h3 {
  color: var(--theme-gold-base);
  margin-bottom: 8px;
  text-align: center;
}

.result-wrapper {
    max-width: 1400px;
    margin: auto;
    padding: 20px;
    font-family: sans-serif;
    width: 95%;
}

.phenotype-title {
    text-align: center;
    font-size: 28px;
    margin-bottom: 20px;
}

.result-columns {
    display: flex;
    gap: 20px;
    flex-wrap: nowrap;
    flex: 1;
    height: 100%;
    width: 100%;
    min-height: 0;
}

.right-column {
    flex: 1 1 50%;
    min-width: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.full-info {
    background-color: #f5f5f5;
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    text-align: justify;
    font-family: 'Poopins', sans-serif; /* You can change this to another ethnographic-feeling font */
    line-height: 1.6;
    white-space: normal;
    max-width: 100%;
    overflow-wrap: break-word;
    box-sizing: border-box;
    flex: 1;
    overflow-y: auto;
}

/* Hide empty full-info and right column when there's no content (countries mode) */
.full-info:empty {
    display: none;
}

.right-column:has(.full-info:empty) {
    display: none;
}

/* When right column is hidden, left column takes full width */
.result-columns:has(.right-column .full-info:empty) .left-column {
    flex: 1 1 100%;
    max-width: 100%;
}

@media (max-width: 768px) {
  .right-column {
    margin-bottom: 20px;
    max-height: none;
    overflow-y: visible;
  }
}

.left-column {
    flex: 1 1 50%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
}

/* When left-column is the only child, take full width (countries mode) */
.result-columns .left-column:only-child {
    flex: 1 1 100%;
    max-width: 100%;
}

.result-stat {
    background: var(--theme-red-base);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 4px;
    width: 80%;
    max-width: 100%;
    text-align: center;
    font-size: 12px;
    box-sizing: border-box;
}

.image-row {
    display: flex;
    justify-content: center;
    gap: 0px;
    margin-top: 0px;
}

.result-image {
    max-height: 120px; /* Each image up to 150px, total 300px to match face container */
    width: auto;
    display: block;
    margin: 0 auto;
}

.map-image {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 6px;
    margin-top: 10px;
}

.cache-clear-container {
  display: flex;
  justify-content: flex-end;
  margin-top: 2em;
}

.cache-clear-btn {
  padding: 0.5em 1em;
  background-color: black;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.3s;
}

.cache-clear-btn:hover {
  background-color: var(--theme-red-deep);
}

.mode-toggle {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  background: #000;
  border: 1px solid var(--theme-gold-base);
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(var(--theme-gold-rgb), 0.2);
  width: 100%;
  max-width: 600px;
  box-sizing: border-box;
  flex-wrap: wrap;
}

.mode-toggle label {
  color: var(--theme-gold-base);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  transition: all 0.2s ease-in-out;
  background-color: #1a1a1a;
  border: 1px solid transparent;
  box-sizing: border-box;
}

.mode-toggle input[type="radio"] {
  display: none;
}

.mode-toggle input[type="radio"]:checked + span {
  background-color: #000000;
  color: var(--theme-gold-base);
  border: 2px solid var(--theme-gold-base);
  box-shadow: 0 0 10px var(--theme-gold-base), 0 0 20px var(--theme-gold-base) inset;
  animation: pulse-gold 1.2s infinite ease-in-out;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
}

.mode-toggle input[type="radio"][value="reversed"]:checked + span {
  background: #f3f3f3;
  color: #1d1d1d;
  border-color: #f3f3f3;
}

