.level-up.card-up {
  z-index: 49;
  gap: 16px;
  background: radial-gradient(circle at 50% 42%, #7824be, #100424 70%);
}

.level-up.card-up.r3 {
  background: radial-gradient(circle at 50% 42%, #be28aa, #160428 70%);
}

.level-up.card-up.r4 {
  background: radial-gradient(circle at 50% 42%, #ffaa3c, #82146e 42%, #14001e 75%);
}

.level-up-title.card-show-title {
  font-size: 2.4rem;
  white-space: nowrap;
}

.card-show-stage {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  perspective: 900px;
}

.card-flip {
  position: relative;
  display: block;
  width: 168px;
  font-size: 20px;
}

.card-up.multi .card-flip {
  width: calc((100% - 20px) / 3);
  margin-top: 6px;
  font-size: 13px;
}

.card-flip-inner {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  transform-style: preserve-3d;
  transition: transform 700ms cubic-bezier(0.3, 1.35, 0.5, 1);
}

.card-flip.flipped .card-flip-inner {
  transform: rotateY(180deg);
}

.card-back,
.card-flip .atlas-card {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.card-flip .atlas-card {
  transform: rotateY(180deg);
  font-size: inherit;
}

.card-back {
  display: block;
  border-radius: 8.3% / 6.2%;
  background: url("../art/atlas/back/card-back.webp") center / 100% 100% no-repeat;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
}

.card-flip:not(.flipped) .card-back {
  animation: card-wait 900ms ease-in-out infinite;
}

.card-flip.flipped.new .atlas-card {
  box-shadow: 0 0 0 1px var(--gold-deep), inset 0 0 0 2px rgba(0, 0, 0, 0.35), 0 0 22px var(--glow), 0 0 40px var(--glow);
}

.card-flip .atlas-card-stars {
  display: none;
}

.card-flip-stars {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 2;
  color: var(--gold);
  font-size: 0.95em;
  line-height: 1;
  letter-spacing: -0.06em;
  white-space: nowrap;
  text-shadow: 0 0 6px rgba(255, 211, 77, 0.9), 0 1px 0 var(--gold-deep), 0 2px 2px #000;
  opacity: 0;
  transform: translate(-50%, -55%) scale(0.4);
  transition: opacity 200ms ease 300ms, transform 300ms ease-out 300ms;
}

.card-flip.flipped .card-flip-stars {
  opacity: 1;
  transform: translate(-50%, -55%);
}

.card-flip-tag {
  position: absolute;
  top: 0.7em;
  right: -0.6em;
  z-index: 2;
  padding: 0.12em 0.4em 0.04em;
  border-radius: 0.3em;
  background: var(--gold-bevel);
  border: 1px solid var(--gold-deep);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.55), 0 0 8px rgba(255, 211, 77, 0.7);
  color: var(--gold-deep);
  font-family: var(--display);
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 200ms ease 450ms, transform 250ms ease-out 450ms;
}

.card-flip.flipped .card-flip-tag {
  opacity: 1;
  transform: none;
}

.card-dust-token {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15em;
  opacity: 0;
  pointer-events: none;
}

.card-dust-token svg {
  display: block;
  width: 70%;
  overflow: visible;
  filter: drop-shadow(0 2px 0 #0d4a70) drop-shadow(0 0 8px rgba(66, 230, 255, 0.85));
}

.card-dust-outer {
  fill: var(--neon-cyan);
  stroke: #e8fdff;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.card-dust-inner {
  fill: #fff;
  opacity: 0.85;
}

.card-dust-amount {
  color: #e8fdff;
  font-family: var(--display);
  font-size: 1.6em;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 #0d4a70, 0 0 8px var(--neon-cyan), 0 0 2px #000;
}

.card-flip.dusted .card-flip-inner {
  animation: card-to-dust 380ms ease-in both;
}

.card-flip.dusted .card-flip-stars {
  opacity: 0;
  transition-delay: 0ms;
}

.card-flip.dusted .card-dust-token {
  animation: dust-token-in 420ms ease-out 200ms both;
}

.card-flip.dusted .card-flip-burst {
  --burst: rgba(66, 230, 255, 0.9);
  animation: card-burst-dust 800ms ease-out 150ms both;
}

@keyframes card-to-dust {
  from { opacity: 1; transform: rotateY(180deg); }
  to { opacity: 0; transform: rotateY(180deg) scale(0.2); }
}

@keyframes dust-token-in {
  from { opacity: 0; transform: scale(0.3); }
  to { opacity: 1; transform: none; }
}

@keyframes card-burst-dust {
  0% { opacity: 0; transform: scale(0.3) rotate(0deg); }
  15% { opacity: 1; }
  55% { opacity: 0.8; }
  100% { opacity: 0; transform: scale(1.15) rotate(-30deg); }
}

.card-flip.dealt {
  animation-name: card-deal;
  animation-timing-function: cubic-bezier(0.2, 0.7, 0.3, 1);
  animation-fill-mode: both;
}

@keyframes card-deal {
  0% { opacity: 0; transform: translate(var(--deal-x), var(--deal-y)) rotate(var(--deal-tilt)) scale(0.3); }
  25% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

.card-flip.r1 { --burst: rgba(255, 240, 200, 0.85); }
.card-flip.r2 { --burst: rgba(90, 160, 255, 0.9); }
.card-flip.r3 { --burst: rgba(255, 79, 216, 0.9); }
.card-flip.r4 { --burst: rgba(255, 211, 77, 1); }

.card-flip-burst {
  position: absolute;
  left: -70%;
  right: -70%;
  top: 50%;
  aspect-ratio: 1;
  translate: 0 -50%;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, #fff 0, var(--burst) 35%, transparent 75%),
    repeating-conic-gradient(from 0deg, var(--burst) 0 7deg, transparent 7deg 24deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent);
  mask-image: radial-gradient(closest-side, #000 55%, transparent);
  opacity: 0;
  pointer-events: none;
}

.card-flip.flipped .card-flip-burst {
  animation: card-burst 900ms ease-out 100ms both;
}

.card-flip.r4.flipped .card-flip-burst {
  animation-duration: 1300ms;
}

@keyframes card-burst {
  0% { opacity: 0; transform: scale(0.3) rotate(0deg); }
  15% { opacity: 1; }
  55% { opacity: 0.8; }
  100% { opacity: 0; transform: scale(1.15) rotate(30deg); }
}

.card-confetti {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.confetti-bit {
  position: absolute;
  top: -16px;
  width: 7px;
  height: 11px;
  border-radius: 1px;
  background: var(--gold);
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: both;
}

.confetti-bit.c1 { background: var(--neon-pink); }
.confetti-bit.c2 { background: var(--neon-cyan); width: 5px; }
.confetti-bit.c3 { background: var(--text); height: 7px; }

@keyframes confetti-fall {
  0% { opacity: 0; transform: translate(0, 0) rotate(0deg) rotateX(0deg); }
  8% { opacity: 1; }
  50% { transform: translate(var(--sway), 55vh) rotate(calc(var(--spin) * 0.5)) rotateX(360deg); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(0, 108vh) rotate(var(--spin)) rotateX(720deg); }
}

.card-dust-total {
  position: absolute;
  top: calc(var(--safe-top) + 20px);
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 18px 3px 14px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-deep), var(--bg));
  border: 2px solid var(--gold-dark);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--gold-deep);
  font-family: var(--display);
  opacity: 0;
  transform: translateX(-50%) scale(0.6);
  transition: opacity 250ms ease, transform 250ms ease-out;
  pointer-events: none;
}

.card-up.collecting .card-dust-total {
  opacity: 1;
  transform: translateX(-50%);
}

.card-dust-total-mark {
  color: var(--neon-cyan);
  font-size: 1.6rem;
  line-height: 1;
  text-shadow: 0 0 8px var(--neon-cyan), 0 1px 0 #000;
}

.card-dust-total-amount {
  color: var(--gold-light);
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 var(--gold-deep), 0 2px 2px #000;
}

.card-dust-total.pop {
  animation: dust-total-pop 260ms ease-out;
}

.card-dust-total.flare {
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--gold-deep), 0 0 26px 6px rgba(66, 230, 255, 0.85);
  transition: box-shadow 200ms ease-out, opacity 250ms ease, transform 250ms ease-out;
}

@keyframes dust-total-pop {
  0% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-50%) scale(1.14); }
  100% { transform: translateX(-50%) scale(1); }
}

.card-up.collecting .card-show-title,
.card-up.collecting .card-show-prizes,
.card-up.collecting #card-collect,
.card-up.collecting .card-flip:not(.dusted) .card-flip-inner,
.card-up.collecting .card-flip:not(.dusted) .card-flip-tag,
.card-up.collecting .card-flip:not(.dusted) .card-flip-stars {
  opacity: 0;
  transition: opacity 250ms ease;
  pointer-events: none;
}

.dust-fly {
  position: absolute;
  z-index: 4;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(66, 230, 255, 0.55), transparent);
  pointer-events: none;
}

