:root {
  /* Brand */
  --color-bg:          #f0f4fb;
  --color-surface:     #ffffff;
  --color-surface-2:   #f8faff;
  --color-border:      #dde3f0;
  --color-border-2:    #c5cfe8;

  /* Text */
  --color-text:        #1a1f36;
  --color-text-muted:  #4b5675;
  --color-text-faint:  #94a3b8;

  /* Primary — blue */
  --color-primary:     #1a56db;
  --color-primary-2:   #2563eb;
  --color-primary-dim: #e8edfa;
  --color-primary-grad: linear-gradient(90deg, #1a56db 0%, #2563eb 100%);
  --color-primary-hover-bg: #dde8ff;

  /* Accents — small use */
  --color-accent-purple:     #7c3aed;
  --color-accent-purple-dim: #ede9fe;
  --color-accent-red:        #dc2626;
  --color-accent-red-dim:    #fef2f2;
  --color-accent-red-text:   #b91c1c;

  /* Semantic */
  --color-success:     #16a34a;
  --color-warning:     #d97706;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

header {
  padding: 1.5rem 1.5rem 1.2rem;
  background: linear-gradient(135deg, #1a56db 0%, #0e3fa8 40%, #7c3aed 75%, #c0392b 100%);
  box-shadow: 0 2px 12px rgba(26, 86, 219, 0.25);
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1600px;
  margin: 0 auto;
}

header h1 {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.header-emoji {
  display: inline-block;
  font-size: 1.6rem;
  margin-left: 0.3rem;
  vertical-align: -2px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
  animation: ball-bounce 2.6s ease-in-out infinite;
}

@keyframes ball-bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25%      { transform: translateY(-4px) rotate(8deg); }
  75%      { transform: translateY(-2px) rotate(-6deg); }
}

header .subtitle {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-actions-hint {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  user-select: none;
  flex-shrink: 0;
}

.btn-header {
  padding: 0.4rem 1rem;
  border-radius: 7px;
  border: 1.5px solid rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.btn-header:hover {
  background: rgba(255,255,255,0.28);
  border-color: rgba(255,255,255,0.8);
}

.btn-header--danger {
  color: #fca5a5;
  border-color: rgba(252, 165, 165, 0.6);
}

.btn-header--danger:hover {
  color: #fecaca;
  border-color: #fca5a5;
  background: rgba(220, 38, 38, 0.2);  /* danger hover — keep literal for rgba */
}

/* ── Toast notifications ── */

#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  animation: toast-in 0.22s ease;
  pointer-events: none;
  max-width: 320px;
}

.toast-success { background: var(--color-success); }
.toast-error   { background: var(--color-accent-red); }
.toast-warning { background: var(--color-warning); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(6px); }
}

/* ── Stage breadcrumb ── */

#stage-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.6rem 1.5rem 0.6rem 1.5rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.crumb {
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  border: 1.5px solid transparent;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.crumb-active {
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-accent-purple) 100%);
  color: #fff;
  border-color: transparent;
}

.crumb-visited {
  background: var(--color-primary-dim);
  color: var(--color-primary);
  border-color: var(--color-border-2);
}

.crumb-visited:hover {
  background: var(--color-primary-hover-bg);
  border-color: var(--color-primary);
}

.crumb-unvisited {
  background: transparent;
  color: var(--color-border-2);
  border-color: #e4eaf7;
  cursor: default;
  text-decoration: line-through;
  opacity: 0.5;
}

.crumb-sep {
  color: var(--color-border-2);
  font-size: 0.85rem;
  user-select: none;
}

/* ── Page layout ── */

#page-layout {
  display: flex;
  align-items: flex-start;
  gap: 0;
  /* no left padding — sidebar pins to viewport edge; top/right/bottom kept */
  padding: 2rem 1.5rem 2rem 0;
  /* ensure content below the fold is reachable via normal page scroll */
  min-height: calc(100vh - 120px);
  /* cap total layout width so ultrawide screens centre content */
  max-width: 2200px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Matches panel ── */

#matches-panel {
  flex-shrink: 0;
  width: 310px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  /* flat left edge — flush to viewport */
  border-radius: 0 10px 10px 0;
  box-shadow: 2px 0 12px rgba(26, 86, 219, 0.09);
  overflow: hidden;
  transition: width 0.25s ease, opacity 0.2s ease;
  margin-right: 1.5rem;
  /* stretch full page height */
  align-self: stretch;
}

#matches-panel.panel-collapsed {
  width: 0;
  opacity: 0;
  margin-right: 0;
  border: none;
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-primary-grad);
  padding: 0.65rem 0.9rem;
}

.panel-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
}

.panel-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.1rem;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.panel-toggle:hover {
  opacity: 1;
}

.panel-body {
  padding: 0.75rem;
}

/* ── Re-open strip ── */

