/* ── ITEM SLOTS ROW ── */
#slots-row {
  display: flex;
  gap: clamp(0.6rem, 2vw, 1.25rem);
  align-items: flex-end;
  min-height: clamp(130px, 22vw, 260px);
}

.item-slot {
  --rarity-color: transparent;
  --rarity-glow: transparent;
  width: clamp(130px, 20vw, 250px);
  height: clamp(178px, 27vw, 340px);
  border: none;
  border-radius: 4px;
  background: transparent;
  box-shadow: 0 0 15px var(--rarity-glow), inset 0 0 15px color-mix(in srgb, var(--rarity-color) 8%, transparent);
  gap: 0.3rem;
  padding: 0.4rem;
  position: relative;
  opacity: 0;
  transform: translateY(30px) scale(0.85);
  transition: none;
  perspective: 600px;
  cursor: pointer;
  overflow: hidden;
}

.item-slot.revealed {
  animation: slot-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.item-slot.is-uncommon {
  --rarity-color: var(--uncommon);
  --rarity-glow: transparent;
  box-shadow: none;
}
.item-slot.is-rare { --rarity-color: var(--rare); --rarity-glow: rgba(179,157,219,0.4); }
.item-slot.is-very-rare { --rarity-color: var(--very-rare); --rarity-glow: rgba(255,138,101,0.4); }
.item-slot.is-legendary { --rarity-color: var(--legendary); --rarity-glow: rgba(255,213,79,0.4); }

.slot-icon {
  font-size: clamp(1.6rem, 3.8vw, 3.4rem);
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
  flex-shrink: 0;
}
.slot-icon img {
  display: block;
  vertical-align: middle;
}
/* Icon size inside .slot; leave room for wrapped name */
.card-front-face .slot .slot-icon img {
  width: 100% !important;
  max-width: 4.2rem !important;
  height: auto !important;
  object-fit: contain;
}

.slot-name {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.46rem, 1.2vw, 0.78rem);
  color: rgba(240,208,112,0.85);
  text-align: center;
  line-height: 1.1;
  letter-spacing: 0.02em;

  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;

  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;

  padding: 0;
}

/* Value only in modal; hidden on in-slot card */
.card-front-face .slot-value {
  display: none;
}
.slot-value {
  font-family: 'Crimson Text', serif;
  font-size: clamp(0.35rem, 0.8vw, 0.52rem);
  color: rgba(168,152,128,0.7);
  font-style: italic;
  flex-shrink: 0;
}

/* ── MYSTERY SLOT (last card) ── */
.item-slot.is-mystery {
  border: none;
  --mystery-color: rgba(179,157,219,0.4);
}

.mystery-question {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(1.2rem, 3vw, 2.5rem);
  color: rgba(179,157,219,0.7);
}

/* ── CARD FLIP (legendary reveal) ── */
#card-flip-wrap {
  position: fixed;
  inset: 0;
  z-index: var(--z-flip);
  gap: clamp(1rem, 3vh, 2rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
  background: radial-gradient(ellipse 80% 80% at 50% 50%, rgba(5,3,0,0.7) 0%, rgba(5,3,0,0.95) 100%);
}
#card-flip-wrap.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Light rays */
#light-rays {
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
}

.ray {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50vmax;
  height: 3px;
  transform-origin: left center;
  background: linear-gradient(to right, rgba(255,213,79,0.6), transparent);
}

/* The card itself — same 1024×1536 layout as #card-modal */
#flip-card-scene {
  perspective: 1000px;
  height: min(65vh, 1536px);
  width: auto;
  aspect-ratio: 1024 / 1536;
  max-width: min(90vw, 1024px);
}

#flip-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
#flip-card.flipped { transform: rotateY(180deg); }

.card-face {
  backface-visibility: hidden;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 22% 13% 26%;
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  box-sizing: border-box;
}

/* Card back — frame + dark fill set from JS by rarity */
.card-back {
  background-image: linear-gradient(135deg, #1a0830 0%, #0d0520 100%);
  border: 2px solid var(--rare);
  box-shadow: 0 0 30px rgba(179,157,219,0.5), 0 0 80px rgba(179,157,219,0.2), inset 0 0 30px rgba(179,157,219,0.1);
  animation: card-back-pulse 1s ease-in-out infinite alternate;
  background-size: 100% 100%;
}

.card-back-symbol {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(2.5rem, 6vw, 5rem);
  color: rgba(179,157,219,0.4);
  animation: symbol-spin 8s linear infinite;
}

.card-back-label {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.55rem, 1.4vw, 0.75rem);
  letter-spacing: 0.32em;
  color: rgba(179,157,219,0.5);
  margin-top: 0.5rem;
  text-transform: uppercase;
  opacity: 0.75;
}

