/*
 * scoreboard.css — the Tab board.
 * Two team columns over a dimmed backdrop, same dark-glass + gold language as
 * the menu. Hidden until scoreboard.js adds .is-open.
 */

/* border-box so the panel's max-height caps its FULL height. Under the default
   content-box, padding and border sit outside the cap and the board overshoots
   86vh — which at 25 a side is exactly when it must not. */
#scoreboard,
#scoreboard *,
#scoreboard *::before,
#scoreboard *::after {
  box-sizing: border-box;
}

#scoreboard {
  position: absolute;
  inset: 0;
  z-index: 40;                 /* above #ui-layer (10), below #main-menu (50) */
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;        /* the board is read-only — clicks reach the game */
                               /* (except .sb-rows, which needs the wheel to scroll) */
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e6e6ee;
  background: rgba(4, 5, 12, 0.55);
  -webkit-user-select: none;
  user-select: none;
}

#scoreboard.is-open { display: flex; }

.sb-panel {
  display: flex;
  /* A column: objective chips across the top, then the two team columns in
     .sb-teams. The teams used to be the panel's direct children. */
  flex-direction: column;
  gap: 14px;
  width: min(1180px, 94vw);
  max-height: 86vh;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 9, 18, 0.9);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sb-teams {
  display: flex;
  gap: 18px;
  /* stretch (not flex-start) so both team columns inherit the row's height —
     that is what gives .sb-rows a bounded box to scroll inside once a team runs
     25 deep. min-height: 0 is what lets this row actually SHRINK to the panel's
     86vh cap; without it a flex item refuses to go below its content height and
     the board overshoots the viewport at 25 a side. */
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
}

.sb-empty {
  padding: 40px 60px;
  font-size: 15px;
  color: rgba(230, 230, 238, 0.45);
}

/* ---------- Objective timers ----------
   Centred over both team columns, because neither objective belongs to a side.
   flex-shrink: 0 so the row keeps its height when .sb-teams below it is being
   squeezed against the panel's 86vh cap. */
.sb-objectives {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex: 0 0 auto;
}

.sb-obj {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
  font-variant-numeric: tabular-nums;
}

.sb-obj-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.4px;
  color: rgba(230, 230, 238, 0.5);
}

.sb-obj-value {
  font-size: 15px;
  font-weight: 800;
  /* Fixed width so a countdown crossing 10:00 -> 9:59 does not shuffle the
     chip, and the two chips stay the same size as each other. */
  min-width: 52px;
  text-align: right;
  color: #e6e6ee;
}

/* Waiting is the neutral state and reads plain. The two chips only take a
   colour once they mean something you have to act on. */
.sb-obj.is-alive {
  border-color: rgba(168, 85, 247, 0.55);
  background: rgba(168, 85, 247, 0.12);
}
.sb-obj.is-alive .sb-obj-value { color: #d6b4ff; }

.sb-obj.is-slain { opacity: 0.42; }

.sb-obj.is-active {
  border-color: rgba(255, 176, 72, 0.7);
  background: rgba(255, 176, 72, 0.14);
}
.sb-obj.is-active .sb-obj-value { color: #ffd9a0; }

/* ---------- Team column ---------- */
.sb-team {
  --team: #f0c040;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sb-team-0 { --team: #5aa9ff; }
.sb-team-1 { --team: #ff5d5d; }

.sb-team-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px 9px;
  border-bottom: 2px solid var(--team);
}
.sb-team-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--team);
}
.sb-team-score {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: rgba(230, 230, 238, 0.65);
  font-variant-numeric: tabular-nums;
}

/* ---------- Rows ---------- */
/* Kept deliberately tight: at 25 a side, a few px of row padding is the
   difference between the whole team fitting on screen and everyone scrolling. */
.sb-row {
  display: grid;
  grid-template-columns: 30px 1fr 88px 42px;
  align-items: center;
  gap: 9px;
  padding: 3px 9px;
  border-radius: 6px;
}

.sb-labels {
  padding-top: 9px;
  padding-bottom: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(230, 230, 238, 0.35);
}
.sb-labels .sb-kda,
.sb-labels .sb-cs { text-align: right; }
.sb-labels .sb-level { text-align: center; }

.sb-rows {
  flex: 1 1 auto;
  min-height: 0;             /* without this a flex child refuses to shrink and never scrolls */
  overflow-y: auto;
  pointer-events: auto;      /* the one interactive part: the wheel scrolls a 25-deep list */
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.sb-rows::-webkit-scrollbar { width: 8px; }
.sb-rows::-webkit-scrollbar-track { background: transparent; }
.sb-rows::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 4px;
}
.sb-rows::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }
.sb-rows .sb-row:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }

.sb-row.is-me {
  background: color-mix(in srgb, var(--team) 18%, transparent);
  box-shadow: inset 2px 0 0 var(--team);
}
.sb-row.is-dead { opacity: 0.45; }

.sb-level {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sb-level-dead {
  background: transparent;
  border-color: transparent;
  color: #ff8a8a;
  font-size: 11px;
}

.sb-who { min-width: 0; }
.sb-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-bot-tag {
  margin-left: 6px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.09);
  color: rgba(230, 230, 238, 0.5);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  vertical-align: 1px;
}
.sb-champ {
  font-size: 11px;
  line-height: 1.2;
  color: rgba(230, 230, 238, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-kda,
.sb-cs {
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.sb-cs { color: rgba(230, 230, 238, 0.6); }

/* Narrow windows: stack the two teams instead of squeezing the columns. One
   scroll for the whole board reads better here than two nested ones. */
@media (max-width: 820px) {
  .sb-panel {
    flex-direction: column;
    max-height: 92vh;
    overflow-y: auto;
    pointer-events: auto;
  }
  .sb-rows { flex: none; overflow-y: visible; }
}

/* ---------- Touch: landscape phone ----------
   Opened by holding the on-screen TAB button (touch.js), so one thumb is busy
   and the other is free to scroll. Scoped to body.touch-mode so a short desktop
   window keeps the desktop board. At 360-430px tall the desktop board fits
   about six rows a side; this fits ~12 and scrolls the rest. Both teams stay
   side by side — even 740px wide leaves each column ~350px, enough for the
   tightened grid below. */
@media (max-height: 520px) {
  body.touch-mode .sb-panel {
    /* % of #scoreboard (inset: 0), not vw/vh: on a phone 100vh includes the
       browser toolbar when it is showing, and the bottom rows would sit under it. */
    width: calc(100% - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    max-height: calc(100% - 12px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    gap: 6px;
    padding: 8px 10px;
    border-radius: 10px;
    /* Scrolls as one, whatever the width: the 820px rule above already does this
       on the narrowest phones, and two nested scrollers the height of a thumb
       are harder to drag than one. */
    overflow-y: auto;
    overscroll-behavior: contain;
    pointer-events: auto;
  }
  body.touch-mode .sb-rows { flex: none; overflow-y: visible; }
  body.touch-mode .sb-teams { gap: 10px; flex: none; }

  body.touch-mode .sb-objectives { gap: 6px; }
  body.touch-mode .sb-obj { gap: 6px; padding: 3px 9px; border-radius: 7px; }
  body.touch-mode .sb-obj-label { font-size: 9px; letter-spacing: 1px; }
  body.touch-mode .sb-obj-value { font-size: 12px; min-width: 40px; }

  body.touch-mode .sb-team-head { padding: 0 6px 4px; }
  body.touch-mode .sb-team-name { font-size: 12px; letter-spacing: 1px; }
  body.touch-mode .sb-team-score { font-size: 11px; }

  body.touch-mode .sb-row {
    grid-template-columns: 24px 1fr 62px 30px;
    gap: 6px;
    padding: 1px 6px;
  }
  body.touch-mode .sb-labels { padding-top: 4px; padding-bottom: 1px; font-size: 8.5px; }
  body.touch-mode .sb-level { height: 18px; font-size: 10.5px; border-radius: 5px; }
  body.touch-mode .sb-level-dead { font-size: 9.5px; }
  body.touch-mode .sb-name { font-size: 11.5px; line-height: 1.2; }
  body.touch-mode .sb-bot-tag { font-size: 8px; margin-left: 4px; }
  /* Champion beside the name instead of under it: the second line doubled every
     row's height, which is half the board on a 360px screen. The name keeps
     priority and the champion is what gets ellipsised. */
  body.touch-mode .sb-who { display: flex; align-items: baseline; gap: 6px; }
  body.touch-mode .sb-name { flex: 0 1 auto; min-width: 0; }
  body.touch-mode .sb-champ { flex: 1 1 0; min-width: 0; font-size: 9.5px; }
  body.touch-mode .sb-kda,
  body.touch-mode .sb-cs { font-size: 11px; }
  body.touch-mode .sb-empty { padding: 20px 30px; font-size: 13px; }
}
