:root {
  color-scheme: dark;
  --ink: #f7fafc;
  --muted: #9fb2bf;
  --paper: #f5f7f3;
  --navy: #071522;
  --panel: #0d2030;
  --panel-2: #122b3c;
  --line: rgba(255, 255, 255, 0.12);
  --red: #e8453c;
  --gold: #f6c842;
  --green: #12a46f;
  --sky: #4dc5ff;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background:
    linear-gradient(180deg, rgba(18, 164, 111, 0.16), transparent 460px),
    var(--navy);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.app-header {
  background: rgba(7, 21, 34, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 500;
}

.brand-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1240px;
  padding: 10px 12px;
}

.brand {
  align-items: center;
  display: inline-flex;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--red), var(--gold));
  border: 2px solid rgba(255, 255, 255, 0.52);
  border-radius: 50%;
  color: #071522;
  display: inline-flex;
  flex: 0 0 40px;
  font-size: 0.82rem;
  font-weight: 950;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.brand strong,
.brand em {
  display: block;
}

.brand strong {
  font-size: clamp(0.94rem, 4.6vw, 1.18rem);
  letter-spacing: 0;
  line-height: 1.05;
  white-space: nowrap;
}

.brand em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  margin-top: 2px;
  text-transform: uppercase;
}

.top-nav {
  display: none;
}

main {
  margin: 0 auto;
  max-width: 1240px;
  padding: 12px 10px 28px;
}

.atlas-grid {
  display: grid;
  gap: 10px;
  scroll-margin-top: 74px;
}

.map-card,
.live-board,
.born-section,
.team-section,
.players-section,
.source-strip {
  background: rgba(13, 32, 48, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.map-card {
  min-width: 0;
}

.map-topline,
.section-head,
.live-title,
.panel-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.map-topline,
.section-head {
  padding: 14px;
}

.map-topline {
  background:
    linear-gradient(90deg, rgba(232, 69, 60, 0.26), transparent 52%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent);
  border-bottom: 1px solid var(--line);
}

.map-topline p,
.map-topline h1,
.section-head p,
.section-head h2,
.panel-head h2 {
  margin: 0;
}

.map-topline p {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.7rem, 9vw, 3.5rem);
  line-height: 0.92;
  margin-top: 3px;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(1.25rem, 6vw, 2.15rem);
  line-height: 1;
}

.section-head p {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  margin-top: 5px;
}

.icon-button {
  background: var(--gold);
  border: 0;
  border-radius: 8px;
  color: #081522;
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 950;
  min-height: 38px;
  padding: 0 12px;
  text-transform: uppercase;
}

.team-rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px;
  scrollbar-width: thin;
}

.team-chip {
  --team-color: var(--gold);
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  flex: 0 0 126px;
  grid-template-columns: 1fr auto;
  min-height: 64px;
  padding: 9px;
  text-align: left;
}

.team-chip span {
  color: var(--team-color);
  font-size: 0.78rem;
  font-weight: 950;
}

.team-chip strong {
  align-self: end;
  font-size: 0.8rem;
  grid-column: 1 / -1;
  line-height: 1.08;
  margin-top: 4px;
}

.team-chip em {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  color: #fff;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
  padding: 3px 7px;
}

