
/* ==================== DARK THEME ==================== */
/* Base */
/* Desktop background image */
@media (min-width: 769px) { 
  body {
    background-color: #0b1220; /* fallback */

    background-image:
      linear-gradient(
        to bottom,
        rgba(11, 18, 32, 0.92),
        rgba(11, 18, 32, 0.85),
        rgba(11, 18, 32, 0.95)
      ),
      url("https://cdn.jsdelivr.net/gh/kindzal/my-assets@master/images/dm3-app-bg.jpg");

    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    background-attachment: fixed;

    animation: bgFadeIn 1.2s cubic-bezier(0.4, 0.0, 0.2, 1) both;   
  }
  .app-container, main {
    background: rgba(17, 24, 39, 0.22);
    backdrop-filter: blur(6px);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  }
  table, .team-card, .bracket-match {
    background-color: rgba(31, 41, 55, 0.95);
  }
}
@keyframes bgFadeIn {
  from {
    background-position: center 40%;
    opacity: 0;
  }
  to {
    background-position: center top;
    opacity: 1;
  }
}
body {
  font-family: 'Open Sans', Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #111827;
  color: #f3f4f6;
  min-height: 100vh;
}
/* Content Wrapper - CENTERED */
.content-wrapper {
  max-width: 1270px;
  margin: 0 auto;
  padding: 0 20px;
}
/* Header - STICKY & CENTERED */
.app-header {
  background-color: #111827; /*#1f2937;*/
  border-bottom: 1px solid #374151;
  padding: 5px;
  margin: 0;
  max-width: 100%;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.app-header-main {
  display: flex;
  align-items: center;
  /*justify-content: center;*/
  gap: 16px;
  max-width: 1211px;
  margin: 0 auto;
  padding: 0 20px;
}
.app-logo {
  max-height: 80px;
  max-width: 140px;
  object-fit: contain;
}
.app-title {
  margin: 0 0 8px 0;
  font-family: 'Roboto', sans-serif;
  font-weight: 700;
  font-size: 1.5em;
  color: #ffffff;
}
.wiki-link {
  display: inline-block;
  padding: 6px 12px;
  font-size: 0.9em;
  font-weight: 600;
  color: #60a5fa;
  text-decoration: none;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.1);
  transition: all 0.2s ease;  
}
.wiki-link:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: #60a5fa;
}
/* Navigation - STICKY & CENTERED */
.app-nav {
  position: sticky;
  top:90px;
  z-index: 90;
  /*background-color: #111827;*/
  padding: 6px 0 6px;
  margin: 0 auto;
  max-width: 1211px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;  
  /*border-bottom: 1px solid #374151;*/
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.app-nav-left {
  justify-content: space-between;  
}
.app-nav button {
  background: #374151;
  color: #d1d5db;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 10px 16px;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.2s ease;
}
.app-nav button:hover {
  background: #4b5563;
  border-color: #6b7280;
  color: #f3f4f6;
}
.app-nav button.active {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
/* Sections */
section {
  display: none;
  margin: 5px auto;
  padding: 0;
}
section.active {
  display: block;
}
.section-title {
  font-family: 'Roboto', sans-serif;
  font-weight: 700;
  font-size: 1.8em;
  color: #ffffff;
  margin-bottom: 20px;
  text-align: center;
}
.loading {
  color: #9ca3af;  
  text-align: center;
}
/* Tables */
table {
  border-collapse: collapse;
  table-layout: auto;
  margin: 16px auto;
  width: 100%;
  max-width: 100%;
  background-color: #1f2937;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
table th {
  white-space: normal;
  line-height: 1.3;
  background: #374151;
  border: none;
  /* border-bottom: 1px solid #4b5563;  */
  padding: 5px;
  color: #d1d5db;
  font-weight: 600;
  text-align: center;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: top;
}

/* Do not uppercase headers in the players ranking table (keep abbreviations intact) */
#players-output table th {
  text-transform: none;
}

/* Also apply same rules for the team view player stats table */
#team-player-stats table th {
  text-transform: none;
}
table td {
  border: none;
  /* border-bottom: 1px solid #374151;  */
  padding: 6px 5px;
  white-space: nowrap;
  color: #f3f4f6;
  text-align: center;
}
table tbody tr {
  background-color: #1f2937;
  transition: background-color 0.15s ease;
}
table tbody tr:nth-child(even) {
  background-color: #1a2332;
}
table tbody tr:hover {
  background-color: #2d3748;
}
table th:nth-child(2), table td:nth-child(2) {
  text-align: left;
}
/* Rank column emphasis */
/* Rank emphasis moved to second column (Rank now column 2) */
#players-output table th:nth-child(2),
#players-output table td:nth-child(2) {
  font-weight: 700;
  text-align: center;
  border-right: 2px solid #3b82f6;
}
#players-output table tbody tr:nth-child(1) td:nth-child(2) {
  color: #fbbf24; /* gold */
}
#players-output table tbody tr:nth-child(2) td:nth-child(2) {
  color: #9ca3af; /* silver-ish */
}
#players-output table tbody tr:nth-child(3) td:nth-child(2) {
  color: #d97706; /* bronze */
}

