/* ==========================================================================
   Scène d'ouverture d'un booster (plein écran, fond sombre)
   ========================================================================== */
.op {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  color: #f6efe2;
  background: radial-gradient(120% 85% at 50% 38%, #3b3229 0%, #1d1915 55%, #100e0c 100%);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  animation: op-in 0.3s ease-out;
}
.op::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.55;
  pointer-events: none;
}
.op.closing { animation: op-out 0.25s ease-in forwards; }
@keyframes op-in { from { opacity: 0; } }
@keyframes op-out { to { opacity: 0; } }

.op-top {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
}
.op-title { font-weight: 800; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-actions { display: flex; gap: 8px; flex: none; }
.op-iconbtn {
  height: 40px;
  min-width: 40px;
  padding: 0 12px;
  display: inline-grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  color: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.op-iconbtn:hover { background: rgba(255, 255, 255, 0.14); }
.op-iconbtn .ic { width: 20px; height: 20px; }

.op-stage {
  --pw: min(64vw, 290px, 40dvh);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
}
.op-stage > * { grid-area: 1 / 1; }
/* Halo hors du flux : il ne doit jamais élargir la scène. */
.op-aura {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--pw) * 2.4);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--aura, #ffd23f) 0%, transparent 62%);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.6);
  transition: opacity 0.5s, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
  z-index: 0;
}
.op-aura.on { opacity: 0.55; transform: translate(-50%, -50%) scale(1); }
.op-aura.on.big { opacity: 0.8; transform: translate(-50%, -50%) scale(1.25); }