.team-chip.active {
  background: color-mix(in srgb, var(--team-color) 18%, rgba(255, 255, 255, 0.08));
  border-color: color-mix(in srgb, var(--team-color) 70%, #ffffff);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.team-chip.all {
  --team-color: var(--gold);
}

.birth-map {
  background:
    linear-gradient(90deg, rgba(77, 197, 255, 0.12), transparent 45%),
    #08131d;
  height: min(63vh, 560px);
  min-height: 430px;
  width: 100%;
}

.map-fallback {
  align-items: center;
  display: grid;
  gap: 6px;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.map-fallback span {
  color: var(--muted);
  font-size: 0.9rem;
}

.leaflet-container {
  background: #08131d;
  color: #071522;
  font-family: inherit;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #f7fafc;
  color: #081522;
}

.leaflet-control-attribution {
  font-size: 0.62rem;
}

.birth-cluster {
  align-items: center;
  background: rgba(246, 200, 66, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 0 7px rgba(246, 200, 66, 0.2), 0 12px 22px rgba(0, 0, 0, 0.35);
  color: #08131d;
  display: inline-flex;
  font-weight: 950;
  justify-content: center;
}

.birth-cluster span {
  align-items: center;
  background: var(--gold);
  border-radius: 50%;
  display: inline-flex;
  height: 100%;
  justify-content: center;
  width: 100%;
}

.birth-cluster-small span {
  font-size: 0.82rem;
}

.birth-cluster-medium span {
  font-size: 0.94rem;
}

.birth-cluster-large span {
  font-size: 1.06rem;
}

.map-popup {
  min-width: 210px;
}

.map-popup h3,
.map-popup p,
.map-popup ul {
  margin: 0;
}

.map-popup h3 {
  font-size: 1rem;
  line-height: 1.1;
}

.map-popup p {
  color: #435160;
  font-size: 0.78rem;
  font-weight: 800;
  margin-top: 3px;
}

.map-popup ul {
  display: grid;
  gap: 6px;
  list-style: none;
  padding: 10px 0 0;
}

.map-popup li {
  align-items: center;
  display: flex;
  gap: 9px;
  justify-content: space-between;
}

.map-popup li strong {
  font-size: 0.8rem;
}

.map-popup li span,
.popup-more {
  color: #5a6a77;
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.live-board {
  padding: 12px;
}

.live-title {
  margin-bottom: 12px;
}

.live-title > span {
  align-items: center;
  background: var(--gold);
  border-radius: 8px;
  color: #071522;
  display: inline-flex;
  flex: 0 0 54px;
  font-size: 0.86rem;
  font-weight: 950;
  height: 48px;
  justify-content: center;
}

.live-title strong,
.live-title em {
  display: block;
}

.live-title strong {
  font-size: 1.05rem;
  line-height: 1.05;
}

.live-title em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 800;
  margin-top: 3px;
}

.stat-stack {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-stack article {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 84px;
  padding: 12px;
}

.stat-stack span,
.team-card em,
.team-card small,
.source-strip strong,
.search-box span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.stat-stack strong {
  display: block;
  font-size: clamp(1.75rem, 9vw, 2.6rem);
  line-height: 1;
  margin-top: 7px;
}

.mini-panel {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 10px;
  padding: 12px;
}

.panel-head {
  margin-bottom: 9px;
}

.panel-head h2 {
  font-size: 1rem;
}

.panel-head span,
#bornLeader,
#snapshotLabel {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.town-list {
  display: grid;
  gap: 8px;
}

.town-list article {
  align-items: center;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 34px 1fr auto;
  min-width: 0;
  padding: 9px;
}

.town-list span {
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 950;
}

.town-list strong,
.town-list em {
  display: block;
  min-width: 0;
}

.town-list strong {
  font-size: 0.86rem;
  line-height: 1.12;
}

.town-list em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  margin-top: 2px;
}

.town-list b {
  align-items: center;
  background: var(--green);
  border-radius: 50%;
  color: #04130d;
  display: inline-flex;
  font-size: 0.8rem;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.team-section,
.born-section,
.players-section,
.source-strip {
  margin-top: 10px;
  scroll-margin-top: 74px;
}

.born-chart {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.born-row {
  --team-color: var(--gold);
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 8px;
  grid-template-columns: 42px minmax(84px, 1fr) 54px;
  min-height: 82px;
  padding: 10px;
  text-align: left;
}

.born-row.active {
  border-color: color-mix(in srgb, var(--team-color) 74%, #ffffff);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.born-code {
  align-items: center;
  background: color-mix(in srgb, var(--team-color) 22%, rgba(255, 255, 255, 0.08));
  border: 1px solid color-mix(in srgb, var(--team-color) 70%, transparent);
  border-radius: 8px;
  color: var(--team-color);
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 950;
  height: 38px;
  justify-content: center;
}

.born-name {
  font-size: 0.9rem;
  font-weight: 950;
  line-height: 1.05;
  min-width: 0;
}

.born-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  grid-column: 1 / -1;
  height: 16px;
  overflow: hidden;
  position: relative;
}

.born-track i {
  background: linear-gradient(90deg, var(--team-color), var(--gold));
  border-radius: inherit;
  display: block;
  height: 100%;
  min-width: 8px;
  width: calc(var(--pct) * 1%);
}

.born-row strong {
  font-size: 1.35rem;
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  line-height: 1;
}

.born-row em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
  grid-column: 1 / -1;
  text-transform: uppercase;
}

.team-grid {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.team-card {
  --team-color: var(--gold);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--team-color) 18%, transparent), transparent 42%),
    rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 8px;
  padding: 12px;
  text-align: left;
}

.team-card.active {
  border-color: color-mix(in srgb, var(--team-color) 74%, #ffffff);
}

.team-card > span {
  color: var(--team-color);
  font-size: 0.85rem;
  font-weight: 950;
}

.team-card h3,
.team-card p {
  margin: 0;
}

.team-card h3 {
  font-size: 1.18rem;
  line-height: 1;
}

.team-card p {
  color: #d5e2e9;
  font-size: 0.78rem;
  font-weight: 800;
}

.team-card div {
  display: grid;
  gap: 3px 8px;
  grid-template-columns: repeat(3, auto 1fr);
}

.team-card div strong {
  font-size: 1.08rem;
  line-height: 1;
}

.team-card small {
  display: block;
  line-height: 1.25;
}

.players-section .section-head {
  align-items: stretch;
  flex-direction: column;
}

.search-box {
  display: grid;
  gap: 6px;
}

.search-box input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #fff;
  min-height: 42px;
  outline: none;
  padding: 0 12px;
  width: 100%;
}

.search-box input:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(77, 197, 255, 0.16);
}

