.modalbox .encounter.encounter-card-stage {
  width: min(100%, 360px);
  height: clamp(164px, 31dvh, 236px);
  margin: 14px auto 16px;
  perspective: 900px;
}

.reveal-card {
  position: relative;
  width: min(86%, 218px);
  height: 100%;
  z-index: 2;
  transform-style: preserve-3d;
}

.reveal-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 2px solid var(--rarity);
  border-radius: 20px;
  backface-visibility: hidden;
}

.reveal-front {
  background: radial-gradient(ellipse at 50% 36%, #fffcee 12%, var(--rarity-light) 95%);
  box-shadow: inset 0 0 0 3px #fff9dfb3, 0 4px 0 var(--rarity-dark), 0 12px 22px #39261430;
}

.modalbox .encounter .reveal-front img {
  width: 92%;
  height: 90%;
  max-width: none;
  max-height: none;
  filter: drop-shadow(0 7px 6px #39261430);
}

.reveal-back {
  transform: rotateY(180deg);
  border-color: #dbad57;
  background: radial-gradient(ellipse, #876236, #4b2a17 85%);
  box-shadow: inset 0 0 0 4px #553116, inset 0 0 0 5px #c89e50, 0 5px 0 #3b2216;
}

.modalbox .encounter .reveal-back img {
  width: 48%;
  height: auto;
  max-height: 70%;
  filter: drop-shadow(0 5px 8px #24150e);
}

.reveal-flash, .reveal-ring, .reveal-particles {
  position: absolute;
  pointer-events: none;
  opacity: 0;
}

.reveal-flash {
  z-index: 3;
  inset: -30% -10%;
  border-radius: 50%;
  background: radial-gradient(ellipse closest-side, #fffdf1b0, var(--rarity) 58%, transparent);
  mix-blend-mode: screen;
}

.reveal-ring {
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 124px;
  aspect-ratio: 1;
  border: 3px solid var(--rarity-light);
  border-radius: 50%;
  box-shadow: 0 0 18px 5px var(--rarity), inset 0 0 12px var(--rarity);
}

.reveal-particles {
  z-index: 4;
  inset: 0;
}

.reveal-particles i {
  position: absolute;
  inset: auto;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px;
  border-radius: 2px;
  background: var(--rarity-light);
  box-shadow: 0 0 10px 2px var(--rarity);
  --spark-distance: clamp(84px, 31vw, 152px);
}

.reveal-particles i:nth-child(even) {
  --spark-distance: clamp(66px, 25vw, 118px);
  width: 4px;
  height: 4px;
}

.is-revealing .reveal-card { animation: encounterTurn var(--reveal-duration) cubic-bezier(.25,.64,.25,1) both; }
.is-revealing .reveal-flash { animation: encounterFlash var(--reveal-duration) ease-out both; }
.is-revealing .reveal-ring { animation: encounterRing var(--reveal-duration) ease-out both; }
.is-revealing .reveal-particles { animation: encounterParticleFade var(--reveal-duration) ease-out both; }
.is-revealing .reveal-particles i { animation: encounterParticleFlight var(--reveal-duration) ease-out both; }
.is-revealing .encounter-info { animation: encounterInfo var(--reveal-duration) ease-out both; }

@keyframes encounterTurn {
  0% { transform: translateY(14px) rotateY(180deg) rotateZ(-9deg) scale(.68); }
  19% { transform: translateY(0) rotateY(180deg) rotateZ(-4deg) scale(.91); }
  66% { transform: translateY(0) rotateY(720deg) rotateZ(0) scale(1.07); }
  82% { transform: translateY(0) rotateY(720deg) rotateZ(0) scale(.985); }
  100% { transform: translateY(0) rotateY(720deg) rotateZ(0) scale(1); }
}

@keyframes encounterFlash {
  0%, 59%, 100% { opacity: 0; transform: scale(.78); }
  67% { opacity: .88; transform: scale(1); }
  88% { opacity: .08; transform: scale(1.13); }
}

@keyframes encounterRing {
  0%, 60% { opacity: 0; transform: translate(-50%, -50%) scale(.5); }
  67% { opacity: .83; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.3); }
}

@keyframes encounterParticleFade {
  0%, 60%, 100% { opacity: 0; }
  69% { opacity: 1; }
}

@keyframes encounterParticleFlight {
  0%, 60% { transform: rotate(var(--spark-angle)) translateX(30px) rotate(45deg) scale(.35); }
  100% { transform: rotate(var(--spark-angle)) translateX(var(--spark-distance)) rotate(100deg) scale(1.1); }
}

@keyframes encounterInfo {
  0%, 62% { opacity: 0; transform: translateY(7px); }
  100% { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .is-revealing .reveal-card,
  .is-revealing .reveal-flash,
  .is-revealing .reveal-ring,
  .is-revealing .reveal-particles,
  .is-revealing .reveal-particles i,
  .is-revealing .encounter-info { animation: none; }
}

.exchange-options {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;}
.exchange-options button {display:grid;grid-template-rows:72px auto;align-items:center;justify-items:center;gap:4px;padding:8px;width:100%;margin:0;border:1px solid #bd9351;border-radius:12px;background:#fff2d1;color:#48321b;font:inherit;}
.exchange-options .leaf-exchange {margin:0;background:#e7efce;border-color:#91a35c;}
.exchange-options .exchange-art {width:100%;height:72px;object-fit:contain;}
.exchange-options .raster-icon {width:58px;height:58px;}
.map-encounter:has(.exchange-options) .encounter-card-stage {display:none;}
.exchanging .exchange-art {animation:animalToLeaf .9s ease-in both;}
.exchanging .leaf-exchange .raster-icon {animation:leafToAnimal .95s ease both;}
@keyframes animalToLeaf {to{transform:translateX(55%) scale(.3);opacity:0;filter:drop-shadow(0 0 8px #9aff5b)}}
@keyframes leafToAnimal {65%,100%{transform:translateX(-25cqw) scale(1.4);filter:drop-shadow(0 0 12px #8aff48)}}
.exchange-options {container-type:inline-size;}
@media(prefers-reduced-motion:reduce){.exchanging .exchange-art,.exchanging .leaf-exchange .raster-icon{animation:none}}

.exchange-preview {display:grid;place-items:center;min-width:0;padding:8px;}
