:root {
  --bg: #050505;
  --bg-soft: #0b0c0c;
  --panel: #101212;
  --panel-2: #161818;
  --text: #f5f1e8;
  --muted: #b7b1a7;
  --faint: #817b72;
  --line: rgba(245, 241, 232, 0.12);
  --orange: #ffad17;
  --orange-dim: rgba(255, 173, 23, 0.16);
  --max: 1320px;
  --sidebar: 248px;
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.wiki-app {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 173, 23, 0.08), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(54, 223, 232, 0.05), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: "Afacad", system-ui, sans-serif;
  line-height: 1.5;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button,
input {
  font: 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;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 30;
  padding: 0.6rem 0.9rem;
  background: var(--orange);
  color: #120f09;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

.wiki-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  min-height: 4.4rem;
  padding: 0.7rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 5, 5, 0.86);
  backdrop-filter: blur(16px);
}

.wiki-nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 0.45rem 0.7rem;
}

.wiki-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.wiki-brand img {
  width: 92px;
  height: auto;
  margin: -1.4rem 0 -1.1rem -0.4rem;
}

.wiki-brand span {
  color: var(--orange);
}

.wiki-search {
  display: flex;
  max-width: 640px;
  width: 100%;
  justify-self: center;
}

.wiki-search input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-right: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0.7rem 0.9rem;
}

.wiki-search input:focus,
.wiki-search button:focus-visible,
.wiki-nav-toggle:focus-visible,
.filter-chip:focus-visible,
.entry-card:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

.wiki-search button,
.button {
  border: 1px solid var(--orange);
  background: var(--orange);
  color: #120f09;
  font-weight: 700;
  padding: 0.7rem 1rem;
  text-decoration: none;
  cursor: pointer;
}

.wiki-utility {
  display: flex;
  gap: 1rem;
  color: var(--muted);
}

.wiki-utility a,
.wiki-sidebar a,
.crumbs a,
.wiki-footer a {
  text-decoration: none;
}

.wiki-utility a:hover,
.wiki-sidebar a:hover,
.crumbs a:hover,
.wiki-footer a:hover {
  color: var(--orange);
}

.wiki-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  width: min(calc(100% - 2rem), var(--max));
  margin: 0 auto;
  min-height: calc(100vh - 9rem);
}

.wiki-sidebar {
  position: sticky;
  top: 4.4rem;
  align-self: start;
  padding: 1.6rem 1rem 2rem 0;
}

.wiki-sidebar nav {
  display: grid;
  gap: 0.15rem;
}

.wiki-sidebar a {
  padding: 0.45rem 0.7rem;
  color: var(--muted);
  border-left: 2px solid transparent;
  line-height: 1.25;
}

.wiki-sidebar a[aria-current="page"] {
  color: var(--orange);
  border-left-color: var(--orange);
  background: var(--orange-dim);
}

.wiki-main {
  min-width: 0;
  padding: 1.8rem 0 4rem 1.2rem;
}

.wiki-loading,
.wiki-empty,
.wiki-error {
  color: var(--muted);
}

.wiki-error {
  color: #ff8a7a;
}

.wiki-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: min(calc(100% - 2rem), var(--max));
  margin: 0 auto;
  padding: 1.4rem 0 2rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.92rem;
}

.wiki-footer p {
  margin: 0;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--orange);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0 0 0.7rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4.4rem);
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.3rem);
}

.lede,
.muted,
.entry-copy p,
.infobox dd,
.empty-note {
  color: var(--muted);
}

.lede {
  max-width: 62ch;
  font-size: 1.18rem;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
  color: var(--faint);
  font-size: 0.92rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: end;
  margin-bottom: 1.4rem;
}

.page-head p {
  margin: 0;
  max-width: 52ch;
}

.count-pill {
  margin-left: 0.35em;
  color: var(--orange);
  font-variant-numeric: tabular-nums;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1.3rem;
}

.filter-chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0.32rem 0.7rem;
  cursor: pointer;
}

