@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");

* {
  box-sizing: border-box;
  font-family: "Poppins", sans-serif !important;
}

#leaderboard-modal-wrapper * {
  box-sizing: border-box;
}

#leaderboard-modal-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999999;
  overflow: hidden;

  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Ensure spinner/loader appears above the modal when modal is open */
body.leaderboard-modal-open #load_screen,
body.leaderboard-modal-open .loader,
body.leaderboard-modal-open .spinner,
body.leaderboard-modal-open .loading-overlay,
body.leaderboard-modal-open .loader_wrapper,
body.leaderboard-modal-open .loaders {
  z-index: 1000000 !important;
}

/* Modal Layout Container */
#leaderboard-modal-wrapper .dg-popup-layout-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: transparent; /* Override any previous background */
  backdrop-filter: none;
}

#leaderboard-modal-wrapper .dg-popup-container {
  pointer-events: auto;
  position: relative;
  width: 100%;
  max-width: 900px;
  /* Fixed height relative to screen to force internal scroll */
  height: 85vh;
  max-height: 900px;
  background-color: #05220f;
  /* Fallback background */
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  /* Clip everything outside this box */
  margin: 0 auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid #dcaf37;
  z-index: 4;
}

#leaderboard-modal-wrapper .rating-heading-section {
  flex: 0 0 auto;

  width: 100%;
  height: auto;
  position: relative;
  z-index: 10;
  background-color: #062d1a;
  padding: 30px 30px 30px 40px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.tournament-banner {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.tournament-banner img {
  border-top-right-radius: 12px;
  width: inherit;
  border-top-left-radius: 12px;
  height: 100%;
  object-fit: cover;
}

.live-master {
  width: fit-content;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.live-master h2 {
  color: white;
  font-size: 24px;
  font-weight: 600;
  margin: 0;
}

.price-pool p {
  color: #8b8b8b;
}

.price-pool h1 {
  color: #ddb037;
}

.price-pool p,
.price-pool h1 {
  margin: 0;
}

.price-pool {
  margin-top: 8px;
}

.close-btn {
  cursor: pointer;
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 1000;
  width: 30px;
  height: 30px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-weight: bold;
  transition: background 0.2s;
}

.close-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.rating-info {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}

.rating-info-card {
  /* background-color: rgba(128, 255, 179, 0.25); */
  background-color: rgba(100,100,100,0.7);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rating-info-card h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.card-details {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-details p {
  margin: 0;
}

/* Bottom Section - Contains Tabs and Scrollable Content */
#leaderboard-modal-wrapper .rating-bottom-section {
  flex: 1;
  /* Take remaining height */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Prevent this container from scrolling, let children scroll */
  position: relative;
  background-color: #062d1a;
  width: 100%;
}

/* Tabs - Fixed at Top of Bottom Section */
#leaderboard-modal-wrapper .tab-bg {
  flex: 0 0 auto;
  width: 100%;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-direction: column;
  margin-top: 8px;
}

#leaderboard-modal-wrapper .tabs-section {
  background: rgba(0, 0, 0, 0.38);
  display: flex;
  width: 100%;
  justify-content: center;
  gap: 20px;
  width: fit-content;
  padding: 8px;
  border-radius: 8px;
}

#leaderboard-modal-wrapper .tabs {
  text-align: center;
  padding: 8px 60px;
  width: auto;
  background: rgba(42, 84, 61, 1);
  border-radius: 4px;
  cursor: pointer;
  color: rgba(204, 206, 204, 1);
  height: fit-content;
}

#leaderboard-modal-wrapper .tabs:hover {
  background-color: #1d3b2b;
}

#leaderboard-modal-wrapper .tabs.active {
  color: #052311;
  font-weight: 600;
  border-radius: 8px;
  background: linear-gradient(
    108.06deg,
    #b38d3e 0%,
    #ffd77b 22.79%,
    #e5bc68 41.4%,
    #ffea93 58.6%,
    #d2a74b 77.21%,
    #a27a2c 100%
  );
}

