:root {
  --blue: #0070d1;
  --blue-pressed: #0064b7;
  --ink: #050608;
  --dark: #0d0f12;
  --dark-card: #171a1f;
  --soft: #f3f5f8;
  --card: #ffffff;
  --muted: #616875;
  --line: #dfe3e8;
  --on-dark: #ffffff;
  --on-dark-muted: rgba(255, 255, 255, 0.7);
  --radius: 8px;
  --pill: 999px;
  --shell: 1280px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  background: var(--card);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(100% - 48px, var(--shell));
  margin-inline: auto;
}

.hero-band {
  min-height: 680px;
  padding: 32px 0 72px;
  background: var(--dark);
  color: var(--on-dark);
}

.hero-content {
  display: grid;
  gap: 48px;
}

.wordmark {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  color: var(--on-dark);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.wordmark-mark {
  width: 18px;
  height: 18px;
  border: 5px solid var(--blue);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--dark);
}

.hero-copy {
  max-width: 850px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--on-dark-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.eyebrow-blue {
  color: var(--blue-pressed);
}

h1,
h2,
p {
  text-wrap: pretty;
}

h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 300;
  letter-spacing: -0.035em;
  line-height: 1.04;
}

.hero-intro {
  max-width: 680px;
  margin: 24px 0 0;
  color: var(--on-dark-muted);
  font-size: clamp(18px, 2vw, 22px);
}

.set-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.set-card {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  background: var(--dark-card);
  transition: border-color 160ms ease, transform 160ms ease;
}

.set-card.is-selected {
  border-color: var(--blue);
}

.set-card:focus-within {
  outline: 3px solid #53b1ff;
  outline-offset: 3px;
}

.set-cover {
  position: relative;
  min-height: 164px;
  overflow: hidden;
  background: #252a31;
}

.set-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.set-cover-fallback {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  padding: 12px;
  color: var(--on-dark-muted);
  font-size: 13px;
  text-align: center;
}

.set-cover.image-failed img {
  display: none;
}

.set-cover.image-failed .set-cover-fallback {
  display: grid;
}

.set-card-body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  padding: 20px;
}

.set-card h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 500;
  line-height: 1.15;
}

.set-card-meta {
  margin: 10px 0 18px;
  color: var(--on-dark-muted);
  font-size: 14px;
}

.primary-button {
  min-height: 48px;
  border: 0;
  border-radius: var(--pill);
  padding: 12px 24px;
  background: var(--blue);
  color: var(--on-dark);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background 120ms ease, transform 120ms ease;
}

.primary-button:hover {
  background: var(--blue-pressed);
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:focus-visible {
  outline: 3px solid #53b1ff;
  outline-offset: 3px;
}

.primary-button:disabled {
  cursor: wait;
  background: #454b54;
  color: #aeb4bd;
}

.set-card .primary-button {
  margin-top: auto;
}

.set-page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.load-message {
  margin: -24px 0 0;
  color: var(--on-dark-muted);
}

.load-message:empty {
  display: none;
}

.opening-band {
  padding: 80px 0;
  background: var(--soft);
}

.rates-band {
  padding: 88px 0 96px;
  background: var(--card);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 36px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 300;
  letter-spacing: -0.025em;
}

.section-meta {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  text-align: right;
}

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

.pack-card {
  min-width: 0;
  perspective: 1100px;
}

.card-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 245 / 342;
  border: 3px solid #9ca3af;
  border-radius: 12px;
  background: #20252b;
  box-shadow: var(--card-glow, none);
  transform: translateZ(0);
}

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 520ms cubic-bezier(0.2, 0.75, 0.2, 1);
}

.pack-card.is-revealed .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 8px;
  backface-visibility: hidden;
}

.card-back {
  display: grid;
  place-items: center;
  background: var(--dark-card);
}

.card-back::before,
.card-back::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.card-back::before {
  width: 56%;
  aspect-ratio: 1;
  border: 3px solid var(--blue);
}

.card-back::after {
  width: 19%;
  aspect-ratio: 1;
  border: 3px solid #fff;
  background: var(--blue);
}

