/* =========================================================
   PAGE SCROLL (keep the normal page scrollbar)
   ========================================================= */

html {
  overflow-y: scroll;
  overflow-x: hidden;
}

/* IMPORTANT: do NOT kill body scrolling (this removed your universal scrollbar) */
body.kvk-matchmaking-page {
  overflow-y: auto;
  overflow-x: hidden;

  background-color: rgb(50, 51, 57);
  font-family: "Segoe UI", sans-serif;
  color: white;
  margin: 0;
  padding: 0;
}

/* =========================================================
   NAV (your breakout trick)
   ========================================================= */

body.kvk-matchmaking-page .top-nav {
  width: 100vw !important;

  margin-left: calc(50% - 50vw) !important;
  margin-right: calc(50% - 50vw) !important;

  left: auto !important;
  right: auto !important;

  padding-left: 10px !important;
  padding-right: 20px !important;

  box-sizing: border-box !important;
}


/* =========================================================
   PAGE WRAP
   ========================================================= */

.kvk-page-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 20px 20px;
  box-sizing: border-box;
}

.kvk-header {
  width: 100%;
  max-width: 80vw;
  margin-top: 20px;
}

.page-title {
  margin: 0 0 14px 0;
  text-align: center;
  color: rgb(255, 0, 0);
  font-size: clamp(26px, 3vw, 42px);
  font-weight: 800;
}

.server-glass {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 15px;
  padding: 14px;
  margin: 12px 0;
  backdrop-filter: blur(10px);
  width: 100%;
  max-width: 80vw;
  box-sizing: border-box;
}

.inner-glass {
  background: rgba(255, 255, 255, 0.025);
  border-radius: 12px;
  padding: 12px;
  margin: 0 auto;
  max-width: 60vw;
}

.controls-form { width: 100%; }

.controls-glass {
  max-width: 70vw;
  padding: 14px;
}

.controls-section { padding: 10px 0; }

.row-title {
  text-align: center;
  font-weight: 800;
  color: #ddd;
  margin-bottom: 10px;
  font-size: clamp(16px, 1.4vw, 20px);
}

.controls-grid {
  display: grid;
  gap: 16px;
  justify-content: center;
  align-items: start;
}

.controls-grid-2 {
  grid-template-columns: 1fr 1fr;
  max-width: 58vw;
  margin: 0 auto;
}

.time-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 8px 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.time-box label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ccc;
  margin-bottom: 4px;
}

.time-box select {
  min-width: 260px;
  height: 40px;
  padding: 0 12px;
  border-radius: 0.375rem;
  border: none;
  background-color: #f0f0f0;
  color: #333;
  font-weight: bold;
  text-align: center;
  cursor: pointer;
  box-sizing: border-box;
}


/* =========================================================
   GENERATE BUTTON + TOOLTIP
   ========================================================= */

.generate-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  background: rgba(255, 0, 0, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 0, 0, 0.35);
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
  min-width: 240px;
}

.generate-btn:hover:not(:disabled) {
  background: rgba(255, 0, 0, 0.5);
  transform: translateY(-1px);
}

.generate-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: rgba(255,255,255,0.06);
  box-shadow: none;
}

.generate-under-zones{
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 16px auto 0 auto;
  position: relative;
  width: fit-content;
}

.generate-tooltip {
  position: absolute;
  top: calc(100%);
  left: 50%;
  transform: translateX(-50%);

  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  color: #fff;
  font-weight: 900;
  white-space: nowrap;
  z-index: 9999;
  box-shadow: 0 10px 22px rgba(0,0,0,0.35);

  display: none;
  pointer-events: none;
}

.generate-btn:disabled:hover + .generate-tooltip {
  display: block;
}


/* =========================================================
   ZONES
   ========================================================= */

.zones-glass {
  width: 100%;
  max-width: 80vw;
  overflow: visible;
}

.zones-grid {
  display: grid;
  gap: 18px;
  justify-content: center;
  align-items: stretch;
  overflow: visible;
}

.zones-6 { grid-template-columns: repeat(3, minmax(240px, 1fr)); }
.zones-4 { grid-template-columns: repeat(2, minmax(260px, 1fr)); }

.zone-card {
  background: rgba(255, 255, 255, 0.025);
  border-radius: 14px;
  padding: 12px;
  min-height: 240px;

  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: visible;
}

.zone-title {
  text-align: center;
  font-weight: 950;
  color: #fff;
  letter-spacing: 0.5px;
}

.zone-selected {
  flex: 1;
  background: rgba(0,0,0,0.10);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
}