.dust-fly svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.pearl-prizes.card-show-prizes {
  min-height: 100px;
}
.card-show-prizes .pearl-prize {
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  justify-content: center;
  text-align: center;
}
#card-collect { width: min(100%, 240px); }

.pearl-prize.card-dust {
  border-color: var(--neon-cyan);
  color: #c8f8ff;
  font-size: 1.2rem;
}

.pearl-prize.card-complete {
  border-color: var(--gold);
  color: var(--gold-light);
}

@media (max-height: 700px) {
  #pearl-sheet .pearl-contents {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 8px;
    align-content: start;
  }
  #pearl-sheet .pearl-headline {
    display: none;
  }
  #pearl-sheet .pearl-contents > * {
    grid-column: 1 / -1;
  }
  #pearl-sheet .pearl-feature {
    padding-top: 2px;
    padding-bottom: 2px;
  }
  #pearl-sheet .pearl-feature-stage {
    width: 84px;
    height: 76px;
  }
  #pearl-sheet .pearl-feature .pearl {
    width: 58px;
    height: 58px;
    font-size: 58px;
    margin-bottom: 10px;
  }
  #pearl-sheet .pearl-contents > .pearl-open-all {
    grid-column: 1;
    margin-bottom: 8px;
  }
  #pearl-sheet .pearl-contents > .atlas-button {
    grid-column: 2;
    gap: 8px;
    min-height: 44px;
    margin-bottom: 8px;
    padding: 2px 8px;
  }
  .atlas-button-state {
    display: none;
  }
  .level-up-title.card-show-title {
    font-size: 2rem;
  }
  .card-flip {
    width: 140px;
    font-size: 17px;
  }
  .card-up.multi .card-show-stage {
    max-width: 290px;
  }
  .card-up.multi .card-flip {
    font-size: 11px;
  }
}

