:root {
  --accent: #e8241a;
  --line: rgba(255, 255, 255, 0.14);
  --text: #fff;
  --text-muted: rgba(255, 255, 255, 0.6);
  --header-h: 80px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #000;
  background-image: radial-gradient(ellipse at top, #2a2a2e 0%, #121214 45%, #000 100%);
  background-attachment: fixed;
}

/* ---------- Header / tab bar ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: stretch;
  gap: 40px;
  height: var(--header-h);
  padding: 0 32px;
  background: rgba(10, 10, 12, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}

.logo img {
  height: 56px;
  width: auto;
}

.tabbar {
  display: flex;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabbar::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 16px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.tab:hover,
.tab:focus-visible {
  color: var(--text);
}

.tab.is-active {
  color: var(--text);
}

.tab:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: -6px;
}

/* ---------- Right side of header ---------- */

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ---------- Sign in button ---------- */

.signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: #0b0b0d;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.signin-btn:hover {
  background: var(--accent);
  color: var(--text);
}

.signin-btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.signin-text {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Signed in: show email, no caps */
.signin-btn.is-signed-in {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--line);
  text-transform: none;
  letter-spacing: 0.01em;
}

.signin-btn.is-signed-in:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* ---------- Sign in / Sign up window ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.auth {
  width: min(400px, calc(100vw - 32px));
  padding: 32px 28px 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #1c1c20 0%, #0d0d0f 100%);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}

.auth::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.auth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.auth-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.auth-logo {
  display: block;
  height: 52px;
  margin: 0 auto 20px;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.auth-mode {
  padding: 9px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.auth-mode:hover {
  color: var(--text);
}

.auth-mode.is-active {
  background: var(--accent);
  color: var(--text);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.field input:focus {
  outline: none;
  border-color: var(--text);
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.field-hint[hidden] {
  display: none;
}

.auth-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(232, 36, 26, 0.14);
  color: #ff8a82;
  font-size: 13px;
}

.auth-submit {
  width: 100%;
  height: 46px;
  margin-top: 4px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.auth-submit:hover {
  filter: brightness(1.12);
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

.auth-mode:focus-visible,
.auth-submit:focus-visible,
.auth-close:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.auth-account {
  text-align: center;
}

.auth-account-label {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-account-email {
  margin: 0 0 24px;
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.auth-signout {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

/* ---------- Language switch ---------- */

.lang {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.lang-btn {
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.is-active {
  background: var(--accent);
  color: var(--text);
}

.lang-btn:focus-visible,
.lang-select:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.lang-select {
  display: none;
  padding: 6px 28px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.05)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E")
    no-repeat right 11px center;
}

.lang-select option {
  background: #141416;
  color: #fff;
}

@media (max-width: 760px) {
  .lang {
    display: none;
  }

  .lang-select {
    display: block;
  }

  /* Phones: icon-only round button */
  .header-actions {
    gap: 8px;
  }

  .signin-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
  }

  .signin-text {
    display: none;
  }
}

/* ---------- Banner slider ---------- */

.banner-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 1034 / 96;
  overflow: hidden;
  background: #000;
}

.slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.2s ease-in-out;
}

.slide.is-active {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .slide {
    transition: none;
  }
}

/* ---------- Teams: side list + team page ---------- */

.teams {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 56px;
}

.teams[hidden] {
  display: none;
}

.teams:not(.is-list-open) {
  grid-template-columns: minmax(0, 1fr);
}

.teams:not(.is-list-open) .team-list {
  display: none;
}

.panel,
.team-list-items,
.team-hero,
.stat,
.player,
.chart-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}

/* List */
.team-list {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  align-self: start;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--header-h) - 32px);
  min-height: 0;
}

/* Heading sits above the box */
.team-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 10px 4px;
}

.team-list-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

/* The box: just the list */
.team-list-items {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  overflow-y: auto;
}

.team-list-items li + li {
  margin-top: 4px;
}

.team-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 7px 12px 7px 8px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.team-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.team-item.is-active {
  background: rgba(232, 36, 26, 0.16);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.team-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-item-rank {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* Logos */
.team-logo {
  flex-shrink: 0;
  width: var(--s);
  height: var(--s);
  border-radius: calc(var(--s) * 0.22);
  object-fit: contain;
}

.team-logo--initials {
  display: grid;
  place-items: center;
  background: hsl(var(--h) 45% 28%);
  color: #fff;
  font-size: calc(var(--s) * 0.38);
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* Open-list button */
.team-list-open {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.team-list-open:hover {
  background: rgba(255, 255, 255, 0.1);
}

.teams:not(.is-list-open) .team-list-open {
  display: inline-flex;
}

/* Team page */
.team-detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.team-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(232, 36, 26, 0.22), transparent 60%),
    rgba(255, 255, 255, 0.035);
}

.team-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 8px;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.team-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rank-badge,
.award-chip,
.demo-chip,
.country {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.rank-badge {
  background: var(--accent);
}

.award-chip {
  background: rgba(240, 190, 60, 0.16);
  color: #f3c94e;
}

.demo-chip {
  border: 1px dashed rgba(255, 255, 255, 0.35);
  color: var(--text-muted);
}

.country {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  vertical-align: middle;
}

.block-title {
  margin: 10px 0 -4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Roster */
.roster {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px 0;
  overflow: hidden;
  text-align: center;
}

.player-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}

.player-photo--empty {
  padding: 10px;
  fill: rgba(255, 255, 255, 0.28);
}

.player .country {
  margin-top: -4px;
}

.player-nick {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}

.player-rating {
  align-self: stretch;
  padding: 6px 0;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.is-good.player-rating { background: rgba(46, 160, 67, 0.35); }
.is-mid.player-rating  { background: rgba(210, 165, 40, 0.35); }
.is-bad.player-rating  { background: rgba(232, 36, 26, 0.3); }

/* Stats */
.stats,
.rank-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.stats {
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
}

.stat-label {
  color: var(--text-muted);
  font-size: 12px;
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat--main {
  background: rgba(232, 36, 26, 0.14);
}

.stat.is-good {
  background: rgba(46, 160, 67, 0.2);
}

.stat.is-good .stat-value {
  color: #6fdc8c;
}

.stat.is-bad {
  background: rgba(232, 36, 26, 0.14);
}

.stat.is-bad .stat-value {
  color: #ff8a82;
}

.awards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.team-empty {
  color: var(--text-muted);
  font-size: 14px;
}

.team-list-empty {
  padding: 14px 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.teams-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 56px 20px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
}

.teams-empty img {
  height: 56px;
  margin-bottom: 10px;
  opacity: 0.5;
}

.teams-empty-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.teams-empty .team-empty {
  margin: 0;
}

/* Rank chart */
.chart-wrap {
  padding: 12px 12px 4px;
}

.rank-chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.chart-label {
  fill: var(--text-muted);
  font-size: 12px;
}

.chart-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 2;
  stroke-linejoin: round;
}

.chart-dot {
  fill: #fff;
}

.chart-dot--now {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 2;
}

.team-item:focus-visible,
.icon-btn:focus-visible,
.team-list-open:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* Tablet: roster wraps */
@media (max-width: 1100px) {
  .roster {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

/* Phones: the list becomes a slide-in drawer */
@media (max-width: 760px) {
  .teams,
  .teams:not(.is-list-open) {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px 12px 40px;
  }

  .team-list,
  .teams:not(.is-list-open) .team-list {
    position: fixed;
    z-index: 40;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    align-self: stretch;
    width: min(320px, 86vw);
    height: 100vh;
    height: 100dvh;
    max-height: none;
    padding: 16px 12px;
    border-right: 1px solid var(--line);
    border-radius: 0 14px 14px 0;
    background: #111114;
    transform: translateX(0);
    transition: transform 0.25s ease;
  }

  .teams:not(.is-list-open) .team-list {
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s 0.25s;
  }

  .team-list-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.6);
  }

  .team-list-backdrop[hidden] {
    display: none;
  }

  .team-list-open,
  .teams:not(.is-list-open) .team-list-open {
    display: inline-flex;
  }

  .team-hero {
    gap: 14px;
    padding: 16px;
  }

  .roster {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .player-photo {
    width: 60px;
    height: 60px;
  }

  .stats,
  .rank-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-value {
    font-size: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .team-list {
    transition: none !important;
  }
}

@media (max-width: 600px) {
  :root {
    --header-h: 64px;
  }

  /* Phones: logo + actions on the first row, tabs on their own row below */
  .site-header {
    flex-wrap: wrap;
    height: auto;
    column-gap: 8px;
    row-gap: 0;
    padding: 0 12px;
  }

  .logo {
    height: 56px;
  }

  .logo img {
    height: 38px;
  }

  .header-actions {
    gap: 8px;
  }

  /* Tabs share the full width evenly; text scales a little with screen width */
  .tabbar {
    order: 3;
    width: calc(100% + 24px);
    margin: 0 -12px;
    height: 42px;
    gap: 0;
  }

  .tab {
    flex: 1 1 auto;
    justify-content: center;
    padding: 0 4px;
    font-size: clamp(10px, 3.2vw, 12.5px);
    letter-spacing: 0.03em;
  }

  .lang-select {
    padding: 5px 20px 5px 8px;
    font-size: 10.5px;
    letter-spacing: 0.04em;
    background-position: right 7px center;
  }

  .signin-btn {
    width: 32px;
    height: 32px;
  }
}
