.bracket-wrapper {
  position: relative;
}

.bracket-content {
  position: relative;
  display: flex;
  flex-direction: row;
  gap: 32px;
  align-items: stretch;
}

.bracket-lines {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 0;
}

.bracket-lines path {
  fill: none;
  stroke: #bbb;
  stroke-width: 2;
  stroke-dasharray: 4 3;
}

.bracket-container {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 20px 0 20px 15px;
  user-select: none;
  scrollbar-width: auto;
  scrollbar-color: #888 #e0e0e0;
}

/* Scrollbar styling */
.bracket-container::-webkit-scrollbar {
  height: 12px;
}

.bracket-container::-webkit-scrollbar-track {
  background: #e0e0e0;
  border-radius: 6px;
}

.bracket-container::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 6px;
}

.bracket-container::-webkit-scrollbar-thumb:hover {
  background: #666;
}

/* Sticky scrollbar container */
.sticky-scrollbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 16px;
  background: #e0e0e0;
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 100;
  display: none;
  scrollbar-width: auto;
  scrollbar-color: #888 #e0e0e0;
}

.scroll-hint {
  position: fixed;
  right: 32px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  opacity: 0;
  z-index: 200;
  pointer-events: none;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.02em;
  user-select: none;
  white-space: nowrap;
  transition: opacity 0.5s ease-out, transform 0.5s ease-out, top 0.15s ease-out;
}

.scroll-hint.show {
  opacity: 1;
  transform: translateY(-50%);
}

.scroll-hint.hide {
  opacity: 0;
}

.sticky-scrollbar.visible {
  display: block;
}

.sticky-scrollbar::-webkit-scrollbar {
  height: 12px;
}

.sticky-scrollbar::-webkit-scrollbar-track {
  background: #e0e0e0;
}

.sticky-scrollbar::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 6px;
}

.sticky-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #666;
}

.sticky-scrollbar-inner {
  height: 1px;
}

/* Hide original scrollbar when sticky is active */
.bracket-container.hide-scrollbar {
  scrollbar-width: none;
}

.bracket-container.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

.bracket-container.scrollable {
  cursor: grab;
}

.bracket-container.scrollable:active {
  cursor: grabbing;
}

.bracket-round {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-width: 180px;
}

.round-header {
  text-align: center;
  margin-bottom: 24px;
  padding: 6px 10px;
  background: #e8e8e8;
}

.round-title {
  font-weight: bold;
  font-size: 0.85rem;
  color: #555;
  line-height: 1.1;
}

.round-date {
  font-size: 0.8rem;
  color: #777;
  line-height: 1.1;
}

/* Special styling for Final and Winner headers */
.bracket-final .round-header,
.bracket-winner .round-header {
  background: #e8e8e8;
}

.round-matches {
  display: grid;
  grid-template-rows: var(--grid-template);
  gap: 24px;
  flex: 1;
  align-items: center;
}

/*
 * Bracket alignment using CSS Grid rows.
 * Each match has inline grid-row placement computed from the bracket tree.
 * First-round matches each occupy 1 row.
 * Later-round matches span the rows of their transitive feeders,
 * and align-self: center keeps them vertically centred within the span.
 */

.round-matches>.match-box {
  align-self: center;
}

/* Winner column */
.bracket-winner .round-matches {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  flex: 1;
  overflow: hidden;
}

.match-box {
  background: #fff;
  overflow: visible;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid #ddd;
  position: relative;
}

.match-id {
  position: absolute;
  top: -8px;
  left: -8px;
  font-size: 0.65rem;
  color: #1565c0;
  font-weight: 600;
  background: #e3f2fd;
  padding: 2px 8px;
  border-radius: 15px;
  z-index: 10;
}

.match-teams {
  display: flex;
  flex-direction: column;
  padding: 8px 4px 4px 4px;
}

.team {
  display: flex;
  align-items: center;
  padding: 2px 10px 2px 6px;
  gap: 3px;
  background: #fff;
  color: #222;
}

.team.loser {
  color: #999;
}

.team:last-child {
  margin-bottom: 6px;
}

.team.winner {
  background: rgba(198, 239, 206, 0.1);
  font-weight: normal;
  color: #222;
}

.team .seed {
  font-size: 0.75rem;
  color: #888;
  min-width: 28px;
}

.match-teams.no-seeds .seed {
  display: none;
}

.team .name {
  flex: 1;
  font-size: 0.85rem;
  white-space: nowrap;
}

.team .name.pending {
  color: #888;
}

.team .score {
  font-weight: bold;
  font-size: 0.85rem;
  min-width: 20px;
  text-align: right;
  color: #999;
}

.team.winner .score {
  color: #333;
}

.match-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  background: #f5f5f5;
  border-top: 1px solid #ddd;
  font-size: 0.75rem;
  color: #666;
}

.match-notes {
  padding: 4px 10px;
  background: #fff9e6;
  font-size: 0.7rem;
  color: #996600;
  font-style: italic;
}

.winner-box {
  background: linear-gradient(135deg, #f9e866 0%, #d4a017 25%, #f9e866 50%, #d4a017 75%, #f9e866 100%);
  background-size: 200% 200%;
  padding: 12px 20px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 15px rgba(212, 160, 23, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.1s ease-out, box-shadow 0.3s ease;
  cursor: default;
}

.winner-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(105deg,
      transparent 40%,
      rgba(255, 255, 255, 0.2) 45%,
      rgba(255, 255, 255, 0.35) 50%,
      rgba(255, 255, 255, 0.2) 55%,
      transparent 60%);
  background-size: 150% 100%;
  background-position: 150% 0;
  pointer-events: none;
  transition: background-position 0.8s ease;
}

.winner-box:hover::before {
  background-position: -50% 0;
}

.winner-box:hover {
  box-shadow:
    0 6px 20px rgba(212, 160, 23, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.champion-name {
  font-size: 1rem;
  font-weight: bold;
  color: #000;
  text-shadow:
    -1px -1px 0 rgba(255, 255, 255, 0.4),
    1px 1px 0 rgba(0, 0, 0, 0.3),
    2px 2px 2px rgba(0, 0, 0, 0.15);
}

.champion-pending {
  font-size: 1rem;
  color: #5c2a00;
  font-weight: bold;
  text-shadow:
    -1px -1px 0 rgba(255, 255, 255, 0.5),
    1px 1px 0 rgba(0, 0, 0, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .team .name {
    font-size: 0.8rem;
  }
}