:root {
  color-scheme: dark;
  --bg: #040507;
  --bg-2: #090c12;
  --surface: rgba(12, 16, 23, 0.84);
  --surface-2: rgba(20, 25, 34, 0.78);
  --line: rgba(119, 159, 184, 0.22);
  --line-strong: rgba(160, 198, 220, 0.38);
  --text: #f4f1eb;
  --muted: #bac4c8;
  --dim: #7c8990;
  --rose: #6da8d8;
  --rose-bright: #a9d8ff;
  --blood: #8f1724;
  --blood-2: #d0434d;
  --gold: #d2aa58;
  --max: 1180px;
  --radius: 8px;
  --shadow: 0 26px 90px rgba(0, 0, 0, 0.55);
  --thorn-vine: url("assets/decor/thorn-vine.png");
  --rose-corner: url("assets/decor/rose-corner.png");
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 8%, rgba(58, 112, 155, 0.26), transparent 25rem),
    radial-gradient(circle at 84% 22%, rgba(143, 23, 36, 0.2), transparent 30rem),
    linear-gradient(180deg, #020304 0%, #07101a 42%, #030405 100%);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  line-height: 1.65;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  opacity: 0.38;
  background:
    linear-gradient(115deg, transparent 0 36%, rgba(109, 168, 216, 0.12) 36.2% 36.6%, transparent 36.8%),
    linear-gradient(64deg, transparent 0 62%, rgba(143, 23, 36, 0.1) 62.2% 62.55%, transparent 62.8%);
  background-size: 340px 340px, 420px 420px;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, #000, transparent 72%);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 0 max(24px, calc((100vw - var(--max)) / 2));
  border-bottom: 1px solid rgba(109, 168, 216, 0.16);
  background: linear-gradient(180deg, rgba(3, 5, 8, 0.92), rgba(3, 5, 8, 0.62));
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  font-family: Cinzel, Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar nav a {
  position: relative;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar nav a::after {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 6px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--blood-2), var(--rose), transparent);
  opacity: 0;
}

.topbar nav a:hover {
  color: var(--text);
}

.topbar nav a:hover::after {
  opacity: 1;
}

.section-band {
  width: min(var(--max), calc(100% - 40px));
  margin: 0 auto;
  padding: 92px 0;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  min-height: min(760px, calc(100vh - 76px));
  padding-top: 52px;
  padding-bottom: 70px;
  overflow: hidden;
}

.hero::before {
  position: absolute;
  inset: 7% 0 5% 35%;
  content: "";
  border: 1px solid rgba(109, 168, 216, 0.18);
  border-radius: 50%;
  transform: rotate(-12deg);
  pointer-events: none;
}

.hero-copy {
  position: relative;
  z-index: 2;
}

.hero-copy h1,
.section-heading h2,
.intro-grid h2,
.character-head h2 {
  margin: 0;
  font-family: Cinzel, Georgia, serif;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.02;
}

.hero-copy h1 {
  max-width: 720px;
  color: var(--text);
  font-size: clamp(60px, 9vw, 126px);
  text-shadow: 0 0 34px rgba(109, 168, 216, 0.18);
}

.hero-copy p {
  max-width: 570px;
  margin: 26px 0 0;
  color: #d7dde0;
  font-size: 19px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 13px;
  margin-top: 34px;
}