.filter-chip[aria-pressed="true"] {
  border-color: var(--orange);
  background: var(--orange-dim);
  color: var(--text);
}

.home-hero {
  display: grid;
  gap: 1.2rem;
  padding: 1rem 0 2rem;
}

.home-hero h1 {
  max-width: none;
}

.stat-grid,
.cat-grid,
.entry-grid,
.matrix {
  display: grid;
  gap: 0.8rem;
}

.stat-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 1.6rem 0 2rem;
}

.stat-grid article,
.cat-card,
.entry-card,
.infobox,
.panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.stat-grid strong {
  display: block;
  color: var(--orange);
  font-size: 2rem;
  line-height: 1;
}

.stat-grid span,
.cat-card p,
.entry-card p {
  color: var(--muted);
}

.stat-grid article,
.cat-card,
.entry-card,
.panel,
.infobox {
  padding: 1rem;
}

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

.cat-card,
.entry-card {
  display: block;
  text-decoration: none;
  min-height: 100%;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}

.entry-card[hidden],
.entry-card.is-filtered-out {
  display: none !important;
}

.cat-card:hover,
.entry-card:hover {
  border-color: rgba(255, 173, 23, 0.7);
  background: rgba(255, 173, 23, 0.06);
  transform: translateY(-1px);
}