.panel-reopen {
  display: none;
  flex-shrink: 0;
  align-self: stretch;
  width: 28px;
  /* flat left edge — flush to viewport, rounded on right like the open panel */
  border-radius: 0 8px 8px 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: none;
  box-shadow: 2px 0 10px rgba(26, 86, 219, 0.09);
  cursor: pointer;
  color: var(--color-primary);
  margin-right: 1rem;
  transition: background 0.15s;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  user-select: none;
}

.panel-reopen:hover {
  background: var(--color-bg);
}

.panel-reopen-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  /* rotate so text reads bottom-to-top */
  transform: rotate(180deg);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-primary);
  white-space: nowrap;
}

.panel-reopen-arrow {
  font-size: 1.2rem;
  line-height: 1;
}

#page-layout.panel-is-collapsed .panel-reopen {
  display: flex;
}

/* ── Round toggle buttons ── */

.round-buttons {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.round-btn {
  flex: 1;
  padding: 0.4rem 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  border-radius: 6px;
  border: 1px solid var(--color-border-2);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.round-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.round-btn.active {
  background: var(--color-primary-grad);
  color: #fff;
  border-color: transparent;
}

/* ── Match list ── */

#matches-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  /* header ~105px + breadcrumb ~42px + panel-header ~40px + round-buttons ~50px + predict-btn ~50px + padding */
  max-height: calc(100vh - 340px);
}

.date-subheader {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8b96b5;
  padding: 0.6rem 0.1rem 0.3rem;
  border-bottom: 1px solid #eef1f9;
  margin-bottom: 0.35rem;
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}

.match-card {
  background: var(--color-surface-2);
  border: 1px solid #e4eaf7;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

.match-card:hover {
  box-shadow: 0 4px 14px rgba(26, 86, 219, 0.12);
  transform: translateY(-1px);
}

.match-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.match-group-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: var(--color-primary-grad);
  color: #fff;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  white-space: nowrap;
}

.match-teams {
  flex: 1;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-teams .vs {
  font-weight: 400;
  color: #8b96b5;
  margin: 0 0.25rem;
}

.match-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.3rem;
}

.match-time {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.match-venue {
  font-size: 0.65rem;
  color: #8b96b5;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
}

/* ── Groups grid ── */

#groups-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  min-width: 0;
  /* prevent cards growing absurdly wide on ultrawide screens */
  max-width: 1500px;
}

.loading {
  grid-column: 1 / -1;
  text-align: center;
  color: #6b7280;
  padding: 3rem;
}

.group-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(26, 86, 219, 0.07);
  transition: box-shadow 0.15s, transform 0.15s;
}

.group-card:hover {
  box-shadow: 0 6px 20px rgba(26, 86, 219, 0.13);
  transform: translateY(-2px);
}

.group-header {
  background: var(--color-primary-grad);
  padding: 0.65rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
}

caption.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

thead tr {
  background: var(--color-surface-2);
}

thead th {
  padding: 0.45rem 0.6rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b96b5;
  text-align: center;
  border-bottom: 1px solid #e4eaf7;  /* slightly darker than --color-border for table clarity */
}

thead th.col-team {
  text-align: left;
  padding-left: 0.9rem;
}

tbody tr {
  border-top: 1px solid #eef1f9;
  transition: background 0.1s;
}

tbody tr:hover {
  background: #f3f6ff;
}

tbody td {
  padding: 0.55rem 0.6rem;
  font-size: 0.85rem;
  text-align: center;
  color: #374151;
}

tbody td.col-team {
  text-align: left;
  padding-left: 0.9rem;
  white-space: nowrap;
}

.team-name {
  font-size: 0.85rem;
  color: var(--color-text);
  font-weight: 500;
}

.stat-gp {
  font-variant-numeric: tabular-nums;
  color: #6b7280;
}

.stat-gd {
  font-variant-numeric: tabular-nums;
  color: #6b7280;
  font-size: 0.8rem;
}

.stat-pts {
  font-weight: 700;
  color: var(--color-primary);
}

/* ── Played match card ── */

.match-card--played {
  background: #f0f2f8;
  border-color: #d0d7ec;
  opacity: 0.85;
}

.match-card--played:hover {
  box-shadow: 0 4px 14px rgba(26, 86, 219, 0.10);
  opacity: 1;
}

.match-score-result {
  display: inline-block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-primary-dim);
  border-radius: 6px;
  padding: 0.05rem 0.55rem;
  margin: 0 0.3rem;
  letter-spacing: 0.04em;
}

.match-score-result .score-digits {
  font-variant-numeric: tabular-nums;
}

/* ── Modal ── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 60, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-card {
  background: var(--color-surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15, 23, 60, 0.22);
  width: 100%;
  max-width: 480px;
  /* cap height so tall modals (predictions + ET + PSO) scroll rather than overflow viewport */
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-primary-grad);
  padding: 0.65rem 0.9rem;
}

