/* ===== TABLE STYLES ===== */
.table-container {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background-color: var(--bg-surface);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 0;
}

table thead,
table tbody {
  display: block;
}

table tbody {
  overflow-y: auto;
  flex-grow: 1;
}

tbody.clickable tr {
  cursor: pointer;
}

th,
td {
  padding: 14px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

thead tr,
tbody tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

th {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-secondary);
  background-color: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

thead tr th:first-child {
  border-top-left-radius: 12px;
}

thead tr th:last-child {
  border-top-right-radius: 12px;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ===== LIGHT MODE TABLE STYLES ===== */
body.light-mode table {
  background-color: var(--bg-surface-light);
  border-color: var(--border-color-light);
}

body.light-mode th,
body.light-mode td {
  border-bottom-color: var(--border-color-light);
}

body.light-mode th {
  background-color: var(--bg-surface-light);
}
/* ===== TABLE CELL STYLES ===== */
.rank {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-blue);
}

.nickname {
  text-align: left;
  font-weight: 600;
}

.user-id {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
}

.final-score {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-red);
}

.shop-name-mobile {
  display: none;
}
/* ===== CUTOFF VIEW STYLES ===== */
.cutoff-container {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 16px;
  height: 100%;
  overflow-y: auto;
}

.cutoff-column {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  gap: 6px;
}

.cutoff-item {
  background-color: var(--bg-surface-accent);
  padding: 8px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  min-height: 48px;
}

.cutoff-item .rank {
  font-size: 16px;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
  font-weight: 700;
}

.cutoff-item .name {
  flex-grow: 1;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cutoff-item .name-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cutoff-item .name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cutoff-item .shop-name {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.8;
}

.cutoff-item .score {
  font-size: 14px;
  font-weight: 600;
  color: #ff4d4d;
  flex-shrink: 0;
}

/* ===== LIGHT MODE CUTOFF STYLES ===== */
body.light-mode .cutoff-column {
  background-color: var(--bg-surface-light);
  border: 1px solid var(--border-color-light);
}

body.light-mode .cutoff-item {
  background-color: var(--bg-surface-accent-light);
}

body.light-mode .cutoff-item .shop-name {
  color: #6c757d;
}

/* ===== TEAM MATCH VIEW STYLES ===== */
.team-match-container {
  height: 100%;
  overflow-y: auto;
  padding: 16px 20px;
}

.team-match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  max-width: 100%;
}

.team-match-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.team-match-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: var(--accent-blue);
}

.team-players-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.team-player {
  background-color: var(--bg-surface-accent);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.team-player:hover {
  background-color: var(--bg-surface-accent);
  border-color: var(--accent-blue);
  transform: translateX(2px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.team-player.leading {
  border: 2px solid var(--accent-green);
  background: linear-gradient(135deg, var(--bg-surface-accent) 0%, rgba(76, 175, 80, 0.12) 100%);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

.team-player-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-player-rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-blue);
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.15) 0%, rgba(33, 150, 243, 0.1) 100%);
  padding: 3px 7px;
  border-radius: 5px;
  flex-shrink: 0;
  min-width: 42px;
  text-align: center;
  border: 1px solid rgba(33, 150, 243, 0.2);
}

.team-player-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
}

.team-player-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-player-score {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
  min-width: 50px;
  text-align: right;
}

.team-player-score.leading-score {
  color: var(--accent-green);
  font-weight: 800;
  font-size: 14px;
}

.team-player-shop {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ===== LIGHT MODE TEAM MATCH STYLES ===== */
body.light-mode .team-match-card {
  background-color: var(--bg-surface-light);
  border-color: var(--border-color-light);
}

body.light-mode .team-player {
  background-color: var(--bg-surface-accent-light);
  border-color: var(--border-color-light);
}

body.light-mode .team-player.leading {
  background: linear-gradient(135deg, var(--bg-surface-accent-light) 0%, rgba(76, 175, 80, 0.15) 100%);
}

/* ===== RESPONSIVE TEAM MATCH STYLES ===== */
@media (max-width: 768px) {
  .team-match-container {
    padding: 12px 16px;
  }

  .team-match-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
  }

  .team-match-card {
    padding: 10px;
  }

  .team-player {
    padding: 7px 8px;
  }

  .team-player-rank {
    font-size: 10px;
    padding: 2px 6px;
    min-width: 38px;
  }

  .team-player-name {
    font-size: 12px;
  }

  .team-player-score {
    font-size: 12px;
    min-width: 45px;
  }

  .team-player-shop {
    font-size: 10px;
  }
}