#leaderboard-modal-wrapper .tabs h2 {
  margin: 0;
  font-size: 16px;
  white-space: nowrap;
  font-weight: 500;
}

.tabs.active h2 {
  color: #052311;
}

/* Scrollable Content Area */
#leaderboard-modal-wrapper .tab-content {
  display: none;
  padding-top: 10px;
  -webkit-overflow-scrolling: touch;
  overflow-y: auto; /* Enable scroll for all tabs */
  overflow-x: hidden;
}

#leaderboard-modal-wrapper .tab-content.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

#leaderboard-modal-wrapper .tab-content.active .leaderboard,
#leaderboard-modal-wrapper .tab-content.active .dg-terms,
#leaderboard-modal-wrapper .tab-content.active .dg-grid-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/*  Scrollbar for Modal Content */
#leaderboard-modal-wrapper .tab-content::-webkit-scrollbar,
#leaderboard-modal-wrapper .tab-content .leaderboard::-webkit-scrollbar,
#leaderboard-modal-wrapper .tab-content .dg-terms::-webkit-scrollbar,
#leaderboard-modal-wrapper .tab-content .dg-grid-wrapper::-webkit-scrollbar {
  width: 6px;
}

#leaderboard-modal-wrapper .tab-content::-webkit-scrollbar-track,
#leaderboard-modal-wrapper .tab-content .leaderboard::-webkit-scrollbar-track,
#leaderboard-modal-wrapper .tab-content .dg-terms::-webkit-scrollbar-track,
#leaderboard-modal-wrapper
  .tab-content
  .dg-grid-wrapper::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

#leaderboard-modal-wrapper .tab-content::-webkit-scrollbar-thumb,
#leaderboard-modal-wrapper .tab-content .leaderboard::-webkit-scrollbar-thumb,
#leaderboard-modal-wrapper .tab-content .dg-terms::-webkit-scrollbar-thumb,
#leaderboard-modal-wrapper
  .tab-content
  .dg-grid-wrapper::-webkit-scrollbar-thumb {
  background: rgba(246, 196, 74, 0.5);
  border-radius: 3px;
}

/* Leaderboard Table Styles */
.leaderboard-points,
.leaderboard-prize {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-weight: 600;
}

.leaderboard {
  margin: 0 16px 0 16px;
  height: auto;
}

.empty-rating-message {
  text-align: center;
  padding: 60px 20px;
  color: rgba(255, 255, 255, 0.7);
}

.empty-rating-message p {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
}

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

.leaderboard-id p {
  margin-right: 20px;
}

.table-column-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  padding: 0px 26px 0 0;
  margin: 8px 16px;
}

.table-column-name p {
  margin: 0;
}

.columns-name-points {
  padding-right: 36px;
}

.columns-name-participants {
  padding-left: 24px;
}

.player-points,
.player-prize {
  display: flex;
  align-items: center;
  justify-content: flex-end; /* Align content to the right */
  gap: 4px;
}