.button,
.text-button,
.filter-button,
.link-button,
.perk-button,
.dialog-close {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 22px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.button:hover,
.text-button:hover,
.filter-button:hover,
.link-button:hover,
.perk-button:hover {
  border-color: rgba(169, 216, 255, 0.72);
  background: rgba(109, 168, 216, 0.1);
  transform: translateY(-1px);
}

.button.primary {
  border-color: rgba(208, 67, 77, 0.65);
  background: linear-gradient(135deg, rgba(143, 23, 36, 0.55), rgba(109, 168, 216, 0.14));
}

.section-index {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  color: var(--rose-bright);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.section-index::before {
  width: 36px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, var(--blood), var(--rose));
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
  gap: 72px;
  border-top: 1px solid var(--line);
}

.intro-grid h2,
.section-heading h2,
.character-head h2 {
  max-width: 920px;
  font-size: clamp(34px, 5vw, 66px);
}

.prose,
.market-note {
  color: var(--muted);
  font-size: 18px;
}

.section-heading {
  max-width: 860px;
  margin-bottom: 34px;
}

.coin-ledger,
.perk-grid,
.faction-grid,
.character-grid {
  display: grid;
  gap: 16px;
}

.coin-ledger {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.coin-card,
.faction-card,
.rule-item,
.layer-card,
.character-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(109, 168, 216, 0.08), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.022));
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
}

.coin-card::after,
.faction-card::after,
.layer-card::after,
.perk-button::after {
  position: absolute;
  right: -26px;
  bottom: -34px;
  z-index: 0;
  width: 132px;
  height: 132px;
  content: "";
  background: var(--rose-corner) left bottom / contain no-repeat;
  filter: drop-shadow(0 0 16px rgba(109, 168, 216, 0.22));
  opacity: 0.34;
  transform: rotate(2deg);
  pointer-events: none;
}

.layer-card::after {
  right: -34px;
  bottom: -48px;
  width: 154px;
  height: 154px;
  opacity: 0.28;
}

.coin-card > *,
.faction-card > *,
.layer-card > *,
.perk-button > * {
  position: relative;
  z-index: 1;
}

.coin-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 18px;
  padding: 24px;
}

.coin-icon {
  width: 46px;
  height: 46px;
  color: var(--gold);
  filter: drop-shadow(0 0 14px rgba(210, 170, 88, 0.24));
}

.coin-icon circle,
.coin-icon path {
  fill: rgba(210, 170, 88, 0.14);
  stroke: currentColor;
  stroke-width: 2;
}

h3 {
  margin: 0 0 10px;
  font-family: Cinzel, Georgia, serif;
  font-size: 22px;
  line-height: 1.15;
}

.coin-card p,
.faction-card p,
.rule-item p,
.layer-copy p,
.character-copy p {
  margin: 0;
  color: var(--muted);
}

.market-note {
  max-width: 880px;
  margin: 24px 0 0;
}

.rule-list {
  display: grid;
  gap: 12px;
}

.rule-item {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) auto;
  gap: 22px;
  align-items: start;
  padding: 22px;
}

.rule-item h3 {
  font-size: 18px;
}

.text-button,
.link-button {
  min-height: 38px;
  padding: 0 16px;
  color: var(--rose-bright);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

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

.perk-button {
  position: relative;
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 18px;
  overflow: hidden;
  text-align: left;
}

.perk-button span {
  font-family: Cinzel, Georgia, serif;
  font-size: 20px;
  font-weight: 700;
}

.perk-button small {
  color: var(--dim);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.layer-toolbar,
.character-filters,
.related-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.layer-toolbar {
  margin-bottom: 22px;
}

.filter-button {
  min-height: 38px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.filter-button.active {
  border-color: rgba(208, 67, 77, 0.75);
  color: var(--text);
  background: rgba(143, 23, 36, 0.3);
}

.layer-grid {
  display: grid;
  gap: 14px;
}

.layer-card {
  display: grid;
  grid-template-columns: 92px 210px minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
  min-height: 178px;
  overflow: hidden;
}

.layer-card.is-focused {
  border-color: var(--rose-bright);
  box-shadow: 0 0 0 2px rgba(109, 168, 216, 0.28), var(--shadow);
}

.layer-number {
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  color: var(--gold);
  font-family: Cinzel, Georgia, serif;
  font-size: 30px;
  font-weight: 700;
}

.layer-card img {
  width: 100%;
  height: 100%;
  min-height: 178px;
  background: var(--bg-2);
  object-fit: cover;
}

.layer-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px 24px 22px 0;
}

.layer-copy h3 {
  font-size: 24px;
}

.layer-copy .text-button {
  align-self: flex-start;
  margin-top: 16px;
}

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

.faction-card {
  padding: 26px;
}

.faction-card .text-button {
  margin-top: 18px;
}

.character-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 32px;
}

.character-tools {
  display: grid;
  gap: 14px;
  width: min(470px, 100%);
}

.search-field {
  position: relative;
  display: block;
}

.search-field span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.search-field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(109, 168, 216, 0.08), rgba(143, 23, 36, 0.08)),
    rgba(255, 255, 255, 0.045);
  color: var(--text);
  padding: 0 20px 0 48px;
  outline: none;
}