.entry-grid {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.entry-grid.wide {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.thumb {
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 1;
  margin: -1rem -1rem 0.85rem;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.06), transparent 58%),
    #090909;
  border-bottom: 1px solid var(--line);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb.card-art {
  aspect-ratio: 2 / 3;
}

.thumb.portrait {
  aspect-ratio: 3 / 4;
}

.thumb.card-art img,
.hero-art.card-art img {
  object-fit: contain;
  background: #070707;
}

.thumb.portrait img,
.hero-art.portrait img {
  object-fit: cover;
}

.thumb.swatch {
  width: 36px;
  height: 36px;
  aspect-ratio: 1;
  margin: 0.15rem 0 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.hero-art.hero-swatch-wrap {
  width: auto;
  height: auto;
  padding: 0;
  background: transparent;
  border: 0;
}

.hero-art.hero-swatch-wrap .thumb.swatch {
  width: 56px;
  height: 56px;
  margin: 0;
}

.thumb.icon-thumb {
  aspect-ratio: auto;
  height: 88px;
  margin: 0 0 0.7rem;
  background: transparent;
  border-bottom: 0;
}

.icon-mask,
.thumb img.icon-screen,
.thumb img.icon-alpha,
.icon-screen,
.icon-alpha {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.icon-mask {
  display: block;
  background-color: var(--icon-color, var(--text));
  -webkit-mask-image: var(--icon-url);
  mask-image: var(--icon-url);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  mask-mode: luminance;
  -webkit-mask-source-type: luminance;
}

.icon-screen {
  object-fit: contain;
  mix-blend-mode: screen;
}

.hero-art.hero-icon {
  display: grid;
  place-items: center;
  width: 140px;
  height: 140px;
  background: transparent;
  border: 0;
}

.hero-art.hero-icon .thumb {
  margin: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  aspect-ratio: auto;
}

.hero-art.hero-icon .icon-mask,
.hero-art.hero-icon .icon-screen,
.hero-art.hero-icon .icon-alpha {
  width: 96px;
  height: 96px;
}

.entry-card h3,
.cat-card h3 {
  margin-bottom: 0.3rem;
  font-size: 1.15rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.42rem;
  border: 1px solid currentColor;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.5rem;
  align-items: start;
}

.hero-art {
  overflow: hidden;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  background: #080808;
}

.hero-art img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  margin: 0 auto;
}

.infobox {
  position: sticky;
  top: 5.2rem;
}

.infobox h2 {
  font-size: 1.1rem;
}

.infobox dl {
  margin: 0;
}

.infobox div + div {
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}

.infobox dt {
  color: var(--faint);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.infobox dd {
  margin: 0.15rem 0 0;
}

.rule-list,
.link-list,
.quote-list {
  display: grid;
  gap: 0.7rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
}

.rule-list li,
.panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.85rem 1rem;
}

.rule-list strong,
.panel h3 {
  display: block;
  margin-bottom: 0.25rem;
}

.quote-list blockquote {
  margin: 0;
  padding-left: 0.9rem;
  border-left: 3px solid var(--orange);
  color: var(--text);
  font-size: 1.08rem;
}

.rich-link {
  color: var(--orange);
  text-decoration: none;
  font-weight: 600;
}

.rich-link.has-color {
  color: var(--link-color);
}

.rich-link:hover {
  text-decoration: underline;
}

.author-block {
  margin-top: 1.6rem;
  padding: 1rem;
  border: 1px dashed rgba(255, 173, 23, 0.35);
  background: rgba(255, 173, 23, 0.04);
}

.author-block.spoiler {
  filter: blur(7px);
  cursor: pointer;
}

.author-block.spoiler.is-open {
  filter: none;
}

.matrix-wrap {
  overflow: visible;
}

.matrix {
  grid-template-columns: minmax(6.5rem, 0.9fr) repeat(9, minmax(0, 1fr));
  min-width: 0;
  width: 100%;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.matrix > * {
  background: var(--bg-soft);
  padding: 0.55rem 0.35rem;
  min-height: 0;
  font-size: 1rem;
  text-align: center;
}

.matrix .head,
.matrix .side {
  color: var(--faint);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.matrix .side {
  text-align: left;
  padding-left: 0.55rem;
}

.impact-pos {
  color: #7dff9a;
}

.impact-neg {
  color: #ff8a7a;
}

.impact-heal {
  color: #7eb6ff;
}

.impact-neutral {
  color: var(--faint);
}

.search-results {
  display: grid;
  gap: 0.55rem;
}

.search-hit {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 0.8rem;
  align-items: center;
  padding: 0.7rem;
  border: 1px solid var(--line);
  text-decoration: none;
}

.search-hit:hover {
  border-color: var(--orange);
}

.search-hit img,
.search-hit .mini-swatch,
.search-hit .thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  background: #111;
}

.search-hit .thumb {
  margin: 0;
  aspect-ratio: 1;
  border: 0;
}

.search-hit .thumb.card-art,
.search-hit .thumb.portrait {
  width: 40px;
  height: auto;
}

.search-hit .thumb.card-art {
  aspect-ratio: 2 / 3;
}

.search-hit .thumb.portrait {
  aspect-ratio: 3 / 4;
}

.search-hit .thumb.icon-thumb,
.search-hit .thumb.search-thumb {
  background: transparent;
}

.search-hit .icon-mask,
.search-hit .icon-screen,
.search-hit .icon-alpha {
  width: 40px;
  height: 40px;
}

.search-hit small {
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

@media (max-width: 980px) {
  .wiki-topbar {
    grid-template-columns: auto 1fr;
  }

  .wiki-utility {
    display: none;
  }

  .wiki-nav-toggle {
    display: inline-flex;
  }

  .wiki-shell {
    grid-template-columns: 1fr;
  }

  .wiki-sidebar {
    display: none;
    position: static;
    padding: 0 0 1rem;
  }

  .wiki-app.nav-open .wiki-sidebar {
    display: block;
  }

  .wiki-main {
    padding-left: 0;
  }

  .stat-grid,
  .cat-grid,
  .detail-layout {
    grid-template-columns: 1fr 1fr;
  }

  .infobox {
    position: static;
  }
}

@media (max-width: 700px) {
  .wiki-topbar {
    grid-template-columns: auto auto;
  }

  .wiki-search {
    grid-column: 1 / -1;
  }

  .wiki-brand img {
    width: 72px;
  }

  .stat-grid,
  .cat-grid,
  .detail-layout,
  .wiki-footer {
    grid-template-columns: 1fr;
  }

  .wiki-footer {
    display: grid;
  }

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .cat-card,
  .entry-card {
    transition: none;
  }
}
