body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Verdana, sans-serif;
  background-color: #f0fff4;
  color: #333;
  transition: 0.4s;
}
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #b3e5fc;
  padding: 1rem 2rem;
}
.logo {
  font-size: 1.5rem;
  color: #0277bd;
  font-weight: bold;
}
.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
}
.nav-links a {
  text-decoration: none;
  color: #0277bd;
  font-weight: 500;
}
.nav-links a:hover {
  color: #388e3c;
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.8rem;
}
.theme-toggle {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
}
main {
  padding: 2rem;
  min-height: 70vh;
}
footer {
  background: #c8e6c9;
  text-align: center;
  padding: 1rem;
}
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin: 12px 0;
}
.alert.error {
  background: #ffebee;
  color: #b71c1c;
  border: 1px solid #ffcdd2;
}
.alert.success {
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #c8e6c9;
}
fieldset {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid #ccc;
  border-radius: 5px;
}
.tabs-container {
  position: relative;
  margin-bottom: 1rem;
}

.tabs-mobile-header {
  display: none;
  padding: 12px 16px;
  background: #b3e5fc;
  border-radius: 6px;
  cursor: pointer;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #01579b;
  border: 1px solid #81d4fa;
  user-select: none;
}

.dropdown-arrow {
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid #ccc;
  flex-wrap: wrap;
}

.tabs a {
  padding: 8px 12px;
  text-decoration: none;
  border-radius: 6px 6px 0 0;
  background: #e1f5fe;
  color: #01579b;
  white-space: nowrap;
  flex-shrink: 0;
}

.tabs a.active {
  background: #b3e5fc;
  font-weight: 600;
}

/* Tournament selector styling to match tabs */
#tselect {
  padding: 8px 12px;
  border: 1px solid #81d4fa;
  border-radius: 6px;
  background: #e1f5fe;
  color: #01579b;
  font-weight: 500;
  font-size: inherit;
  cursor: pointer;
  min-width: 200px;
}

#tselect:focus {
  outline: none;
  background: #b3e5fc;
  border-color: #4fc3f7;
  box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.2);
}

#tselect:hover {
  background: #b3e5fc;
  border-color: #4fc3f7;
}

/* Mobile styles */
@media (max-width: 768px) {
  .tabs-mobile-header {
    display: flex;
  }

  .tabs {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    flex-direction: column;
    gap: 0;
    border-bottom: none;
  }

  .tabs.mobile-open {
    display: flex;
  }

  .dropdown-arrow {
    transition: transform 0.2s ease;
  }

  .tabs a {
    border-radius: 0;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
  }

  .tabs a:last-child {
    border-bottom: none;
    border-radius: 0 0 6px 6px;
  }

  .tabs a:first-child {
    border-radius: 0;
  }

  body.dark .tabs {
    background: #1a1a1a;
    border-color: #333;
  }

  body.dark .tabs-mobile-header {
    background: #2a2a2a;
    border-color: #444;
    color: #80d8ff;
  }

  body.dark .tabs a {
    background: #1a1a1a;
    color: #80d8ff;
    border-bottom-color: #333;
  }

  body.dark .tabs a.active {
    background: #2a2a2a;
  }
}
body.dark {
  background: #0b0b0b;
  color: #f0f0f0;
}
body.dark .navbar {
  background: #111;
}
body.dark .logo {
  color: #80d8ff;
}
body.dark .nav-links a {
  color: #80d8ff;
}

/* Group Table Styles */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
}

/* Fixed column widths for consistent table sizing */
.table th:nth-child(1),
.table td:nth-child(1) {
  width: 8%;
  text-align: center;
}

.table th:nth-child(2),
.table td:nth-child(2) {
  width: 40%;
  min-width: 120px;
}

.table th:nth-child(3),
.table td:nth-child(3) {
  width: 10%;
  text-align: center;
}

.table th:nth-child(4),
.table td:nth-child(4) {
  width: 10%;
  text-align: center;
}

.table th:nth-child(5),
.table td:nth-child(5) {
  width: 15%;
  text-align: center;
}

.table th:nth-child(6),
.table td:nth-child(6) {
  width: 17%;
  text-align: center;
}

.table th {
  background: #f5f5f5;
  font-weight: 600;
  color: #333;
}

.table tbody tr:hover {
  background: #f9f9f9;
}

