/* RC6.2 — Companion Gacha Commercial Polish (presentation only) */

body.gacha-cx-open {
  overflow: hidden;
}

.gacha-cx-overlay {
  position: fixed;
  inset: 0;
  z-index: 13000;
  display: grid;
  place-items: center;
  font-family: system-ui, 'Segoe UI', sans-serif;
  pointer-events: none;
}

/* Slot modals win while buy/info/settings/history are open (RC Final P0-1). */
body.friends-slot-modal-active .gacha-cx-overlay {
  pointer-events: none !important;
  visibility: hidden !important;
}

.gacha-cx-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 2, 12, 0.72);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  pointer-events: none;
}

.gacha-cx-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, 0.65) 100%);
}

.gacha-cx-ambient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.gacha-cx-dust {
  position: absolute;
  bottom: -8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(251, 191, 36, 0.45);
  animation: gacha-cx-dust-rise linear forwards;
}

@keyframes gacha-cx-dust-rise {
  to { transform: translateY(-120vh); opacity: 0; }
}

.gacha-cx-paws {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
}

.gacha-cx-paws span {
  position: absolute;
  font-size: 1.4rem;
  animation: gacha-cx-paw-float 6s ease-in-out infinite;
}

.gacha-cx-paws span:nth-child(1) { left: 8%; top: 18%; animation-delay: 0s; }
.gacha-cx-paws span:nth-child(2) { right: 12%; top: 28%; animation-delay: 1.2s; }
.gacha-cx-paws span:nth-child(3) { left: 18%; bottom: 22%; animation-delay: 2.4s; }
.gacha-cx-paws span:nth-child(4) { right: 20%; bottom: 16%; animation-delay: 3.6s; }

@keyframes gacha-cx-paw-float {
  0%, 100% { transform: translateY(0) rotate(-12deg); opacity: 0.15; }
  50% { transform: translateY(-12px) rotate(8deg); opacity: 0.35; }
}

.gacha-cx-shell {
  position: relative;
  width: min(900px, 96vw);
  min-height: min(700px, 92vh);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem 1.35rem;
  border-radius: 22px;
  pointer-events: auto;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(124, 58, 237, 0.35), transparent 55%),
    linear-gradient(165deg, #1a0f2e 0%, #0c0618 48%, #120820 100%);
  border: 2px solid transparent;
  background-clip: padding-box;
  box-shadow:
    0 0 0 2px rgba(167, 139, 250, 0.55),
    0 0 40px rgba(124, 58, 237, 0.45),
    0 0 80px rgba(251, 191, 36, 0.12),
    inset 0 0 60px rgba(124, 58, 237, 0.15);
  overflow: hidden;
}

.gacha-cx-shell::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 24px;
  padding: 2px;
  background: linear-gradient(135deg, #fde68a, #a78bfa, #7c3aed, #fbbf24);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.85;
}

.gacha-cx-ribbon {
  align-self: center;
  margin-top: -0.35rem;
  padding: 0.35rem 2.2rem;
  background: linear-gradient(180deg, #fbbf24, #d97706);
  clip-path: polygon(6% 0, 94% 0, 100% 50%, 94% 100%, 6% 100%, 0 50%);
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.4);
}

.gacha-cx-ribbon span {
  font-weight: 900;
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  color: #1a0f2e;
}

.gacha-cx-header {
  text-align: center;
  margin: 0.65rem 0 0.85rem;
}

.gacha-cx-title {
  margin: 0;
  font-size: clamp(1.55rem, 3.2vw, 2.15rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff7e8 0%, #fde68a 35%, #fbbf24 70%, #f59e0b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 8px rgba(251, 191, 36, 0.35));
  text-transform: uppercase;
}

.gacha-cx-case {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.gacha-cx-case.is-dimmed {
  opacity: 0.35;
  transform: scale(0.96);
}

.gacha-cx-case.is-hidden {
  display: none;
}

.gacha-cx-case-window {
  position: relative;
  height: 168px;
  margin: 0 auto;
  width: min(760px, 100%);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(251, 191, 36, 0.35);
  box-shadow: inset 0 0 30px rgba(124, 58, 237, 0.25);
}

.gacha-cx-case-mask {
  position: absolute;
  inset: 8px 0;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
}

.gacha-cx-case-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 72px;
  z-index: 2;
  pointer-events: none;
}

.gacha-cx-case-edge--left {
  left: 0;
  background: linear-gradient(90deg, rgba(12, 6, 24, 0.95), transparent);
}

.gacha-cx-case-edge--right {
  right: 0;
  background: linear-gradient(270deg, rgba(12, 6, 24, 0.95), transparent);
}

.gacha-cx-track {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  will-change: transform;
  filter: blur(0);
}

.gacha-cx-center-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 156px;
  height: 148px;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(251, 191, 36, 0.45);
  border-radius: 14px;
  pointer-events: none;
  z-index: 3;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.gacha-cx-center-frame.is-active {
  border-color: #fbbf24;
  box-shadow:
    0 0 24px rgba(251, 191, 36, 0.65),
    inset 0 0 20px rgba(251, 191, 36, 0.2);
  animation: gacha-cx-frame-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes gacha-cx-frame-pulse {
  from { transform: translate(-50%, -50%) scale(1); }
  to { transform: translate(-50%, -50%) scale(1.03); }
}

.gacha-cx-center-glow {
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.25), transparent 70%);
  opacity: 0;
  transition: opacity 0.35s;
}