.modal-group-badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
}

.modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.1rem;
  transition: color 0.15s;
}

.modal-close:hover { color: #fff; }

.modal-teams-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.25rem 1.4rem 1rem;
}

.modal-team-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
  text-align: center;
}

.modal-team-name:first-child { text-align: left; }
.modal-team-name:last-child  { text-align: right; }

/* Score picker */

.score-picker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.score-side {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.score-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--color-border-2);
  background: var(--color-bg);
  color: var(--color-primary);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-btn:hover {
  background: var(--color-primary-hover-bg);
  border-color: var(--color-primary);
}

.score-input {
  width: 44px;
  height: 36px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
  border: 2px solid var(--color-border-2);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  /* hide spin buttons */
  -moz-appearance: textfield;
}

.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.score-input:focus { border-color: var(--color-primary); }

.score-sep {
  font-size: 1.4rem;
  font-weight: 700;
  color: #8b96b5;
  margin: 0 0.15rem;
}

/* Modal sections (prob bar, odds) */

.modal-section {
  padding: 0 1.4rem 0.9rem;
}

.modal-section:first-of-type {
  padding-top: 0.2rem;
}

.prob-bar-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8b96b5;
  margin-bottom: 0.45rem;
}

.prob-bar {
  display: flex;
  height: 28px;
  border-radius: 7px;
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 700;
  color: #ffffff;
}

.prob-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  transition: width 0.3s ease;
  min-width: 0;
}

/* Hide label if segment is too narrow */
.prob-seg:not([style*="width:0%"]) {
  padding: 0 4px;
}

.prob-home { background: var(--color-success); }
.prob-draw { background: #8b96b5; }
.prob-away { background: var(--color-accent-red); }

.prob-bar-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 0.3rem;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.legend-home { color: var(--color-success); }
.legend-draw { color: #8b96b5; }
.legend-away { color: var(--color-accent-red); }

/* Predicted result */

.modal-predicted-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #eef1f9;
  padding-top: 0.75rem;
}

.modal-predicted-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
}

.modal-predicted-score {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: 0.08em;
}

/* Odds */

.modal-odds-row {
  border-top: 1px solid #eef1f9;
  padding-top: 0.75rem;
}

.modal-odds-title {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8b96b5;
  margin-bottom: 0.5rem;
}

.odds-group {
  display: flex;
  gap: 0.6rem;
}

.odds-item {
  flex: 1;
  background: var(--color-surface-2);
  border: 1px solid #e4eaf7;
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  text-align: center;
}

.odds-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  color: #8b96b5;
  margin-bottom: 0.2rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.odds-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
}

.odds-note {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.62rem;
  color: #a0aabf;
  line-height: 1.4;
  cursor: help;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modal action buttons */

.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  padding: 0.85rem 1.4rem 1.1rem;
  border-top: 1px solid #eef1f9;
}

.btn-cancel, .btn-confirm, .btn-reset {
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.btn-reset {
  margin-right: auto;
  background: var(--color-accent-red-dim);
  color: var(--color-accent-red);
  border: 1px solid #fecaca;
}

.btn-reset:hover { background: #fecaca; }

.btn-cancel {
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.btn-cancel:hover { background: #e4eaf7; }

.btn-confirm {
  background: var(--color-primary-grad);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26, 86, 219, 0.25);
}

.btn-confirm:hover {
  box-shadow: 0 4px 14px rgba(26, 86, 219, 0.35);
}

/* ── Main content area (wraps groups + KO views) ── */

#main-content {
  flex: 1;
  min-width: 0;
}

#view-groups {
  /* groups-grid is inside here; nothing special needed */
}

/* ── Knockout stage views ── */

#view-r32, #view-r16 {
  padding: 1.5rem 1.5rem 1.5rem 0;
}

.ko-stage-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-text);
  margin-bottom: 1.25rem;
}

.bracket-placeholder {
  border: 2px dashed var(--color-border-2);
  border-radius: 10px;
  padding: 4rem 2rem;
  text-align: center;
  color: #8b96b5;
  font-size: 0.88rem;
  font-weight: 500;
  background: var(--color-surface-2);
}

.ko-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  gap: 1rem;
}

