:root {
  color-scheme: dark;
  --bg: #05080e;
  --panel: rgba(11, 18, 29, .86);
  --panel-strong: #0c1420;
  --line: rgba(131, 179, 226, .14);
  --line-hover: rgba(70, 181, 255, .42);
  --text: #f4f8fc;
  --muted: #8fa2b6;
  --blue: #4bc5ff;
  --blue-strong: #168cff;
  --cyan: #5af2e5;
  --radius: 18px;
  --shadow: 0 22px 80px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    radial-gradient(circle at 50% -15%, #102b48 0, transparent 42%),
    var(--bg);
  background-size: 42px 42px, 42px 42px, auto, auto;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
.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; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: .11;
  pointer-events: none;
  animation: ambient-drift 14s ease-in-out infinite alternate;
}
.ambient-one { top: 9%; left: -180px; background: #16a1ff; }
.ambient-two { right: -210px; top: 52%; background: #18d8c7; animation-delay: -5s; }
@keyframes ambient-drift { to { transform: translate3d(30px, -22px, 0) scale(1.08); } }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 14px 22px 0;
}
.nav-shell {
  width: min(1240px, 100%);
  min-height: 74px;
  margin: 0 auto;
  padding: 9px 12px 9px 14px;
  display: grid;
  grid-template-columns: minmax(260px, auto) minmax(250px, 410px) auto;
  align-items: center;
  gap: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(7, 12, 20, .80);
  box-shadow: 0 12px 45px rgba(0,0,0,.25);
  backdrop-filter: blur(18px) saturate(1.3);
}
.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  outline: none;
}
.brand-link:focus-visible {
  box-shadow: 0 0 0 3px rgba(75,197,255,.22);
}
.brand-emblem {
  width: 50px;
  height: 50px;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(27,130,255,.34));
  transition: transform .32s cubic-bezier(.2,.8,.2,1), filter .32s ease;
}
.brand-wordmark {
  width: min(232px, 22vw);
  min-width: 165px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 7px 13px rgba(0,0,0,.36));
  transition: transform .32s cubic-bezier(.2,.8,.2,1), filter .32s ease;
}
.brand-emblem-link:hover .brand-emblem { transform: rotate(-7deg) scale(1.08); filter: drop-shadow(0 0 23px rgba(27,130,255,.55)); }
.brand-wordmark-link:hover .brand-wordmark { transform: translateY(-3px) scale(1.025); filter: drop-shadow(0 11px 19px rgba(0,0,0,.52)) drop-shadow(0 0 10px rgba(75,197,255,.10)); }

.nav-search {
  height: 44px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding-left: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.035);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.nav-search:focus-within { border-color: rgba(75,197,255,.58); background: rgba(31,98,143,.10); box-shadow: 0 0 0 4px rgba(75,197,255,.08); }