.player-points p,
.player-prize p {
  text-align: right; /* Ensure text is right-aligned */
  white-space: nowrap; /* Prevent wrapping */
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.row-gold {
  display: flex;
  justify-content: space-between;
  background: linear-gradient(
    96.23deg,
    rgba(229, 188, 104, 0.71) 1.16%,
    rgba(12, 10, 10, 0) 98.84%
  );
  border: 1px solid #dcaf37;
  padding: 8px 16px;
  border-radius: 10px;
  color: white;
  margin-bottom: 10px;
  align-items: center;
}

.row-silver {
  display: flex;
  justify-content: space-between;
  background: linear-gradient(
    96.23deg,
    rgba(135, 143, 137, 0.71) 1.16%,
    rgba(12, 10, 10, 0) 98.84%
  );
  border: 1px solid #dcaf37;
  padding: 8px 16px;
  border-radius: 10px;
  color: white;
  margin-bottom: 10px;
  align-items: center;
}

.row-bronze {
  display: flex;
  justify-content: space-between;
  background: linear-gradient(
    96.23deg,
    rgba(156, 117, 113, 0.71) 1.16%,
    rgba(12, 10, 10, 0) 98.84%
  );
  border: 1px solid #dcaf37;
  padding: 8px 16px;
  border-radius: 10px;
  color: white;
  margin-bottom: 10px;
  align-items: center;
}

.row-player {
  display: flex;
  justify-content: space-between;
  background-color: #06180a;
  border: 1px solid #dcaf37;
  padding: 12px 16px 12px 28px;
  border-radius: 10px;
  color: white;
  margin-bottom: 10px;
  align-items: center;
}

.table-column-prize {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.prize-tooltip-container {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.prize-question-icon {
  display: block;
}

.prize-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: #1a1a2e;
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 280px;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 10000;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.prize-tooltip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  right: 8px;
  border: 6px solid transparent;
  border-bottom-color: #1a1a2e;
}

.prize-tooltip-container:hover .prize-tooltip {
  opacity: 1;
  visibility: visible;
}

.prize-tooltip img {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.prize-tooltip p {
  color: #ffffff !important;
  font-size: 14px;
  line-height: 1.5;
  margin: 0 !important;
  font-weight: 400;
}

.column-name {
  width: 25%;
}

.player-rank {
  display: flex;
  align-items: center;
}

.row .rank {
  width: 30px;
  font-weight: bold;
}

.my-rank-btn-section {
  margin: 16px;
  align-items: center;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  position: relative;
  z-index: 10;
  order: 999;
}

.my-rank-btn {
  background-color: #dcaf37;
  padding: 10px 106px;
  color: #06180a;
  border: none;
  border-radius: 40px;
  z-index: 3;
}

.my-rank-btn:hover {
  background-color: #a27a2c;
  cursor: pointer;
}

.bottom-fade {
  width: 100%;
  background: linear-gradient(180deg, rgba(24, 19, 19, 0) 0%, #06180a 54.9%);
  height: 120px;
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 2;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
  pointer-events: none;
}

.my-rank-btn h2 {
  margin: 0;
  font-size: 14px;
}

/* User rank highlight animation */
.user-rank-highlight {
  animation: rankFlash 0.6s ease-in-out 3;
  box-shadow: 0 0 20px rgba(220, 175, 55, 0.8) !important;
}

@keyframes rankFlash {
  0%, 100% {
    background-color: inherit;
    border-color: #dcaf37;
  }
  50% {
    background-color: rgba(220, 175, 55, 0.2);
    border-color: #ffd77b;
  }
}

/* Terms */
.dg-terms {
  background-color: #0f532a;
  border-radius: 16px;
  margin: 0 16px;
}

/* Ensure Terms scrolls when inside active tab */
#leaderboard-modal-wrapper .tab-content.active .dg-terms {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.terms-info {
  padding: 16px;
  display: flex;
  flex-direction: column;
  color: white;
  border-bottom: 1px solid rgb(255, 255, 255, 0.4);
  gap: 4px;
}

.terms-info h2 {
  margin: 0;
  font-size: 14px;
}

.terms-info p {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
}

/* Games Grid */
.dg-grid-container {
  height: auto;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 81px;
  gap: 8px;
  margin: 0 16px;
}

.cell {
  background: #d9d9d9;
  border-radius: 6px;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Game hover effect - using gameImageBox structure */
#leaderboard-modal-wrapper .cell .gameImageBox {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 6px;
}

#leaderboard-modal-wrapper .cell .gameImageBox .img-fluid {
  width: 100% !important;
  height: 100% !important;
  border-radius: 6px;
}

#leaderboard-modal-wrapper .cell .hoverWrap {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(5px);
  background-color: rgba(255, 255, 255, 0.8);
  background-color: rgb(18 18 18 / 23%);
  background-position: center;
  z-index: 5;
  border-radius: 6px;
  cursor: pointer;
  pointer-events: auto;
}

#leaderboard-modal-wrapper .cell:hover .hoverWrap {
  display: block;
  pointer-events: auto;
}