.btn-ko-back {
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  border: 1.5px solid var(--color-border-2);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.btn-ko-back:hover {
  background: var(--color-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-ko-next {
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  border: none;
  background: var(--color-primary-grad);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(26, 86, 219, 0.25);
  transition: box-shadow 0.15s, opacity 0.15s;
}

.btn-ko-next:hover:not(:disabled) {
  box-shadow: 0 4px 14px rgba(26, 86, 219, 0.35);
}

.btn-ko-next:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* ── SVG bracket ── */

.bracket-svg {
  display: block;
  overflow: visible;
  margin: 0 auto;
}

/* Modal body scroll wrapper — sits between header and actions, scrolls if content is tall */
.modal-body-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

/* Allow horizontal scroll for large bracket SVGs — vertical falls through to page scroll */
#view-r32 {
  overflow-x: auto;
}

/* R16 scroll: allow both axes; height constrained by page layout so vertical scroll works */
.bracket-scroll-wrapper {
  overflow: auto;
  width: 100%;
  /* cap height so the nav row below is always reachable — page scrolls the rest */
  max-height: calc(100vh - 220px);
  display: flex;
  justify-content: center;
  /* prevent centering from hiding left edge when content overflows */
  justify-content: safe center;
}

.bracket-node {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(26, 86, 219, 0.07);
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  transition: box-shadow 0.15s;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

.bracket-node:hover {
  box-shadow: 0 4px 16px rgba(26, 86, 219, 0.16);
}

.bn-badge {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--color-border-2);
  letter-spacing: 0.04em;
  pointer-events: none;
}

.bn-team {
  padding: 0 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text);
  height: 33px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 3px solid transparent;
}

.bn-team.bn-placeholder {
  font-style: italic;
  color: var(--color-text-faint);
  font-weight: 400;
}

.bn-divider {
  height: 1px;
  background: #eef1f9;
  flex-shrink: 0;
}

.bn-team.bn-winner {
  background: #f0fdf4;
  border-left-color: #16a34a;
  color: #14532d;
  font-weight: 700;
}

.bn-team.bn-loser {
  opacity: 0.45;
}

.bn-team-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bn-score {
  flex: 0 0 auto;
  margin-left: 6px;
  padding-left: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: inherit;
}

.bn-pen {
  font-size: 0.72em;
  font-weight: 600;
  color: #64748b;
}

/* ── Vertical bracket-column winner node ── */

.bv-winner-node {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: var(--color-text-faint);
  background: var(--color-surface-2);
  border: 1.5px solid var(--color-border-2);
  border-radius: 5px;
  letter-spacing: 0.04em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bv-winner-resolved {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
  font-weight: 800;
}

/* ── Settings modal ── */

.settings-modal-card {
  max-width: 600px;
  width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-body {
  padding: 1rem 1.4rem 0.25rem;
}

.settings-hint {
  font-size: 0.75rem;
  font-style: italic;
  color: #8b96b5;
  margin-bottom: 1rem;
  line-height: 1.45;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.settings-label {
  flex: 0 0 80px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}


.settings-select,
.settings-input {
  flex: 1;
  padding: 0.45rem 0.65rem;
  border: 1.5px solid var(--color-border-2);
  border-radius: 7px;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  transition: border-color 0.15s;
}

.settings-select:focus,
.settings-input:focus {
  border-color: var(--color-primary);
}

.settings-actions {
  justify-content: flex-end;
  gap: 0.6rem;
}

.settings-test-btn {
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  border: 1.5px solid var(--color-primary);
  background: transparent;
  color: var(--color-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.settings-test-btn:hover:not(:disabled) {
  background: var(--color-primary-hover-bg);
}

.settings-row--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}

.settings-row--stacked .settings-label {
  flex: none;
}

.settings-optional {
  font-weight: 400;
  color: #8b96b5;
}

.settings-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.45rem 0.65rem;
  border: 1.5px solid var(--color-border-2);
  border-radius: 7px;
  font-size: 0.82rem;
  font-family: 'Courier New', Courier, monospace;
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
  line-height: 1.5;
}

.settings-textarea:focus {
  border-color: var(--color-primary);
}

.settings-hint--textarea {
  margin-bottom: 0;
}

/* Warning note in Settings modal (localStorage key risk) */
.settings-hint--warning {
  color: #c8922a;
  background: rgba(200, 146, 42, 0.08);
  border-left: 3px solid #c8922a;
  padding: 0.45rem 0.65rem;
  border-radius: 3px;
  margin-bottom: 1rem;
}

.settings-test-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* ── KO match result modal ── */

.ko-modal-card {
  max-width: 520px;
}

.ko-meta-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.4rem 0;
  font-size: 0.75rem;
  color: #8b96b5;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.ko-meta-sep { opacity: 0.5; }

.ko-section {
  padding: 0.75rem 1.4rem 0;
}

.ko-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8b96b5;
  margin-bottom: 0.1rem;
}

.ko-section-sublabel {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-style: italic;
}

/* ET / Pen sections expand in — hidden by default until step triggers */
.ko-section-expandable {
  overflow: hidden;
  animation: ko-expand 0.2s ease;
}

.ko-section-hidden {
  display: none;
}

@keyframes ko-expand {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

.ko-inline-error {
  font-size: 0.72rem;
  color: var(--color-accent-red);
  font-weight: 600;
  min-height: 1.1em;
  padding: 0.15rem 0 0.1rem;
}


/* Wider input for penalty scores (can be 2 digits) */
.ko-pen-input {
  width: 52px;
}

/* ── Predict button row ── */

.modal-predict-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0 1.4rem 0.75rem;
}

.btn-predict {
  flex-shrink: 0;
  padding: 0.38rem 0.9rem;
  border-radius: 7px;
  border: 1.5px solid var(--color-accent-purple);
  background: transparent;
  color: var(--color-accent-purple);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-predict:hover:not(:disabled) {
  background: var(--color-accent-purple);
  color: #fff;
}

.btn-predict:disabled {
  opacity: 0.6;
  cursor: wait;
}

.modal-predict-status {
  flex: 1;
  font-size: 0.72rem;
  font-style: italic;
  color: #6b7280;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  max-height: 2.6em;
  cursor: pointer;
  transition: max-height 0.2s ease;
}

.modal-predict-status.expanded {
  -webkit-line-clamp: unset;
  max-height: 30em;
  overflow: auto;
}

.modal-predict-status[data-has-content="true"]::after {
  content: " [+]";
  font-style: normal;
  color: var(--color-primary);
  font-weight: 700;
}

.modal-predict-status.expanded[data-has-content="true"]::after {
  content: " [−]";
}

/* ── Actual result button ── */
.btn-use-actual {
  flex-shrink: 0;
  padding: 0.38rem 0.9rem;
  border-radius: 7px;
  border: 1.5px solid var(--color-success);
  background: transparent;
  color: var(--color-success);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-use-actual:hover {
  background: var(--color-success);
  color: #fff;
}

/* ── Divergence banner ── */
.modal-diverge-banner {
  margin: 0 1.4rem 0.5rem;
  padding: 0.3rem 0.65rem;
  border-radius: 5px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: var(--color-warning);
  font-size: 0.72rem;
  font-weight: 600;
}

/* ── Match card actual indicator ── */
.match-actual-indicator {
  margin-left: 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  vertical-align: middle;
}

.match-actual-match {
  color: var(--color-success);
}

.match-actual-diverge {
  color: var(--color-accent-red);
}

/* Confidence headline: bold, coloured via inline style set by JS */
.predict-status-headline {
  font-style: normal;
  font-weight: 700;
  font-size: 0.74rem;
}

/* Reasoning text after the headline */
.predict-status-reasoning {
  font-style: italic;
  color: #6b7280;
}

/* ── Batch predict buttons ── */

/* Full-width button below the match list inside the panel */
.btn-predict-panel {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.45rem 0;
  text-align: center;
}

/* Title row for R32 — title left, predict button right.
   max-width matches the R32 bracket SVG width (4*300 + 3*72 = 1416) so the
   title's left edge aligns with the first bracket column. */
.ko-stage-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 auto 1.25rem;
  max-width: 1416px;
  width: 100%;
}

.ko-stage-title-row .ko-stage-title {
  margin-bottom: 0;
}

/* Row of 4 batch predict buttons above the R16 bracket.
   max-width matches R16 tree SVG width so the buttons line up with the bracket. */
.ko-batch-row {
  display: flex;
  gap: 0.5rem;
  margin: 0 auto 1rem;
  max-width: 1284px;
  width: 100%;
  flex-wrap: wrap;
}

#view-r16 > .ko-stage-title {
  max-width: 1284px;
  margin: 0 auto 1rem;
  width: 100%;
}

.ko-batch-row .btn-predict {
  flex: 1 1 auto;
  text-align: center;
}

.btn-predict-batch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: #c5cfe8;
  color: #94a3b8;
}

.btn-predict-batch.btn-predict-loading:disabled {
  cursor: wait;
  opacity: 0.75;
  color: var(--color-accent-purple);
  border-color: var(--color-accent-purple);
}

/* ── Responsive ── */

/* ── Qualifier banner ── */

#qualifier-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  margin-bottom: 1.1rem;
  /* span all columns in the groups CSS grid */
  grid-column: 1 / -1;
}

.qualifier-banner-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: #166534;  /* dark green on green-tinted banner — keep for contrast */
}