.zone-empty {
  width: 100%;
  text-align: center;
  color: #bdbdbd;
  font-weight: 700;
  padding: 8px 0;
}

.server-chip {
  border: none;
  border-radius: 999px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 900;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  transition: background 120ms ease, transform 120ms ease;
}

.server-chip:hover {
  background: rgba(255, 0, 0, 0.35);
  transform: translateY(-1px);
}

.zone-search {
  position: relative;
  z-index: 1;
}

.zone-search:focus-within {
  z-index: 999;
}

.zone-input {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 12px;
  padding: 0 12px;
  background: #f0f0f0;
  color: #222;
  font-weight: 900;
  text-align: center;
  box-sizing: border-box;
}

.zone-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);

  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;

  background: rgba(30, 30, 34, 0.98);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;

  z-index: 9999;
  box-shadow: 0 16px 32px rgba(0,0,0,0.45);
}

.result-row {
  width: 100%;
  border: none;
  background: transparent;
  color: #fff;
  text-align: center;
  padding: 10px 10px;
  cursor: pointer;
  font-weight: 900;
}

.result-row:hover {
  background: rgba(255, 0, 0, 0.25);
}

.result-row.muted {
  color: #bcbcbc;
  cursor: default;
}


/* =========================================================
   RESULTS
   ========================================================= */

.results-glass{
  width: 100%;
  max-width: 80vw;
}

/* One source of truth */
:root{
  --kvk-left-col: 260px;
  --kvk-col: 120px;
  --kvk-cols: 17;
  --kvk-gap: 10px;

   --kvk-table-width: calc(
    var(--kvk-left-col) +
    (var(--kvk-cols) * var(--kvk-col)) +
    (var(--kvk-cols) * var(--kvk-gap))
  );

}

/* =========================================================
   MASTER SCROLLER (REAL horizontal scroll happens here)
   ========================================================= */

#kvkMasterXScroll.kvk-xscroll{
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 14px;
  background: rgba(255,255,255,0.02);

  scrollbar-width: none;
}
#kvkMasterXScroll.kvk-xscroll::-webkit-scrollbar{
  height: 0px;
}

/* KEY FIX:
   This MUST be 100% width so midbar + team blocks are normal-width,
   while the grids/strips stay max-content and create the horizontal scroll. */
.kvk-master-inner{
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px;
  box-sizing: border-box;

  width: 100%;
  min-width: 100%;
}

/* =========================================================
   VISIBLE MIDDLE SCROLLBAR (the one you drag)
   ========================================================= */

.kvk-midbar{
  width: 100%;
  height: 16px;
  overflow-x: auto;
  overflow-y: hidden;

  background: transparent;     /* track handles the look */
  border-radius: 0;            /* IMPORTANT: remove clipping */
  padding: 0;                  /* IMPORTANT: remove inset */
  box-sizing: border-box;

  user-select: none;
  cursor: grab;

  /* Optional: makes overlay scrollbars behave more consistently */
  -webkit-overflow-scrolling: auto;
}
.kvk-midbar:active{ cursor: grabbing; }

/* Inner is just the “scroll width” spacer set by JS */
.kvk-midbar-inner{
  height: 1px;
  width: 0px; /* JS sets */
}

/* WebKit scrollbar styling */
.kvk-midbar::-webkit-scrollbar{ height: 16px; }

.kvk-midbar::-webkit-scrollbar-track{
  background: rgba(255,255,255,0.06);
  border-radius: 999px;        /* rounding goes HERE */
}

.kvk-midbar::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.40);
  border-radius: 999px;        /* rounding goes HERE */
}

.kvk-midbar::-webkit-scrollbar-thumb:hover{
  background: rgba(255,255,255,0.60);
}

/* =========================================================
   GRID (header + strips match exactly)
   These are what create the horizontal scroll width.
   ========================================================= */

.kvk-grid{
  display: grid;
  grid-template-columns: var(--kvk-left-col) repeat(var(--kvk-cols), var(--kvk-col));
  gap: var(--kvk-gap);
  align-items: center;

  width: max-content;
  min-width: max-content;
}

.kvk-table.table-header{
  padding: 10px 12px;
  margin-top: 6px;
  background: transparent;
  border-radius: 0;
  box-sizing: border-box;
}

.kvk-table.table-header .th{
  font-size: 1.05rem;
  font-weight: 1000;
  color: #fff;
  letter-spacing: 0.4px;
  text-align: center;
  white-space: nowrap;
}

/* =========================================================
   STRIP POOL + DROPZONES
   ========================================================= */

.strip-pool{
  position: sticky;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  z-index: 4;
}

