:root {
  --ink: #f3f1e8;
  --muted: #9aa9a0;
  --surface: #132b25;
  --surface-raised: #18352d;
  --line: rgba(220, 239, 227, 0.12);
  --gold: #ffbf43;
  --gold-soft: #ffe09a;
  --red: #ef5a59;
  --blue: #4ba6e9;
  --green: #69c982;
  --purple: #b378dc;
  --common: #5a9fd4;
  --uncommon: #65b77b;
  --rare: #e75d5d;
  --legendary: #b47be0;
}

.app-promo { margin: 24px 0 0; font-size: 13px; line-height: 1.7; color: var(--muted); }
.app-promo a { text-decoration: none; }
.app-promo strong { color: var(--gold); font-weight: 600; white-space: nowrap; }

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 52% -10%, rgba(40, 103, 80, 0.48), transparent 34rem),
    linear-gradient(145deg, #0c1c18 0%, #0d211b 45%, #081511 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
  content: "";
  opacity: 0.13;
  pointer-events: none;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

a {
  color: inherit;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 30rem;
  height: 30rem;
  border-radius: 999px;
  filter: blur(100px);
  opacity: 0.08;
  pointer-events: none;
}

.ambient-one {
  top: 15%;
  left: -18rem;
  background: #00a3ff;
}

.ambient-two {
  right: -18rem;
  bottom: 5%;
  background: #ffb000;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 48px;
  height: 48px;
  flex: none;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 4px 0 #07120f, 0 8px 20px rgba(0, 0, 0, 0.28);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: -0.02em;
  font-size: 16px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.random-button {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: #d9e1dc;
  transition: 160ms ease;
}

.random-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 191, 67, 0.5);
  color: var(--gold-soft);
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.hero {
  max-width: 800px;
  padding: 92px 0 74px;
}

.eyebrow,
.dialog-kicker,
.panel-label {
  margin: 0 0 18px;
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  max-width: 720px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(54px, 8vw, 100px);
  font-weight: 500;
  letter-spacing: -0.07em;
  line-height: 0.88;
}

h1 em {
  color: var(--gold);
  font-weight: 500;
}

.hero-copy {
  max-width: 620px;
  margin: 32px 0 0;
  color: #a8b7ae;
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.7;
}

.catalog {
  padding-bottom: 80px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(19, 43, 37, 0.88);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.search-box {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 52px;
  padding: 0 15px;
  border: 1px solid rgba(231, 239, 233, 0.13);
  border-radius: 11px;
  background: rgba(5, 15, 12, 0.42);
  transition: 160ms ease;
}

.search-box:focus-within {
  border-color: rgba(255, 191, 67, 0.65);
  box-shadow: 0 0 0 3px rgba(255, 191, 67, 0.1);
}

.search-box svg {
  flex: none;
  fill: none;
  stroke: #83978b;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.search-box input::placeholder {
  color: #71847a;
}

kbd {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: #819188;
  font-size: 11px;
}

.sort-control {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 8px 0 12px;
  border: 1px solid rgba(231, 239, 233, 0.13);
  border-radius: 11px;
  background: rgba(5, 15, 12, 0.42);
}

.sort-control label {
  color: #7f9186;
  font-size: 12px;
}

.sort-control select {
  min-height: 50px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #dfe7e2;
  font-size: 13px;
}

.pack-panel {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 24, 19, 0.62);
}

.pack-heading {
  display: flex;
  gap: 20px;
  align-items: end;
  justify-content: space-between;
}

.pack-label {
  margin: 0 0 4px;
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pack-heading p:last-child,
.pack-heading > span {
  margin: 0;
  color: #71847a;
  font-size: 11px;
}

.pack-heading > span {
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.pack-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pack-option {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  color: #a5b4ab;
  font-size: 11px;
  transition: 150ms ease;
}

button.pack-option:hover,
.pack-option.active {
  border-color: rgba(255, 191, 67, 0.48);
  background: rgba(255, 191, 67, 0.08);
  color: #f3e3b8;
}

.pack-option.loading {
  opacity: 0.72;
}

.pack-option small {
  color: #6e8277;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

.pack-check {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--gold);
  line-height: 1;
}

.base-pack {
  border-color: rgba(105, 201, 130, 0.3);
  color: #b8d5bf;
}

.filter-row {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  margin: 22px 2px 30px;
}

.category-scroller {
  margin: 24px -2px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-scroller::-webkit-scrollbar {
  display: none;
}

.categories {
  display: flex;
  width: max-content;
  min-width: 100%;
  gap: 8px;
  padding: 2px;
}

.category-filter {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: #90a097;
  white-space: nowrap;
  transition: 150ms ease;
}

.category-filter span {
  color: #65786e;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

.category-filter:hover,
.category-filter.active {
  border-color: color-mix(in srgb, var(--category-color, var(--gold)), transparent 35%);
  background: color-mix(in srgb, var(--category-color, var(--gold)), transparent 90%);
  color: #f4f3ec;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: #9baaa2;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  transition: 150ms ease;
}

.filter span {
  margin-left: 5px;
  opacity: 0.55;
}

.filter:hover,
.filter.active {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.filter.common.active { border-color: var(--common); color: #9fd5fb; }
.filter.uncommon.active { border-color: var(--uncommon); color: #9ee1ae; }
.filter.rare.active { border-color: var(--rare); color: #ff9b99; }
.filter.legendary.active { border-color: var(--legendary); color: #deb7fb; }

.result-count {
  flex: none;
  margin: 0;
  color: #75877d;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.joker-grid {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.joker-card {
  --rarity-color: var(--common);
  position: relative;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 15px;
  min-height: 154px;
  overflow: hidden;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.036), transparent 50%),
    rgba(16, 37, 31, 0.82);
  color: inherit;
  text-align: left;
  transition: transform 170ms ease, border-color 170ms ease, background 170ms ease;
  content-visibility: auto;
  contain-intrinsic-size: 154px;
}

.joker-card[data-rarity="Uncommon"] { --rarity-color: var(--uncommon); }
.joker-card[data-rarity="Rare"] { --rarity-color: var(--rare); }
.joker-card[data-rarity="Legendary"] { --rarity-color: var(--legendary); }

.joker-card::after {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--rarity-color), transparent);
  content: "";
  opacity: 0;
  transition: opacity 170ms ease;
}

.joker-card:hover,
.joker-card:focus-visible {
  z-index: 1;
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--rarity-color), transparent 45%);
  outline: 0;
  background: rgba(23, 52, 43, 0.97);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.22);
}

.joker-card:hover::after,
.joker-card:focus-visible::after {
  opacity: 1;
}

.card-image-wrap {
  align-self: start;
  perspective: 500px;
}

.card-image-wrap img {
  display: block;
  width: 84px;
  height: auto;
  transform: rotate(-1deg);
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.35));
  transition: transform 180ms ease;
}

.joker-card:hover .card-image-wrap img {
  transform: rotate(1deg) scale(1.04);
}

.card-copy {
  min-width: 0;
  align-self: center;
}

.card-topline {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-bottom: 7px;
}

.rarity-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 999px;
  background: var(--rarity-color);
  box-shadow: 0 0 8px var(--rarity-color);
}