.player-list {
  display: grid;
  gap: 8px;
  max-height: 680px;
  overflow: auto;
  padding: 0 10px 10px;
}

.player-row {
  --team-color: var(--gold);
  align-items: start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-left: 5px solid var(--team-color);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 44px 1fr;
  min-width: 0;
  padding: 10px;
}

.player-row > span {
  color: var(--team-color);
  font-size: 0.78rem;
  font-weight: 950;
}

.player-row strong,
.player-row em {
  display: block;
  min-width: 0;
}

.player-row strong {
  font-size: 0.94rem;
  line-height: 1.12;
}

.player-row em {
  color: var(--muted);
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 800;
  margin-top: 2px;
}

.player-row p {
  color: #dce8ef;
  font-size: 0.82rem;
  font-weight: 800;
  grid-column: 1 / -1;
  line-height: 1.22;
  margin: 0;
}

.player-row b {
  background: rgba(246, 200, 66, 0.16);
  border: 1px solid rgba(246, 200, 66, 0.38);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.68rem;
  grid-column: 1 / -1;
  justify-self: start;
  padding: 4px 8px;
  text-transform: uppercase;
}

.empty-state {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  padding: 16px;
  text-align: center;
}

.source-strip {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.source-strip p {
  color: #d8e3e9;
  font-size: 0.86rem;
  font-weight: 760;
  line-height: 1.45;
  margin: 5px 0 0;
}

.source-strip a {
  border-bottom: 1px solid rgba(246, 200, 66, 0.58);
  color: var(--gold);
  display: inline-block;
  margin: 0 9px 4px 0;
}

@media (min-width: 700px) {
  main {
    padding: 16px 16px 38px;
  }

  .top-nav {
    display: flex;
    gap: 6px;
  }

  .top-nav a {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #dce7ee;
    font-size: 0.76rem;
    font-weight: 900;
    padding: 9px 11px;
    text-transform: uppercase;
  }

  .atlas-grid {
    grid-template-columns: minmax(0, 1fr) 340px;
  }

  .birth-map {
    height: 650px;
  }

  .live-board {
    align-self: stretch;
  }

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

  .born-row {
    grid-template-columns: 52px 170px minmax(240px, 1fr) 72px 128px;
    min-height: 58px;
  }

  .born-track {
    grid-column: auto;
  }

  .born-row strong {
    grid-column: auto;
    grid-row: auto;
  }

  .born-row em {
    grid-column: auto;
    justify-self: end;
    white-space: nowrap;
  }

  .players-section .section-head {
    align-items: center;
    flex-direction: row;
  }

  .search-box {
    min-width: 330px;
  }

  .player-row {
    align-items: center;
    grid-template-columns: 54px minmax(170px, 1.2fr) minmax(240px, 1fr) auto;
  }

  .player-row p,
  .player-row b {
    grid-column: auto;
  }
}

@media (min-width: 1024px) {
  .team-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .source-strip {
    grid-template-columns: 1fr 1fr;
  }
}
