.card-perspective {
  --card-width: 332px;
  --card-height: calc(var(--card-width) * 1.39759);
  position: relative;
  width: var(--card-width);
  height: var(--card-height);
  perspective: 1100px;
  perspective-origin: 50% 45%;
  flex: 0 0 auto;
  z-index: 2;
}

.card-motion {
  --rx: 0deg;
  --ry: 0deg;
  --px: 0;
  --py: 0;
  --mx: 50%;
  --my: 50%;
  --lift: 0;
  --rim-light: #f4e9bc;
  --rim-mid: #b8cbd0;
  --rim-dark: #708d9c;
  position: relative;
  width: 100%;
  height: 100%;
  outline: none;
  border-radius: 17px;
  transform-style: preserve-3d;
  transform: rotateX(calc(3deg + var(--rx))) rotateY(calc(-8deg + var(--ry)))
    rotateZ(-4deg) translateY(calc(var(--lift) * -9px));
  will-change: transform;
  touch-action: pan-y;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.card-motion:active {
  cursor: grabbing;
}

.card-motion:focus-visible::after {
  content: '';
  position: absolute;
  inset: -13px;
  border: 2px solid #577a65;
  border-radius: 26px;
  transform: translateZ(2px);
  pointer-events: none;
}

.card-flipper {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform 780ms cubic-bezier(0.22, 0.75, 0.15, 1);
}

.is-flipped .card-flipper {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 17px;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: opacity 0s linear 250ms;
}

.card-front {
  opacity: 1;
  transform: translateZ(1px);
}

.card-back {
  opacity: 0;
  transform: rotateY(180deg) translateZ(2px);
}

.is-flipped .card-front {
  opacity: 0;
}

.is-flipped .card-back {
  opacity: 1;
}

.card-base,
.card-world,
.card-stars,
.card-creature,
.card-print,
.card-foil,
.card-glare,
.card-rim {
  position: absolute;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  pointer-events: none;
}

.card-base {
  inset: 0;
  border-radius: 17px;
  border: 1px solid #faedce;
  background: linear-gradient(135deg, var(--rim-light) 0%, var(--rim-mid) 23%,
    #f2edcf 36%, var(--rim-dark) 49%, var(--rim-light) 70%, #80b3c7 87%, #d1c792);
  box-shadow: 1px 1px 0 #736d52, 2px 2px 0 #9b9783, 3px 3px 0 #6d7465,
    4px 4px 0 #bbba9e, 6px 7px 0 #6c7f77, 11px 17px 23px #182b422b,
    20px 31px 44px #1024381f, inset 0 0 0 3px #f2edcf77;
  transform: translateZ(0);
}

.edge-detail {
  position: absolute;
  inset: 3px;
  border: 1px solid #263e444a;
  border-radius: 13px;
  box-shadow: inset 0 0 0 1px #fff8d933;
}

.card-world {
  inset: 8px;
  border-radius: 11px;
  overflow: hidden;
  background: #052841;
  box-shadow: 0 0 0 1px #203e50;
  transform: translate3d(calc(var(--px) * -6px), calc(var(--py) * -6px), 8px);
  transition: transform 150ms ease-out, filter 400ms ease;
}

.card-world img {
  width: 114%;
  height: 112%;
  max-width: none;
  margin: -7% 0 0 -7%;
  display: block;
  object-fit: cover;
  object-position: center 46%;
  filter: saturate(1.2) contrast(1.07);
}

.world-vignette,
.card-world-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #0620379c, transparent 24%, #06384d08 44%,
    #031a3099 73%, #061b30eb), radial-gradient(ellipse at 50% 38%, transparent 25%, #0416295c);
}

.card-stars {
  inset: 12px;
  overflow: visible;
  transform-style: preserve-3d;
  transform: translate3d(calc(var(--px) * 3px), calc(var(--py) * 3px), 22px);
  transition: transform 150ms ease-out;
}

.card-stars > i,
.card-stars .star,
.card-stars .card-star {
  position: absolute;
  left: var(--star-x);
  top: var(--star-y);
  width: var(--star-size, 3px);
  height: var(--star-size, 3px);
  border-radius: 50%;
  background: #fff3c6;
  box-shadow: 0 0 7px #fff0a9b0, 0 0 15px #96faff60;
  animation: card-twinkle 3.8s ease-in-out infinite alternate;
  animation-delay: var(--star-delay, 0s);
}

.orbital-ring {
  position: absolute;
  width: 112%;
  height: 45%;
  left: -6%;
  top: 25%;
  border: 1px solid #e9d5a65c;
  border-radius: 50%;
  box-shadow: 0 0 10px #c5f7f014;
}

.ring-one {
  transform: rotate(-35deg);
}

.ring-two {
  top: 33%;
  transform: rotate(38deg);
  border-color: #aee8fa36;
}

.card-creature {
  inset: -3% -11% 17%;
  transform-style: preserve-3d;
  transform: translate3d(calc(var(--px) * 16px), calc(var(--py) * 13px), 45px);
  transition: transform 150ms ease-out;
}

.card-creature img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 13px 7px #00192a77) drop-shadow(0 0 13px #a0e6ff1c);
}