.qualifier-banner-next {
  flex-shrink: 0;
  padding: 0.4rem 1rem;
  background: var(--color-success);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.qualifier-banner-next:hover {
  background: #15803d;
}

/* ── Group table row qualification highlights ── */

tbody tr.row-qualified-top {
  border-left: 3px solid var(--color-success);
}

tbody tr.row-qualified-third {
  border-left: 3px solid #ca8a04;
}

tbody tr.row-eliminated {
  opacity: 0.55;
}

@media (max-width: 1300px) {
  #groups-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1000px) {
  #matches-panel {
    width: 260px;
  }
  #groups-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  #page-layout {
    flex-direction: column;
    padding: 1rem;
  }
  #matches-panel {
    width: 100%;
    margin-right: 0;
    margin-bottom: 1rem;
    border-radius: 10px;
    align-self: auto;
  }
  #matches-panel.panel-collapsed {
    width: 100%;
    height: 0;
    opacity: 0;
  }
  /* on mobile the strip doesn't make sense — hide it */
  #page-layout.panel-is-collapsed .panel-reopen {
    display: none;
  }
  #groups-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem;
  }
  header h1 {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  #groups-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Phase 4.2 — Multi-agent settings modal ── */

.agents-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  margin-top: 0.25rem;
}

#agents-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.agent-row {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.agent-row-top,
.agent-row-bottom {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.agent-enabled-wrap {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.agent-enabled {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.agent-name {
  flex: 1 1 120px;
  min-width: 80px;
}

.agent-provider {
  flex: 0 0 auto;
  min-width: 130px;
}

.agent-model {
  flex: 1 1 180px;
  min-width: 140px;
}

.agent-apikey {
  flex: 1 1 200px;
  min-width: 140px;
}

.agent-proxy-note {
  font-size: 0.7rem;
  font-style: italic;
  color: #8b96b5;
  flex: 1;
}

.agent-test-btn {
  padding: 0.32rem 0.65rem;
  border-radius: 6px;
  border: 1.5px solid var(--color-primary);
  background: transparent;
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.agent-test-btn:hover:not(:disabled) {
  background: var(--color-primary-hover-bg);
}

.agent-test-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-agent-delete {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #fecaca;
  background: var(--color-accent-red-dim);
  color: var(--color-accent-red);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s;
}

.btn-agent-delete:hover {
  background: #fecaca;
}


.btn-add-agent {
  padding: 0.35rem 0.9rem;
  border-radius: 7px;
  border: 1.5px dashed var(--color-primary);
  background: transparent;
  color: var(--color-primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  display: inline-block;
}

.btn-add-agent:hover:not(:disabled) {
  background: var(--color-bg);
}

.btn-add-agent:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Show-all picks panel ── */

.show-all-picks {
  margin: 0 1.4rem 0.75rem;
  background: var(--color-surface-2);
  border: 1px solid #e4eaf7;
  border-radius: 8px;
  padding: 0.55rem 0.75rem 0.4rem;
}

.show-all-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b96b5;
  margin-bottom: 0.4rem;
}

.show-all-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-top: 1px solid #eef1f9;
}

.show-all-row:first-of-type {
  border-top: none;
}

.show-all-agent {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  flex: 0 0 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.show-all-score {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text);
  flex: 1;
  font-variant-numeric: tabular-nums;
}

/* Confidence badge in show-all rows — colour set inline by JS */
.show-all-conf {
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  margin-right: 0.15rem;
}

.btn-apply-pick {
  padding: 0.18rem 0.55rem;
  border-radius: 5px;
  border: 1px solid var(--color-primary);
  background: transparent;
  color: var(--color-primary);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

.btn-apply-pick:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ── Squad popover ── */

.squad-popover {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(15, 23, 60, 0.22);
  width: 340px;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 1100;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  animation: modal-in 0.15s ease;
}

.squad-popover-header {
  background: var(--color-primary-grad);
  padding: 0.6rem 0.85rem;
  border-radius: 9px 9px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.squad-popover-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}

.squad-popover-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.1rem;
  transition: color 0.15s;
}

.squad-popover-close:hover { color: #fff; }

.squad-popover-meta {
  padding: 0.55rem 0.85rem 0.45rem;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  border-bottom: 1px solid #eef1f9;
}

.squad-popover-meta span {
  display: block;
  margin-bottom: 0.2rem;
}


.squad-popover-section-title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8b96b5;
  padding: 0.5rem 0.85rem 0.2rem;
}


.squad-popover-result {
  padding: 0.25rem 0.85rem;
  font-size: 0.70rem;
  color: #374151;
  border-bottom: 1px solid #f4f6fc;
  font-variant-numeric: tabular-nums;
}

.squad-popover-result:last-child { border-bottom: none; }

.player-popover-injury {
  margin: 0.45rem 0.85rem 0.25rem;
  padding: 0.4rem 0.55rem;
  font-family: inherit;
  font-size: 0.70rem;
  color: var(--color-accent-red-text);
  background: var(--color-accent-red-dim);
  border-left: 3px solid #f87171;
  border-radius: 4px;
  line-height: 1.35;
}

.player-popover-injury strong {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.squad-popover-empty {
  padding: 0.9rem 0.85rem;
  font-size: 0.78rem;
  color: #8b96b5;
  font-style: italic;
}

/* Team name in modal is clickable for squad popover */
.modal-team-name.squad-trigger {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.modal-team-name.squad-trigger:hover {
  color: var(--color-primary);
}

/* ── Lineup popover (Phase 4 Step 4) ── */

.lineup-popover {
  width: 320px;
  /* Override the max-height set on .squad-popover so the pitch SVG is never cut off */
  max-height: 92vh;
  overflow-y: auto;
}

.lineup-popover-meta {
  padding: 0.45rem 0.85rem 0.4rem;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  border-bottom: 1px solid #eef1f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lineup-meta-manager {
  font-weight: 600;
  color: var(--color-text);
}

.lineup-popover-pitch {
  padding: 0.55rem 0.55rem 0.65rem;
  display: flex;
  justify-content: center;
  background: #0f5c2e;
}

/* ── Tournament right panel ── */

#tournament-panel {
  flex-shrink: 0;
  width: 310px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px 0 0 10px;
  box-shadow: -2px 0 12px rgba(26, 86, 219, 0.09);
  overflow: hidden;
  transition: width 0.25s ease, opacity 0.2s ease;
  margin-left: 1.5rem;
  align-self: stretch;
}

#tournament-panel.tournament-panel-collapsed {
  width: 0;
  opacity: 0;
  margin-left: 0;
  border: none;
  pointer-events: none;
}

.tournament-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-primary-grad);
  padding: 0.65rem 0.9rem;
}

.tournament-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tournament-refresh-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.45);
  color: #fff;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, opacity 0.15s;
  opacity: 0.8;
}