/* ===== PLACEHOLDER STYLES ===== */
.placeholder-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  min-height: 200px;
  background-color: var(--bg-surface);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 500;
}

.table-container .placeholder-row td {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 500;
}

/* ===== LIGHT MODE PLACEHOLDER STYLES ===== */
body.light-mode .placeholder-container {
  background-color: var(--bg-surface-light);
  border-color: var(--border-color-light);
}
/* ===== BRACKET VIEW STYLES ===== */
.bracket-split-container {
  display: flex;
  gap: 20px;
  height: 100%;
}

.bracket-matchups-container {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bracket-leaderboard-container {
  flex: 1;
  min-width: 0;
  border-left: 1px solid var(--border-color);
  padding-left: 20px;
  display: flex;
  flex-direction: column;
}

.matchup {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
}

.matchup .player {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background-color: var(--bg-surface-accent);
  transition: all 0.3s ease;
  cursor: pointer;
}

.matchup .player:hover {
  background-color: var(--bg-hover);
}

.matchup .vs {
  font-weight: bold;
  color: var(--text-secondary);
}

.matchup .player-details {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.matchup .player-details .rank {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--bg-main);
  border-radius: 5px;
  padding: 3px 6px;
}

.matchup .name-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow: hidden;
}

.matchup .name-wrapper .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.matchup .player-shop {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.matchup .player-score {
  font-size: 1.1rem;
  font-weight: bold;
}

.matchup .player.winning {
  border-color: var(--accent-yellow);
  box-shadow: 0 0 10px rgba(255, 193, 7, 0.4);
  animation: winning-glow 2s infinite alternate ease-in-out;
}

@keyframes winning-glow {
  from {
    box-shadow: 0 0 5px rgba(255, 193, 7, 0.2);
  }
  to {
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.6);
  }
}

/* ===== LIGHT MODE BRACKET STYLES ===== */
body.light-mode .bracket-leaderboard-container {
  border-color: var(--border-color-light);
}

body.light-mode .matchup {
  background-color: var(--bg-surface-light);
  border-color: var(--border-color-light);
}

body.light-mode .matchup .player {
  background-color: var(--bg-surface-accent-light);
}

body.light-mode .matchup .player:hover {
  background-color: #e9ecef;
}

body.light-mode .matchup .player-details .rank {
  background-color: var(--bg-main-light);
}
/* ===== RESPONSIVE DESIGN ===== */

/* Large Desktop (1200px+) */
@media (min-width: 1200px) {
  .bracket-container {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Tablet (769px - 1100px) */
@media (min-width: 769px) and (max-width: 1100px) {
  .tablet-hide,
  .mobile-hide {
    display: none;
  }

  .shop-name-mobile {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
  }

  .cutoff-container {
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
  }
}

/* Small Desktop/Tablet (1024px and below) */
@media (max-width: 1024px) {
  .bracket-split-container {
    flex-direction: column;
    height: auto;
  }

  .bracket-leaderboard-container {
    border-left: none;
    padding-left: 0;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
  }

  body.light-mode .bracket-leaderboard-container {
    border-color: var(--border-color-light);
  }
}

/* Mobile (768px and below) */
@media (max-width: 768px) {
  tbody.clickable tr {
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-hide {
    display: none;
  }

  .shop-name-mobile {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
  }

  th,
  td {
    padding: 12px 8px;
  }

  .cutoff-container {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  .cutoff-column {
    padding: 8px;
  }

  .cutoff-item {
    padding: 6px 8px;
    gap: 8px;
    min-height: 40px;
  }

  .cutoff-item .rank {
    font-size: 14px;
    width: 28px;
  }

  .cutoff-item .name {
    font-size: 13px;
  }

  .cutoff-item .shop-name {
    font-size: 10px;
  }

  .cutoff-item .score {
    font-size: 12px;
    font-weight: 600;
    color: #ff4d4d;
  }

  .matchup {
    flex-direction: column;
  }
}
/* ===== FINAL STAGE STYLES ===== */
.final-stage-section {
  margin-bottom: 32px;
}

.final-stage-section:last-child {
  margin-bottom: 0;
}

.final-stage-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

/* ===== LIGHT MODE FINAL STAGE STYLES ===== */
body.light-mode .final-stage-title {
  color: #1a1c1e !important;
  border-bottom-color: var(--border-color-light);
}