.search-icon { color: var(--blue); font-size: 23px; line-height: 1; transform: rotate(-15deg); }
.nav-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.nav-search input::placeholder { color: #718397; }
.nav-search button, .discord-button {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
}
.nav-search button { margin-right: 5px; padding: 0 15px; background: linear-gradient(135deg, var(--blue), var(--blue-strong)); color: #02101c; }

.nav-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.server-pill {
  height: 40px;
  max-width: 185px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255,255,255,.025);
  cursor: pointer;
  color: #cad7e4;
  font-size: 12px;
  font-weight: 700;
  transition: border-color .2s ease, transform .2s ease;
}
.server-pill:hover { border-color: rgba(90,242,229,.42); transform: translateY(-1px); }
.server-pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pulse-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #4ff3a7; box-shadow: 0 0 0 0 rgba(79,243,167,.55); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(79,243,167,0); } 100% { box-shadow: 0 0 0 0 rgba(79,243,167,0); } }
.discord-button { padding: 0 17px; background: #5865f2; color: white; transition: transform .2s ease, filter .2s ease; }
.discord-button:hover { transform: translateY(-2px); filter: brightness(1.12); }

main { width: min(1120px, calc(100% - 34px)); margin: 0 auto; }
.ranking-section { padding: 46px 0 80px; }
.ranking-overview {
  margin-bottom: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.ranking-title-group { min-width: 0; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #7ed9ff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.eyebrow i { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 14px var(--cyan); }
.crystal-mark, .title-crystal, .head-crystal, .inline-crystal, .crystal-icon {
  display: inline-block;
  object-fit: contain;
  vertical-align: middle;
  filter: drop-shadow(0 0 6px rgba(75,197,255,.62)) drop-shadow(0 0 12px rgba(168,105,255,.24));
  transform-origin: center;
  user-select: none;
  pointer-events: none;
}
.crystal-mark {
  width: 21px;
  height: 21px;
  margin-right: 3px;
  animation: crystal-float 2.8s ease-in-out infinite;
}
.title-crystal {
  width: .72em;
  height: .72em;
  margin-left: 8px;
  vertical-align: .05em;
  animation: crystal-pulse 2.4s ease-in-out infinite;
}
.head-crystal { width: 18px; height: 18px; margin-right: 6px; }
.inline-crystal { width: 16px; height: 16px; margin-right: 5px; }
@keyframes crystal-float { 50% { transform: translateY(-2px) rotate(8deg); filter: drop-shadow(0 0 9px rgba(75,197,255,.82)) brightness(1.16); } }
@keyframes crystal-pulse { 50% { transform: scale(1.14) rotate(8deg); filter: drop-shadow(0 0 10px rgba(75,197,255,.9)) brightness(1.24); } }
.ranking-title-group h1, .search-modal h2 {
  margin: 7px 0 0;
  font-size: clamp(27px, 4.3vw, 42px);
  line-height: 1.05;
  letter-spacing: -.045em;
}
.corner-stats {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(108px, auto));
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(8,15,25,.70);
  box-shadow: 0 12px 38px rgba(0,0,0,.20);
  overflow: hidden;
  backdrop-filter: blur(12px);
}
.stat-item { min-height: 62px; padding: 10px 14px; display: grid; align-content: center; gap: 3px; }
.stat-item + .stat-item { border-left: 1px solid var(--line); }
.stat-item strong { display: flex; align-items: center; gap: 7px; color: #eef8ff; font-size: 15px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-item > span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ff3a7; box-shadow: 0 0 12px rgba(79,243,167,.72); }

.ranking-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); overflow: hidden; backdrop-filter: blur(13px); }
.ranking-head, .ranking-row { display: grid; grid-template-columns: 84px minmax(0, 1fr) 150px; align-items: center; }
.ranking-head { min-height: 50px; padding: 0 22px; border-bottom: 1px solid var(--line); color: #6f8398; font-size: 10px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.ranking-head span:last-child { display: inline-flex; align-items: center; justify-content: flex-end; text-align: right; }
.ranking-list { min-height: 260px; }
.ranking-row {
  position: relative;
  min-height: 78px;
  padding: 10px 22px;
  border-bottom: 1px solid rgba(131,179,226,.085);
  isolation: isolate;
  content-visibility: auto;
  contain-intrinsic-size: 78px;
  transition: transform .23s ease, background .23s ease, border-color .23s ease;
}
.ranking-row:last-child { border-bottom: 0; }
.ranking-row::before { content: ""; position: absolute; inset: 8px 10px; z-index: -1; border-radius: 13px; background: linear-gradient(90deg, rgba(75,197,255,.09), transparent 65%); opacity: 0; transform: scaleX(.97); transition: opacity .23s ease, transform .23s ease; }
.ranking-row::after { content: ""; position: absolute; left: 0; top: 18%; bottom: 18%; width: 2px; border-radius: 0 4px 4px 0; background: linear-gradient(var(--blue), var(--cyan)); opacity: 0; transform: scaleY(.4); transition: opacity .23s ease, transform .23s ease; }
.ranking-row:hover { transform: translateX(5px); border-color: rgba(75,197,255,.18); }
.ranking-row:hover::before { opacity: 1; transform: scaleX(1); }
.ranking-row:hover::after { opacity: 1; transform: scaleY(1); }
.rank-number { font-size: 18px; font-weight: 900; color: #64788d; font-variant-numeric: tabular-nums; }
.player-cell { min-width: 0; display: flex; align-items: center; gap: 14px; }
.avatar-wrap { position: relative; width: 48px; height: 48px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.09); border-radius: 12px; overflow: hidden; background: linear-gradient(135deg,#132235,#08111c); box-shadow: 0 8px 20px rgba(0,0,0,.24); transition: transform .23s ease, border-color .23s ease, box-shadow .23s ease; }
.ranking-row:hover .avatar-wrap, .search-result:hover .avatar-wrap { transform: translateY(-2px) scale(1.07) rotate(-1deg); border-color: rgba(75,197,255,.5); box-shadow: 0 11px 28px rgba(0,0,0,.35), 0 0 18px rgba(75,197,255,.10); }
.avatar-wrap img { width: 100%; height: 100%; display: block; object-fit: cover; image-rendering: pixelated; }
.avatar-fallback { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; color: var(--blue); }
.player-copy { min-width: 0; display: grid; gap: 0; }
.player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 850; letter-spacing: -.01em; transition: color .2s ease, transform .2s ease; }
.ranking-row:hover .player-name { color: #bfeaff; transform: translateX(2px); }
.player-copy small { color: #6f8398; font-size: 11px; }
.tier-cell { display: flex; justify-content: flex-end; }
.tier-badge { min-width: 82px; height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid rgba(75,197,255,.25); border-radius: 10px; background: rgba(75,197,255,.07); color: #9ce4ff; box-shadow: inset 0 0 18px rgba(75,197,255,.035); font-size: 13px; font-weight: 950; letter-spacing: .07em; transition: transform .23s ease, filter .23s ease, box-shadow .23s ease; }
.crystal-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  object-fit: contain;
  opacity: .96;
  transition: transform .23s ease, filter .23s ease;
}
.ranking-row:hover .crystal-icon, .search-result:hover .crystal-icon { transform: rotate(14deg) scale(1.12); filter: brightness(1.3); }
.ranking-row:hover .tier-badge, .search-result:hover .tier-badge { transform: scale(1.07); filter: brightness(1.18); box-shadow: 0 0 21px currentColor; }
.tier-ht1 { color: #ffe69a; border-color: rgba(255,199,72,.44); background: rgba(255,184,41,.09); box-shadow: 0 0 24px rgba(255,184,41,.08); }
.tier-lt1 { color: #f8d995; border-color: rgba(212,174,89,.34); background: rgba(212,174,89,.07); }
.tier-ht2 { color: #ffab8e; border-color: rgba(255,105,70,.4); background: rgba(255,91,55,.08); }
.tier-lt2 { color: #ffbf87; border-color: rgba(255,144,58,.33); background: rgba(255,144,58,.07); }
.tier-ht3 { color: #d5b5ff; border-color: rgba(168,105,255,.42); background: rgba(145,77,255,.08); }
.tier-lt3 { color: #c8b9ee; border-color: rgba(151,125,214,.3); background: rgba(151,125,214,.06); }
.tier-ht4 { color: #9edaff; border-color: rgba(61,174,255,.38); background: rgba(61,174,255,.07); }
.tier-lt4 { color: #a9c9df; border-color: rgba(111,164,201,.3); background: rgba(111,164,201,.06); }
.tier-ht5, .tier-lt5 { color: #bcc6d0; border-color: rgba(172,187,201,.24); background: rgba(172,187,201,.05); }

.rank-top-1 { background: linear-gradient(90deg, rgba(255,186,54,.075), transparent 58%); }
.rank-top-2 { background: linear-gradient(90deg, rgba(193,215,234,.065), transparent 58%); }
.rank-top-3 { background: linear-gradient(90deg, rgba(213,126,72,.065), transparent 58%); }
.rank-top-1 .rank-number { color: #ffd66e; text-shadow: 0 0 16px rgba(255,205,94,.32); }
.rank-top-2 .rank-number { color: #dce8f2; }
.rank-top-3 .rank-number { color: #e8a173; }
.rank-top-1 .avatar-wrap { border-color: rgba(255,199,72,.34); }

.loading-state, .empty-state { min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; padding: 30px; text-align: center; }
.loading-state span, .empty-state span { color: var(--muted); font-size: 13px; }
.loader { width: 38px; height: 38px; margin-bottom: 5px; border: 3px solid rgba(75,197,255,.12); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(1,5,10,.76); backdrop-filter: blur(12px); animation: fade-in .18s ease; }
.modal-backdrop[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } }
.search-modal { position: relative; width: min(620px, 100%); max-height: min(720px, calc(100vh - 40px)); overflow: auto; padding: 30px; border: 1px solid rgba(75,197,255,.22); border-radius: 20px; background: #0a111c; box-shadow: 0 30px 100px rgba(0,0,0,.65); animation: modal-in .24s ease; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.search-modal > p { margin: 9px 0 20px; color: var(--muted); }
.modal-close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.035); cursor: pointer; color: #b6c6d5; font-size: 24px; line-height: 1; }
.search-results { display: grid; gap: 10px; }
.search-result { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 14px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); transition: transform .2s ease, border-color .2s ease, background .2s ease; }
.search-result:hover { transform: translateY(-2px); border-color: var(--line-hover); background: rgba(75,197,255,.05); }
.search-result .result-rank { color: var(--muted); font-size: 12px; }

.toast { position: fixed; z-index: 80; left: 50%; bottom: 24px; max-width: calc(100% - 32px); padding: 11px 16px; border: 1px solid rgba(90,242,229,.25); border-radius: 11px; background: rgba(8,18,27,.94); box-shadow: 0 15px 50px rgba(0,0,0,.4); color: #c9fff8; font-size: 13px; font-weight: 750; opacity: 0; transform: translate(-50%, 14px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
footer { min-height: 95px; display: flex; align-items: center; justify-content: center; gap: 9px; border-top: 1px solid var(--line); color: #65788b; font-size: 12px; }
footer img { object-fit: contain; opacity: .74; }

@media (max-width: 980px) {
  .nav-shell { grid-template-columns: auto 1fr auto; gap: 12px; }
  .brand-wordmark { width: 190px; min-width: 145px; }
  .server-pill { display: none; }
  .ranking-overview { align-items: stretch; }
  .corner-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .topbar { padding: 9px 10px 0; }
  .nav-shell { grid-template-columns: 1fr auto; min-height: auto; padding: 9px 9px 9px 12px; border-radius: 16px; }
  .nav-search { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .brand-emblem { width: 42px; height: 42px; }
  .brand-wordmark { width: min(215px, 48vw); min-width: 145px; }
  .discord-button { height: 38px; }
  main { width: min(100% - 20px, 1120px); }
  .ranking-section { padding-top: 32px; }
  .ranking-overview { display: grid; gap: 16px; }
  .corner-stats { width: 100%; }
  .ranking-head { display: none; }
  .ranking-row { grid-template-columns: 48px minmax(0,1fr) auto; min-height: 74px; padding: 10px 12px; }
  .rank-number { font-size: 15px; }
  .avatar-wrap { width: 42px; height: 42px; border-radius: 10px; }
  .player-cell { gap: 10px; }
  .player-name { font-size: 14px; }
  .tier-badge { min-width: 68px; height: 31px; gap: 5px; font-size: 11px; }
  .crystal-icon { width: 18px; height: 18px; }
  .search-modal { padding: 26px 16px 18px; }
  .search-result { grid-template-columns: auto minmax(0,1fr); }
  .search-result .tier-badge { grid-column: 2; justify-self: start; }
}
@media (max-width: 470px) {
  .brand { gap: 6px; }
  .brand-emblem { width: 37px; height: 37px; }
  .brand-wordmark { width: 172px; min-width: 0; }
  .corner-stats { grid-template-columns: 1fr 1fr; }
  .status-item { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid var(--line); }
  .stat-item { min-height: 56px; padding: 9px 12px; }
}

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