:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --ink: #0f1c33;
  --muted: #586579;
  --line: #dbe2eb;
  --accent: #087f7c;
  --accent-ink: #ffffff;
  --accent-soft: #dff3f2;
  --shadow: 0 1px 2px rgba(15, 28, 51, .06), 0 4px 14px rgba(15, 28, 51, .05);
  --radius: 14px;
  --radius-sm: 9px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a101d; --surface: #131b2c; --surface-2: #19233a; --ink: #e9eef7; --muted: #97a4ba;
    --line: #26324a; --accent: #35c9c3; --accent-ink: #06211f; --accent-soft: #12333a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a101d; --surface: #131b2c; --surface-2: #19233a; --ink: #e9eef7; --muted: #97a4ba;
  --line: #26324a; --accent: #35c9c3; --accent-ink: #06211f; --accent-soft: #12333a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.rd {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.55 var(--font);
  min-height: 100vh; display: flex; flex-direction: column;
}
.rd :where(h1, h2, h3, p, ul, dl, dd, figure) { margin: 0; padding: 0; }
.rd :where(ul) { list-style: none; }
.rd :where(a) { color: inherit; text-decoration: none; }
.rd :where(img) { max-width: 100%; height: auto; display: block; }
.rd :where(button, input, select) { font: inherit; color: inherit; }
.rd [hidden] { display: none !important; }
.rd :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: 100%; max-width: 1280px; margin-inline: auto; padding-inline: 20px; }
.site-main { flex: 1; padding-bottom: 64px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.admin-bar .site-header { top: 32px; }
.site-header__in { display: flex; align-items: center; gap: 20px; min-height: 64px; }
.site-header__spacer { flex: 1; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 900; font-size: 22px; letter-spacing: .02em; color: var(--ink); }
.logo__mark { width: 30px; height: 30px; color: var(--accent); flex: none; }
.logo__text b { color: var(--accent); font-weight: 900; }
.site-nav { display: flex; gap: 4px; }
.site-nav a { padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 700; font-size: 15px; white-space: nowrap; }
.site-nav a:hover { background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.theme-toggle { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

/* Search and fields */
.search { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
.search svg { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 42px; padding: 0 14px 0 38px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.search input::placeholder { color: var(--muted); }
.search--header { max-width: 420px; margin-left: auto; }
.search--header input { background: var(--surface-2); }
.search--hero input { height: 54px; font-size: 17px; border-radius: 12px; box-shadow: var(--shadow); }
.field select {
  height: 42px; padding: 0 34px 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: var(--radius-sm);
  font-weight: 700; font-size: 15px; cursor: pointer; max-width: 100%;
}
.btn:hover { filter: brightness(1.08); }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }

/* Hero */
.hero { background: var(--surface); border-bottom: 1px solid var(--line); overflow: hidden; }
.hero__in { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 32px; align-items: center; padding-block: 56px; }
.hero h1 { font-size: clamp(32px, 4.4vw, 54px); line-height: 1.06; font-weight: 900; letter-spacing: -.02em; text-wrap: balance; }
.hero h1 span { color: var(--accent); }
.hero__copy > p { margin: 18px 0 26px; font-size: 18px; color: var(--muted); max-width: 46ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.hero__fan { position: relative; height: 380px; }
.hero__fan img {
  position: absolute; left: 50%; bottom: 0; width: 210px; border-radius: 11px; box-shadow: 0 10px 30px rgba(8, 20, 40, .28);
  transform-origin: 50% 130%;
  transform: translateX(-50%) rotate(calc(var(--i) * 11deg));
}

/* Blocks and heads */
.block { margin-top: 44px; }
.block__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.block__head h2 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.block__head a { color: var(--accent); font-weight: 700; font-size: 15px; white-space: nowrap; }
.page-head { padding-block: 32px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.page-head h1 { font-size: clamp(28px, 3.4vw, 40px); font-weight: 900; letter-spacing: -.02em; line-height: 1.1; flex: 1 1 auto; }
.page-head .search { flex: 1 1 320px; max-width: 480px; }
.page-head--set { display: block; }
.page-head--set h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head__info { color: var(--muted); margin-top: 6px; }
.page-head:not(.page-head--set) .page-head__info { margin: 0; flex-basis: 100%; }
.crumbs { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.crumbs a:hover { color: var(--accent); }
.crumbs span { margin-inline: 4px; opacity: .6; }
.badge { display: inline-block; padding: 3px 9px; background: var(--ink); color: var(--surface); border-radius: 6px; font-size: 14px; font-weight: 800; letter-spacing: .06em; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.rd .panel.wrap { max-width: 1240px; width: calc(100% - 40px); }
.panel h2 { font-size: 20px; font-weight: 800; margin-bottom: 14px; }

/* Set tiles */
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.set-tile { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease; }
.set-tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.set-tile__art { display: block; height: 130px; background: linear-gradient(135deg, var(--accent-soft), var(--surface-2)); overflow: hidden; }
.set-tile__art img { width: 100%; height: auto; margin-top: -22%; }
.set-tile__code { position: absolute; top: 10px; left: 10px; padding: 2px 8px; background: #0f1c33; color: #fff; border-radius: 5px; font-size: 12px; font-weight: 800; letter-spacing: .06em; }
.set-tile__body { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 14px; }
.set-tile__name { font-weight: 800; font-size: 16px; line-height: 1.25; }
.set-tile__info { color: var(--muted); font-size: 13.5px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 20px; }
.filters .search { flex: 1 1 220px; }
.filters__count { margin-left: auto; color: var(--muted); font-size: 14px; font-weight: 600; padding-inline: 6px; white-space: nowrap; }

/* Card grid */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px 16px; }
.tile { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tile--landscape { grid-column: span 2; }
.tile__img { display: block; aspect-ratio: 744 / 1039; border-radius: 4.6% / 3.3%; overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.tile--landscape .tile__img { aspect-ratio: 1039 / 744; border-radius: 3.3% / 4.6%; }
.tile__img img { width: 100%; height: 100%; object-fit: cover; }
.tile:hover .tile__img { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(8, 20, 40, .22); }
.tile__meta { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; line-height: 1.3; }
.tile__num { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; font-size: 12.5px; }
.tile__name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile:hover .tile__name { color: var(--accent); }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }

/* Collection controls */
.tile__link { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.qty { display: inline-flex; align-items: center; align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.qty__btn { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; cursor: pointer; font-size: 18px; font-weight: 700; line-height: 1; }
.qty__btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.qty__btn:disabled { opacity: .35; cursor: default; }
.qty__n { min-width: 26px; text-align: center; font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.is-owned > .qty { border-color: var(--accent); }
.is-owned > .qty .qty__n { color: var(--accent); }
.has-collection .tile:not(.is-owned) .tile__img img { filter: grayscale(.9); opacity: .55; }
.has-collection .tile:not(.is-owned):hover .tile__img img { filter: none; opacity: 1; }
.progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.progress__bar { flex: 1 1 220px; max-width: 420px; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress__bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .25s ease; }
.progress__label { font-weight: 700; font-size: 14px; }
.own-box { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 20px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.own-box__label { font-weight: 800; }
.own-box__login { color: var(--accent); font-weight: 600; }
.own-box > .qty { align-self: center; }
.market-link { margin-top: 12px; }
.market-link svg { width: 16px; height: 16px; flex: none; }
.account-link { flex: none; height: 40px; padding: 0 14px; }
.account-link[aria-current="page"] { border-color: var(--accent); color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px); padding: 12px 18px; background: var(--ink); color: var(--surface); border-radius: var(--radius-sm); font-weight: 600; box-shadow: var(--shadow); }

/* Account pages */
.auth { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.auth__form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.auth__form h2 { margin-bottom: 2px; }
.auth__form .btn { align-self: flex-start; }
.auth__lost { color: var(--accent); font-size: 14px; font-weight: 600; }
.auth__note { color: var(--muted); font-size: 13.5px; }
.input { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; }
.input input { height: 44px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 400; font-size: 16px; }
.input--hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-error { padding: 10px 12px; background: #fde8e6; color: #9b1c12; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; }
.guest-text { color: var(--muted); margin-bottom: 16px; max-width: 60ch; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpis div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpis dt { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.kpis dd { font-size: 30px; font-weight: 900; line-height: 1.2; font-variant-numeric: tabular-nums; }
.set-progress { display: flex; flex-direction: column; }
.set-row { display: grid; grid-template-columns: 52px minmax(0, 1.2fr) minmax(80px, 1fr) 84px; align-items: center; gap: 12px; padding: 10px 6px; border-top: 1px solid var(--line); border-radius: 6px; }
.set-row:first-child { border-top: 0; }
.set-row:hover { background: var(--surface-2); }
.set-row .badge { justify-self: start; font-size: 12px; }
.set-row__name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-row .progress__bar { max-width: none; flex: none; }
.set-row__n { text-align: right; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.rd .panel:not(.wrap) { margin-bottom: 24px; }

/* Pagination */
.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 32px; }
.pagination .page-numbers { min-width: 40px; height: 40px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 700; font-size: 14px; }
.pagination .page-numbers.current { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pagination a.page-numbers:hover { border-color: var(--accent); color: var(--accent); }
.pagination .dots { border: 0; background: none; }

/* Card detail */
.card-page { padding-top: 28px; }
.card-detail { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 36px; align-items: start; }
.card-detail--landscape { grid-template-columns: minmax(0, 520px) minmax(0, 1fr); }
.card-detail__img { position: sticky; top: 88px; }
.card-detail__img img { width: 100%; border-radius: 4.6% / 3.3%; box-shadow: 0 14px 36px rgba(8, 20, 40, .25); }
.card-detail--landscape .card-detail__img img { border-radius: 3.3% / 4.6%; }
.card-detail__body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.card-detail h1 { font-size: clamp(26px, 3vw, 36px); font-weight: 900; letter-spacing: -.02em; line-height: 1.12; }
.card-detail__type { color: var(--muted); font-weight: 600; margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px 4px 9px; border: 1px solid var(--line); border-radius: 999px; font-size: 13.5px; font-weight: 700; }
.dom::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--muted)); }
.dom--fury { --c: #d64533; } .dom--calm { --c: #2f9e6b; } .dom--mind { --c: #2f7fd6; }
.dom--body { --c: #e07a1f; } .dom--chaos { --c: #8a4fd0; } .dom--order { --c: #c9a21a; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.stats div { min-width: 96px; padding: 10px 14px; background: var(--surface-2); border-radius: var(--radius-sm); }
.stats dt { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.stats dd { font-size: 26px; font-weight: 900; line-height: 1.15; font-variant-numeric: tabular-nums; }
.rules { margin-top: 20px; padding: 16px 18px; background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 16.5px; }
.rules p + p { margin-top: 8px; }
.rules ul { list-style: disc; padding-left: 20px; margin-top: 8px; }
.kw { display: inline-block; padding: 0 7px; background: var(--ink); color: var(--surface); border-radius: 5px; font-size: .82em; font-weight: 800; letter-spacing: .02em; line-height: 1.55; vertical-align: 1px; }
.arrow { color: var(--accent); font-weight: 800; }
.sym { display: inline-flex; align-items: center; justify-content: center; width: 1.4em; height: 1.4em; border-radius: 50%; vertical-align: -.28em; font-size: .9em; font-weight: 800; line-height: 1; }
.sym--energy { background: var(--ink); color: var(--surface); font-variant-numeric: tabular-nums; }
.sym--exhaust { border: 1.5px solid currentColor; }
.sym--rune { background: var(--c, var(--muted)); width: 1.05em; height: 1.05em; vertical-align: -.12em; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .45); }
.sym--rune.dom--rainbow { background: conic-gradient(#d64533, #e07a1f, #c9a21a, #2f9e6b, #2f7fd6, #8a4fd0, #d64533); }
.sym--might { width: .8em; height: .8em; border-radius: 2px; background: var(--accent); transform: rotate(45deg); margin-inline: .25em; vertical-align: -.02em; }
.flavour { margin-top: 14px; color: var(--muted); font-style: italic; }
.facts { margin-top: 22px; border-top: 1px solid var(--line); }
.facts div { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts dt { flex: 0 0 120px; color: var(--muted); font-size: 14px; }
.facts dd { font-weight: 600; min-width: 0; }
.facts a { color: var(--accent); }
.card-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; }
.card-nav .btn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; line-height: 40px; }

/* Prose pages */
.prose { max-width: 760px; padding-top: 40px; }
.prose h1 { font-size: 36px; font-weight: 900; margin-bottom: 18px; letter-spacing: -.02em; }
.prose :where(p, ul, ol, h2, h3) { margin-bottom: 14px; }
.prose a:not(.btn) { color: var(--accent); text-decoration: underline; }
.prose--center { text-align: center; padding-block: 80px; }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding-block: 36px 28px; color: var(--muted); font-size: 14px; }
.site-footer__in { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px 48px; }
.site-footer__brand p { margin-top: 10px; max-width: 44ch; }
.site-footer__links { display: flex; flex-direction: column; gap: 6px; }
.site-footer__links strong { color: var(--ink); margin-bottom: 4px; }
.site-footer__links a:hover { color: var(--accent); }
.site-footer__legal, .site-footer__copy { grid-column: 1 / -1; font-size: 12.5px; line-height: 1.6; }
.site-footer__legal { border-top: 1px solid var(--line); padding-top: 18px; }

@media (max-width: 900px) {
  .hero__in { grid-template-columns: 1fr; padding-block: 36px; }
  .hero__fan { height: 250px; order: -1; }
  .hero__fan img { width: 140px; }
  .card-detail, .card-detail--landscape { grid-template-columns: 1fr; gap: 22px; }
  .card-detail__img { position: static; max-width: 380px; margin-inline: auto; }
  .card-detail--landscape .card-detail__img { max-width: 520px; }
}
@media (max-width: 782px) {
  .admin-bar .site-header { top: 46px; }
}
@media (max-width: 720px) {
  .wrap { padding-inline: 16px; }
  .rd .panel.wrap { width: calc(100% - 32px); padding: 14px; }
  .site-header__in { flex-wrap: wrap; gap: 6px 10px; padding-block: 10px; }
  .site-header__logo { margin-right: auto; }
  .site-nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .search--header { order: 4; flex-basis: 100%; max-width: none; }
  .site-header__spacer { display: none; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 14px 12px; }
  .filters__count { margin-left: 0; flex-basis: 100%; }
  .field { flex: 1 1 130px; }
  .field select { width: 100%; }
  .site-footer__in { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr; gap: 10px; }
  .kpis dd { font-size: 24px; }
  .set-row { grid-template-columns: 48px minmax(0, 1fr) 70px; }
  .set-row .progress__bar { grid-column: 1 / -1; order: 4; }
  .qty__btn { width: 34px; height: 34px; }
  .card-detail__body { padding: 18px; }
  .facts dt { flex-basis: 96px; }
}
@media (prefers-reduced-motion: reduce) {
  .rd * { transition: none !important; }
}