@keyframes atlas-ready {
  0%, 100% { box-shadow: 0 0 0 1px var(--gold-deep), 0 3px 0 rgba(0, 0, 0, 0.55), 0 0 8px rgba(255, 211, 77, 0.5); }
  50% { box-shadow: 0 0 0 1px var(--gold-deep), 0 3px 0 rgba(0, 0, 0, 0.55), 0 0 20px rgba(255, 211, 77, 0.95); }
}

@keyframes atlas-claimed {
  0% { filter: brightness(1.8); transform: scale(1.02); }
  100% { filter: none; transform: none; }
}

@keyframes atlas-got {
  0% { transform: rotateY(90deg) scale(0.9); filter: brightness(2); }
  100% { transform: none; filter: none; }
}

@keyframes atlas-legend {
  0%, 100% { box-shadow: 0 0 0 1px var(--gold-deep), inset 0 0 0 2px rgba(0, 0, 0, 0.35), 0 0 8px rgba(255, 211, 77, 0.6); }
  50% { box-shadow: 0 0 0 1px var(--gold-deep), inset 0 0 0 2px rgba(0, 0, 0, 0.35), 0 0 18px rgba(255, 211, 77, 1), 0 0 30px rgba(255, 79, 216, 0.6); }
}

@keyframes card-wait {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-4px) rotate(-1.5deg); }
}

@media (prefers-reduced-motion: reduce) {
  .card-flip-inner,
  .card-flip-tag {
    transition: none;
  }
  .card-flip-burst,
  .card-confetti {
    display: none;
  }
  .card-flip-stars {
    transition: none;
  }
  .card-flip.dusted .card-flip-inner {
    animation: none;
    opacity: 0;
  }
  .card-flip.dusted .card-dust-token {
    animation: none;
    opacity: 1;
  }
  .atlas-set.complete .atlas-claim,
  .atlas-album.complete .atlas-claim,
  .atlas-medal.complete .atlas-medal-ring,
  .atlas-chip.complete .atlas-medal-ring,
  .atlas-stop.ready .atlas-coin,
  .atlas-stop.claimed-now .atlas-coin,
  .atlas-album.claimed-now,
  .atlas-set.claimed-now,
  .atlas-slot.got-now .atlas-card,
  .atlas-card.r4:not(.missing),
  .card-flip:not(.flipped) .card-back {
    animation: none;
  }
  .atlas-set-fill,
  .atlas-track-fill {
    transition: none;
  }
}