.card-print {
  inset: 3.23% 5.12% 2.8%;
  color: #fff8dc;
  transform-style: preserve-3d;
  transform: translate3d(calc(var(--px) * 7px), calc(var(--py) * 7px), 58px);
  text-shadow: 0 1px 3px #001829db;
  transition: transform 150ms ease-out;
}

.card-heading {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  padding: 2px 0 9px;
  isolation: isolate;
}

.card-heading::before {
  content: '';
  position: absolute;
  inset: -10px -8px -6px;
  z-index: -1;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, #042539ed, #07334a9c 52%, transparent);
}

.basic-label {
  display: block;
  width: fit-content;
  margin-bottom: 2px;
  color: #d2e7e4;
  font-size: calc(var(--card-width) * 0.0196);
  font-weight: 800;
  letter-spacing: 1.4px;
  line-height: 1.5;
  text-transform: uppercase;
}

.card-heading h2 {
  margin: 0;
  font-size: calc(var(--card-width) * 0.077);
  font-weight: 800;
  letter-spacing: -1.15px;
  line-height: 1.02;
}

.card-heading h2 em {
  margin-left: 3px;
  color: #efce7d;
  font-size: 0.76em;
  font-weight: 800;
  letter-spacing: -1.5px;
}

.card-hp {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-top: 10px;
  white-space: nowrap;
}

.card-hp small {
  align-self: flex-end;
  margin-bottom: 4px;
  font-size: calc(var(--card-width) * 0.021);
  font-weight: 700;
}

.card-hp b {
  font-size: calc(var(--card-width) * 0.074);
  letter-spacing: -1.2px;
  line-height: 1;
}