.tournament-refresh-btn:hover {
  background: rgba(255,255,255,0.18);
  opacity: 1;
}

.tournament-refresh-btn.winners-spinning {
  animation: spin 1s linear infinite;
  opacity: 0.55;
  pointer-events: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#tournament-panel-list.winners-loading {
  opacity: 0.5;
  pointer-events: none;
}

.winners-timestamp {
  font-size: 0.62rem;
  color: var(--color-text-faint);
  text-align: center;
  padding: 0.4rem 0.25rem 0.1rem;
  font-style: italic;
}

.tournament-panel-body {
  padding: 0.75rem;
}

/* Reopen strip for right panel — mirrors left strip but flipped */
.tournament-panel-reopen {
  display: none;
  flex-shrink: 0;
  align-self: stretch;
  width: 28px;
  border-radius: 8px 0 0 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-right: none;
  box-shadow: -2px 0 10px rgba(26, 86, 219, 0.09);
  cursor: pointer;
  color: var(--color-primary);
  margin-left: 1rem;
  transition: background 0.15s;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  user-select: none;
}

.tournament-panel-reopen:hover {
  background: var(--color-bg);
}

/* Show reopen strip when panel is collapsed */
#page-layout.tournament-panel-is-collapsed .tournament-panel-reopen {
  display: flex;
}