.gacha-cx-center-frame.is-active .gacha-cx-center-glow {
  opacity: 1;
}

.gacha-cx-center-sparkles {
  position: absolute;
  inset: 0;
}

.gacha-cx-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px #fde68a;
}

/* Cards */
.gacha-cx-card {
  flex: 0 0 140px;
  height: 132px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0.45rem 0.35rem 0.5rem;
  border-radius: 12px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  transform-style: preserve-3d;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gacha-cx-card--pet:hover {
  transform: translateY(-4px) rotateX(4deg) scale(1.04);
}

.gacha-cx-card-shine {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: linear-gradient(125deg, transparent 40%, rgba(255, 255, 255, 0.12) 50%, transparent 60%);
  pointer-events: none;
}

.gacha-cx-card-reflection {
  position: absolute;
  bottom: 0;
  left: 10%;
  right: 10%;
  height: 28%;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.06));
  border-radius: 0 0 10px 10px;
  pointer-events: none;
}

.gacha-cx-card img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
  z-index: 1;
}

.gacha-cx-card-name {
  font-size: 0.62rem;
  font-weight: 700;
  color: #e2e8f0;
  margin-top: 0.15rem;
  z-index: 1;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gacha-cx-card.cat-room-rarity--common { border-color: rgba(34, 197, 94, 0.55); box-shadow: 0 0 12px rgba(34, 197, 94, 0.2); }
.gacha-cx-card.cat-room-rarity--uncommon { border-color: rgba(56, 189, 248, 0.55); box-shadow: 0 0 14px rgba(56, 189, 248, 0.25); }
.gacha-cx-card.cat-room-rarity--rare { border-color: rgba(168, 85, 247, 0.6); box-shadow: 0 0 16px rgba(168, 85, 247, 0.3); }
.gacha-cx-card.cat-room-rarity--epic { border-color: rgba(249, 115, 22, 0.65); box-shadow: 0 0 18px rgba(249, 115, 22, 0.35); }
.gacha-cx-card.cat-room-rarity--legendary { border-color: rgba(251, 191, 36, 0.75); box-shadow: 0 0 22px rgba(251, 191, 36, 0.45); }
.gacha-cx-card.cat-room-rarity--mythic { border-color: rgba(239, 68, 68, 0.75); box-shadow: 0 0 22px rgba(239, 68, 68, 0.45); }

.gacha-cx-card--teaser {
  justify-content: center;
  gap: 0.35rem;
}

.gacha-cx-card-silhouette {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.15), rgba(0, 0, 0, 0.85) 70%);
  filter: blur(0.3px);
}

.gacha-cx-card--teaser-legendary {
  border-color: rgba(251, 191, 36, 0.8);
  box-shadow: 0 0 24px rgba(251, 191, 36, 0.5);
  animation: gacha-cx-teaser-flash 1.2s ease-in-out infinite;
}

.gacha-cx-card--teaser-mythic {
  border-color: rgba(239, 68, 68, 0.85);
  box-shadow: 0 0 26px rgba(239, 68, 68, 0.55);
  animation: gacha-cx-teaser-flash 0.9s ease-in-out infinite;
}

@keyframes gacha-cx-teaser-flash {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

.gacha-cx-card-teaser-label {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fde68a;
}

/* Chest */
.gacha-cx-chest-scene {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 220px;
  perspective: 800px;
}

.gacha-cx-chest-scene.hidden {
  display: none;
}

.gacha-cx-chest-scene.is-hidden {
  display: none;
}

.gacha-cx-chest {
  position: relative;
  width: 140px;
  height: 110px;
  transform-style: preserve-3d;
}

.gacha-cx-chest-body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72px;
  border-radius: 8px 8px 12px 12px;
  background:
    linear-gradient(180deg, #6b4423 0%, #3d2514 100%);
  border: 2px solid #fbbf24;
  box-shadow: inset 0 -8px 16px rgba(0, 0, 0, 0.4), 0 12px 24px rgba(0, 0, 0, 0.45);
}

.gacha-cx-chest-lid {
  position: absolute;
  top: 18px;
  left: -4px;
  right: -4px;
  height: 36px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #8b5a2b, #5c3a1e);
  border: 2px solid #fbbf24;
  transform-origin: 50% 100%;
}

.gacha-cx-chest-lock {
  position: absolute;
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, #fde68a, #d97706);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
}

.gacha-cx-chest-beam {
  position: absolute;
  bottom: 48%;
  left: 50%;
  transform: translateX(-50%) scaleY(0);
  width: 120px;
  height: 200px;
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.85), transparent);
  opacity: 0;
  filter: blur(8px);
  pointer-events: none;
}

