/* ── ONGOING TAB — Enhanced ── */
.ongoing-hero {
  background: linear-gradient(135deg, rgba(255,59,92,0.08) 0%, rgba(59,142,255,0.08) 100%), var(--surface);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 16px;
  box-shadow: 0 12px 32px -22px rgba(0,0,0,0.8);
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.ongoing-live-count {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 3em;
  color: var(--green);
  line-height: 1;
  text-shadow: 0 0 20px rgba(0,230,118,0.4);
}

/* ── FINISHED TAB — Enhanced ── */
.tag-legend-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
}

/* ══════════════════════════════════════════════
   FINISHED MATCHES — result list
   One grid row per match: id | red | score | blue | result.
   The old layout centred a ~180px cluster inside a 1290px card,
   so 86% of every row was empty black. Columns now span the row
   and the names sit against the score in the middle.
   ══════════════════════════════════════════════ */

/* a result list reads better in a column than stretched to 1340px */
#finished { max-width: 1120px; }

/* ── Tag legend, collapsed ── */
.fin-legend {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 14px;
}
.fin-legend > summary {
  list-style: none;
  cursor: pointer;
  outline: none;
  padding: 11px 16px;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1em;
  letter-spacing: 3px;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 8px;
}
.fin-legend > summary::-webkit-details-marker { display: none; }
.fin-legend > summary::after {
  content: '▾';
  margin-left: auto;
  font-size: 13px;
  transition: transform 0.2s;
}
.fin-legend[open] > summary::after { transform: rotate(180deg); }
.fin-legend-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 9px 18px;
  padding: 4px 16px 15px;
  border-top: 1px solid var(--border);
  padding-top: 13px;
}
.fin-legend-item { display: flex; align-items: flex-start; gap: 8px; }
.fin-legend-item .finished-tag { white-space: nowrap; flex-shrink: 0; }
.fin-legend-item > span:last-child { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ── List ── */
#finishedMatchesGrid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(min(460px, 100%), 1fr)) !important;
  gap: 12px !important;
}

