/* Standings tiebreaker info tooltips */
.tiebreaker-hint {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 6px;
}

.tiebreaker-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.tiebreaker-btn:hover,
.tiebreaker-hint.open .tiebreaker-btn,
.tiebreaker-hint:focus-within .tiebreaker-btn {
  color: var(--accent);
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.1);
}

.tiebreaker-tip {
  display: none;
  position: absolute;
  z-index: 50;
  width: min(300px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  text-align: left;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  font-weight: 400;
}

.tiebreaker-tip::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.tiebreaker-hint.open .tiebreaker-tip,
.tiebreaker-hint:hover .tiebreaker-tip,
.tiebreaker-hint:focus-within .tiebreaker-tip {
  display: block;
}

/* Desktop: tooltip to the right of the button */
@media (min-width: 641px) {
  .tiebreaker-tip {
    left: calc(100% + 12px);
    top: 50%;
    right: auto;
    bottom: auto;
    transform: translateY(-50%);
    width: min(300px, 36vw);
  }

  .tiebreaker-tip::after {
    left: -6px;
    top: 50%;
    right: auto;
    bottom: auto;
    border-right: none;
    border-top: none;
    transform: translateY(-50%) rotate(45deg);
  }

  /* Flip left when near right edge of viewport */
  .tiebreaker-hint.tiebreaker-hint--left .tiebreaker-tip {
    left: auto;
    right: calc(100% + 12px);
    transform: translateY(-50%);
  }

  .tiebreaker-hint.tiebreaker-hint--left .tiebreaker-tip::after {
    left: auto;
    right: -6px;
    transform: translateY(-50%) rotate(-135deg);
  }
}

/* Mobile: tooltip above or below the button */
@media (max-width: 640px) {
  .tiebreaker-hint.tiebreaker-hint--above .tiebreaker-tip {
    left: 50%;
    right: auto;
    bottom: calc(100% + 12px);
    top: auto;
    transform: translateX(-50%);
  }

  .tiebreaker-hint.tiebreaker-hint--above .tiebreaker-tip::after {
    left: 50%;
    right: auto;
    bottom: -6px;
    top: auto;
    border-right: none;
    border-bottom: none;
    transform: translateX(-50%) rotate(45deg);
  }

  .tiebreaker-hint.tiebreaker-hint--below .tiebreaker-tip {
    left: 50%;
    right: auto;
    top: calc(100% + 12px);
    bottom: auto;
    transform: translateX(-50%);
  }

  .tiebreaker-hint.tiebreaker-hint--below .tiebreaker-tip::after {
    left: 50%;
    right: auto;
    top: -6px;
    bottom: auto;
    border-right: none;
    border-top: none;
    transform: translateX(-50%) rotate(-135deg);
  }
}

.tiebreaker-tip-title {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 10px;
  line-height: 1.35;
}

.tiebreaker-tip-list {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.tiebreaker-tip-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.tiebreaker-tip-list li:last-child {
  margin-bottom: 0;
}

.tiebreaker-step-num {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.tiebreaker-tip-foot {
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
}

.standings-caption {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
}

.standings-caption .tiebreaker-hint {
  margin-left: 0;
}

@media (hover: none) {
  .tiebreaker-hint:not(.open) .tiebreaker-tip {
    display: none;
  }
}

html[data-theme="light"] .tiebreaker-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .tiebreaker-tip {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .tiebreaker-tip-foot {
  border-top-color: rgba(0, 0, 0, 0.08);
}

@media (prefers-reduced-motion: reduce) {
  .tiebreaker-btn {
    transition: none;
  }
}
