:root {
  color-scheme: dark;
  --bg: #0f1418;
  --panel: #171d23;
  --panel-2: #20272e;
  --surface: #11171c;
  --ink: #f4f7fb;
  --muted: #aab4c0;
  --faint: #75818d;
  --line: #303943;
  --accent: #f59e0b;
  --accent-2: #22d3ee;
  --danger: #fb7185;
  --shadow: 0 18px 44px rgb(0 0 0 / 34%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 5vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgb(17 23 28 / 95%);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 16px;
  min-width: 0;
}

h1,
p {
  margin: 0;
}

h1 {
  color: #fff;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.05;
}

#summary {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #10161b;
  color: var(--ink);
}

button {
  cursor: pointer;
  padding: 0 14px;
  font-weight: 750;
}

button:hover,
select:hover,
input:focus {
  border-color: var(--accent);
}

.layout {
  display: grid;
  gap: 24px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 5vw, 56px) 48px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1.8fr) repeat(5, minmax(140px, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: 0 10px 28px rgb(0 0 0 / 18%);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  padding: 0 10px;
  color: var(--ink);
  text-transform: none;
  font-weight: 550;
}

input::placeholder {
  color: var(--faint);
}

.check {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
  text-transform: none;
  font-size: 13px;
  font-weight: 700;
}

.check input {
  width: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--accent);
}

.results {
  min-width: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 24px 14px;
}

.card {
  --pointer-x: 50%;
  --pointer-y: 38%;
  --foil-opacity: 0.13;
  --foil-glare: 0.10;
  display: grid;
  min-width: 0;
  border-radius: 8px;
  color: var(--ink);
}