/* ── Finished match cards — head-to-head result ── */
.fmatch {
  border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: 14px;
  overflow: hidden; background: var(--surface); transition: border-color .16s, transform .14s;
}
.fmatch:hover { transform: translateY(-2px); }
.fmatch.red  { border-left-color: var(--red); }
.fmatch.blue { border-left-color: var(--blue); }
.fmatch.draw { border-left-color: var(--gold); }
.fmatch-head { display: flex; align-items: center; gap: 9px; padding: 11px 15px 10px; border-bottom: 1px solid var(--border); }
.fmatch-id { font-family: 'Bebas Neue', sans-serif; font-size: 1.3rem; letter-spacing: 2px; color: var(--gold); }
.fmatch-round { font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--muted); background: var(--surface3); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }
.fmatch-badge { margin-left: auto; font-size: 11px; font-weight: 800; letter-spacing: 1px; padding: 4px 12px; border-radius: 20px; white-space: nowrap; }
.fmatch-badge.red  { color: var(--red);  background: rgba(255,59,92,.12);  border: 1px solid rgba(255,59,92,.35); }
.fmatch-badge.blue { color: var(--blue); background: rgba(59,142,255,.12); border: 1px solid rgba(59,142,255,.35); }
.fmatch-badge.draw { color: var(--gold); background: rgba(245,200,66,.12); border: 1px solid rgba(245,200,66,.35); }
.fmatch-body { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 14px 16px; }
.fmatch-team { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.fmatch-team.left  { align-items: flex-end; }
.fmatch-team.right { align-items: flex-start; }
.fmatch-p { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fmatch-team.left .fmatch-p { flex-direction: row-reverse; }
.fmatch-name { font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmatch-name.win-r { color: var(--red); }
.fmatch-name.win-b { color: var(--blue); }
.fmatch-name.lose  { color: var(--muted); font-weight: 500; }
.fmatch-av-dim { opacity: .45; }
.fmatch-score { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 13px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--border); }
.fmatch-g { display: flex; align-items: center; font-family: 'Bebas Neue', sans-serif; font-size: 1.55rem; line-height: 1; font-variant-numeric: tabular-nums; }
.fmatch-g .gl { font-family: 'Space Grotesk', sans-serif; font-size: 8.5px; font-weight: 800; letter-spacing: .5px; color: var(--muted); width: 16px; }
.fmatch-g .r { color: var(--red); }
.fmatch-g .b { color: var(--blue); }
.fmatch-g .sep { color: var(--muted2); padding: 0 5px; }
.fmatch-g .dim { opacity: .4; }
.fmatch-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 9px 15px 11px; border-top: 1px solid var(--border); }
.fmatch-foot-r { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.fmatch-ump { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.fmatch-admin { display: flex; gap: 5px; }
@media (max-width: 480px) {
  .fmatch-body { gap: 8px; padding: 12px; }
  .fmatch-name { font-size: 13.5px; }
  .fmatch-g { font-size: 1.4rem; }
}

.frow {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.18s, background 0.15s;
}
/* no cursor:pointer / lift — the row is not clickable, only its buttons are */
.frow:hover { background: var(--surface2); border-color: var(--border2); }
.frow.winner-red  { border-left-color: var(--red); }
.frow.winner-blue { border-left-color: var(--blue); }
.frow.draw-match  { border-left-color: var(--gold); }

/* ── Main row ── */
.frow-main {
  display: grid;
  grid-template-areas: "id red score blue result";
  grid-template-columns: 74px minmax(0,1fr) auto minmax(0,1fr) 106px;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
}

.frow-id { grid-area: id; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.frow-match-id {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.15em;
  letter-spacing: 2px;
  color: var(--gold);
}

/* teams sit against the score, not out at the card edges */
.frow-team { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.frow-team-left  { grid-area: red;  align-items: flex-end;   text-align: right; }
.frow-team-right { grid-area: blue; align-items: flex-start; text-align: left; }

.frow-player {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.frow-player.loser { color: var(--muted); font-weight: 500; }
.frow-team-left  .frow-player.winner { color: var(--red); }
.frow-team-right .frow-player.winner { color: var(--blue); }

/* ── Score ── */
.frow-score-hero {
  grid-area: score;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 12px;
  background: rgba(255,255,255,0.022);
  border-radius: 10px;
  flex-shrink: 0;
}
.frow-score-row { display: flex; align-items: center; white-space: nowrap; }
.frow-glabel {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--muted);
  background: var(--surface3);
  padding: 2px 5px;
  border-radius: 3px;
  margin-right: 7px;
  flex-shrink: 0;
}
.frow-glabel.g2-label { color: var(--gold); background: rgba(245,200,66,0.1); }
.frow-snum {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.7em;
  line-height: 1.05;
  min-width: 30px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.frow-snum.red  { color: var(--red); }
.frow-snum.blue { color: var(--blue); }
.frow-ssep {
  color: rgba(255,255,255,0.25);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.3em;
  line-height: 1;
  padding: 0 2px;
}

.frow-main .result-badge { grid-area: result; justify-self: end; white-space: nowrap; }

/* ── Footer: tags + umpire + admin ── */
.frow-footer {
  border-top: 1px solid rgba(255,255,255,0.04);
  padding: 7px 16px 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.frow-footer:empty { display: none; }

.frow-tag-icon {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.frow-umpire {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

/* 39 rows x 3 buttons is a lot of chrome — keep it quiet until hover */
.frow-admin {
  margin-left: auto;
  display: flex;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.16s;
}
.frow:hover .frow-admin,
.frow:focus-within .frow-admin { opacity: 1; }
@media (hover: none) { .frow-admin { opacity: 0.6; } }

.frow-admin-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.frow-admin-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.frow-admin-btn.edit  { color: var(--blue); border-color: rgba(59,142,255,0.2); }
.frow-admin-btn.edit:hover { background: rgba(59,142,255,0.08); }
.frow-admin-btn.del   { color: var(--danger); border-color: rgba(255,69,96,0.2); }
.frow-admin-btn.del:hover { background: rgba(255,69,96,0.08); }

/* ── Tablet: drop the fixed id/result rails, let them share the top ── */
@media (max-width: 860px) {
  .frow-main {
    grid-template-areas:
      "id   id     result"
      "red  score  blue";
    grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
    gap: 8px 10px;
    padding: 10px 13px 12px;
  }
  .frow-id { justify-self: start; }
  .frow-main .result-badge { justify-self: end; }
  .frow-score-hero { padding: 3px 10px; }
}

/* ── Phone: the score block is wider than two name columns can afford
   at 375px, so it drops to its own full-width row and goes horizontal ── */
@media (max-width: 560px) {
  #finished { padding-left: 12px; padding-right: 12px; }
  .frow-main {
    grid-template-areas:
      "id    result"
      "red   blue"
      "score score";
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
    padding: 11px 13px 12px;
  }
  .frow-team-left  { align-items: flex-start; text-align: left; }
  .frow-score-hero {
    flex-direction: row;
    justify-content: center;
    gap: 16px;
    padding: 5px 10px;
    margin-top: 2px;
  }
  .frow-player { font-size: 13.5px; }
  .frow-snum { font-size: 1.5em; min-width: 26px; }
  .frow-footer { padding: 6px 13px 8px; }
  .fin-legend-body { grid-template-columns: 1fr; }
}

/* Live card score bigger on ongoing tab */
.live-card .score-big {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 3.2em;
  line-height: 1;
}

/* ══════════════════════════════════════════
   ONGOING TAB — Court Grid + Queue List
   ══════════════════════════════════════════ */

/* Court grid: cards keep a sensible max width and the row is centred, so a
   lone live match sits in the middle instead of clinging to the left. auto-fit
   collapses empty tracks and packs 1 / 2 / 3 cards across as the width allows
   (1 col on phones), which also drops the old fixed 2- and 3-column rules. */
.court-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 560px));
  justify-content: center;
  gap: 20px;
}
@media (max-width: 640px) {
  .court-grid { gap: 14px; }
}

/* ── Court card ── */