.card-back-label {
  position: absolute;
  bottom: 10%;
  z-index: 1;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.card-front {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  transform: rotateY(180deg);
  background: #fff;
  color: var(--ink);
}

.card-media {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #e8ebef;
}

.card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-fallback {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  padding: 14px;
  color: #343a43;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.card-media.image-failed img {
  display: none;
}

.card-media.image-failed .image-fallback {
  display: grid;
}

.card-caption {
  min-width: 0;
  padding: 10px;
  background: #fff;
}

.card-name {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rarity-label {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.rarity-common .card-stage,
.rarity-uncommon .card-stage,
.rarity-rare .card-stage {
  border-color: #9ca3af;
}

.rarity-reverseHolo .card-stage,
.rarity-pokeBallFoil .card-stage,
.rarity-masterBallFoil .card-stage {
  border-color: transparent;
  background: linear-gradient(135deg, #ff4d6d, #fbbf24, #34d399, #60a5fa, #a78bfa);
  padding: 2px;
}

.rarity-doubleRare .card-stage {
  border-color: #c0c0c0;
  --card-glow: 0 0 18px rgba(192, 192, 192, 0.42);
}

.rarity-ultraRare .card-stage {
  border-color: #d4af37;
  --card-glow: 0 0 18px rgba(212, 175, 55, 0.42);
}

.rarity-aceSpecRare .card-stage,
.rarity-megaAttackRare .card-stage {
  border-color: #a855f7;
  --card-glow: 0 0 21px rgba(168, 85, 247, 0.5);
}

.rarity-illustrationRare .card-stage {
  border-color: #6366f1;
  --card-glow: 0 0 26px rgba(99, 102, 241, 0.52);
}

.rarity-hyperRare .card-stage {
  border-color: #ef4444;
  --card-glow: 0 0 26px rgba(239, 68, 68, 0.52);
}

.rarity-specialIllustrationRare .card-stage {
  border-color: transparent;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  padding: 3px;
  --card-glow: 0 0 34px rgba(239, 68, 68, 0.64);
}

.rarity-megaHyperRare .card-stage {
  border-color: #fbbf24;
  --card-glow: 0 0 38px rgba(251, 191, 36, 0.72);
}

.rarity-megaHyperRare.is-revealed .card-front::after {
  content: "";
  position: absolute;
  inset: -30% auto -30% -45%;
  width: 30%;
  transform: rotate(18deg);
  background: rgba(255, 255, 255, 0.72);
  animation: shine-pass 900ms 520ms ease-out 1 both;
}

@keyframes shine-pass {
  from {
    left: -45%;
  }
  to {
    left: 125%;
  }
}

.result-bar {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 28px;
  border-top: 1px solid #d4d8de;
  padding-top: 24px;
}

.result-bar p {
  margin: 0;
  color: #343a43;
  font-size: 17px;
}

.rates-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.rates-row {
  display: grid;
  grid-template-columns: 1.45fr 0.7fr 1fr 0.75fr 0.7fr;
  align-items: center;
  gap: 18px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding: 17px 20px;
}

.rates-row:last-child {
  border-bottom: 0;
}

.rates-header {
  background: var(--soft);
  color: #4a515c;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.rates-tier {
  font-weight: 700;
}

.rates-value {
  font-variant-numeric: tabular-nums;
}

.rates-source {
  color: var(--blue-pressed);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.site-footer {
  padding: 48px 0;
  background: var(--blue);
  color: #fff;
}

.footer-content {
  display: grid;
  gap: 16px;
}

.footer-content nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
}

.footer-content a {
  font-weight: 700;
  text-underline-offset: 4px;
}

.footer-content p {
  max-width: 900px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
}

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

  .set-card {
    grid-template-columns: 104px 1fr;
  }

  .set-cover {
    min-height: 146px;
  }

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

@media (max-width: 700px) {
  .shell {
    width: min(100% - 32px, var(--shell));
  }

  .hero-band {
    min-height: auto;
    padding: 24px 0 48px;
  }

  .hero-content {
    gap: 36px;
  }

  h1 {
    font-size: clamp(38px, 12vw, 54px);
  }

  .opening-band,
  .rates-band {
    padding: 56px 0;
  }

  .section-heading,
  .result-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-meta {
    text-align: left;
  }

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

  .result-bar .primary-button {
    width: 100%;
  }

  .rates-header {
    display: none;
  }

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

  .rates-row > span,
  .rates-row > a {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .rates-row > :not(.rates-tier)::before {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .rates-tier {
    grid-column: 1 / -1;
    font-size: 17px;
  }
}

@media (max-width: 400px) {
  .shell {
    width: min(100% - 24px, var(--shell));
  }

  .set-card {
    grid-template-columns: 90px minmax(0, 1fr);
  }

  .set-card-body {
    padding: 15px;
  }

  .set-card h2 {
    font-size: 18px;
  }

  .set-card-meta {
    font-size: 12px;
  }

  .primary-button {
    min-height: 44px;
    padding-inline: 18px;
  }

  .pack-grid {
    gap: 10px;
  }

  .card-caption {
    padding: 8px;
  }

  .card-name {
    font-size: 12px;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