.card button {
  display: grid;
  gap: 10px;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.image-wrap {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 744 / 1039;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid #05080a;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #0a0d10, #29313a 48%, #050607),
    #171d23;
  box-shadow:
    0 16px 34px rgb(0 0 0 / 42%),
    0 0 0 1px rgb(255 255 255 / 4%);
}

.card.is-foil-card .image-wrap {
  border-color: color-mix(in srgb, var(--accent) 24%, #05080a);
}

.card.is-premium-foil .image-wrap {
  --foil-opacity: 0.17;
  --foil-glare: 0.14;
  box-shadow:
    0 18px 42px rgb(0 0 0 / 48%),
    0 0 24px rgb(245 158 11 / 12%);
}

.image-wrap img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-wrap.is-landscape img {
  width: 140%;
  height: 71.5%;
  object-fit: fill;
  transform: rotate(90deg);
}

.foil-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 180ms ease,
    background-position 140ms ease,
    filter 180ms ease;
  will-change: opacity, background-position;
}

.image-wrap.is-foil .foil-prism,
.detail-image-shell.is-foil-detail .foil-prism {
  opacity: calc(var(--foil-opacity) * 0.82);
  background-image:
    repeating-linear-gradient(
      112deg,
      rgb(255 92 116 / 24%) 0%,
      rgb(255 220 104 / 22%) 9%,
      rgb(88 214 255 / 22%) 18%,
      rgb(178 132 255 / 22%) 27%,
      rgb(255 255 255 / 16%) 36%,
      rgb(255 92 116 / 24%) 45%
    ),
    radial-gradient(
      farthest-corner circle at var(--pointer-x) var(--pointer-y),
      rgb(255 255 255 / 46%) 0%,
      rgb(255 255 255 / 12%) 24%,
      transparent 52%
    );
  background-size:
    260% 260%,
    cover;
  background-position:
    var(--pointer-x) var(--pointer-y),
    center;
  background-blend-mode: overlay, screen;
  mix-blend-mode: soft-light;
  filter: brightness(1.06) contrast(1.08) saturate(1.12);
}

.image-wrap.is-foil .foil-lines,
.detail-image-shell.is-foil-detail .foil-lines {
  opacity: calc(var(--foil-opacity) * 0.72);
  background-image:
    repeating-linear-gradient(
      96deg,
      transparent 0 7px,
      rgb(255 255 255 / 18%) 8px,
      transparent 11px
    ),
    linear-gradient(
      128deg,
      transparent 22%,
      rgb(255 255 255 / 24%) 48%,
      transparent 68%
    );
  background-size:
    42px 42px,
    190% 190%;
  background-position:
    center,
    var(--pointer-x) var(--pointer-y);
  mix-blend-mode: overlay;
  filter: brightness(1.05) contrast(1.25);
}

.image-wrap.is-foil .foil-glare,
.detail-image-shell.is-foil-detail .foil-glare {
  opacity: var(--foil-glare);
  background-image:
    radial-gradient(
      farthest-corner circle at var(--pointer-x) var(--pointer-y),
      rgb(255 255 255 / 88%) 0%,
      rgb(255 255 255 / 24%) 14%,
      transparent 44%
    ),
    linear-gradient(
      135deg,
      transparent 28%,
      rgb(255 255 255 / 20%) 48%,
      transparent 62%
    );
  background-size:
    cover,
    190% 190%;
  background-position:
    center,
    var(--pointer-x) var(--pointer-y);
  mix-blend-mode: screen;
  filter: brightness(1.04) contrast(1.1);
}

.image-wrap.is-premium .foil-prism {
  opacity: calc(var(--foil-opacity) * 0.95);
  mix-blend-mode: screen;
  filter: brightness(1.04) contrast(1.04) saturate(1.06);
}

.image-wrap.is-premium .foil-lines {
  opacity: calc(var(--foil-opacity) * 0.84);
}

.card.is-foil-card:hover {
  --foil-opacity: 0.22;
  --foil-glare: 0.22;
}

.card.is-premium-foil:hover {
  --foil-opacity: 0.28;
  --foil-glare: 0.30;
}

@media (prefers-reduced-motion: no-preference) {
  .image-wrap.is-premium .foil-prism {
    animation: foil-drift 12s linear infinite;
  }

  .image-wrap.is-premium .foil-lines,
  .detail-image-shell.is-foil-detail:hover .foil-prism {
    animation: foil-drift 16s linear infinite reverse;
  }
}

.card-body {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.card-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.card-title strong {
  min-width: 0;
  overflow: hidden;
  color: #fff;
  font-size: 15px;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cost {
  display: inline-grid;
  flex: 0 0 auto;
  min-width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: #05080a;
  color: #fff7cc;
  font-weight: 850;
}

.meta,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #26303a;
  color: #dbe3ec;
  font-size: 12px;
  font-weight: 750;
}

.foil-pill {
  background: linear-gradient(110deg, #fef08a, #93c5fd, #f9a8d4, #86efac);
  color: #161a1f;
}

.chip.Body {
  background: #435c37;
}

.chip.Calm {
  background: #225d69;
}

.chip.Chaos {
  background: #6b2f64;
}

.chip.Colorless {
  background: #48515a;
}

.chip.Fury {
  background: #88421f;
}

.chip.Mind {
  background: #3c3d8f;
}

.chip.Order {
  background: #806719;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.card-id {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-price {
  color: #fff;
  font-weight: 850;
  white-space: nowrap;
}

.effect,
.detail-effect {
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-line;
}

.effect {
  font-size: 13px;
}

.empty {
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.rb-symbol {
  display: inline-grid;
  width: 1.35em;
  height: 1.35em;
  place-items: center;
  margin: 0 0.08em;
  border: 1px solid rgb(244 247 251 / 22%);
  border-radius: 999px;
  background: #05080a;
  color: #fffdf8;
  font-size: 0.82em;
  font-weight: 900;
  line-height: 1;
  vertical-align: -0.16em;
}

.rb-symbol.might {
  background: #202020;
  color: #fef08a;
}

.rb-symbol.exhaust {
  background: #d6deea;
  color: #10161b;
}

.rb-symbol.energy {
  background: #164e63;
  color: #ecfeff;
}

.rb-symbol.rune.body {
  background: #596d45;
}

.rb-symbol.rune.calm {
  background: #2f7f91;
}

.rb-symbol.rune.chaos {
  background: #7c3a72;
}

.rb-symbol.rune.fury {
  background: #9a3412;
}

.rb-symbol.rune.mind {
  background: #4f46e5;
}

.rb-symbol.rune.order {
  background: #b08918;
}

.rb-symbol.rune.rainbow {
  background: conic-gradient(#ef4444, #f59e0b, #22c55e, #06b6d4, #6366f1, #d946ef, #ef4444);
}

dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 80px rgb(0 0 0 / 48%);
}

dialog::backdrop {
  background: rgb(3 6 8 / 72%);
}

.icon-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  background: #10161b;
}

.detail {
  display: grid;
  grid-template-columns: minmax(260px, 380px) 1fr;
  gap: 24px;
  padding: 24px;
}

.detail.has-landscape {
  grid-template-columns: minmax(430px, 1.25fr) minmax(280px, 0.75fr);
}

.detail-images {
  display: grid;
  gap: 12px;
}

.detail-image-shell {
  --pointer-x: 50%;
  --pointer-y: 38%;
  --foil-opacity: 0.11;
  --foil-glare: 0.10;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid #05080a;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #0a0d10, #29313a 48%, #050607),
    #171d23;
}

.detail-images img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
}

.detail-image-shell.is-landscape img {
  aspect-ratio: 1039 / 744;
}

.detail-image-shell.is-foil-detail {
  border-color: color-mix(in srgb, var(--accent) 20%, #05080a);
}

.detail-image-shell.is-foil-detail:hover {
  --foil-opacity: 0.19;
  --foil-glare: 0.22;
}

.detail-copy {
  display: grid;
  align-content: start;
  gap: 16px;
  padding-right: 28px;
}

.detail-copy h2 {
  margin: 0;
  color: #fff;
  font-size: 30px;
  line-height: 1.1;
}

.detail-copy p {
  line-height: 1.5;
}

.price {
  color: var(--accent);
  font-weight: 850;
}

.banned {
  color: var(--danger);
}

@media (max-width: 980px) {
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters label:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: start;
  }

  .brand {
    display: grid;
    gap: 5px;
  }

  .detail,
  .detail.has-landscape {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .layout {
    padding-inline: 12px;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 10px;
  }

  .card-title strong {
    font-size: 13px;
  }

  .meta,
  .chips {
    display: none;
  }
}

@keyframes foil-drift {
  from {
    background-position: 0% 50%, center;
  }
  to {
    background-position: 180% 50%, center;
  }
}