.search-field::before {
  position: absolute;
  left: 19px;
  top: 50%;
  width: 13px;
  height: 13px;
  content: "";
  border: 2px solid var(--rose-bright);
  border-radius: 50%;
  transform: translateY(-58%);
}

.search-field::after {
  position: absolute;
  left: 31px;
  top: 28px;
  width: 8px;
  height: 2px;
  content: "";
  background: var(--rose-bright);
  transform: rotate(45deg);
}

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

.character-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  overflow: hidden;
}

.portrait-frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 18%, rgba(109, 168, 216, 0.14), transparent 42%),
    #05070a;
}

.portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-count {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(4, 5, 7, 0.78);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.character-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.character-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.character-copy .text-button {
  align-self: flex-start;
  margin-top: auto;
}

.detail-dialog {
  width: min(900px, calc(100% - 32px));
  max-height: min(780px, calc(100vh - 32px));
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 14% 0%, rgba(109, 168, 216, 0.14), transparent 19rem),
    linear-gradient(180deg, #090d13, #050608);
  color: var(--text);
  box-shadow: var(--shadow);
}

.detail-dialog[open] {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 40;
  transform: translate(-50%, -50%);
}

.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(5px);
}

.dialog-close {
  position: sticky;
  top: 0;
  float: right;
  width: 42px;
  height: 42px;
  margin: 0 0 10px 10px;
  font-size: 24px;
}

.dialog-body {
  display: grid;
  gap: 18px;
  padding: 14px;
}

.dialog-body h2 {
  margin: 0;
  font-family: Cinzel, Georgia, serif;
  font-size: 36px;
  line-height: 1.12;
}

.dialog-intro {
  max-width: 720px;
  margin: 0;
  color: #dce5e8;
  font-size: 17px;
}

.dialog-text p {
  margin: 0 0 12px;
  color: var(--muted);
}

.dialog-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.dialog-gallery img {
  width: 100%;
  aspect-ratio: 4 / 5;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #05070a;
  object-fit: contain;
}

.related-actions {
  padding: 2px 0;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .topbar nav {
    width: 100%;
    overflow-x: auto;
  }

  .hero,
  .intro-grid,
  .rule-item,
  .layer-card {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .coin-ledger,
  .faction-grid,
  .character-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .layer-number {
    min-height: 70px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .layer-copy {
    padding: 22px;
  }
}

@media (max-width: 660px) {
  .section-band {
    width: min(100% - 28px, var(--max));
    padding: 64px 0;
  }

  .hero-copy h1 {
    font-size: 48px;
  }

  .topbar nav {
    flex-wrap: wrap;
    gap: 4px 8px;
    overflow: visible;
  }

  .topbar nav a {
    padding: 7px 8px;
    font-size: 11px;
  }

  .coin-card::after,
  .faction-card::after,
  .layer-card::after,
  .perk-button::after {
    right: -32px;
    bottom: -42px;
    width: 112px;
    height: 112px;
    opacity: 0.24;
  }

  .hero-copy p,
  .prose,
  .market-note {
    font-size: 16px;
  }

  .coin-ledger,
  .faction-grid,
  .character-grid,
  .perk-grid {
    grid-template-columns: 1fr;
  }

  .character-head {
    align-items: stretch;
    flex-direction: column;
  }

}