.strip-dropzone{
  position: relative;
  border-radius: 14px;
  background: transparent;
  padding: 12px;

  overflow-x: visible;    /* IMPORTANT: do NOT clip horizontal content */
  overflow-y: auto;

  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;

  width: max-content;     /* allow wide content */
  min-width: 100%;        /* but fill the visible width too */
}

/* Pool can be tall */
#poolDrop.strip-dropzone{
  max-height: 560px;
  min-height: 0;
}

/* Teams: compact by default */
#team1Drop.strip-dropzone,
#team2Drop.strip-dropzone{
  max-height: 320px;
  min-height: 110px;
}


/* vertical scrollbar styling */
.strip-dropzone::-webkit-scrollbar{ width: 14px; }
.strip-dropzone::-webkit-scrollbar-track{
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
}
.strip-dropzone::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.35);
  border-radius: 999px;
}
.strip-dropzone::-webkit-scrollbar-thumb:hover{
  background: rgba(255,255,255,0.55);
}

.strip-dropzone.drag-over{
  outline: 2px solid rgba(0,255,120,0.45);
  background: rgba(0,255,120,0.08);
}

/* Hint centered INSIDE the visible dropzone (not the whole table width) */
.drop-hint{
  position: absolute;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  text-align: center;
  color: rgba(255,255,255,0.35);
  font-weight: 900;

  pointer-events: none;
}

/* =========================================================
   TEAM BLOCKS (now normal-width, not table-width)
   ========================================================= */

.team-block{
  position: sticky;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  z-index: 4;
}

.team-block-title{
  text-align: center;
  font-weight: 950;
  color: #fff;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

/* Total row centered in the visible area (normal width) */
.kvk-total-row{
  position: sticky;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  z-index: 4;

  padding: 12px;          /* <-- MATCH .strip-dropzone padding */
}

/* =========================================================
   ZONE STRIPS (these create the wide scroll width)
   ========================================================= */

.zone-strip{
  display: grid;
  grid-template-columns: var(--kvk-left-col) repeat(var(--kvk-cols), var(--kvk-col));
  gap: var(--kvk-gap);
  align-items: center;

  width: max-content;
  min-width: max-content;

  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.04);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);

  cursor: grab;
  user-select: none;
  box-sizing: border-box;
}
.zone-strip:active{ cursor: grabbing; }
.zone-strip.dragging{ opacity: 0.55; }

.zs-left{
  max-height: 55px;
  overflow: auto;
  padding-right: 6px;

  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  text-align: left;
  box-sizing: border-box;
}

.zs-left-row{
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.zs-left-label{
  font-size: 0.82rem;
  font-weight: 1000;
  color: rgba(255,255,255,0.70);
  white-space: nowrap;
}

.zs-left-value{
  font-weight: 950;
  color: #fff;
  font-size: 0.88rem;
  white-space: nowrap;
}

.zs-cell{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

.zs-cell span{
  font-size: 0.8rem;
  font-weight: 900;
  color: rgba(255,255,255,0.55);
  line-height: 1;
}

.zs-cell b{
  margin-top: 4px;
  font-size: 0.95rem;
  font-weight: 950;
  color: #fff;
}

/* These must be the SAME width as the table, otherwise right-side drops fail */
.strip-pool,
.team-block,
.kvk-total-row{
  position: relative;
  left: auto;
  width: var(--kvk-table-width);
  min-width: var(--kvk-table-width);
  box-sizing: border-box;
}


#kvkMidBar{
  width: var(--kvk-table-width);
  height: 14px;
  border-radius: 999px;

  position: relative;
  box-sizing: border-box;

  /* JS controls interaction */
  overflow: hidden;
  user-select: none;
  cursor: grab;

  background: rgba(255,255,255,0.10);
}

#kvkMidBar:active{ cursor: grabbing; }

/* Track filler (purely visual) */
#kvkMidBarInner{
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}

/* Custom thumb (created by JS) */
#kvkMidThumb{
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;

  border-radius: 999px;
  background: rgba(255,255,255,0.45);
  cursor: grab;

  transition: background 0.15s ease;
}

#kvkMidThumb:hover{
  background: rgba(255,255,255,0.65);
}

/* Prevent horizontal page overflow from visual extension */
.results-glass{
  overflow-x: hidden;
}

#team1Drop.strip-dropzone,
#team2Drop.strip-dropzone{
  outline: 2px solid rgba(0, 255, 120, 0.55);
  outline-offset: -2px;              /* draw inside the box */
  background-color: rgba(0, 255, 120, 0.06) !important;
}