.card-rarity {
  color: #778a7f;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-pack {
  min-width: 0;
  overflow: hidden;
  padding: 2px 5px;
  border: 1px solid rgba(255, 191, 67, 0.25);
  border-radius: 4px;
  color: #bda66d;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.joker-card h2 {
  margin: 0 0 8px;
  overflow: hidden;
  color: #f1f2ec;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-effect {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #95a79d;
  font-size: 11px;
  line-height: 1.48;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.empty-state {
  margin: 60px auto 0;
  text-align: center;
}

.empty-state > span {
  display: grid;
  width: 58px;
  height: 66px;
  margin: 0 auto 22px;
  place-items: center;
  transform: rotate(5deg);
  border: 2px solid #6f8177;
  border-radius: 7px;
  color: #83968b;
  font-family: Georgia, serif;
  font-size: 28px;
}

.empty-state h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 26px;
}

.empty-state p {
  margin: 8px 0 20px;
  color: var(--muted);
}

.empty-state button {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--ink);
}

footer {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 42px;
  border-top: 1px solid var(--line);
  color: #66786e;
  font-size: 11px;
}

footer p {
  margin: 0;
}

footer nav {
  display: flex;
  gap: 18px;
}

footer a:hover {
  color: var(--gold-soft);
}

.joker-dialog {
  width: min(780px, calc(100% - 28px));
  max-width: none;
  max-height: calc(100vh - 28px);
  overflow: visible;
  padding: 0;
  border: 1px solid rgba(233, 241, 236, 0.17);
  border-radius: 22px;
  background: #10241f;
  color: var(--ink);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.58);
}

.joker-dialog::backdrop {
  background: rgba(2, 8, 6, 0.8);
  backdrop-filter: blur(10px);
}

.joker-dialog[open] {
  animation: dialog-in 180ms ease-out;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-shell {
  position: relative;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 460px;
  overflow: hidden;
  border-radius: inherit;
}

.dialog-close {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(6, 19, 15, 0.66);
  color: #b7c3bc;
  font-size: 21px;
}

.dialog-close:hover {
  color: white;
}

.dialog-art-wrap {
  position: relative;
  display: grid;
  min-height: 460px;
  overflow: hidden;
  place-items: center;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--dialog-rarity, var(--common)), transparent 67%), transparent 52%),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 8px),
    #0b1b17;
}