/* Card front — frame + dark fill set from JS; layout matches modal */
.card-front {
  transform: rotateY(180deg);
  background-image: linear-gradient(160deg, #1c1200 0%, #0d0900 100%);
  border: 2px solid var(--legendary);
  box-shadow: 0 0 40px rgba(255,213,79,0.6), 0 0 100px rgba(255,213,79,0.3), inset 0 0 40px rgba(255,213,79,0.08);
  background-size: 100% 100%;
}

.card-rarity-badge {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.55rem, 1.4vw, 0.75rem);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  text-align: center;
  width: 100%;
  margin-bottom: 0.5rem;
  opacity: 0.75;
  flex-shrink: 0;
}

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-size: clamp(3rem, 9vw, 5rem);
  margin: 0.4rem 0 0.7rem;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.8));
  flex-shrink: 0;
  animation: card-icon-float 3s ease-in-out infinite alternate;
}
.card-icon img {
  width: clamp(3rem, 9vw, 5rem);
  height: clamp(3rem, 9vw, 5rem);
  object-fit: contain;
  display: block;
}
.card-icon span {
  display: block;
  line-height: 1;
}

.card-divider {
  width: 70%;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255,213,79,0.5), transparent);
  margin: 0.3rem auto 0.5rem;
  flex-shrink: 0;
}

.card-desc-divider {
  width: 55%;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255,213,79,0.3), transparent);
  margin: 0 auto 0.5rem;
  flex-shrink: 0;
}

.card-item-name {
  font-family: 'Cinzel Decorative', serif;
  font-weight: 700;
  font-size: clamp(1rem, 2.8vw, 1.5rem);
  color: var(--gold-light);
  text-align: center;
  width: 100%;
  line-height: 1.2;
  margin-bottom: 0.25rem;
  text-shadow: 0 0 18px rgba(255,213,79,0.4);
  flex-shrink: 0;
}

.card-item-value {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.55rem, 1.2vw, 0.7rem);
  color: rgba(255,213,79,0.7);
  letter-spacing: 0.1em;
  text-align: center;
  width: 100%;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.card-item-desc {
  font-family: 'Crimson Text', serif;
  font-size: clamp(0.6rem, 1.3vw, 0.78rem);
  font-style: italic;
  color: rgba(200,180,140,0.9);
  text-align: center;
  width: 100%;
  line-height: 1.5;
  flex-shrink: 0;
  overflow: hidden;
}

.card-item-req {
  font-family: 'Crimson Text', serif;
  font-size: clamp(0.5rem, 1vw, 0.6rem);
  font-style: italic;
  color: rgba(179,157,219,0.85);
  text-align: center;
  width: 100%;
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(179,157,219,0.2);
  flex-shrink: 0;
}

/* ── YOU FOUND A THING ── */
#found-text {
  font-family: 'Cinzel Decorative', serif;
  font-weight: 900;
  font-size: clamp(1.2rem, 4vw, 3rem);
  color: var(--gold-light);
  text-align: center;
  letter-spacing: 0.05em;
  text-shadow:
    0 0 20px rgba(255,213,79,0.8),
    0 0 60px rgba(255,180,30,0.4),
    0 4px 8px rgba(0,0,0,0.8);
  opacity: 0;
  transform: scale(0.7) translateY(20px);
}
#found-text.appear {
  animation: found-appear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards;
}

/* ── CARD INNER (3D flip) ── */
.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.card-inner.flipped {
  transform: rotateY(180deg);
}

.card-back-face {
  backface-visibility: hidden;
  gap: 0.3rem;
  padding: 0.4rem;
  background-size: 100% 100%, cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 4px;
}

.card-front-face {
  backface-visibility: hidden;
  padding: 16% 18% 22%;
  text-align: center;
  overflow-wrap: anywhere;
  box-sizing: border-box;
  background-size: 100% 100%, cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 4px;
  transform: rotateY(180deg);
}

/* Icon + name as one flex unit (value/description hidden on card) */
.card-front-face .slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  box-sizing: border-box;
}

.card-front-face .slot .slot-icon {
  margin-top: 0;
  margin-bottom: 0.1rem;
}

.card-back-face .back-question {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(1.2rem, 2.5vw, 2rem);
  opacity: 0.5;
  line-height: 1;
}

/* ── MYSTERY SLOT GLOW (activated after all items land) ── */
.item-slot.is-mystery.activated {
  --rarity-color: var(--rare);
  --rarity-glow: rgba(179,157,219,0.6);
  animation: mystery-slot-throb 1s ease-in-out infinite alternate;
}