/* Totals areas */
#team1Total.kvk-total-row,
#team2Total.kvk-total-row{
  padding: 12px;            /* same as dropzones */
  background-clip: padding-box;
}
/* (optional) make the "Total" label easier to see */
#team1Total .total-label,
#team2Total .total-label{
  color: rgba(255,255,255,0.95);
  font-weight: 900;
}

/* ===== TOTAL ROW AS A REAL GRID (aligns with header + strips) ===== */
.kvk-total-row .total-values{
  width: 100%;
}

/* totals use the SAME grid columns as strips */
.kvk-total-grid{
  display: grid;
  grid-template-columns: var(--kvk-left-col) repeat(var(--kvk-cols), var(--kvk-col));
  gap: var(--kvk-gap);
  align-items: center;

  width: max-content;
  min-width: max-content;

  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.03);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
  box-sizing: border-box;
}

/* LEFT COL container */
.kvk-total-grid .total-left{
  width: 100%;
}

/* servers pill (shorter) */
.kvk-total-grid .total-servers{
  width: 100%;
  height: 26px;           /* slightly shorter */
  padding: 0 10px;
  border-radius: 10px;

  display: flex;
  align-items: center;
  gap: 8px;

  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  box-sizing: border-box;
}


.kvk-total-grid .total-servers .ts-label{
  flex: 0 0 auto;
  font-weight: 900;
  color: rgba(255,255,255,0.70);
}

.kvk-total-grid .total-servers .ts-value{
  flex: 0 0 auto;
  font-weight: 950;
  color: #fff;
}

/* each total cell aligns with its column */
.kvk-total-grid .total-cell{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

.kvk-total-grid .total-cell span{
  font-size: 0.8rem;
  font-weight: 900;
  color: rgba(255,255,255,0.55);
  line-height: 1;
}

.kvk-total-grid .total-cell b{
  margin-top: 4px;
  font-size: 0.95rem;
  font-weight: 950;
  color: #fff;
}

/* subtle scrollbar for servers pill */
.kvk-total-grid .total-servers::-webkit-scrollbar{ height: 8px; }
.kvk-total-grid .total-servers::-webkit-scrollbar-track{
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
}
.kvk-total-grid .total-servers::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
}
.kvk-total-grid .total-servers::-webkit-scrollbar-thumb:hover{
  background: rgba(255,255,255,0.40);
}

.kvk-page-wrap{
  position: relative;
}

/* Zones section sits above the results section */
.zones-glass{
  position: relative;
  z-index: 50;
}

/* Results section sits below zones */
.results-glass{
  position: relative;
  z-index: 1;
}

/* Make sure the focused zone card rises above siblings */
.zone-card{
  position: relative;
  z-index: 1;
}

.zone-search{
  position: relative;
  z-index: 1;
}

/* When typing, raise that specific dropdown stack */
.zone-search:focus-within{
  z-index: 99999;
}

/* Dropdown itself */
.zone-results{
  position: absolute;
  z-index: 999999;  /* really on top */
}

.zones-grid{
  position: relative;
  z-index: 1;
}

.zone-card{
  position: relative;
  z-index: 1;          /* default */
}

/* when you click/type in a zone input, that whole card rises above siblings */
.zone-card:focus-within{
  z-index: 1000000;
}

/* keep the dropdown above everything inside that card */
.zone-search{
  position: relative;
  z-index: 2;
}

.zone-results{
  position: absolute;
  z-index: 1000001;
  pointer-events: auto;  /* ensure it can be clicked */
}

.toast{
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2147483647;

  width: min(92vw, 720px);
  padding: 22px 26px;
  border-radius: 18px;

  background: rgba(0,0,0,0.78);
  border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(14px);

  color: #fff;
  font-weight: 900;
  font-size: 1.05rem;
  line-height: 1.4;
  text-align: center;

  box-shadow: 0 22px 60px rgba(0,0,0,0.55);
  animation: toastFadeIn 0.25s ease-out;
}
@keyframes toastFadeIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -55%) scale(0.96);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -48%) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}
/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {
  .kvk-header,
  .server-glass,
  .inner-glass,
  .zones-glass,
  .results-glass {
    max-width: 94vw;
  }

  .controls-grid-2 {
    grid-template-columns: 1fr;
    max-width: 94vw;
  }

  .zones-6 { grid-template-columns: 1fr; }
  .zones-4 { grid-template-columns: 1fr; }

  .time-box select {
    width: 100%;
    min-width: 0;
  }

  .generate-btn {
    width: 90%;
    min-width: 0;
  }
}