:root {
  color-scheme: dark;
  --ink: #f1eef7;
  --muted: #b9b2c6;
  --line: #3b3247;
  --panel: #17131e;
  --page: #09070d;
  --topbar: #100c17;
  --control: #1d1726;
  --control-line: #554762;
  --thead: #241b2e;
  --hover: #21182d;
  --accent: #9a42ff;
  --accent-ink: #f7f0ff;
  --link: #c98cff;
  --link-hover: #f1e6ff;
  --gold: #d8d1de;
  --danger: #fda4af;
  --verified-bg: #2d2140;
  --verified-ink: #e8d5ff;
  --unverified-bg: #37202a;
  --unverified-ink: #ffcad9;
}

[data-theme="light"] {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #657282;
  --line: #d7dee7;
  --panel: #ffffff;
  --page: #f4f7fa;
  --topbar: #ffffff;
  --control: #ffffff;
  --control-line: #b9c3cf;
  --thead: #eef4f5;
  --hover: #f7faf9;
  --accent: #0f766e;
  --accent-ink: #073b36;
  --link: #0f766e;
  --link-hover: #0b4f4a;
  --gold: #b7791f;
  --danger: #9f1239;
  --verified-bg: #dff6ef;
  --verified-ink: #073b36;
  --unverified-bg: #ffe5eb;
  --unverified-ink: #9f1239;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding: 28px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--topbar);
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
  letter-spacing: 0;
}

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

.totus-mark {
  display: inline-flex;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  overflow: hidden;
  outline-offset: 4px;
}

.totus-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.icon-links {
  display: inline-flex;
  gap: 8px;
}

.icon-link {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control);
  color: var(--ink);
  text-decoration: none;
}

.icon-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-link:focus-visible,
.totus-mark:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.22);
}

.icon-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.temple-link img {
  display: block;
  width: 24px;
  height: 18px;
  object-fit: contain;
}

.source-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.source-meta span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.22);
}

.theme-icon {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.36);
}

[data-theme="light"] .theme-icon {
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.16);
}

main {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 24px clamp(12px, 3vw, 32px) 48px;
}

.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
}

.intro p {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 800;
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cta-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--control);
  color: var(--link);
  font-weight: 800;
  text-decoration: none;
}

.cta-link:hover {
  border-color: var(--accent);
  color: var(--link-hover);
}

.cta-link:focus-visible {
  outline: 3px solid rgba(154, 66, 255, 0.24);
}

.cta-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary div {
  min-height: 92px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.summary span,
label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.summary strong {
  font-size: 1.75rem;
  line-height: 1.1;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--control);
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

.board {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--thead);
  color: var(--ink);
  font-size: 0.75rem;
  text-transform: uppercase;
}

th button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-transform: inherit;
}

th button::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0.32;
}

th button[data-direction="asc"]::after {
  border-bottom: 6px solid currentColor;
  opacity: 1;
}

th button[data-direction="desc"]::after {
  border-top: 6px solid currentColor;
  opacity: 1;
}

th button[data-direction="none"]::after {
  border-top: 6px solid currentColor;
}

th button:hover,
th button:focus-visible {
  color: var(--accent);
  outline: none;
}

tbody tr:hover {
  background: var(--hover);
}

.place {
  color: var(--gold);
  font-weight: 800;
}

.rsn {
  font-weight: 800;
}

.rsn-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.rsn a,
td a {
  color: var(--link);
  text-decoration-color: rgba(201, 140, 255, 0.45);
  text-underline-offset: 3px;
}

.rsn a:hover,
td a:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
}

.temple-warning {
  display: inline-grid;
  flex: 0 0 18px;
  place-items: center;
  width: 18px;
  height: 18px;
  color: #f59e0b;
  cursor: help;
  outline-offset: 3px;
}

.temple-warning svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.rank-icon {
  display: block;
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.verified {
  background: var(--verified-bg);
  color: var(--verified-ink);
}

.unverified {
  background: var(--unverified-bg);
  color: var(--unverified-ink);
}

.empty {
  margin: 0;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    grid-template-columns: auto 1fr;
  }

  .brand-copy {
    grid-column: 1 / -1;
  }

  .source-meta {
    justify-content: flex-start;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .totus-mark {
    width: 64px;
    height: 64px;
  }

  .summary,
  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .intro {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .summary,
  .controls {
    grid-template-columns: 1fr;
  }

  .summary div {
    min-height: 76px;
  }
}