.table caption {
  font-size: 1.1rem;
  font-weight: bold;
  margin: 1rem 0 0.5rem 0;
  text-align: left;
}

/* Dark mode support */
body.dark .table {
  background: #1a1a1a;
}

body.dark .table th {
  background: #2a2a2a;
  color: #f0f0f0;
}

body.dark .table td {
  color: #f0f0f0;
  border-bottom-color: #333;
}

body.dark .table tbody tr:hover {
  background: #2a2a2a;
}

/* Group Table Caption Styles */
.table-caption {
  font-weight: bold;
  margin: 0.5rem 0;
  text-align: left;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }
  .nav-links {
    display: none;
    position: absolute;
    left: 0;
    top: 64px;
    background: #b3e5fc;
    width: 100%;
    flex-direction: column;
    padding: 1rem 0;
    border-top: 1px solid #ccc;
  }
  .nav-links.active {
    display: flex;
  }
  body.dark .nav-links {
    background: #111;
  }

  .table-caption {
    font-size: 1rem;
    margin: 0.3rem 0;
  }

  /* Mobile responsive column widths */
  .table th:nth-child(2),
  .table td:nth-child(2) {
    min-width: 100px;
  }

  /* Mobile-specific table overrides */
  .table th,
  .table td {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  .table-caption {
    font-size: 1rem;
    margin: 0.3rem 0;
  }

  /* Mobile responsive column widths */
  .table th:nth-child(2),
  .table td:nth-child(2) {
    min-width: 100px;
  }
}

/* Tournament Bracket Styles */
.tournament-bracket {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  padding: 2rem 1rem;
}

.bracket-container {
  display: flex;
  gap: 4rem;
  min-width: fit-content;
  align-items: flex-start;
  position: relative;
}

.tournament-round {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-width: 200px;
}

.round-label {
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  color: #333;
  text-align: center;
  width: 100%;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #b3e5fc;
}

.match-container {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  align-items: center;
  position: relative;
  justify-content: center;
}

.match {
  background: white;
  border: 2px solid #e1f5fe;
  border-radius: 8px;
  width: 180px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.match:hover {
  border-color: #81d4fa;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.team {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-weight: 500;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  position: relative;
}

.team.bottom {
  border-bottom: none;
}

.team:empty::after {
  content: "TBD";
  color: #999;
  font-style: italic;
}

.team.winner {
  font-weight: bold;
  background: #e8f5e9;
  color: #2e7d32;
}

.team.bye {
  font-style: italic;
  color: #999;
}

.champion-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.champion-slot {
  width: 180px;
  height: 80px;
  background: linear-gradient(135deg, #ffd700, #ffb000);
  border: 3px solid #ff8f00;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.1rem;
  color: #333;
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
  position: relative;
}

.champion-slot::before {
  content: "🏆";
  font-size: 1.5rem;
  margin-right: 0.5rem;
}

.champion-slot:empty::after {
  content: "🏆 Champion";
  color: #333;
}

/* Dark mode styles */
body.dark .tournament-bracket {
  background: transparent;
}

body.dark .round-label {
  color: #f0f0f0;
  border-bottom-color: #444;
}

body.dark .match {
  background: #2a2a2a;
  border-color: #444;
}

body.dark .match:hover {
  border-color: #666;
}

body.dark .team {
  background: #333;
  border-bottom-color: #555;
  color: #f0f0f0;
}

body.dark .team:empty::after {
  color: #888;
}

body.dark .tournament-round:not(:last-child)::after,
body.dark
  .tournament-round:not(:last-child):not(:first-child)
  .match-container::before,
body.dark
  .tournament-round:not(:last-child):not(:first-child)
  .match-container::after,
body.dark .tournament-round:not(:last-child) .match::after {
  background: #555;
}

/* Mobile styles */
@media (max-width: 768px) {
  .bracket-container {
    gap: 2.5rem;
  }

  .tournament-round {
    min-width: 150px;
  }

  .match {
    width: 180px;
  }

  .team {
    height: 35px;
    padding: 0 0.75rem;
    font-size: 0.9rem;
  }

  .champion-slot {
    width: 140px;
    height: 70px;
    font-size: 1rem;
  }

  .round-label {
    font-size: 1rem;
  }

  .tournament-round:not(:last-child)::after {
    right: -1.25rem;
    width: 1.25rem;
  }

  .tournament-round:not(:last-child):not(:first-child)::before {
    left: -1.25rem;
  }
}