#leaderboard-modal-wrapper .cell .gameImageBox_middle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#leaderboard-modal-wrapper .cell .gameImageBox_middle .i_live {
  padding: 2rem;
  width: 2rem;
  height: 2rem;
}

/* Mobile Responsiveness */
@media (max-width: 1080px) {
  /* Hide header and top-header when modal is open on mobile */
  body.modal-open-mobile header,
  body.modal-open-mobile .top-header {
    display: none !important;
  }

  #leaderboard-modal-wrapper .dg-popup-layout-container {
    padding: 0;
    align-items: flex-start;
    justify-content: flex-start;
  }

  #leaderboard-modal-wrapper .dg-popup-container {
    width: 100%;
    height: auto;
    justify-content: flex-start;
    margin: 0 8px;
    bottom: 0;
    position: absolute;
    top: 0;
    gap: 8px;
    border: 0;
    max-width: 100%;
    border-radius: 0;
    max-height: 100vh;
  }

  #leaderboard-modal-wrapper .rating-heading-section {
    padding: 24px;
    justify-content: center;
    align-items: center;
  }

  /* Banner adjustments */
  #leaderboard-modal-wrapper .tournament-banner img {
    border-top-right-radius: 16px;
    height: -webkit-fill-available;
    border-top-left-radius: 16px;
    width: 100%;
    object-fit: cover;
  }

  #leaderboard-modal-wrapper .live-master h2 {
    font-size: 20px;
  }

  #leaderboard-modal-wrapper .live-master img {
    width: 25%;
  }

  #leaderboard-modal-wrapper .price-pool h1 {
    font-size: 16px;
  }

  #leaderboard-modal-wrapper .price-pool {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  /* Info Cards (Participants, Prizes, Time) */
  #leaderboard-modal-wrapper .rating-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
  }

  #leaderboard-modal-wrapper .rating-info-card {
    width: 100%;
    height: auto;
    padding: 8px 16px;
    gap: 8px;
    width: max-content;
  }

  #leaderboard-modal-wrapper .rating-info-card h2 {
    font-size: 12px;
    font-weight: 400;
  }

  #leaderboard-modal-wrapper .close-btn {
    right: 24px;
    top: 24px;
  }

  #leaderboard-modal-wrapper .tab-bg {
    width: 100%;
    margin-top: 0;
  }

  #leaderboard-modal-wrapper .tabs-section {
    border-radius: 0;
    align-items: center;
    justify-content: space-evenly;
    display: flex;
    width: 100%;
    gap: 8px;
    padding: 8px;
    box-sizing: border-box;
    min-width: 0;
  }

  #leaderboard-modal-wrapper .tabs {
    width: fit-content;
    align-items: center;
    justify-content: center;
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 12px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 4px;
  }

  #leaderboard-modal-wrapper .tabs h2 {
    font-size: 14px;
  }

  #leaderboard-modal-wrapper .leaderboard {
    height: calc(100vh - 398px);
    overflow-y: auto;
    margin: 0 16px 0 16px;
  }

  #leaderboard-modal-wrapper .row-player {
    padding: 12px 16px 12px 24px;
  }

  #leaderboard-modal-wrapper .table-column-name p {
    font-size: 12px;
  }

  #leaderboard-modal-wrapper .player-rank img {
    width: 100%;
  }

  #leaderboard-modal-wrapper .my-rank-btn-section {
    padding: 0 16px;
  }

  #leaderboard-modal-wrapper .my-rank-btn {
    margin-bottom: 10px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Terms */
  #leaderboard-modal-wrapper .dg-terms {
    margin: 16px 16px;
    height: 434px;
  }

  /* Games */
  #leaderboard-modal-wrapper .dg-grid-container {
    height: 478px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(6, 120px);
    gap: 8px;
    margin: 16px;
  }

  #leaderboard-modal-wrapper .cell {
    background: #d9d9d9;
    border-radius: 6px;
    width: 100%;
    height: 100%;
  }
}