#tournament-panel-list {
  overflow-y: auto;
  /* header ~105px + breadcrumb ~42px + panel-header ~40px + round-buttons ~50px + padding ~40px */
  max-height: calc(100vh - 290px);
  margin-top: 0.5rem;
}

/* Tournament list rows */
.tournament-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.25rem;
  border-bottom: 1px solid #f4f6fc;
  font-size: 0.72rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
}

.tournament-row:nth-child(even) {
  background: var(--color-surface-2);
}

.tournament-row:hover {
  background: #edf2ff;
}

.t-rank {
  flex: 0 0 22px;
  text-align: right;
  color: #8b96b5;
  font-weight: 600;
  font-size: 0.65rem;
}

.t-code {
  flex: 0 0 30px;
  font-weight: 700;
  color: var(--color-text-muted);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
}

.t-name {
  flex: 1 1 auto;
  color: var(--color-text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.t-prob {
  flex: 0 0 40px;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.70rem;
}

/* Probability colour tiers */
.t-prob-high   { color: var(--color-success); }
.t-prob-mid    { color: var(--color-primary); }
.t-prob-low    { color: #6b7280; }
.t-prob-vlow   { color: var(--color-border-2); }

.t-odds {
  flex: 0 0 42px;
  text-align: right;
  color: #8b96b5;
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
}

/* Player-specific columns */
.t-player-name {
  flex: 1 1 auto;
  color: var(--color-text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.t-team-code {
  flex: 0 0 28px;
  font-size: 0.62rem;
  font-weight: 700;
  color: #8b96b5;
  letter-spacing: 0.04em;
}


@media (max-width: 1100px) {
  #tournament-panel {
    width: 0;
    opacity: 0;
    margin-left: 0;
    border: none;
    pointer-events: none;
  }
  .tournament-panel-reopen {
    display: none !important;
  }
}

/* ── Country flags ── */

.team-flag {
  display: inline-block;
  vertical-align: middle;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
  margin-right: 6px;
  flex-shrink: 0;
  object-fit: cover;
}

/* Squad popover header uses w40 flags — keep them from pushing text down */
.squad-popover-title .team-flag {
  vertical-align: middle;
  width: 40px;
  height: 30px;
  margin-right: 8px;
}

/* Inside bracket nodes flags sit in tight rows — reduce right margin */
.bn-team .team-flag {
  margin-right: 4px;
}

/* Inside match cards .match-teams is a single centred span — prevent wrapping */
.match-teams .team-flag {
  margin-right: 3px;
  margin-left: 2px;
  vertical-align: -2px;
}

/* ── Data Freshness ── */

/* Shared pill — used as age badge and inline status indicator */
.freshness-pill {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', Courier, monospace;
  line-height: 1.4;
  white-space: nowrap;
}

.freshness-pill-fresh   { background: #dcfce7; color: #15803d; }
.freshness-pill-stale   { background: #fef3c7; color: #a16207; }
.freshness-pill-unknown { background: #f3f4f6; color: #6b7280; }

/* Small badge appended to Tournament panel title */
.freshness-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0.1rem 0.4rem;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', Courier, monospace;
  vertical-align: 1px;
  cursor: help;
  line-height: 1.4;
  white-space: nowrap;
}

.freshness-badge--fresh   { background: rgba(220, 252, 231, 0.2); color: rgba(255,255,255,0.85); }
.freshness-badge--stale   { background: #fef3c7; color: #a16207; }
.freshness-badge--unknown { background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.65); }

/* Inline age appended to odds-note in the match modal */
.freshness-inline {
  font-size: 0.60rem;
  font-variant-numeric: tabular-nums;
  color: #a0aabf;
}

.freshness-inline.freshness-stale {
  color: #a16207;
}

/* Header-level data status pill — sits in .header-actions */
.data-freshness-pill {
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1.5px solid rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.12);
  color: #fff;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.data-freshness-pill:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.75);
}

.data-freshness-pill--stale {
  border-color: #fde68a;
  background: rgba(254, 243, 199, 0.18);
}

.data-freshness-pill--stale:hover {
  background: rgba(254, 243, 199, 0.30);
}

/* Freshness modal */
.freshness-modal-card {
  max-width: 560px;
}

.fd-body {
  padding: 1rem 1.4rem 0.5rem;
}

.fd-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.fd-th {
  padding: 0.4rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b96b5;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.fd-cell {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #f4f6fc;
  vertical-align: middle;
}

.fd-file {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'Courier New', Courier, monospace;
  color: var(--color-text);
}

.fd-ts {
  font-size: 0.70rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.fd-age {
  white-space: nowrap;
}

.fd-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b96b5;
  margin-bottom: 0.6rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--color-border);
}

.fd-refresh-instructions {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.fd-refresh-instructions p {
  margin-bottom: 0.6rem;
}

.fd-refresh-instructions ol {
  padding-left: 1.2rem;
  margin-bottom: 0.6rem;
}

.fd-refresh-instructions li {
  margin-bottom: 0.3rem;
}

.fd-refresh-instructions code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.72rem;
  background: var(--color-bg);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  border: 1px solid var(--color-border);
}

.fd-note {
  font-size: 0.70rem;
  color: var(--color-text-faint);
  font-style: italic;
  margin-bottom: 0 !important;
}

/* ── Tournament panel — Stats tab ── */

/* Allow 3 tab buttons to wrap if they don't fit */
.tournament-tabs {
  flex-wrap: wrap;
  row-gap: 0.35rem;
}

.stats-placeholder {
  font-size: 0.78rem;
  color: var(--color-text-faint);
  font-style: italic;
  padding: 1rem 0.25rem;
  text-align: center;
}

.stats-section {
  margin-bottom: 0.6rem;
  border-bottom: 1px solid #f0f2f9;
  padding-bottom: 0.5rem;
}

.stats-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.stats-section-title {
  font-size: 0.60rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: 0.35rem;
}

.stats-progress-label {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  margin-bottom: 0.3rem;
}

.stats-progress-track {
  height: 7px;
  background: #e4eaf7;
  border-radius: 4px;
  overflow: hidden;
}

.stats-progress-fill {
  height: 100%;
  background: var(--color-primary-grad);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.stats-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.72rem;
  padding: 0.18rem 0;
  font-variant-numeric: tabular-nums;
}

.stats-subrow {
  font-size: 0.65rem;
  color: var(--color-text-faint);
  font-style: italic;
  padding: 0 0 0.25rem 0.1rem;
  margin-top: -0.1rem;
}

.stats-label {
  flex: 0 0 auto;
  color: var(--color-text-muted);
  font-weight: 600;
  white-space: nowrap;
  min-width: 68px;
}

.stats-value {
  flex: 1 1 auto;
  color: var(--color-text);
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-rank-name {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  color: var(--color-text-muted);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  min-width: 52px;
}

.stats-tag {
  font-size: 0.62rem;
  font-weight: 600;
  color: #8b96b5;
  background: #f0f2f9;
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
  margin-left: 3px;
  white-space: nowrap;
}

.stats-muted {
  font-weight: 400;
  color: var(--color-text-faint);
  font-size: 0.65rem;
}
