:root {
  --bg: #050508;
  --bg-2: #0b0d12;
  --card: #12141c;
  --card-2: #171a24;
  --line: #242836;
  --text: #f4f6fb;
  --muted: #8b93a7;
  --accent: #5aa7ff;
  --accent-2: #6d7cff;
  --gold: #e8b84a;
  --danger: #ff6b6b;
  --radius: 16px;
  --pad: 16px;
  --font: "Plus Jakarta Sans", "PingFang SC", "Noto Sans SC", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}
body {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  min-height: 100dvh;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(90, 167, 255, 0.16), transparent 55%),
    radial-gradient(700px 360px at 90% 8%, rgba(109, 124, 255, 0.12), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
button, select, input { font: inherit; color: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button, a, .card, .person, .filter { touch-action: manipulation; }
.card, .person, .filter, .topbar, .toolbar, .sort-btn {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.bio, #search { -webkit-user-select: text; user-select: text; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
img { max-width: 100%; }

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-areas:
    "brand draw"
    "search search";
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: calc(10px + var(--safe-top)) var(--pad) 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.topbar > .btn-ghost { grid-area: draw; }

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  min-height: 44px;
}
.logo-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 16px rgba(90, 167, 255, 0.45);
}
.brand-name { font-weight: 800; letter-spacing: 0.02em; }

.search-wrap {
  grid-area: search;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0e1016;
  color: var(--muted);
}
.search-wrap:focus-within { border-color: #2f5d93; }
#search {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: 16px;
  min-width: 0;
}
#search:focus-visible { outline: none; }
#search::placeholder { color: #6d7588; }
#search::-webkit-search-cancel-button { appearance: none; display: none; }
.search-clear {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin-right: -4px;
  border: 0;
  border-radius: 50%;
  background: #1c2130;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.search-clear[hidden] { display: none; }

.btn-ghost,
.btn-primary,
.text-btn {
  min-height: 44px;
  border-radius: 999px;
  cursor: pointer;
}
.btn-ghost {
  border: 1px solid var(--line);
  background: #10131a;
  padding: 0 14px;
  white-space: nowrap;
}
.draw-short { display: inline; }
.draw-full { display: none; }
.btn-ghost,
.btn-primary { transition: transform .16s ease, background .2s ease, border-color .2s ease; }
.btn-ghost:active,
.btn-primary:active { transform: scale(0.97); }
.btn-ghost:active { background: #1a1f2b; }
.btn-primary {
  border: 0;
  background: var(--accent);
  color: #061018;
  font-weight: 700;
  padding: 0 16px;
}
.text-btn {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0;
  min-height: 36px;
}

.hero {
  display: grid;
  gap: 16px;
  padding: 22px var(--pad) 8px;
}
.hero-copy { animation: rise .5s ease both; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.18em;
  font-weight: 700;
}
.hero h1 {
  margin: 0;
  font-size: clamp(28px, 8vw, 52px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.lede {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  padding: 12px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(90, 167, 255, 0.08), rgba(255,255,255,0.02));
  border: 1px solid var(--line);
}
.stat b {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}
.stat span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}
.sync-line {
  margin: 12px 0 0;
  color: #667086;
  font-size: 12px;
  line-height: 1.4;
  word-break: break-all;
}

.spotlight {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  animation: rise .55s ease both;
}
#spotlight-body { opacity: 0; transform: translateY(8px); transition: opacity .28s ease, transform .28s ease; }
#spotlight-body.is-in { opacity: 1; transform: none; }
.spot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.person {
  display: grid;
  gap: 10px;
  padding-right: 28px;
}
.who {
  display: flex;
  gap: 12px;
  min-width: 0;
}
.avatar {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  background: #1c2130;
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .35s ease;
}
.avatar img.is-on { opacity: 1; }
.avatar .glyph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #d7e6ff;
}
.who h2, .who h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.handle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}
.badge.gold { color: #1a1406; background: var(--gold); }
.badge.blue { color: #d7ecff; background: #1d3a5c; }
.badge.lost { color: #ffd5d5; background: #4a1d1d; }

.bio {
  margin: 0;
  color: #c5ccda;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.bio a { word-break: break-all; }

.card-go {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #1a1e29;
  border: 1px solid var(--line);
  pointer-events: none;
}

.toolbar {
  display: grid;
  gap: 10px;
  padding: 10px var(--pad) 8px;
  position: sticky;
  top: var(--topbar-h, calc(var(--safe-top) + 102px));
  z-index: 22;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
}
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #10131a;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  transition: background .2s ease, border-color .2s ease, color .2s ease, transform .15s ease;
}
.filter:active { transform: scale(0.96); }
.filter[aria-pressed="true"] {
  background: #1a2b44;
  border-color: #2f5d93;
  color: var(--text);
}
.filter-short { display: none; }
.filter-count { margin-left: 4px; color: inherit; opacity: 0.7; }
.tools {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sort-btn {
  flex: 1;
  min-height: 42px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #10131a;
  text-align: left;
}
.sort-btn span { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.sort-btn b {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chev {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-top: -4px;
}
.sort-short { display: none; }
.layout-switch {
  display: flex;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #10131a;
}
.layout-switch button {
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.layout-switch button[aria-pressed="true"] {
  background: #1a2b44;
  color: var(--text);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity .2s ease;
}
.sheet.is-on { opacity: 1; }
.sheet[hidden] { display: none; }
.sheet-panel {
  width: 100%;
  background: var(--card-2);
  border-radius: 18px 18px 0 0;
  padding: 10px 12px calc(16px + var(--safe-bottom));
  transform: translateY(12px);
  transition: transform .22s ease;
}
.sheet.is-on .sheet-panel { transform: none; }
.sheet-bar {
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: #3a4050;
  margin: 4px auto 12px;
}
.sheet-title {
  margin: 0 8px 10px;
  color: var(--muted);
  font-size: 12px;
}
.sheet-item {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0 12px;
  font-size: 15px;
}
.sheet-item[aria-selected="true"] {
  background: #1a2b44;
  color: #d7ecff;
}
body.sheet-open { overflow: hidden; }

body.is-cols-2 .avatar { width: 40px !important; height: 40px !important; }
body.is-cols-2 .card { padding: 10px 32px 10px 10px; }
body.is-cols-2 .who h3 { font-size: 15px; }
body.is-cols-2 .handle { font-size: 11px; }
body.is-cols-2 .bio {
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
body.is-cols-2 .badge { font-size: 9px; }
body.is-cols-2 .card-go { width: 28px; height: 28px; top: 8px; right: 8px; }

main { padding: 8px var(--pad) calc(28px + var(--safe-bottom)); }
.result-line {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}
.grid {
  position: relative;
  width: 100%;
}
.card,
.person {
  position: relative;
  cursor: pointer;
}
.card {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  visibility: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 40px 14px 14px;
  transition: border-color .2s ease, left .2s ease, top .2s ease;
}
.card.is-placed {
  visibility: visible;
  animation: rise .42s ease both;
  animation-delay: calc(var(--i, 0) * 28ms);
}
.card:active { transform: scale(0.99); }
.sentinel {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 18px 0 8px;
}
.card.lost { opacity: 0.78; }
.card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.empty {
  text-align: center;
  padding: 48px 12px;
  color: var(--muted);
}
.empty h3 { margin: 0 0 8px; color: var(--text); }

.to-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(18px + var(--safe-bottom));
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #151821;
  color: var(--text);
  font-size: 18px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.to-top[hidden] { display: none; }
body.kb-on .to-top { display: none; }

.colophon {
  border-top: 1px solid var(--line);
  padding: 16px var(--pad) calc(20px + var(--safe-bottom));
  color: #667086;
  font-size: 12px;
}
.colophon p { margin: 4px 0; }

.draw-dialog {
  width: min(100%, 100vw);
  max-width: none;
  max-height: min(88dvh, 720px);
  overflow: auto;
  margin: 0;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  background: var(--card-2);
  color: var(--text);
  padding: 18px 16px calc(18px + var(--safe-bottom));
}
.draw-dialog.is-fallback {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
}
.draw-dialog[open] {
  animation: sheet-in .26s cubic-bezier(.22, .8, .32, 1);
}
.draw-dialog.is-out {
  animation: sheet-out .26s ease forwards;
}
.draw-dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
.draw-dialog[open]::backdrop { animation: fade .28s ease; }
.draw-dialog.is-out::backdrop { animation: fade-out .26s ease forwards; }

@keyframes sheet-in {
  from { transform: translateY(110%); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes sheet-out {
  from { transform: none; opacity: 1; }
  to { transform: translateY(110%); opacity: 0; }
}
@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
.dialog-x {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 28px;
}
.spot-kicker {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.dialog-hint { color: var(--muted); font-size: 12px; margin: 14px 0 0; min-height: 1.2em; }
#draw-body {
  overflow: hidden;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
}
.draw-reel {
  will-change: transform;
}
.draw-slide {
  padding: 12px 36px 12px 12px;
  box-sizing: border-box;
}
.draw-slide .who h2 { font-size: 16px; }
.draw-bio {
  margin-top: 10px;
  animation: fade .2s ease both;
}
#draw-body.is-land { animation: draw-pop .26s cubic-bezier(.22, .8, .32, 1); }
.draw-dialog.is-spinning #draw-body { pointer-events: none; }

@keyframes draw-pop {
  0% { transform: scale(0.985); }
  70% { transform: scale(1.012); }
  100% { transform: scale(1); }
}
.desk-only { display: none; }

@media (max-width: 759px) {
  .topbar {
    gap: 8px;
    padding: calc(8px + var(--safe-top)) var(--pad) 8px;
  }
  .brand { min-height: 40px; }
  .logo-img { width: 32px; height: 32px; }
  .brand-name { font-size: 16px; }
  .search-wrap { min-height: 40px; }
  .topbar > .btn-ghost { min-height: 40px; padding: 0 12px; font-size: 13px; }
  .hero { padding: 12px var(--pad) 4px; gap: 10px; }
  .hero-copy { animation: none; }
  .eyebrow { display: none; }
  .hero h1 { font-size: 22px; letter-spacing: -0.02em; }
  .lede,
  .sync-line { display: none; }
  .stats { gap: 6px; }
  .stat { padding: 8px 6px; border-radius: 10px; }
  .stat b { font-size: 16px; }
  .stat span { font-size: 10px; }
  .spotlight { padding: 10px; }
  .spot-head { margin-bottom: 8px; }
  .spotlight .bio {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .toolbar { gap: 8px; padding: 8px var(--pad) 6px; }
  .filter { min-height: 34px; padding: 0 10px; font-size: 12px; }
  .filter-full { display: none; }
  .filter-short { display: inline; }
  .filter-count { display: none; }
  .filters {
    mask-image: linear-gradient(90deg, #000 86%, transparent);
  }
  .sort-btn { min-height: 38px; }
  .sort-full { display: none; }
  .sort-short { display: inline; }
  .to-top { bottom: calc(28px + var(--safe-bottom)); }
  .layout-switch button { width: 38px; height: 38px; }
  .card-go { display: none; }
  .card { padding: 12px; }
  body.is-cols-2 .card { padding: 8px; }
  body.is-cols-2 .bio { -webkit-line-clamp: 2; }
  body.is-cols-2 .badges { display: none; }
  body.search-on .toolbar,
  body.search-on .hero { display: none; }
  body.search-on .topbar { border-bottom-color: #2f5d93; }
}

@media (min-width: 760px) {
  :root { --pad: 28px; }
  .topbar {
    grid-template-areas: "brand search draw";
    grid-template-columns: auto 1fr auto;
    gap: 12px;
  }
  .hero {
    grid-template-columns: 1.2fr 0.8fr;
    align-items: start;
    padding-top: 36px;
  }
  .stats { max-width: 520px; }
  .stat b { font-size: 28px; }
  .toolbar {
    grid-template-columns: 1fr auto;
    align-items: center;
    position: static;
    background: none;
    backdrop-filter: none;
    top: auto;
  }
  .filters { flex-wrap: wrap; overflow: visible; mask-image: none; }
  .sort-btn { width: 260px; flex: none; }
  .sheet {
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .sheet-panel {
    width: min(360px, 100%);
    border-radius: 16px;
    transform: scale(0.96);
  }
  .sheet.is-on .sheet-panel { transform: none; }
  .sheet-bar { display: none; }
  .card:hover { border-color: #3a4660; }
  .desk-only { display: block; }
  .draw-short { display: none; }
  .draw-full { display: inline; }
  .draw-dialog {
    width: min(480px, 92vw);
    margin: auto;
    border-radius: 18px;
    padding: 22px;
  }
  .draw-dialog[open] { animation: pop-in .22s cubic-bezier(.22, .8, .32, 1); }
  .draw-dialog.is-out { animation: pop-out .22s ease forwards; }
}


@keyframes pop-in {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes pop-out {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(0.94); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