.op-packwrap { position: relative; width: var(--pw); z-index: 3; }
.op-packwrap .pack {
  filter: drop-shadow(0 0 1px #000) drop-shadow(0 22px 34px rgba(0, 0, 0, 0.6));
  animation: op-pack-in 0.6s cubic-bezier(0.3, 1.4, 0.5, 1);
}
@keyframes op-pack-in { from { transform: translateY(40px) scale(0.8) rotate(-6deg); opacity: 0; } }
.op-packwrap.wiggle .pack { animation: op-wiggle 0.5s; }
@keyframes op-wiggle {
  20% { transform: rotate(-4deg); }
  40% { transform: rotate(3.5deg); }
  60% { transform: rotate(-2.5deg); }
  80% { transform: rotate(1.5deg); }
}
.pack-flap { will-change: transform; }

.op-tear {
  position: absolute;
  left: -14%;
  right: -14%;
  top: -10%;
  height: 38%;
  z-index: 6;
  cursor: grab;
  touch-action: none;
}
.op-tear:active { cursor: grabbing; }
.op-tear:focus-visible { outline: 3px dashed #ffd23f; outline-offset: -6px; border-radius: 10px; }
.op-tearline, .op-tearglow, .op-finger { position: absolute; pointer-events: none; z-index: 5; }
.op-tearline {
  left: 2%;
  right: 2%;
  top: 14.2%;
  border-top: 2.5px dashed rgba(255, 255, 255, 0.9);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
  transition: opacity 0.2s;
}
.op-tearglow {
  left: 0;
  top: 14.2%;
  height: 4px;
  width: calc(var(--p, 0) * 100%);
  margin-top: -2px;
  border-radius: 2px;
  background: #fffbe8;
  box-shadow: 0 0 10px 3px rgba(255, 226, 140, 0.95), 0 0 24px 6px rgba(255, 190, 80, 0.5);
}
.op-tearglow.rev { left: auto; right: 0; }
.op-finger {
  top: 14.2%;
  left: 6%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.12);
  animation: op-finger 2.2s ease-in-out infinite;
}
@keyframes op-finger {
  0% { left: 4%; opacity: 0; transform: scale(1.3); }
  12% { opacity: 1; transform: scale(1); }
  70% { left: 92%; opacity: 1; }
  85%, 100% { left: 96%; opacity: 0; }
}
.op.torn .op-tearline, .op.torn .op-finger, .op.touched .op-finger { opacity: 0; animation: none; }

.op-stack {
  position: relative;
  width: calc(var(--pw) * 0.86);
  aspect-ratio: 63 / 88;
  z-index: 2;
  cursor: pointer;
}
.op-slot { position: absolute; inset: 0; transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
.op-card { position: absolute; inset: 0; }
.op-card .card-back, .op-card .card { box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45); border-radius: 6cqw; }
.op-slot.charging .op-card { animation: op-shake 0.08s linear infinite; }
.op-slot.charging .op-card .card-back {
  filter: drop-shadow(0 0 10px var(--glow)) drop-shadow(0 0 28px var(--glow));
}
.op-slot.charge-shine .op-card { animation-duration: 0.14s; }
@keyframes op-shake {
  0% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-1.5px, 1px) rotate(-0.6deg); }
  50% { transform: translate(1.5px, -1px) rotate(0.6deg); }
  75% { transform: translate(-1px, -1px) rotate(-0.3deg); }
  100% { transform: translate(0, 0) rotate(0); }
}
.op-badge {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 4;
  padding: 6px 13px;
  border: 2.5px solid #221d17;
  border-radius: 999px;
  background: #ffd23f;
  color: #221d17;
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  box-shadow: 3px 3px 0 #221d17;
  transform: rotate(10deg) scale(0);
  transition: transform 0.4s cubic-bezier(0.3, 1.7, 0.5, 1);
}
.op-badge.dup { background: #fbf7ee; }
.op-slot.show-badge .op-badge { transform: rotate(10deg) scale(1); }
.op-rarity {
  position: absolute;
  left: 50%;
  bottom: -46px;
  transform: translateX(-50%) translateY(6px);
  opacity: 0;
  white-space: nowrap;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 26px;
  color: var(--glow);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s, transform 0.3s;
}
.op-slot.show-badge .op-rarity { opacity: 1; transform: translateX(-50%); }

.op-bottom {
  position: relative;
  z-index: 10;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 6px 16px calc(18px + env(safe-area-inset-bottom));
}
.op-dots { display: flex; gap: 8px; min-height: 12px; }
.op-dots i {
  width: 11px;
  height: 11px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  transition: background 0.3s, border-color 0.3s, transform 0.3s;
}
.op-dots i.done { background: var(--c); border-color: var(--c); transform: scale(1.15); }
.op-msg { margin: 0; min-height: 34px; font-family: var(--hand); font-weight: 700; font-size: 27px; text-align: center; line-height: 1.15; }
.op-msg.error { color: #ffb4a3; }

.op-fx { position: absolute; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }
.op-confetti { position: absolute; display: block; border-radius: 1px; will-change: transform, opacity; }

.op-summary {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  align-content: safe center;
  justify-items: center;
  gap: 22px;
  padding: 70px 16px 30px;
  overflow-y: auto;
  touch-action: pan-y;
  animation: op-in 0.35s ease-out;
}
.op-summary h2 { margin: 0; font-size: clamp(28px, 6vw, 40px); }
.op-summary h2 span { color: #ffd23f; }
.op-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px 14px; max-width: 1000px; }
.op-sum-card {
  position: relative;
  width: clamp(98px, 28vw, 172px);
  animation: op-pop 0.45s cubic-bezier(0.3, 1.5, 0.5, 1) backwards;
  animation-delay: calc(var(--i) * 70ms);
}
@keyframes op-pop { from { transform: translateY(24px) scale(0.85); opacity: 0; } }
/* Étiquette en bas de la carte : le nom reste lisible. */
.op-tag {
  position: absolute;
  left: 50%;
  bottom: -26px;
  z-index: 4;
  padding: 2px 9px;
  border: 2px solid #221d17;
  border-radius: 999px;
  background: #ffd23f;
  color: #221d17;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
  transform: translateX(-50%) rotate(-4deg);
  box-shadow: 2px 2px 0 #221d17;
}
.op-grid { row-gap: 40px; padding-bottom: 20px; }
.op-tag.dup { background: #fbf7ee; }
.op-sum-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.op .btn { box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.55); }
.op .btn:hover { box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.55); }
.op-summary-note { color: rgba(246, 239, 226, 0.75); margin: -8px 0 0; text-align: center; }
/* Crayon sur chaque carte du récap (coin bas-droit : le titre reste lisible) : proposer sa version */
.op-propose {
  position: absolute;
  right: -12px;
  bottom: -14px;
  z-index: 5;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid #221d17;
  border-radius: 50%;
  background: #fbf7ee;
  color: #221d17;
  box-shadow: 2px 2px 0 #221d17;
  transform: rotate(-10deg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s cubic-bezier(0.3, 1.5, 0.5, 1), background-color 0.15s;
}
.op-propose:hover { transform: rotate(-10deg) scale(1.12); }
.op-propose:focus-visible { outline: 3px solid #ffd23f; outline-offset: 2px; }
.op-propose.done { background: #ffd23f; }
.op-propose .ic { width: 19px; height: 19px; }
@media (max-width: 560px) {
  .op-propose { width: 34px; height: 34px; right: -9px; bottom: -12px; }
  .op-propose .ic { width: 17px; height: 17px; }
}
.op-propose-hint {
  max-width: 520px;
  margin: -6px 0 0;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.15;
  text-align: center;
  color: #ffd23f;
}

@media (max-height: 640px) {
  .op-stage { --pw: min(60vw, 250px, 36dvh); }
  .op-msg { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  .op-slot.charging .op-card { animation: none; }
}