/* Mirror rank emphasis for team-player-stats (team view) */
#team-player-stats table th:nth-child(2),
#team-player-stats table td:nth-child(2) {
  font-weight: 700;
  text-align: center;
  border-right: 2px solid #3b82f6;
}
#team-player-stats table tbody tr:nth-child(1) td:nth-child(2) {
  color: #fbbf24; /* gold */
}
#team-player-stats table tbody tr:nth-child(2) td:nth-child(2) {
  color: #9ca3af; /* silver-ish */
}
#team-player-stats table tbody tr:nth-child(3) td:nth-child(2) {
  color: #d97706; /* bronze */
}
/* Rank tooltip */
.rank-header {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-direction: column;
  /*gap: 6px;*/
}
.rank-tooltip-icon {
  cursor: pointer;
  font-size: 0.9em;
  color: #60a5fa;
  user-select: none;
}
.rank-tooltip {
  display: none;
  position: fixed;
  background: #1f2937;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.9em;
  line-height: 1.4;
  min-width: 220px;
  max-width: 320px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 9100;
  color: #d1d5db;
}
.rank-tooltip.open {
  display: block;
}
/* Standings Team Cell */
td.team-cell {
  vertical-align: middle;
  position: relative;
}
td.team-cell .team-name-link {
  margin: 0;
  padding: 0;
}
td.team-cell .standings-team-logo {
  vertical-align: middle;
  margin-right: 8px;
}
.standings-team-logo {
  width: 32px;
  height: 32px;
  border-radius: 3px;
  object-fit: contain;
  background: transparent;
  flex-shrink: 0;
}

/* New Standings Design */
.standings-container {
  max-width: 700px;
  margin: 0 auto;
}
.standings-table {
  width: 100%;
  border-collapse: collapse;
  background: #1f2937;
  border-radius: 8px;
  overflow: hidden;
}
.standings-table thead th {
  background: #374151;
  padding: 12px 16px;
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9ca3af;
  text-align: left;
  /* border-bottom: 1px solid #4b5563; */
}

.standings-table thead th:first-child {
  padding-left: 24px;
  width: 40px;
  text-align: center;
}
.standings-table thead th:nth-child(n+3) {
  text-align: center;
}
.standings-table tbody tr {
  transition: background 0.15s ease;
}
.standings-table tbody tr:nth-child(even) {
  background: #1a2332;
}
.standings-table tbody tr:hover {
  background: #2d3748;
}
.standings-table td {
  padding: 12px 16px;
  vertical-align: middle;
  /* border-bottom: 1px solid #374151; */
}
.standings-rank {
  font-weight: 700;
  color: #d1d5db;
  font-size: 1em;
  width: 40px;
}
.standings-team-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 3px 6px;
  margin: -3px -6px;
  border-radius: 4px;
}
.standings-team-cell:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.05);
}
.standings-logo {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: contain;
  background: transparent;
  pointer-events: none;
}
.standings-name {
  font-weight: 600;
  color: #f3f4f6;
  pointer-events: none;
}
.standings-record {
  text-align: center;
  font-weight: 600;
  font-family: 'Droid Sans Mono', monospace;
}
.standings-wins {
  color: #34d399;
}
.standings-losses {
  color: #f87171;
}
.standings-dash {
  color: #6b7280;
  margin: 0 4px;
}
.standings-neutral {
  color: #d1d5db;
}
.standings-positive {
  color: #34d399;
}
.standings-negative {
  color: #f87171;
}