.card-hp > span {
  display: grid;
  width: calc(var(--card-width) * 0.063);
  height: calc(var(--card-width) * 0.063);
  margin-left: 3px;
  place-items: center;
  border: 1px solid #95d7e980;
  border-radius: 50%;
  background: linear-gradient(140deg, #91e5f5, #237394);
  box-shadow: inset 0 0 4px #d6fbfa70;
  color: #073e63;
}

.card-hp svg {
  width: 66%;
  height: 66%;
  fill: currentColor;
  stroke-width: 1.5;
}

.card-bottom {
  position: absolute;
  inset: auto -3px 0;
  padding: 29px 5px 0;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(180deg, transparent, #05253bca 18%, #05243beb 47%, #052034f5);
}

.creature-species {
  margin-bottom: 10px;
  padding: 4px 0;
  border-top: 1px solid #d9e4c842;
  border-bottom: 1px solid #d9e4c82b;
  color: #d2e5da;
  font-size: calc(var(--card-width) * 0.0192);
  font-weight: 600;
  letter-spacing: 0.25px;
  text-align: center;
}

.attack {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: calc(var(--card-width) * 0.065);
}

.energy-cost {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.energy-cost svg {
  width: calc(var(--card-width) * 0.035);
  height: calc(var(--card-width) * 0.035);
  padding: 2px;
  border-radius: 50%;
  color: #123c4e;
  fill: #2b6480;
  background: linear-gradient(145deg, #f1f7db, #95cbd9);
  box-shadow: 0 0 0 0.5px #f3f0c794;
  stroke-width: 1.5;
}

.attack strong {
  font-size: calc(var(--card-width) * 0.041);
  font-weight: 800;
  letter-spacing: -0.3px;
}

.attack > b {
  margin-left: auto;
  font-size: calc(var(--card-width) * 0.058);
  font-weight: 800;
  letter-spacing: -0.8px;
}

.card-bottom p {
  margin: 4px 0 11px;
  max-width: 94%;
  color: #e3eeeb;
  font-size: calc(var(--card-width) * 0.0213);
  font-weight: 500;
  line-height: 1.55;
}

.second-attack {
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1px solid #d9e4c827;
}

.card-rule {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 12px;
  padding: 6px 0 5px;
  border-top: 1px solid #d6dfbc59;
  border-bottom: 1px solid #d6dfbc33;
  color: #c7ded9;
  font-size: calc(var(--card-width) * 0.018);
  letter-spacing: 0.12px;
}

.card-rule span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.card-rule svg {
  width: 8px;
  height: 8px;
}

.card-collector {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  padding: 7px 0 1px;
  color: #e6ddb3;
  font-size: calc(var(--card-width) * 0.0175);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.card-collector span:last-child {
  color: #eccc75;
}

.card-rim {
  inset: 4px;
  border: 1px solid #ffeab3b0;
  border-radius: 13px;
  box-shadow: inset 0 0 0 1px #2d798359;
  transform: translateZ(62px);
}

.card-foil,
.card-glare {
  inset: 6px;
  border-radius: 12px;
  opacity: 0;
  transform: translateZ(63px);
  transition: opacity 350ms ease;
}

.card-foil {
  background: repeating-linear-gradient(116deg, #ffbfb3 0%, #e4c286 7%, #b5f3c2 15%,
    #9bdcef 24%, #cbb3ed 33%, #ffbfb3 42%);
  background-size: 230% 230%;
  background-position: var(--mx) var(--my);
  mix-blend-mode: color-dodge;
  mask-image: repeating-linear-gradient(110deg, #0009 0 1px, transparent 1px 4px),
    radial-gradient(ellipse at var(--mx) var(--my), #000, transparent 78%);
}

.card-glare {
  background: radial-gradient(ellipse at var(--mx) var(--my), #fffbea78 0%,
    #b6f3fb24 20%, transparent 64%);
  mix-blend-mode: screen;
}

.has-foil .card-foil {
  opacity: 0.19;
}

.has-foil .card-glare {
  opacity: calc(0.13 + var(--lift) * 0.38);
}

.finish-gold {
  --rim-light: #fff0b0;
  --rim-mid: #caa05a;
  --rim-dark: #93723c;
}

.finish-gold .card-base {
  background: linear-gradient(132deg, #fff2b2, #bc8d3c 24%, #f8dda0 39%, #9e692e 51%,
    #efd092 69%, #ad7b32 90%, #f1d99b);
}

.finish-gold .card-world img {
  filter: sepia(0.3) saturate(1.3) hue-rotate(345deg) contrast(1.05);
}

.finish-gold .card-foil {
  background: repeating-linear-gradient(115deg, #fdce67, #fff1b5 14%, #cd903e 26%, #ffe0a1 42%);
  background-size: 230% 230%;
}

.finish-gold .card-rim {
  border-color: #ffdf87;
  box-shadow: inset 0 0 0 1px #a47434, 0 0 8px #ffd67520;
}

.finish-silver {
  --rim-light: #edf5fa;
  --rim-mid: #a3b6c8;
  --rim-dark: #778292;
}

.finish-silver .card-base {
  background: linear-gradient(132deg, #f1f5f5, #98a9ba 24%, #e9f6f7 40%, #6f8598 53%,
    #e7edf3 70%, #91a5b6 89%, #d9e1ee);
}

.finish-silver .card-world img {
  filter: saturate(0.5) brightness(0.97) contrast(1.1);
}

.finish-silver .card-creature img {
  filter: saturate(0.7) drop-shadow(0 13px 7px #00192a77);
}

.finish-silver .card-foil {
  background: repeating-linear-gradient(115deg, #adc8e0, #fff 14%, #909cb5 26%, #e5effc 42%);
  background-size: 230% 230%;
}

.finish-silver .card-rim {
  border-color: #e2f2ff;
}

.card-back {
  overflow: hidden;
  border: 5px solid #adba98;
  color: #d5d8b4;
  background: radial-gradient(ellipse at 48% 42%, #487164 0%, #284e44 36%, #163e34 77%);
  box-shadow: 1px 1px 0 #647b67, 3px 3px 0 #bac2a5, 5px 5px 0 #5b7361,
    11px 17px 23px #182b422b, 20px 31px 44px #1024381f,
    inset 0 0 0 1px #eff1d1b0, inset 0 0 35px #082a2080;
}

.card-back::before,
.card-back::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.card-back::before {
  inset: 5px;
  border: 1px solid #bec9a660;
  border-radius: 7px;
  background-image: radial-gradient(#e0e3ba4a 0.6px, transparent 0.8px);
  background-size: 12px 12px;
}

.card-back::after {
  inset: 15px;
  border: 1px solid #bdc9a840;
  border-radius: 50% 50% 8px 8px / 27% 27% 8px 8px;
}

.back-border {
  position: absolute;
  inset: 26px 20px;
  border: 1px solid #c6ceac48;
  border-radius: 48% 48% 48% 48% / 34% 34% 34% 34%;
}

.back-orbit {
  position: absolute;
  width: 87%;
  height: 41%;
  top: 29%;
  left: 6.5%;
  border: 1px solid #c7cfac75;
  border-radius: 50%;
}

.orbit-a {
  transform: rotate(53deg);
}

.orbit-b {
  transform: rotate(-53deg);
}

.orbit-c {
  transform: rotate(90deg);
  border-color: #c7cfac40;
}

.back-edition,
.back-number {
  position: absolute;
  left: 0;
  width: 100%;
  color: #d0d6b3;
  font-size: calc(var(--card-width) * 0.023);
  font-weight: 600;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
}

.back-edition {
  top: 10%;
}

.back-number {
  bottom: 9%;
  font-size: calc(var(--card-width) * 0.021);
  letter-spacing: 2px;
}

.back-center {
  --paper: #34594b;
  position: absolute;
  inset: 28% 10%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  text-shadow: 0 2px 4px #092d24;
}

.back-center > svg,
.back-center > .brand-mark {
  width: 48px;
  height: 54px;
  color: #d3d7b6;
}

.back-center .brand-mark i {
  inset: 9px 6px;
  border-width: 1.5px;
  border-radius: 4px;
}

.back-center .brand-mark i:nth-child(3)::after {
  font-size: 22px;
}

.back-center strong,
.back-center > span:not(.brand-mark),
.back-center .wordmark {
  color: #e0dfbb;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: calc(var(--card-width) * 0.116);
  font-weight: 400;
  letter-spacing: -1.3px;
  line-height: 1;
}

.back-center small {
  color: #c0cbaa;
  font-size: calc(var(--card-width) * 0.021);
  letter-spacing: 2.5px;
  text-transform: uppercase;
}

.back-star {
  position: absolute;
  width: 10px;
  height: 10px;
  color: #d6d8b5;
}

.star-a {
  top: 22%;
  left: calc(50% - 5px);
}

.star-b {
  bottom: 22%;
  left: calc(50% - 5px);
}

.layer-label {
  position: absolute;
  left: 50%;
  bottom: -35px;
  display: block;
  width: max-content;
  padding: 5px 8px;
  border: 1px solid #dddfd3;
  border-radius: 4px;
  background: #fbfaf2f5;
  color: #3e5145;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  line-height: 1.2;
  text-shadow: none;
  text-transform: uppercase;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 250ms ease;
}

.is-exploded .card-world {
  overflow: visible;
  transform: translate3d(-69px, 8px, 8px) rotateY(-9deg);
}

.is-exploded .depth-layer {
  transition: transform 650ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.is-exploded .card-world img,
.is-exploded .world-vignette,
.is-exploded .card-world-vignette {
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 11px;
}

.is-exploded .card-creature {
  transform: translate3d(0, -8px, 88px) rotateY(-4deg);
}

.is-exploded .card-print {
  transform: translate3d(69px, -15px, 145px) rotateY(7deg);
}

.is-exploded .card-print::before {
  content: '';
  position: absolute;
  inset: -8px;
  border: 1px solid #9bc2bf66;
  border-radius: 9px;
  background: #c2e8e114;
  box-shadow: 0 9px 24px #0b302817;
}

.is-exploded .card-stars {
  transform: translate3d(-28px, 0, 35px);
}

.is-exploded .layer-label {
  opacity: 1;
  transform: none;
}

.is-exploded .card-world .layer-label {
  top: -30px;
  right: auto;
  bottom: auto;
  left: 12px;
}

.is-exploded .card-creature .layer-label {
  top: 54%;
  right: auto;
  bottom: auto;
  left: -5px;
}

.is-exploded .card-print .layer-label {
  top: auto;
  right: 0;
  bottom: -28px;
  left: auto;
}

.is-exploded .card-rim,
.is-exploded .card-foil,
.is-exploded .card-glare {
  opacity: 0;
}

.card-ground-shadow {
  position: absolute;
  left: 10%;
  bottom: -40px;
  width: 90%;
  height: 26px;
  border-radius: 50%;
  background: #2c453740;
  filter: blur(16px);
  transform: rotate(-4deg);
  pointer-events: none;
  z-index: -1;
}

.motion-notice {
  position: absolute;
  left: 50%;
  bottom: -60px;
  width: max-content;
  max-width: 120%;
  color: #747c6f;
  font-size: 10px;
  text-align: center;
  transform: translateX(-50%);
}

.experience.is-expanded .card-perspective {
  --card-width: min(420px, calc((100dvh - 200px) * 0.7155), 62vw);
}

@keyframes card-twinkle {
  from { opacity: 0.36; }
  to { opacity: 0.95; }
}

@media (max-width: 1200px) {
  .card-perspective { --card-width: 303px; }
}

@media (max-width: 980px) {
  .card-perspective { --card-width: 270px; }
  .is-exploded .card-world { transform: translate3d(-43px, 8px, 8px) rotateY(-9deg); }
  .is-exploded .card-print { transform: translate3d(43px, -15px, 115px) rotateY(7deg); }
}

@media (max-width: 740px) {
  .card-perspective { --card-width: 307px; }
  .card-motion { transform: rotateX(calc(3deg + var(--rx))) rotateY(calc(-6deg + var(--ry))) rotateZ(-3deg); }
  .experience.is-expanded .card-perspective {
    --card-width: min(340px, calc((100dvh - 190px) * 0.7155), 78vw);
  }
  .is-exploded .card-world { transform: translate3d(-25px, 8px, 8px) rotateY(-9deg); }
  .is-exploded .card-creature { transform: translate3d(0, -8px, 65px) rotateY(-4deg); }
  .is-exploded .card-print { transform: translate3d(25px, -15px, 95px) rotateY(7deg); }
  .card-ground-shadow { bottom: -30px; }
}

@media (max-width: 390px) {
  .card-perspective { --card-width: 278px; }
  .card-rule { margin-top: 9px; }
  .creature-species { margin-bottom: 7px; }
}

@media (max-width: 360px) {
  .card-perspective { --card-width: 240px; }
  .card-creature { left: -7%; right: -7%; }
  .card-bottom { padding-top: 15px; }
  .card-rule { margin-top: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .card-motion { transform: rotateX(3deg) rotateY(-8deg) rotateZ(-4deg); will-change: auto; }
  .card-flipper,
  .card-face,
  .card-world,
  .card-stars,
  .card-creature,
  .card-print,
  .card-foil,
  .card-glare,
  .layer-label { transition: none; }
  .card-stars > i,
  .card-stars .star,
  .card-stars .card-star { animation: none; }
}
