* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0a0e17;
  color: #e0e0e0;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border-bottom: 2px solid #8b1a1a;
}

header h1 {
  font-size: 1.8rem;
  color: #fff;
  margin-bottom: 0.75rem;
}

nav {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

nav button {
  padding: 0.5rem 1.5rem;
  border: 1px solid #444;
  background: transparent;
  color: #aaa;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

nav button.active {
  background: #8b1a1a;
  color: #fff;
  border-color: #8b1a1a;
}

nav button:hover:not(.active) {
  border-color: #888;
  color: #fff;
}

main { padding: 1.5rem; overflow-x: auto; }

/* Bracket layout */
.bracket-container {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: max-content;
}

.round {
  display: flex;
  flex-direction: column;
  min-width: 200px;
  flex-shrink: 0;
}

.round-header {
  text-align: center;
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 0.75rem 0.75rem;
  font-weight: 600;
}

.matches {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1;
  gap: 4px;
  padding: 0 0.75rem;
}

.match {
  background: #151a2e;
  border: 1px solid #2a2f45;
  border-radius: 8px;
  overflow: hidden;
}

.match .team {
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  transition: background 0.15s;
  border-left: 3px solid transparent;
  white-space: nowrap;
}

.match .team:first-child {
  border-bottom: 1px solid #2a2f45;
}

.match .team:hover {
  background: #1e2540;
}

.match .team.picked {
  background: #1a2e1a;
  border-left-color: #4caf50;
  color: #fff;
}

.match .team.locked {
  cursor: default;
}

.match .team.locked:hover {
  background: transparent;
}

.match .team.correct {
  background: #1a3a1a;
  border-left-color: #4caf50;
}

.match .team.wrong {
  background: #3a1a1a;
  border-left-color: #f44336;
  text-decoration: line-through;
  opacity: 0.6;
}

.match .team.pending {
  background: #1a2e1a;
  border-left-color: #ff9800;
}

.team .flag {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.team .team-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Champion column */
.champion-col {
  display: flex;
  flex-direction: column;
  min-width: 180px;
  flex-shrink: 0;
}

.champion-col .matches {
  justify-content: center;
}

.team-slot {
  padding: 0.75rem 1rem;
  text-align: center;
  font-weight: 600;
  background: #151a2e;
  border: 1px solid #2a2f45;
  border-radius: 8px;
  font-size: 0.95rem;
}

.team-slot.empty {
  color: #555;
}

.team-slot.filled {
  color: #fff;
  border-color: #ffd700;
  background: linear-gradient(135deg, #2a2000, #1a1500);
}

.team-slot.correct {
  border-color: #4caf50;
  background: linear-gradient(135deg, #1a3a1a, #0a1a0a);
}

.team-slot.wrong {
  border-color: #f44336;
  background: linear-gradient(135deg, #3a1a1a, #1a0a0a);
}

/* Submit */
#submit-area {
  text-align: center;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

#player-name {
  padding: 0.6rem 1rem;
  border: 1px solid #444;
  background: #151a2e;
  color: #fff;
  border-radius: 6px;
  font-size: 1rem;
  width: 220px;
}

#player-name:focus {
  outline: none;
  border-color: #8b1a1a;
}

#submit-picks {
  padding: 0.6rem 1.5rem;
  background: #8b1a1a;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

#submit-picks:hover { background: #a52020; }
#submit-picks:disabled { background: #444; cursor: not-allowed; }

.hidden { display: none !important; }

/* Players list */
#players-list {
  max-width: 500px;
  margin: 0 auto;
}

.player-card {
  background: #151a2e;
  border: 1px solid #2a2f45;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.player-card:hover {
  border-color: #8b1a1a;
}

.player-card .name {
  font-weight: 600;
  font-size: 1rem;
}

.player-card .date {
  color: #666;
  font-size: 0.8rem;
}

.player-stats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-card .score {
  font-size: 0.85rem;
  color: #aaa;
  font-weight: 600;
}

.player-card .status {
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}

.status.alive {
  background: #1a3a1a;
  color: #4caf50;
}

.status.busted {
  background: #3a1a1a;
  color: #f44336;
}

.no-players {
  text-align: center;
  color: #666;
  padding: 3rem;
  font-size: 1.1rem;
}

#back-to-players {
  background: transparent;
  border: 1px solid #444;
  color: #aaa;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

#back-to-players:hover {
  border-color: #888;
  color: #fff;
}

#player-bracket-title {
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1a3a1a;
  color: #4caf50;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  border: 1px solid #4caf50;
  font-size: 0.9rem;
  z-index: 100;
  animation: fadeInOut 3s ease forwards;
}

.toast.error {
  background: #3a1a1a;
  color: #f44336;
  border-color: #f44336;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* Submit bar in champion column */
#submit-area:not(.hidden) {
  padding: 0.5rem 0;
}

/* Mobile: keep classic bracket, just shrink it */
@media (max-width: 768px) {
  header { padding: 1rem; }
  header h1 { font-size: 1.3rem; margin-bottom: 0.5rem; }

  nav button {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
  }

  main { padding: 0.5rem; }

  .round { min-width: 120px; }

  .match .team {
    padding: 0.3rem 0.35rem;
    font-size: 0.65rem;
    gap: 0.2rem;
    border-left-width: 2px;
  }

  .team .flag { font-size: 0.75rem; }

  .round-header {
    font-size: 0.55rem;
    padding: 0 0.4rem 0.4rem;
    letter-spacing: 0.5px;
  }

  .matches { padding: 0 0.3rem; gap: 2px; }

  .champion-col { min-width: 110px; }

  .team-slot {
    padding: 0.4rem 0.5rem;
    font-size: 0.7rem;
  }

  #player-name { width: 100%; }
  #submit-picks { width: 100%; }

  #players-list { max-width: 100%; }

  .toast {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    bottom: 5rem;
  }
}