.dialog-art-wrap img {
  position: relative;
  z-index: 1;
  width: 164px;
  height: auto;
  transform: rotate(-2deg);
  image-rendering: pixelated;
  filter: drop-shadow(0 23px 15px rgba(0, 0, 0, 0.42));
}

.dialog-glow {
  position: absolute;
  width: 170px;
  height: 240px;
  border: 1px solid color-mix(in srgb, var(--dialog-rarity, var(--common)), transparent 50%);
  border-radius: 18px;
  transform: rotate(5deg);
  box-shadow: 0 0 60px color-mix(in srgb, var(--dialog-rarity, var(--common)), transparent 72%);
}

.collection-number {
  position: absolute;
  bottom: 18px;
  left: 20px;
  color: #65796e;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.dialog-content {
  display: flex;
  min-width: 0;
  padding: 44px 38px 30px;
  flex-direction: column;
}

.dialog-heading {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.dialog-kicker {
  margin-bottom: 10px;
}

.dialog-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 5vw, 45px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.rarity-badge {
  margin: 2px 32px 0 0;
  padding: 6px 8px;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: var(--dialog-rarity, var(--common));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.effect-panel {
  margin: 30px 0 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(4, 14, 11, 0.38);
}

.panel-label {
  margin-bottom: 12px;
  color: #788c80;
  font-size: 9px;
}

.joker-description {
  color: #e5e9e6;
  font-size: 15px;
  line-height: 1.5;
}

.joker-description .text-green { color: var(--green); }
.joker-description .text-attention { color: var(--gold-soft); }
.joker-description .text-tarot { color: var(--purple); }
.joker-description .text-planet { color: #52c3bd; }
.joker-description .text-inactive { color: #7e9086; }
.joker-description .text-mult,
.joker-description .text-red { color: var(--red); }
.joker-description .text-xmult {
  padding: 1px 3px;
  border-radius: 3px;
  background: var(--red);
  color: white;
}
.joker-description .text-chips,
.joker-description .text-blue { color: var(--blue); }
.joker-description .text-money { color: var(--gold); }
.joker-description .text-spades { color: #8aa9c1; }
.joker-description .text-clubs { color: #a5b8ab; }
.joker-description .text-hearts { color: #f36664; }
.joker-description .text-diamonds { color: #e9a63e; }
.joker-description .text-variable { color: var(--purple); }

.joker-meta {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.4fr;
  margin: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.joker-meta div {
  padding: 14px 4px;
}

.joker-meta div + div {
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.joker-meta dt {
  color: #70847a;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.joker-meta dd {
  margin: 5px 0 0;
  color: #d6ded9;
  font-size: 13px;
}

.dialog-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding-top: 25px;
}

.dialog-nav button {
  border: 0;
  background: transparent;
  color: #9aaca2;
  font-size: 12px;
}

.dialog-nav button:first-child { text-align: left; }
.dialog-nav button:last-child { text-align: right; }
.dialog-nav button:hover { color: var(--gold-soft); }

.dialog-nav > span {
  color: #62766b;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

@media (max-width: 720px) {
  .site-header,
  main,
  footer {
    width: min(100% - 26px, 1180px);
  }

  .site-header {
    padding: 17px 0;
  }

  .random-button {
    padding: 9px 11px;
    font-size: 12px;
  }

  .hero {
    padding: 62px 0 52px;
  }

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

  .sort-control {
    justify-content: space-between;
  }

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

  .pack-heading {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .category-scroller {
    margin-right: -13px;
  }

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

  footer {
    align-items: start;
    flex-direction: column;
  }

  .dialog-shell {
    display: block;
    max-height: calc(100vh - 28px);
    overflow-y: auto;
  }

  .dialog-art-wrap {
    min-height: 285px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .dialog-art-wrap img {
    width: 126px;
  }

  .dialog-glow {
    width: 130px;
    height: 190px;
  }

  .dialog-content {
    padding: 30px 22px 22px;
  }

  .joker-meta {
    grid-template-columns: 1fr 1fr;
  }

  .joker-meta div:last-child {
    grid-column: 1 / -1;
    padding-left: 4px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .dialog-nav {
    margin-top: 4px;
  }
}

@media (max-width: 460px) {
  .brand small,
  .random-button span {
    display: none;
  }

  h1 {
    font-size: 55px;
  }

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

  .joker-card {
    grid-template-columns: 78px minmax(0, 1fr);
    min-height: 144px;
  }

  .card-image-wrap img {
    width: 78px;
  }

  .rarity-badge {
    margin-right: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
