:root {
  --navy-950: #06101e;
  --navy-900: #081527;
  --navy-850: #0b1b30;
  --navy-800: #10243d;
  --navy-700: #193653;
  --line: #27435f;
  --text: #f7fbff;
  --muted: #9cb0c4;
  --cyan: #46c8ff;
  --cyan-soft: #b8ebff;
  --gold: #f5c34b;
  --gold-soft: #ffe7a1;
  --red: #ff6c64;
  --green: #66daa2;
  --shadow: 0 18px 46px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }

html { color-scheme: dark; scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(6, 16, 30, .82), rgba(6, 16, 30, .93)),
    url("assets/royal-background.png") center top / cover fixed,
    var(--navy-950);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(70, 200, 255, .38); outline-offset: 2px; }
img { display: block; max-width: 100%; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 76px;
  padding: 10px clamp(18px, 4vw, 58px);
  border-bottom: 1px solid rgba(156, 176, 196, .18);
  background: rgba(6, 16, 30, .94);
  backdrop-filter: blur(16px);
}

.wordmark {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.wordmark img { width: 47px; height: 47px; object-fit: contain; }
.wordmark span { display: grid; line-height: 1; }
.wordmark strong { color: var(--gold); font-size: 14px; letter-spacing: .17em; }
.wordmark small { margin-top: 5px; color: var(--text); font-size: 10px; font-weight: 800; letter-spacing: .21em; }

.view-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--navy-900);
}

