:root {
  --bg: #0b0d12;
  --panel: #121725;
  --panel-2: #0f121a;

  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.12);

  --text: #eaeaea;
  --muted: rgba(234,234,234,0.65);

  --accent: #7c5cff;

  /* Added semantic colors for match results */
  --win: #10b981;
  --loss: #ef4444;
}

#search-results td a {
  display: block;
  width: 100%;
  height: 100%;
}

td {
    padding: 10px 12px;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);

  /* STICKY FOOTER: Allows layout elements to stretch vertically */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1,
h2,
h3 {
  letter-spacing: -0.015em;
}

h1,
h2,
h3,
strong {
  font-weight: 700;
}

/* ---------------- HEADER ---------------- */

header {
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
}

.header-container {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-container h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.header-container nav ul {
  list-style: none;
  display: flex;
  gap: 20px;
  margin: 0;
  padding: 0;
}

/* ---------------- LAYOUT ---------------- */

main {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  flex: 1;

  /* Prevent actual page content from getting hidden behind the floating footer */
  padding: 32px 20px 100px 20px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
}

/* ---------------- CARDS ---------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  min-width: 0;
  overflow: hidden;
}

.card + .card {
  margin-top: 20px;
}

.card > h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 2rem;
  font-weight: 600;
}

.table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
}

/* ---------------- PLAYER DASHBOARD ELEMENTS ---------------- */

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.player-profile-name {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.player-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.player-rating {
  text-align: right;
}

.player-rating h1 {
  margin: 0;
  font-size: 2.5rem;
  color: var(--accent);
  line-height: 1;
  font-weight: 800;
}

.player-rating p {
  margin: 4px 0 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Dynamic grid adjustments for performance stats */
.player-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}

.player-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.stat {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.stat strong {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
}

/* ---------------- HOMEPAGE LEADERBOARD ---------------- */

.rank {
  color: var(--muted);
  width: 70px;
}

.num-header {
  text-align: right;
}

.rating-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rating-main {
  font-weight: 700;
  color: var(--accent);
}

.rating-deviation {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 0.25rem;
}

/* ---------------- LATEST REPLAYS/MATCHES ---------------- */

.latest-replays {
    margin-top: 2rem;
}

.latest-replays h2 {
    margin-bottom: 1rem;
}

.replay-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.replay-card {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 1rem;
}

.replay-time {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-bottom: 0.75rem;
}

.replay-players {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
}

.winner,
.loser {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.label {
    font-size: 0.75rem;
    text-transform: uppercase;
    opacity: 0.6;
}

.replay-player-name {
    font-size: 1.1rem;
    font-weight: bold;
}

.vs {
    font-weight: bold;
    opacity: 0.6;
}

.character-icons {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
}

.character-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex-shrink: 0;
}

.matchup-characters {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.character-team {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1rem;
    border-radius: 6px;
}

.characters-column {
    text-align: center;
    vertical-align: middle;
}

/* Player timeline */
.characters-column .character-icon {
    width: 64px;
    height: 64px;
}

/* Latest replay */
.replay-card .character-icon {
    width: 64px;
    height: 64px;
}

/* Result highlighting */
.winner-team {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.loser-team {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    opacity: 0.7;
}
.win,
.loss {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
}

.win {
    color: var(--win);
    background: rgba(16, 185, 129, 0.15);
}

.loss {
    color: var(--loss);
    background: rgba(239, 68, 68, 0.15);
}

.rating-up {
    color: var(--win);
    font-weight: 600;
}

.rating-down {
    color: var(--loss);
    font-weight: 600;
}

/* ---------------- TABLE ---------------- */

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  padding: 12px;
  border-bottom: 1px solid var(--border-strong);
  font-size: 0.875rem;
}

td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.925rem;
}

tr:hover {
  background: rgba(124, 92, 255, 0.04);
}

.leaderboard-table {
  width: 100%;
  min-width: 500px;
  white-space: nowrap;
}

.leaderboard-title {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 16px;
}

.leaderboard-info {
  margin: 0 auto 16px;
  max-width: 500px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: center;
}

/* ---------------- LINKS ---------------- */

a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent);
}

/* ---------------- SEARCH ---------------- */

.player-search {
  position: relative;
  margin-bottom: 20px;
}

input[type="search"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
  font-size: 14px;
}

input[type="search"]:focus {
  border-color: var(--accent);
}

/* dropdown */

#search-results {
  position: absolute;
  width: 100%;
  top: calc(100% + 8px);
  left: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 50;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

#search-results table {
  width: 100%;
  border-collapse: collapse;
}

#search-results td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

#search-results tr:hover {
  background: rgba(124, 92, 255, 0.08);
}

.search-empty {
  padding: 12px;
  color: var(--muted);
}

/* ---------------- FOOTER ---------------- */

footer {
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  padding: 24px 20px;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  box-sizing: border-box;

}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 14px;
  color: var(--muted);
}

.footer-content p {
  margin: 0;
}

.footer-nav ul {
  list-style: none;
  display: flex;
  gap: 24px;
  margin: 0;
  padding: 0;
}

.footer-nav a {
  color: var(--muted);
  transition: color 0.2s ease;
}

.footer-nav a:hover {
  color: var(--accent);
}

/* ---------------- RESPONSIVE / MOBILE ---------------- */

@media (max-width: 768px) {

    .content {
      flex: 0 1 auto;
    }

 header {
     padding: 12px 16px;
   }

   .header-container {
     flex-direction: column;
     align-items: center;
     text-align: center;
     gap: 12px;
   }

   .header-container h1 {
     font-size: 1.5rem;
   }

   .header-container nav {
     width: 100%;
   }

   .header-container nav ul {
     justify-content: center;
     flex-wrap: wrap;
     gap: 16px;
   }

  body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  main {
    flex: none;
  }

  .card {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  .player-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
  }

  .player-rating {
    text-align: center;
  }

  .player-profile-name {
    font-size: 1.6rem;
  }

  .player-rating h1 {
    font-size: 2rem;
  }

  .player-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat {
    padding: 12px;
  }

  td, th {
      padding-left: 4px;
      padding-right: 4px;
    }

  .table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .leaderboard-table td,
    .leaderboard-table th {
      white-space: normal;
    }

    .leaderboard-table .rating-cell {
      white-space: nowrap;
    }

  .leaderboard-table {
      width: 100%;
      min-width: 0;
      white-space: nowrap;
    }

  .character-icon {
    width: 48px;
    height: 48px;
  }

  footer {
    text-align: center;
  }

  .footer-content {
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .footer-nav ul {
    justify-content: center;
    flex-wrap: wrap;
  }
}