/* Map Stats Dominant Team */
.map-dominant-team {
  display: flex;
  align-items: center;
  gap: 6px;
}
.map-dominant-team .team-name-link {
  transform-origin: left center;
}
/* Teams Grid */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.team-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 16px;
  transition: all 0.2s ease;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.team-card:hover {
  background: #2d3748;
  border-color: #4b5563;
}
.team-card-name-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.team-card-name-row .team-view-logo {
  margin-top: 0;
  flex-shrink: 0;
}
.team-card-name-row .team-view-name {
  font-size: 1.3em;
  margin-bottom: 0;
}
/* Round Headers */
h1, h2, h3, .round-header {
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  color: #ffffff;
}
.round-header {
  font-size: 1.3em;
  margin-bottom: 16px;
  text-align: center;
}
.round-deadline {
  font-weight: 400;
  font-size: 0.85em;
  color: #9ca3af;
  display: block;
  margin-top: 4px;
}
/* ==================== ROUND NAVIGATION ==================== */
.round-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  justify-content: center;
}
.round-nav button {
  background: #1e3a5f;
  color: #93c5fd;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  padding: 8px 18px;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 48px;
  padding-block: 5px;
  padding-inline: 13px;
  display: inline-block;
  box-sizing: border-box;
  margin: 0em 0em 0em 0em;
}
.round-nav button:hover {
  background: #2563eb;
  border-color: #60a5fa;
  color: #ffffff;
}
.round-nav button.active {
  background: #3b82f6;
  border-color: #60a5fa;
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
/* ==================== RECENT GAMES - CENTERED ==================== */
/*.recent-games {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  align-items: center;
}*/
.recent-show-more {
  display: block;
  margin: 12px auto 0;
  font-weight: 600;
  color: #60a5fa;
  cursor: pointer;
  user-select: none;
  width: fit-content;
  text-align: center;
}
.recent-show-more:hover {
  color: #93c5fd;
}
/* ==================== GROUP BRACKET / SCHEDULE ==================== */
.bracket-wrapper {
  margin-top: 20px;
}
.round-block {
  display: none;
  margin-bottom: 32px;
}
.round-block.active {
  display: block;
}
.recent-hidden {
  padding-top: 30px;
}
.round-games, .recent-games, .recent-hidden {
  display: flex;
  gap: 40px;
  align-items: stretch;
  flex-wrap: wrap;
  justify-content: center;
  padding-bottom: 10px;
}
/* Shared game card */
.bracket-game {
  width: 300px;
  flex-shrink: 0;
}
.bracket-match {
  background: #1f2937;
  border: 1px solid #374151;
  padding: 10px;
  border-radius: 8px;
  position: relative;
  transition: all 0.2s ease;
}
.bracket-match:hover {
  background: #2d3748;
  border-color: #4b5563;
}
.bracket-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  word-break: break-word;
  color: #f3f4f6;
  border-radius: 4px;
  transition: all 0.2s ease;
}
.bracket-team-logo {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  object-fit: contain;
  flex-shrink: 0;
  background: transparent;
}
.bracket-team-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.bracket-team-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bracket-player.winner {
  font-weight: 700;
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}
@keyframes winnerPulse {
  0% {
    box-shadow: 0 0 0 rgba(52, 211, 153, 0);
  }
  50% {
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.4);
  }
  100% {
    box-shadow: 0 0 0 rgba(52, 211, 153, 0);
  }
}
.bracket-player.winner.advanced {
  animation: winnerPulse 2s ease-in-out infinite;
}
.bracket-score {
  font-family: 'Droid Sans Mono', monospace;
  min-width: 28px;
  text-align: right;
  font-weight: 600;
}
.bracket-match.unplayed {
  background: rgba(59, 130, 246, 0.05);
  border-color: #3b82f6;
  opacity: 0.7;
}
.bracket-match.unplayed .bracket-player {
  opacity: 0.8;
}
.bracket-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 0;
  min-height: 22px;
}
.stage-badge {
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #9ca3af;
  background: rgba(156, 163, 175, 0.15);
  border: 1px solid rgba(156, 163, 175, 0.3);
  border-radius: 3px;
  padding: 2px 6px;
}
.stage-badge.stage-g {
  color: #9ca3af;
  background: rgba(156, 163, 175, 0.15);
  border-color: rgba(156, 163, 175, 0.3);
}
.stage-badge.stage-qf {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
}
.stage-badge.stage-sf {
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.3);
}
.stage-badge.stage-f {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.3);
}
.stage-badge.stage-b {
  color: #d97706;
  background: rgba(217, 119, 6, 0.15);
  border-color: rgba(217, 119, 6, 0.3);
}
.walkover-icon {
  display: block;
  text-align: center;
  min-height: 22px;
  font-size: 1.1em;
  transition: all 0.2s ease;
}
.walkover-icon:hover {
  transform: scale(1.1);
}
.view-game-link {
  cursor: pointer;
  color: #e2e8f0;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.view-game-link:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
  color: #ffffff;
}
.view-game-link.disabled {
  visibility: hidden;
  pointer-events: none;
}
.info-scheduled-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}
.info-scheduled-icon {
  font-size: 1em;
  line-height: 1;
  flex-shrink: 0;
}
@keyframes scheduledPulse {
  0%   { box-shadow: 0 0 0 rgba(96, 165, 250, 0); }
  50%  { box-shadow: 0 0 12px rgba(96, 165, 250, 0.4); }
  100% { box-shadow: 0 0 0 rgba(96, 165, 250, 0); }
}
.info-scheduled {
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 4px;
  padding: 3px 6px;
  animation: scheduledPulse 2s ease-in-out infinite;
}
/* Popup - HIGHEST Z-INDEX */
.bracket-popup-wrapper {
  display: none;
  position: fixed;
  /*top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);*/
  background: #1f2937;
  border: 1px solid #4b5563;
  border-radius: 8px;
  padding: 12px;
  z-index: 9600;
  min-width: 300px;
  max-width: 450px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}