.nav-button {
  display: inline-flex;
  min-width: 108px;
  height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.nav-button img { width: 27px; height: 27px; object-fit: contain; filter: saturate(.7); }
.nav-button.active { background: var(--navy-700); color: var(--text); box-shadow: inset 0 0 0 1px rgba(70, 200, 255, .2); }
.nav-button.active img { filter: none; }

.header-actions { display: flex; justify-content: flex-end; align-items: center; gap: 9px; }

.button, .text-button {
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.button { min-height: 42px; padding: 0 17px; }
.button.primary { background: var(--gold); color: #1a160b; box-shadow: 0 5px 16px rgba(245, 195, 75, .18); }
.button.primary:hover { background: #ffd264; }
.text-button { padding: 9px 8px; background: transparent; color: var(--muted); }
.text-button:hover { color: var(--text); }

main { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 72px; }

.utility-row {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(156, 176, 196, .12);
}

.dataset-line { display: flex; min-width: 0; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.dataset-line strong { color: var(--cyan-soft); }
.dataset-line span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(102, 218, 162, .12); }

.control-dock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 26px 0 15px;
}

.control-dock > span, .select-control > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
}

.control-dock small { color: var(--muted); font-size: 11px; }

.segment {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--navy-900);
}

.segment button {
  min-width: 86px;
  height: 36px;
  padding: 0 13px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segment button.active { background: var(--cyan); color: #05121f; box-shadow: 0 5px 18px rgba(70, 200, 255, .2); }

.view { display: none; }
.view.active { display: block; }

.player-finder {
  display: grid;
  grid-template-columns: minmax(230px, .8fr) minmax(340px, 1.6fr);
  gap: clamp(28px, 6vw, 88px);
  align-items: center;
  min-height: 245px;
  padding: 40px clamp(25px, 5vw, 72px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(110deg, rgba(8, 21, 39, .74), rgba(16, 36, 61, .95)),
    var(--navy-900);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .18em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 9px; font-size: clamp(34px, 5vw, 56px); line-height: .98; letter-spacing: -.045em; }
h2 { margin-bottom: 7px; font-size: clamp(30px, 4vw, 46px); line-height: 1; letter-spacing: -.035em; }
h3 { margin-bottom: 0; font-size: 20px; letter-spacing: -.02em; }
.finder-copy > p:last-child, .clan-heading p:last-child, .identity-main p:last-child { margin-bottom: 0; color: var(--muted); }

.search-shell { position: relative; }
.search-shell > input {
  width: 100%;
  height: 66px;
  padding: 0 62px 0 53px;
  border: 2px solid var(--cyan);
  border-radius: 12px;
  background: #f6fbff;
  color: #081527;
  font-size: 18px;
  font-weight: 750;
  box-shadow: 0 15px 34px rgba(0, 0, 0, .22);
}

.search-shell > input::placeholder { color: #6c7f91; }
.search-icon { position: absolute; z-index: 2; top: 16px; left: 19px; color: #244866; font-size: 29px; line-height: 1; }
kbd { position: absolute; top: 20px; right: 18px; padding: 5px 9px; border: 1px solid #cbd7df; border-radius: 6px; background: #e8f0f5; color: #506476; font: 700 12px ui-monospace, monospace; }

.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  width: 100%;
  max-height: 330px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #d2dde6;
  border-radius: 11px;
  background: #f7fbff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .34);
}

.search-result {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #10243d;
  text-align: left;
}

.search-result:hover, .search-result:focus-visible { background: #e2f5fd; }
.search-result img { width: 34px; height: 34px; object-fit: contain; }
.search-result strong { display: block; font-size: 14px; }
.search-result small { color: #617588; }
.member-chip { padding: 4px 7px; border-radius: 999px; background: #d9f5e6; color: #176d48 !important; font-size: 9px !important; font-weight: 900; letter-spacing: .08em; }

.dashboard { margin-top: 20px; }

.identity-card, .clan-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 25px 28px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--navy-900);
}

.identity-main, .clan-heading { display: flex; align-items: center; gap: 19px; min-width: 0; }
.identity-icon { width: 86px; height: 65px; object-fit: contain; }
.identity-main h2 { margin-bottom: 6px; }

.title-stack { display: flex; max-width: 650px; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.player-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px 9px 8px;
  border: 1px solid rgba(245, 195, 75, .4);
  border-radius: 9px;
  background: rgba(245, 195, 75, .08);
}
.player-title img { width: 31px; height: 31px; object-fit: contain; }
.player-title strong { display: block; color: var(--gold-soft); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.player-title small { display: block; max-width: 205px; margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.25; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}

#playerStats { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.metric-card {
  position: relative;
  min-height: 148px;
  overflow: hidden;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--navy-900);
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -28px;
  bottom: -38px;
  width: 105px;
  height: 105px;
  border-radius: 50%;
  background: rgba(70, 200, 255, .055);
}

.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric-top > span { color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.metric-top img { width: 36px; height: 36px; object-fit: contain; }
.metric-card > strong { display: block; margin-top: 15px; font-size: clamp(24px, 3vw, 33px); line-height: 1; letter-spacing: -.04em; }
.metric-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.rank-pill { position: relative; z-index: 1; padding: 4px 7px; border: 1px solid rgba(70, 200, 255, .25); border-radius: 999px; background: rgba(70, 200, 255, .09); color: var(--cyan-soft); font-weight: 850; white-space: nowrap; }

.two-column { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(330px, .8fr); gap: 12px; }

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--navy-900);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .12);
}

.panel-heading {
  display: flex;
  min-height: 77px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 17px 20px;
  border-bottom: 1px solid rgba(156, 176, 196, .14);
}
.panel-heading .eyebrow { margin-bottom: 4px; }
.panel-note { color: var(--muted); font-size: 11px; }
.panel-heading > img { width: 48px; height: 48px; object-fit: contain; }

.chart {
  display: flex;
  min-height: 294px;
  align-items: stretch;
  gap: clamp(9px, 1.35vw, 21px);
  padding: 25px 24px 19px;
  overflow-x: auto;
}

.bar-item { display: flex; min-width: 52px; flex: 1 0 52px; flex-direction: column; justify-content: flex-end; text-align: center; }
.bar-value { margin-bottom: 7px; color: var(--cyan-soft); font-size: 11px; font-weight: 850; }
.bar-track { display: flex; height: 185px; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line); }
.bar-fill { position: relative; width: min(36px, 70%); min-height: 2px; border-radius: 5px 5px 1px 1px; background: var(--cyan); box-shadow: 0 0 20px rgba(70, 200, 255, .16); }
.bar-fill.best { background: var(--gold); box-shadow: 0 0 22px rgba(245, 195, 75, .2); }
.bar-fill.zero { background: var(--line); box-shadow: none; }
.bar-label { margin-top: 10px; color: var(--muted); font-size: 10px; font-weight: 800; white-space: nowrap; }
.bar-sub { margin-top: 3px; color: #71879b; font-size: 9px; white-space: nowrap; }

.performance-list { margin: 0; padding: 6px 20px 12px; list-style: none; counter-reset: performance; }
.performance-list li {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 11px;
  min-height: 62px;
  border-bottom: 1px solid rgba(156, 176, 196, .12);
  counter-increment: performance;
}
.performance-list li:last-child { border-bottom: 0; }
.performance-list li::before {
  content: counter(performance);
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 7px;
  background: var(--navy-700);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}
.performance-list li:first-child::before { background: var(--gold); color: #261d08; }
.performance-list strong { display: block; font-size: 13px; }
.performance-list small { color: var(--muted); font-size: 10px; }
.performance-list b { color: var(--gold-soft); font-size: 15px; }

.table-panel { margin-top: 12px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 18px; border-bottom: 1px solid rgba(156, 176, 196, .12); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
td { color: #dbe6ef; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(70, 200, 255, .035); }
.player-cell button { display: block; padding: 0; border: 0; background: transparent; color: var(--text); font-weight: 850; text-align: left; }
.player-cell button:hover { color: var(--cyan); }
.player-cell small { display: block; margin-top: 2px; color: var(--muted); }
.place { color: var(--cyan-soft); font-weight: 850; }
.status-active { color: var(--green); font-weight: 800; }
.status-missed { color: var(--red); font-weight: 800; }

.clan-hero { margin-top: 5px; background: linear-gradient(120deg, var(--navy-900), var(--navy-800)); }
.clan-heading > img { width: 92px; height: 92px; object-fit: contain; }
.clan-heading h1 { margin-bottom: 5px; }

.select-control { display: grid; gap: 6px; }
select, .mini-search {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--navy-850);
  color: var(--text);
}
select { min-width: 155px; padding: 0 34px 0 11px; }
.table-tools { display: flex; align-items: flex-end; gap: 8px; }
.mini-search { display: flex; height: 40px; align-items: center; gap: 7px; padding: 0 10px; }
.mini-search input { width: 130px; border: 0; outline: 0; background: transparent; color: var(--text); }
.mini-search input::placeholder { color: var(--muted); }

.clan-panels { grid-template-columns: minmax(0, 1.6fr) minmax(340px, .75fr); }
.leaderboard-heading { align-items: flex-end; }
.ranking-wrap { max-height: 585px; overflow-y: auto; }
.ranking-wrap thead { position: sticky; top: 0; z-index: 2; background: var(--navy-900); }
.rank-number { width: 30px; color: var(--muted); font-size: 15px; font-weight: 900; }
.rank-number.top { color: var(--gold); }
.metric-value { color: var(--cyan-soft); font-weight: 900; }
.records-panel .performance-list { max-height: 580px; overflow-y: auto; }
.clan-chart-panel { margin-top: 12px; }
.clan-chart .bar-track { height: 205px; }

.loading {
  display: flex;
  min-height: 320px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}
.loading span { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--cyan); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-state { max-width: 620px; margin: 70px auto; padding: 30px; border: 1px solid rgba(255, 108, 100, .35); border-radius: 14px; background: rgba(255, 108, 100, .06); text-align: center; }
.error-state strong { font-size: 20px; }
.error-state p { margin: 8px 0 18px; color: var(--muted); }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(20px, 4vw, 58px);
  border-top: 1px solid rgba(156, 176, 196, .14);
  color: var(--muted);
  font-size: 11px;
}

.toast {
  position: fixed;
  z-index: 60;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7fbff;
  color: #081527;
  font-size: 12px;
  font-weight: 800;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #playerStats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-column, .clan-panels { grid-template-columns: 1fr; }
  .records-panel .performance-list { max-height: none; }
  .title-stack { justify-content: flex-start; }
  .identity-card { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 760px) {
  .site-header { position: relative; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 16px; }
  .view-nav { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .nav-button { flex: 1; }
  .header-actions .text-button { display: none; }
  main { width: min(100% - 24px, 1480px); }
  .utility-row { min-height: 42px; }
  .utility-row > .text-button, .dataset-line span:last-child { display: none; }
  .control-dock { flex-wrap: wrap; gap: 8px 11px; padding-top: 18px; }
  .control-dock > small { width: 100%; text-align: center; }
  .segment { flex: 1; }
  .segment button { min-width: 0; flex: 1; padding: 0 7px; }
  .player-finder { grid-template-columns: 1fr; min-height: 0; gap: 25px; padding: 30px 20px; }
  h1 { font-size: 38px; }
  .search-shell > input { height: 58px; padding-left: 49px; font-size: 15px; }
  .search-icon { top: 13px; }
  kbd { display: none; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #playerStats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { min-height: 138px; padding: 15px; }
  .identity-card, .clan-hero { padding: 20px; }
  .identity-main, .clan-heading { align-items: flex-start; }
  .identity-icon, .clan-heading > img { width: 61px; height: 61px; flex: 0 0 auto; }
  .title-stack { width: 100%; }
  .player-title { width: 100%; }
  .player-title small { max-width: none; }
  .clan-hero { align-items: stretch; flex-direction: column; }
  .table-tools { width: 100%; flex-wrap: wrap; }
  .mini-search { flex: 1; }
  .mini-search input { width: 100%; }
  .leaderboard-heading { align-items: flex-start; flex-direction: column; }
  .panel-heading { padding: 15px; }
  th, td { padding: 12px 14px; }
  footer { flex-direction: column; }
}

@media (max-width: 430px) {
  .wordmark img { width: 40px; height: 40px; }
  .header-actions .button { padding: 0 12px; }
  .metric-grid { grid-template-columns: 1fr; }
  #playerStats { grid-template-columns: 1fr; }
  .metric-card { min-height: 120px; }
  .chart { padding-inline: 14px; }
  .search-result { grid-template-columns: 32px 1fr; }
  .search-result .member-chip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