/* Reveal */
.gacha-cx-reveal {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  padding: 0.5rem 0;
}

.gacha-cx-reveal.hidden {
  display: none;
}

.gacha-cx-reveal-rays {
  position: absolute;
  inset: 10% 15%;
  background: radial-gradient(circle, var(--gacha-rarity-color, #fbbf24), transparent 65%);
  opacity: 0.35;
  filter: blur(20px);
  pointer-events: none;
}

.gacha-cx-stars {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  letter-spacing: 0.15em;
  color: var(--gacha-rarity-color, #fbbf24);
  text-shadow: 0 0 12px var(--gacha-rarity-color, #fbbf24);
}

.gacha-cx-portrait-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin-bottom: 0.65rem;
}

.gacha-cx-portrait-glow {
  position: absolute;
  inset: -15%;
  background: radial-gradient(circle, var(--gacha-rarity-color, #fbbf24), transparent 70%);
  opacity: 0.5;
  animation: gacha-cx-glow-pulse 1.5s ease-in-out infinite;
}

@keyframes gacha-cx-glow-pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.08); }
}

.gacha-cx-portrait {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.5));
  z-index: 1;
}

.gacha-cx-portrait--alive {
  animation: gacha-cx-pet-breathe 2.4s ease-in-out infinite;
}

@keyframes gacha-cx-pet-breathe {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.03) rotate(1deg); }
}

.gacha-cx-paw-wave {
  position: absolute;
  right: -4px;
  top: 20%;
  font-size: 1.4rem;
  z-index: 2;
  animation: gacha-cx-wave 1.8s ease-in-out infinite;
}

@keyframes gacha-cx-wave {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-18deg) translateY(-4px); }
  75% { transform: rotate(12deg) translateY(-2px); }
}

.gacha-cx-rarity-pill {
  display: inline-block;
  margin: 0 0 0.35rem;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #0c0618;
  background: var(--gacha-rarity-color, #fbbf24);
  box-shadow: 0 0 16px var(--gacha-rarity-color, #fbbf24);
}

.gacha-cx-reveal-name {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 900;
  color: #fff7e8;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.gacha-cx-reveal-tagline {
  margin: 0.25rem 0 0.75rem;
  font-size: 0.95rem;
  color: rgba(255, 247, 232, 0.82);
}

.gacha-cx-book {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 1rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.gacha-cx-book-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255, 247, 232, 0.65);
}

.gacha-cx-book-count {
  font-size: 1.05rem;
  color: #fde68a;
}

/* Footer buttons */
.gacha-cx-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  margin-top: auto;
  padding-top: 0.75rem;
}

.gacha-cx-btn {
  border: 0;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.gacha-cx-btn:active {
  transform: scale(0.97);
}

.gacha-cx-btn--open,
.gacha-cx-btn--adopt {
  width: min(420px, 100%);
  padding: 0.95rem 1.25rem;
  font-size: 1.05rem;
  color: #052e16;
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 45%, #15803d 100%);
  box-shadow:
    0 4px 0 #14532d,
    0 8px 24px rgba(34, 197, 94, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.gacha-cx-btn--open:hover,
.gacha-cx-btn--adopt:hover {
  box-shadow:
    0 4px 0 #14532d,
    0 12px 32px rgba(34, 197, 94, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.gacha-cx-btn--continue {
  padding: 0.45rem 1.2rem;
  font-size: 0.78rem;
  color: rgba(255, 247, 232, 0.75);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.gacha-cx-btn.hidden {
  display: none;
}

.gacha-cx-confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 5;
}

.gacha-cx-overlay[data-gacha-rarity='legendary'] .gacha-cx-shell,
.gacha-cx-overlay[data-gacha-rarity='mythic'] .gacha-cx-shell {
  box-shadow:
    0 0 0 2px var(--gacha-rarity-color),
    0 0 50px var(--gacha-rarity-color),
    inset 0 0 60px rgba(124, 58, 237, 0.2);
}

@media (max-width: 640px) {
  .gacha-cx-shell {
    min-height: auto;
    padding: 1rem;
  }
  .gacha-cx-case-window {
    height: 148px;
  }
  .gacha-cx-card {
    flex: 0 0 120px;
    height: 118px;
  }
  .gacha-cx-card img {
    width: 72px;
    height: 72px;
  }
}