/* Dark overlay when popup is open */
.popup-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 9550;
}
.popup-overlay.active {
  display: block;
}
.bracket-popup-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 10px;
  gap: 12px;
  color: #ffffff;
}
.popup-team {
  display: flex;
  align-items: center;
  gap: 8px;
}
.popup-team-b {
  text-align: right;
}
.popup-team-logo {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  object-fit: contain;
  background: transparent;
}
.popup-map-score {
  font-family: 'Droid Sans Mono', monospace;
  font-weight: 600;
  font-size: 1.1em;
  color: #9ca3af;
  padding: 2px 6px;
  border-radius: 4px;
}
.popup-map-score-winner {
  color: #34d399;
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.3);
}
.bracket-popup-body-match {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  padding: 6px;
  background: rgba(55, 65, 81, 0.3);
  border-radius: 4px;
}
.popup-score {
  font-family: 'Droid Sans Mono', monospace;
  min-width: 32px;
  text-align: center;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  color: #9ca3af;
}
.popup-score-winner {
  color: #34d399;
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.3);
  font-weight: 700;
}
.map-name {
  flex-grow: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
}
.map-name:hover {
  color: #93c5fd;
  text-decoration: underline;
}
/* ==================== PLAYOFFS ==================== */
.playoffs-wrap {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.playoffs-bracket {
  position: relative;
  overflow-x: auto;
  padding-bottom: 12px;
}
.playoffs-title {
  font-size: 1.5em;
  font-weight: 700;
  margin: 0 0 12px 0;
  color: #ffffff;
  text-align: center;
}
.stage-row {
  position: relative;
  display: flex;
  gap: 40px;
  align-items: flex-start;
  justify-content: center;  
  min-width: 1000px;
}
.stage-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}
.stage-header {
  text-align: center;
  font-family: 'Roboto', sans-serif;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  font-size: 1.1em;
  color: #d1d5db;
}
.stage-col .bracket-game {
  width: 300px;
}
/* Bracket vertical alignment */
.stage-semifinals,
.stage-final-b {
  margin-top: 70px;
}
.stage-semifinals .bracket-game:nth-child(3) {
  margin-top: 120px;
}
.stage-final {
  margin-top: 190px;
}
.stage-bronze {
  margin-top: 310px;
}
.stage-bronze-header {
  text-align: center;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  white-space: nowrap;
  color: #d1d5db;
}
.stage-final-separator,
.stage-final-b-separator {
  width: 300px;
  height: 1px;
  background: linear-gradient(to right, transparent, #4b5563, transparent);
  margin: 18px 0;
}
.stage-final > .stage-header,
.stage-final-b > .stage-header {
  width: 300px;
  margin-left: 0;
  margin-right: 0;
  text-align: center;
}
.bracket-winner {
  font-family: 'Roboto', sans-serif;
  font-weight: 700;
  font-size: 1.1em;
  padding: 16px 20px;
  border-radius: 8px;
  width: fit-content;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
}
.bracket-winner-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  vertical-align: middle;
}
.bracket-final-row {
  display: flex;
  align-items: center;
  justify-content: center;
}
.bracket-winner-wrap {
  margin-left: 24px;
  display: flex;
  align-items: center;
}
.bracket-winner.main {
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid #fbbf24;
  color: #fbbf24;
}
.bracket-winner.losers {
  background: rgba(96, 165, 250, 0.15);
  border: 1px solid #60a5fa;
  color: #60a5fa;
}
.nav-toggle {
  display: none;
}
/* Wiki link styled as navigation button */
.nav-wiki-link {
  background: #374151;
  color: #d1d5db;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 10px 16px;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
  margin-left: auto;
}

