@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-0: #05080E;
  --bg-1: #0B1020;
  --panel: #111625;
  --panel-soft: #161E31;
  --line: #243049;
  --text: #FFFFFF;
  --muted: #8A9BB4;

  --attack-neon: #FF1111;
  --attack-base: #D11010;
  --attack-shadow: #660808;
  --attack-hot: #FF4A22;

  --defend-neon: #00D4FF;
  --defend-base: #0A66C2;
  --defend-shadow: #042859;

  --purple: #A124E3;
  --toxic: #5C942D;
  --success: #28C76F;
  --gold: #FFC107;

  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1rem;
  --space-4: 1.25rem;
  --space-5: 1.6rem;
  --space-6: 2rem;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 14px 38px rgba(0, 0, 0, 0.4);
  --header-banner-image: url('/assets/images/ql-adtourney-banner.png');
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: clip;
}

body {
  font-family: 'Inter', sans-serif;
  color: var(--text);
  line-height: 1.58;
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(0, 212, 255, 0.1), transparent),
    radial-gradient(1000px 700px at 95% -15%, rgba(255, 17, 17, 0.1), transparent),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 42%, var(--bg-0));
}

h1,
h2,
h3,
.page-title,
.dashboard-title,
.draft-title,
.leaderboard-title,
.tournament-title,
.admin-title,
.error-title,
.success-title {
  font-family: 'Orbitron', sans-serif;
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0.03em;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

/* Shared widths */
.main-content,
.page-content,
.admin-content,
.draft-content {
  width: min(1240px, 96vw);
  margin-inline: auto;
}

.page-content,
.main-content,
.admin-content,
.draft-content {
  padding-block: clamp(1rem, 2vw, 2.1rem);
}

/* Navigation */
.navbar {
  position: sticky;
  top: 0;
  z-index: 2200;
  padding: 0.7rem 1rem;
  background: rgba(8, 13, 24, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.nav-content {
  width: min(1240px, 96vw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--defend-neon);
  font-size: clamp(1rem, 1.6vw, 1.35rem);
}

.logo-svg {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.user-menu {
  position: relative;
}

.user-menu.guest-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.user-button,
.steam-login-nav,
.standings-link {
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.48rem 0.85rem;
  font-size: 0.92rem;
  text-decoration: none;
  transition: all 0.2s ease;
}

.user-button,
.steam-login-nav {
  background: linear-gradient(140deg, var(--defend-base), var(--defend-shadow));
  color: #fff;
  cursor: pointer;
}

.standings-link {
  background: rgba(17, 22, 37, 0.9);
  color: var(--defend-neon);
}

.user-button:hover,
.steam-login-nav:hover,
.standings-link:hover,
.standings-link.active {
  box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.32), 0 8px 18px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}

.steam-logo {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 0.4rem;
  filter: brightness(0) invert(1);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  max-width: min(90vw, 260px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(11, 16, 32, 0.97);
  box-shadow: var(--shadow);
  display: none;
  z-index: 2600;
  overflow: hidden;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: block;
  text-decoration: none;
  padding: 0.58rem 0.85rem;
  color: #D7E5FF;
}

.dropdown-item:hover,
.dropdown-item.active {
  background: rgba(0, 212, 255, 0.12);
  color: var(--defend-neon);
}

/* Surface blocks */
.container,
.card,
.stats-card,
.users-section,
.pool-section,
.preferences-section,
.week-section,
.match-card,
.bye-card,
.error-container,
.gaming-joke,
.console-output,
.tournament-info,
.user-info,
.discord-section,
.color-reference,
.test-case {
  background: linear-gradient(180deg, var(--panel), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.container {
  width: min(980px, 100%);
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(1rem, 2vw, 2rem);
}

.dashboard-header,
.page-header,
.admin-header,
.draft-header,
.leaderboard-header,
.tournament-header,
.success-header {
  position: relative;
  min-height: clamp(180px, 22vw, 320px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: var(--space-5);
  padding: clamp(0.95rem, 1.8vw, 1.4rem);
  background:
    linear-gradient(120deg, rgba(5, 8, 14, 0.88), rgba(5, 8, 14, 0.6)),
    var(--header-banner-image);
  background-size: cover, cover;
  background-repeat: no-repeat, no-repeat;
  background-position: center, center;
}

.dashboard-title,
.page-title,
.admin-title,
.draft-title,
.leaderboard-title,
.tournament-title,
.success-title {
  color: var(--defend-neon);
  font-size: clamp(1.7rem, 2.4vw, 2.5rem);
}

.admin-title,
.error-title {
  color: var(--attack-neon);
}

.dashboard-subtitle,
.page-subtitle,
.admin-subtitle,
.draft-subtitle,
.leaderboard-subtitle,
.tournament-subtitle,
.next-steps,
.login-text,
.no-role,
.muted-detail,
.muted-italic,
.original,
.games-count {
  color: var(--muted);
}

.highlight {
  color: var(--defend-neon);
  font-weight: 700;
}

.highlight-captain,
.pref-title-captain {
  color: var(--purple);
}

.pref-accent-captain {
  border-left: 4px solid var(--purple);
}

/******** Buttons & controls ********/
.btn,
.save-button,
.save-all-btn,
.steam-login-button,
.discord-button,
.qlstats-link,
.btn-set-winner,
.btn-init,
.btn-reset,
.btn-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: var(--radius-sm);
  padding: 0.52rem 0.95rem;
  min-height: 40px;
  border: 1px solid rgba(0, 212, 255, 0.38);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn,
.save-button,
.save-all-btn,
.steam-login-button,
.discord-button,
.btn-set-winner,
.btn-init {
  color: #fff;
  background: linear-gradient(140deg, var(--defend-base), var(--defend-shadow));
}

.btn:hover,
.save-button:hover,
.save-all-btn:hover,
.steam-login-button:hover,
.discord-button:hover,
.qlstats-link:hover,
.btn-set-winner:hover,
.btn-init:hover {
  box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.35), 0 10px 24px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}

.btn-danger,
.warning-section,
.btn-reset,
.btn-clear {
  color: #FFE6E6;
  border-color: rgba(255, 17, 17, 0.5);
  background: linear-gradient(140deg, rgba(209, 16, 16, 0.24), rgba(102, 8, 8, 0.24));
}

.btn-danger:hover,
.btn-reset:hover,
.btn-clear:hover {
  box-shadow: 0 0 0 1px rgba(255, 17, 17, 0.28), 0 10px 22px rgba(0, 0, 0, 0.35);
}

.save-button-captain {
  border-color: rgba(161, 36, 227, 0.5);
}

/******** Forms ********/
.input-group,
.checkbox-group {
  display: grid;
  gap: var(--space-3);
}

.input-item,
.checkbox-item {
  background: rgba(17, 22, 37, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

.input-label,
.checkbox-title,
.section-title,
.card-title,
.users-title,
.pool-title,
.discord-title,
.warning-title {
  color: var(--defend-neon);
  font-weight: 700;
}

.checkbox-label {
  display: grid;
  gap: 0.3rem;
}

.checkbox-description,
.input-description,
.row-status,
.status-saving {
  color: var(--muted);
}

.text-input,
.score-input,
.winner-select {
  width: 100%;
  max-width: 240px;
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: 9px;
  padding: 0.48rem 0.6rem;
  background: rgba(5, 8, 14, 0.75);
  color: var(--text);
}

.text-input:focus,
.score-input:focus,
.winner-select:focus {
  outline: none;
  border-color: var(--defend-neon);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2);
}

.score-input.dirty {
  border-color: var(--attack-hot);
}

.score-input.saved,
.status-saved,
.toast.success,
.success-message,
.system-online,
.success-title,
.team-winner {
  color: var(--success);
  border-color: rgba(40, 199, 111, 0.55);
}

.status-error,
.toast.error,
.error-message {
  color: var(--attack-neon);
}

/******** Tables ********/
.users-section,
.card,
.week-section,
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.users-table,
.leaderboard-table,
table#standingsTable,
table#scoresTable,
.dataTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  min-width: 680px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.users-table th,
.users-table td,
.leaderboard-table th,
.leaderboard-table td,
table#standingsTable th,
table#standingsTable td,
table#scoresTable th,
table#scoresTable td,
.dataTable th,
.dataTable td {
  border-bottom: 1px solid rgba(36, 48, 73, 0.75);
  padding: 0.65rem 0.75rem;
  white-space: nowrap;
}

.users-table th,
.leaderboard-table th,
table#standingsTable thead th,
table#scoresTable thead th,
.dataTable thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #121B2E;
  color: var(--defend-neon);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
}

.users-table tr:hover,
.leaderboard-table tr:hover,
table#standingsTable tbody tr:hover,
table#scoresTable tbody tr:hover,
.dataTable tbody tr:hover {
  background: rgba(0, 212, 255, 0.06);
}

.rank-1 { color: var(--gold); }
.rank-2 { color: #C0C8D6; }
.rank-3 { color: #D48B43; }
.rank-other { color: var(--muted); }

.elo-high { color: var(--success); }
.elo-medium { color: var(--attack-hot); }
.elo-low { color: var(--attack-neon); }

.role-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 700;
  margin: 2px;
  border: 1px solid var(--line);
}

.role-admin { color: var(--attack-neon); border-color: rgba(255, 17, 17, 0.5); }
.role-user { color: var(--toxic); border-color: rgba(92, 148, 45, 0.5); }
.role-captain { color: var(--purple); border-color: rgba(161, 36, 227, 0.5); }

/******** Brackets / draft ********/
.week-section { padding: var(--space-3); }

.week-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.65rem;
}

.week-label,
.match-key,
.bracket-col-header {
  color: var(--defend-neon);
  font-weight: 700;
}

.week-line {
  height: 1px;
  flex: 1;
  background: rgba(36, 48, 73, 0.95);
}

.week-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  align-items: start;
}

.match-card {
  padding: 0.85rem;
  margin-bottom: 0.6rem;
}

.match-header,
.match-result,
.winner-select-row,
.match-teams,
.control-bar,
.card-header,
.users-header,
.action-buttons,
.stats-summary,
.captains-row,
.player-pool,
.dashboard-grid,
.stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.dashboard-grid,
.stats-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.captains-row {
  align-items: stretch;
}

.captain-zone {
  flex: 1 1 230px;
  min-width: 230px;
  max-width: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(11, 16, 32, 0.85);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.captain-name {
  font-weight: 700;
  color: var(--defend-neon);
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(36, 48, 73, 0.85);
}

.captain-players {
  min-height: 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.player-pool {
  align-items: flex-start;
}

.match-full-row-all { grid-column: 1 / -1; }
.match-full-row-right { grid-column: 2; }
.bye-card-center { text-align: center; }

.team-name,
.player-name,
.tbd-name {
  overflow-wrap: anywhere;
}

.tbd-name {
  color: var(--muted);
  font-style: italic;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(0, 212, 255, 0.35);
  background: rgba(10, 22, 44, 0.65);
  padding: 0.38rem 0.72rem;
  user-select: none;
}

.player-chip:hover {
  border-color: var(--defend-neon);
}

.captain-zone.drag-over {
  border-color: var(--defend-neon);
  box-shadow: inset 0 0 0 1px rgba(0, 212, 255, 0.4);
}

.bracket-tooltip {
  position: fixed;
  background: rgba(15, 20, 25, 0.95);
  color: #c7d5e0;
  border: 1px solid rgba(102, 192, 244, 0.35);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.875rem;
  font-weight: 600;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  display: none;
}

.player-chip-ghost {
  position: fixed;
  margin: 0;
  z-index: 9999;
  opacity: 0.9;
  cursor: grabbing;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/******** 404 / utility ********/
.error-container {
  width: min(900px, 96vw);
  margin: 2rem auto;
  padding: clamp(1.2rem, 2vw, 2.2rem);
  text-align: center;
  position: relative;
}

.error-code {
  font-size: clamp(4rem, 11vw, 8rem);
  color: var(--attack-neon);
}

.error-subtitle,
.discord-title,
.test-ref-title,
.tournament-info h3,
.thank-you h3 {
  color: var(--defend-neon);
}

.warning-section {
  border: 1px solid rgba(255, 17, 17, 0.4);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

.message,
.flash,
.toast {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.8rem;
}

.flash-success,
.success-message {
  border-color: rgba(40, 199, 111, 0.45);
}

.flash-error,
.error-message {
  border-color: rgba(255, 17, 17, 0.45);
}

.inline-note,
.muted-detail,
.muted-italic,
.next-steps,
.login-text,
.test-footnote-text,
.pool-count,
.row-status,
.stat-label {
  color: var(--muted);
}

.form-top-gap { margin-top: var(--space-5); }
.vs-separator { margin: 0 4px; }
.ready-respawn { color: #ffff00; }
.quake-nowrap { white-space: nowrap; }
.quake-color-0 { color: #000000; }
.quake-color-1 { color: #ff0000; }
.quake-color-2 { color: #00ff00; }
.quake-color-3 { color: #ffff00; }
.quake-color-4 { color: #3366ff; }
.quake-color-5 { color: #00ffff; }
.quake-color-6 { color: #ff00ff; }
.quake-color-7 { color: #ffffff; }
.color-black-sample { color: #000000; background: #fff; padding: 2px 5px; }
.color-red-sample { color: #ff0000; }
.color-green-sample { color: #00ff00; }
.color-yellow-sample { color: #ffff00; }
.color-blue-sample { color: #0000ff; }
.color-cyan-sample { color: #00ffff; }
.color-magenta-sample { color: #ff00ff; }
.color-white-sample { color: #ffffff; }

.float-icon-1 { top: 10%; left: 15%; animation-delay: 0s; }
.float-icon-2 { top: 20%; right: 10%; animation-delay: 2s; }
.float-icon-3 { bottom: 30%; left: 10%; animation-delay: 4s; }
.float-icon-4 { bottom: 20%; right: 20%; animation-delay: 1s; }
.float-icon-5 { top: 60%; left: 50%; animation-delay: 3s; }

/* Desktop-first overlap protection */
@media (min-width: 1100px) {
  .container,
  .users-section,
  .card,
  .week-section,
  .pool-section,
  .preferences-section,
  .stats-card {
    overflow: visible;
  }

  .users-table,
  .leaderboard-table,
  table#standingsTable,
  table#scoresTable,
  .dataTable {
    min-width: 100%;
  }
}

@media (max-width: 960px) {
  .week-columns,
  .dashboard-grid,
  .stats-summary {
    grid-template-columns: 1fr;
  }

  .match-full-row-right,
  .match-full-row-all {
    grid-column: auto;
  }

  .logo {
    font-size: 1rem;
  }
}

@media (max-width: 768px) {
  .navbar {
    padding: 0.55rem 0.7rem;
  }

  .nav-content {
    width: min(1200px, 98vw);
    gap: 0.55rem;
  }

  .user-menu.guest-links {
    width: 100%;
    justify-content: flex-start;
  }

  .logo-svg {
    width: 28px;
    height: 28px;
  }

  .container,
  .card,
  .stats-card,
  .users-section,
  .pool-section,
  .preferences-section,
  .week-section,
  .error-container {
    padding: 0.85rem;
  }

  .users-table,
  .leaderboard-table,
  table#standingsTable,
  table#scoresTable,
  .dataTable {
    min-width: 560px;
  }
}