.nav-wiki-link:hover {
  background: #4b5563;
  border-color: #6b7280;
  color: #f3f4f6;
}
/* ==================== MOBILE ==================== */
@media (max-width: 768px) {
  body {
    font-size: 16px;
  }
  .content-wrapper {
    padding: 0 12px;
  }
  .app-header {
    padding: 16px 12px;
  }  
  .app-logo {
    max-height: 60px;
    max-width: 120px;
  }
  .app-title {
    font-size: 1.3em;
  }
  .app-nav {
    top: 100px;
    padding: 12px;
    gap: 6px;
  }
  .app-nav button {
    padding: 8px 12px;
    font-size: 0.9em;
  }
  section h2 {
    font-size: 1.5em;
  }
  table {
    display: table;
    width: 100%;
    font-size: 0.9em;
  }
  
  .content-wrapper {
    overflow-x: auto;
  }
  .round-games {
    flex-direction: column;
    gap: 18px;
  }
  .bracket-game {
    width: 100% !important;
  }
  .stage-col {
    width: 100%;
    min-width: 0;
  }
  .stage-row {
    min-width: 0;
    flex-direction: column;
    gap: 24px;
  }
  .stage-col .bracket-game {
    width: 100% !important;
  }
  #players-output table:not(.show-all-cols) th:nth-child(n+9),
  #players-output table:not(.show-all-cols) td:nth-child(n+9) {
    display: none;
  }
  #players-output table.show-all-cols th,
  #players-output table.show-all-cols td {
    display: table-cell;
  }
  /* Mirror mobile reduced-columns behaviour for team view player stats */
  #team-player-stats table:not(.show-all-cols) th:nth-child(n+9),
  #team-player-stats table:not(.show-all-cols) td:nth-child(n+9) {
    display: none;
  }
  #team-player-stats table.show-all-cols th,
  #team-player-stats table.show-all-cols td {
    display: table-cell;
  }

  .players-toggle {
    display: block;
    margin: 10px auto 6px;
    font-size: 0.95em;
    font-weight: 600;
    color: #60a5fa;
    background: none;
    border: none;
    padding: 8px 0;
    cursor: pointer;
  }
  .stage-quarterfinals > .stage-header,
  .stage-semifinals > .stage-header,
  .stage-semifinals-b > .stage-header,
  .stage-final > .stage-header,
  .stage-bronze > .stage-header,
  .stage-final-b > .stage-header {
    width: auto !important;
    text-align: center;
  }
  .stage-final-separator,
  .stage-final-b-separator {
    width: auto !important;
  }
  .round-header {
    text-align: center;
  }
  .stage-semifinals,
  .stage-final,
  .stage-bronze,
  .stage-final-b {
    margin-top: 0 !important;
  }
  .stage-semifinals .bracket-game:nth-child(3) {
    margin-top: 0 !important;
  }
  .stage-header {
    text-align: left;
    padding-left: 4px;
  }
  .bracket-final-row {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .bracket-winner-wrap {
    margin-left: 0;
  }
  
  .teams-grid {
    grid-template-columns: 1fr;
  }
  .round-nav {
    justify-content: flex-start;
  }
  .round-nav button {
    min-width: 80px;
    padding: 8px 14px;    
  }   
  /* ==================== MOBILE APP-STYLE DRAWER ==================== */      
  .app-header-main {
    justify-content: flex-start;
    padding: 0;
  }
  /* Hamburger in header */
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    font-size: 1.6em;
    background: none;
    color: #60a5fa;
    border: none;
    cursor: pointer;
  }

  /* Overlay behind menu */
  .nav-overlay {
    position: fixed;
    top: 92px;        /* Start below header (same as drawer) */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    /*z-index: 104;*/
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .nav-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* Drawer menu */
  .app-nav {
    position: fixed;
    top: 94px;
    left: 0;
    height: calc(100dvh - 118px);
    /* width: 78%; */
    max-width: 320px;
    background: #111827;
    z-index: 105;
    /* padding: 80px 14px 14px; */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
  }

  .app-nav.open {
    transform: translateX(0);
  }

  .nav-wiki-link {
    margin-top: auto;
  }

  /* Nav buttons = big touch targets */
  .app-nav button {
    padding: 14px 16px;
    font-size: 1.05em;
    border-radius: 10px;
    text-align: left;
  }
  .nav-wiki-link {
    padding: 14px 16px;
    font-size: 1.05em;
    border-radius: 10px;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
  }

  /* MAP STATS - mobile */
  .mapstats-grid {
    grid-template-columns: 1fr !important;
  }
  .map-card-snap {
    width: 120px !important;
    min-width: 120px !important;
  }
  .map-card-img {
    height: 140px !important;
    min-height: 120px !important;
  }
  .map-stat-label {
    min-width: 90px !important;
  }
  /* Compact standings on mobile to avoid horizontal scroll */
  .standings-table {
    font-size: 0.85em;
    max-width: 100%;
  }
  .standings-table thead th {
    padding: 8px 10px;
    font-size: 0.7em;
  }
  .standings-table td {
    padding: 6px 8px;
    font-size: 0.9em;
    white-space: normal; /* allow wrapping to avoid horizontal overflow */
  }
  .standings-logo {
    width: 22px;
    height: 22px;
  }
  .standings-rank {
    width: 36px;
    font-size: 0.95em;
  }
  .standings-team-cell {
    gap: 6px;
  }
  .standings-table thead th:first-child {
    padding-left: 10px;
    width: 36px;
  }

  /* Mobile: make team view panel full-width and avoid horizontal scrollbars */
  .team-view-overlay {
    align-items: stretch;
    justify-content: flex-end;
  }

  .team-view-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none !important;
    overflow-x: hidden; /* prevent horizontal scrollbar */
    overflow-y: auto;   /* allow vertical scrolling if needed */
  }

  .team-view-overlay.active .team-view-panel {
    transform: none !important;
  }
}
/* ==================== END OF MOBILE VIEW ==================== */
/* ==================== MAP STATS ==================== */
.mapstats-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  margin-bottom: 24px;
  padding: 14px 20px;
  background: rgba(31, 41, 55, 0.9);
  border: 1px solid #374151;
  border-radius: 10px;
  font-size: 0.95em;
  color: #d1d5db;
}
.mapstats-summary strong {
  color: #f3f4f6;
  font-weight: 700;
}
.mapstats-summary-sep {
  color: #4b5563;
  font-size: 1.2em;
}
.mapstats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 8px;
}
.map-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.map-card:hover {
  background: #243040;
  border-color: #4b5563;
}
.map-card-snap {
  position: relative;
  width: 180px;
  min-width: 180px;
  flex-shrink: 0;
  overflow: hidden;
}
.map-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
  min-height: 160px;
}
.map-card:hover .map-card-img {
  transform: scale(1.04);
}
.map-card-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 100%);
  color: #ffffff;
  font-family: 'Roboto', sans-serif;
  font-weight: 700;
  font-size: 0.9em;
  letter-spacing: 0.08em;
  padding: 18px 10px 8px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.map-card-body {
  flex: 1;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  justify-content: center;
}  
  
.map-stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88em;
  flex-wrap: wrap;
  min-height: 22px;
}
.map-stat-icon {
  font-size: 1em;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.map-stat-label {
  color: #9ca3af;
  font-size: 0.9em;
  min-width: 105px;
  flex-shrink: 0;
}
.map-stat-value {
  color: #f3f4f6;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.map-stat-accent {
  color: #60a5fa;
  font-weight: 500;
  font-size: 0.92em;
}
.map-bar-wrap {
  flex: 1;
  height: 6px;
  background: rgba(75, 85, 99, 0.4);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
  max-width: 200px;
  align-self: center;
}
.map-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.map-game-link {
  color: #e2e8f0;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95em;
  transition: all 0.2s ease;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.map-game-link:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
  color: #ffffff;
}
.map-game-link-logos {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.map-team-logo {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  object-fit: contain;
  background: transparent;
  vertical-align: middle;
}
.map-game-score {
  font-weight: 600;
  font-family: 'Droid Sans Mono', monospace;
}
.map-game-vs {
  color: #9ca3af;
  font-size: 0.85em;
  margin: 0 2px;
}

/* ==================== CAPTAIN BADGE ==================== */
.captain-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  font-size: 14px;
  font-weight: 700;
  border-radius: 4px;
  margin-left: 4px;  
  text-transform: uppercase;
}
.captain-name {
  font-weight: 600;
}

/* ==================== TEAM VIEW OVERLAY ==================== */
.team-view-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9500;
  display: flex;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.team-view-overlay.active {
  opacity: 1;
  visibility: visible;
}
.team-view-panel {
  position: relative;
  width: 90%;
  max-width: 1478px;
  height: 100%;
  background: #111827;
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}
.team-view-overlay.active .team-view-panel {
  transform: translateX(0);
}
.team-view-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 10;
}
.team-view-close:hover {
  background: rgba(255, 255, 255, 0.2);
}
.team-view-header {
  padding: 20px;
  background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
  border-bottom: 1px solid #374151;
}
.team-view-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.team-view-logo {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: contain;
  flex-shrink: 0;
  background: transparent;
  margin-top: 15px;
}
.team-view-info {
  flex: 1;
  min-width: 0;
}
.team-view-rank {
  font-size: 0.75em;
  font-weight: 600;
  color: #f59e0b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.team-view-division {
  color: #60a5fa;
}
.team-view-name {
  font-size: 1.5em;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.team-view-tag {
  font-size: 0.55em;
  font-weight: 500;
  color: #9ca3af;
  background: rgba(55, 65, 81, 0.6);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #4b5563;
}
.team-view-players {
  font-size: 0.95em;
  color: #d1d5db;
}
.team-view-content {
  padding: 20px;
}
.team-view-section h3 {
  font-size: 1.1em;
  font-weight: 600;
  color: #9ca3af;
  margin: 24px 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.team-view-section:first-child h3 {
  margin-top: 0;
}
.team-view-games {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.team-view-games .bracket-game {
  flex: 0 0 auto;
  max-width: 280px;
}
.team-view-empty {
  color: #6b7280;
  font-style: italic;
}

/* Team Map Stats */
.team-mapstats-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 16px;
  background: rgba(31, 41, 55, 0.5);
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9em;
  color: #d1d5db;
}
.team-mapstats-summary strong {
  color: #fff;
}
.team-mapstats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.team-map-card {
  position: relative;
  border: 1px solid #374151;
  border-radius: 8px;
  min-width: 200px;
  max-width: calc(20% - 10px);
  flex: 1 1 calc(20% - 10px);
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.team-map-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.3) 0%, rgba(17, 24, 39, 0.85) 40%, rgba(17, 24, 39, 0.95) 100%);
  z-index: 0;
}
.team-map-card-name {
  position: relative;
  z-index: 1;
  font-weight: 700;
  color: #fff;
  font-size: 1.1em;
  padding: 10px 12px 6px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  text-transform: uppercase;
}
.team-map-card-stats {
  position: relative;
  z-index: 1;
  padding: 6px 12px 12px;
}
.team-map-stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.85em;
}
.team-map-stat-row:last-child {
  margin-bottom: 0;
}
.team-map-stat-icon {
  font-size: 0.9em;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.team-map-stat-label {
  color: #9ca3af;
  flex-shrink: 0;
}
.team-map-stat-value {
  color: #fff;
  font-weight: 500;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.team-map-bar {
  flex: 1;
  height: 6px;
  background: #374151;
  border-radius: 3px;
  overflow: hidden;
  min-width: 40px;
  max-width: 80px;
}
.team-map-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: #3b82f6;
}
.team-map-vs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9em;
}
.team-map-vs-score {
  font-family: 'Droid Sans Mono', monospace;
  font-weight: 600;
}
.team-map-vs-label {
  color: #6b7280;
  margin: 0 2px;
}
.team-map-vs-logo {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  object-fit: contain;
  vertical-align: middle;
}
.team-map-vs-tag {
  font-size: 0.8em;
  font-weight: 500;
  color: #9ca3af;
  background: rgba(55, 65, 81, 0.6);
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid #4b5563;
  white-space: nowrap;
}

/* Clickable team names */
.team-name-link {
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  margin: -3px -6px;
  border-radius: 4px;
}
.team-name-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: scale(1.05);
}
.team-name-link img {
  pointer-events: none;
}
