.screen.packs { background: #3b2a1c; color: #fff6e0; }
.packs .topbar h1 { color: #fff6e0; }
.packs .back { filter: drop-shadow(0 2px 0 rgb(0 0 0 / 0.4)); }
.pack-note { text-align: center; font-weight: 800; min-height: 3em; }
.pack-stage { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.9rem 0.6rem; justify-items: center; padding: 0.5rem 0.25rem; min-height: 22rem; align-content: start; }
.pack-stage > .flip { grid-column: span 2; }
.pack-stage > .flip:nth-child(4) { grid-column: 2 / span 2; }
.pack-stage > .flip:nth-child(5) { grid-column: 4 / span 2; }
.pack-stage > .empty-note, .pack-stage > .pack-art { grid-column: 1 / -1; }
.pack-stage > .empty-note { color: var(--ink); width: 100%; }
.pack-art { position: relative; width: min(62%, 15rem); justify-self: center; animation: pack-bob 1.6s ease-in-out infinite; filter: drop-shadow(0 10px 14px rgb(0 0 0 / 0.5)); }
.pack-art img { width: 100%; }
.pack-art span { position: absolute; right: -0.25rem; bottom: 0; padding: 0.1rem 0.7rem; border-radius: 999px; background: var(--gold); color: #3a2616; font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; }
@keyframes pack-bob { 50% { transform: translateY(-8px) rotate(1.5deg); } }

.flip { width: 100%; aspect-ratio: 2 / 3; perspective: 800px; animation: deal 320ms cubic-bezier(.2,.9,.3,1.1) backwards; border-radius: 0.8rem; }
.flip-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 460ms cubic-bezier(.3,.8,.3,1); }
.flip.is-flipped .flip-inner { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 0.8rem; }
.flip-front { transform: rotateY(180deg); }
.flip-back { filter: drop-shadow(0 0 0.45rem var(--glow)); }
.flip[data-r='L'] .flip-back { animation: rainbow 2s linear infinite; }
.flip.is-flipped[data-r='R'] .flip-front, .flip.is-flipped[data-r='SR'] .flip-front, .flip.is-flipped[data-r='L'] .flip-front, .flip.is-flipped[data-r='SP'] .flip-front { filter: drop-shadow(0 0 0.6rem var(--glow)); }
.flip-new, .flip-dup { position: absolute; left: 50%; bottom: 31%; transform: translateX(-50%); padding: 0.05rem 0.6rem; border-radius: 999px; font-family: var(--font-display); font-weight: 800; font-size: 0.85rem; white-space: nowrap; box-shadow: 0 2px 0 rgb(0 0 0 / 0.3); }
.flip-new { background: var(--gold); color: #3a2616; top: 0.4rem; bottom: auto; left: auto; right: 0.3rem; transform: none; }
.flip-dup { background: #3a2616; color: #ffe27a; border: 1px solid #ffe27a; }
@keyframes deal { from { opacity: 0; transform: translateY(-24px) scale(0.9); } }
@keyframes rainbow { to { filter: drop-shadow(0 0 0.55rem #ff9ad0) hue-rotate(360deg); } }
.pack-actions { display: flex; flex-direction: column; gap: 0.6rem; margin-top: auto; }
@media (min-height: 640px) and (max-width: 520px) { .pack-actions { padding-top: 1rem; } }

.packs .chip { color: var(--ink); }

/* ───── Xé pack ───── */
.pack-tear { position: relative; grid-column: 1 / -1; justify-self: center; width: min(62%, 15rem); aspect-ratio: 1; animation: pack-shake 0.62s ease-in; --beam: #fff6d6; }
.pack-tear.best-R { --beam: #ffd23f; } .pack-tear.best-SR { --beam: #b26bff; }
.pack-tear.best-L { --beam: #ff9ad0; } .pack-tear.best-SP { --beam: #ff3a2d; }
.pack-tear .half { position: absolute; inset: 0; filter: drop-shadow(0 10px 14px rgb(0 0 0 / 0.5)); }
.pack-tear .half img { width: 100%; height: 100%; object-fit: contain; }
.pack-tear .half-l { clip-path: polygon(0 0, 52% 0, 47% 12%, 56% 25%, 48% 38%, 57% 52%, 49% 66%, 56% 80%, 50% 100%, 0 100%); animation: tear-l 0.28s 0.62s cubic-bezier(.5,0,1,.6) forwards; }
.pack-tear .half-r { clip-path: polygon(52% 0, 100% 0, 100% 100%, 50% 100%, 56% 80%, 49% 66%, 57% 52%, 48% 38%, 56% 25%, 47% 12%); animation: tear-r 0.28s 0.62s cubic-bezier(.5,0,1,.6) forwards; }
.pack-tear .crack-beam {
  position: absolute; inset: 0; clip-path: polygon(51% 0, 53% 0, 48% 12%, 57% 25%, 49% 38%, 58% 52%, 50% 66%, 57% 80%, 51% 100%, 49% 100%, 55% 80%, 48% 66%, 56% 52%, 47% 38%, 55% 25%, 46% 12%);
  background: var(--beam); filter: drop-shadow(0 0 8px var(--beam)); opacity: 0; animation: beam 0.62s ease-in forwards;
}
.pack-tear .crack-flash { position: absolute; inset: -30%; background: radial-gradient(circle, #fff 0, var(--beam) 25%, transparent 60%); opacity: 0; animation: flash 0.5s 0.6s ease-out forwards; }
.pack-tear.best-L .crack-beam { background: linear-gradient(180deg, #ff5a5a, #ffd23f, #4fd16a, #3fa6ff, #a566e8); }
.pack-tear.best-SP .crack-beam { background: linear-gradient(180deg, #ff3a2d, #14090c, #c2262e); }
@keyframes pack-shake { 0% { transform: rotate(0); } 15% { transform: rotate(-4deg) scale(1.02); } 30% { transform: rotate(4deg) scale(1.04); } 45% { transform: rotate(-5deg) scale(1.06); } 60% { transform: rotate(5deg) scale(1.08); } 100% { transform: rotate(0) scale(1.08); } }
@keyframes beam { 0%, 35% { opacity: 0; } 55%, 100% { opacity: 1; } }
@keyframes beam-out { to { opacity: 0; } }
@keyframes tear-l { to { transform: translateX(-70%) rotate(-18deg); opacity: 0; } }
@keyframes tear-r { to { transform: translateX(70%) rotate(18deg); opacity: 0; } }
@keyframes flash { 0% { opacity: 0.95; transform: scale(0.4); } 100% { opacity: 0; transform: scale(1.4); } }

/* ───── Sao hiện trên thẻ ───── */
.pack-stage { row-gap: 1.7rem; padding-top: 1.4rem; }
.flip { position: relative; }
.flip-stars { position: absolute; left: 50%; top: -1.35rem; transform: translateX(-50%); display: flex; gap: 0.1rem; pointer-events: none; z-index: 3; }
.flip-stars .star { display: block; width: 1.4rem; height: 1.4rem; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); background: #dfe3e8; opacity: 0; transform: translateY(120%) scale(0); }
.flip-stars.r-R .star { background: linear-gradient(135deg, #fff3a8, #f0b429); }
.flip-stars.r-SR .star { background: linear-gradient(135deg, #e8cbff, #9a55e0); }
.flip.is-flipped .flip-stars .star { animation: star-out 0.55s calc(0.35s + var(--k, 0) * 0.14s) cubic-bezier(.2,1.4,.4,1) forwards; }
@keyframes star-out { 0% { opacity: 0; transform: translateY(260%) scale(0.2) rotate(-90deg); } 70% { opacity: 1; transform: translateY(-8%) scale(1.3) rotate(10deg); } 100% { opacity: 1; transform: none; } }
.flip-stars.big { top: -2.75rem; }
.star-plate { display: grid; place-items: center; padding: 0.15rem 1.3rem; border-radius: 0.3rem; border: 2px solid #fff; background: linear-gradient(90deg, #ff5a5a, #ffd23f, #4fd16a, #3fa6ff, #a566e8, #ff5a5a); background-size: 200% 100%; animation: plate-flow 2.4s linear infinite; box-shadow: 0 0 14px #fff8; }
.flip-stars.r-SP .star-plate { background: linear-gradient(90deg, #14090c, #7a1018, #14090c); background-size: 200% 100%; border-color: #ff3a2d; box-shadow: 0 0 14px #ff3a2d99; }
.flip-stars.big .star { width: 2.6rem; height: 2.6rem; background: linear-gradient(135deg, #fff, #ffe27a, #ff9ad0, #7ec8ff); }
.flip-stars.big.r-SP .star { background: linear-gradient(135deg, #ffb3a7, #e0402a, #5a0d12); }
.flip.is-flipped .flip-stars.big .star { animation-duration: 0.8s; animation-delay: 2.3s; }
.flip.is-grand:not(.is-flipped) .flip-stars { display: none; }
@keyframes plate-flow { to { background-position: 200% 0; } }

/* Huyền thoại / Đặc biệt: lật chậm, lật xong chỉ thấy ánh sáng 7 màu (hoặc đỏ đen), một lúc sau ánh sáng tắt mới thấy thẻ */
.flip.is-grand .flip-inner { transition-duration: 1100ms; }
.flip-aura { position: absolute; inset: 0; border-radius: 0.8rem; opacity: 1; transition: opacity 700ms ease-out; mix-blend-mode: normal; pointer-events: none; }
.aura-L { background: conic-gradient(from 0deg, #ff5a5a, #ffd23f, #4fd16a, #3fa6ff, #a566e8, #ff5a5a); animation: spin-aura 2s linear infinite; box-shadow: 0 0 30px 10px #fff9; }
.aura-SP { background: conic-gradient(from 0deg, #14090c, #c2262e, #14090c, #7a1018, #14090c); animation: pulse-aura 1.2s ease-in-out infinite; box-shadow: 0 0 30px 10px #ff3a2d99; }
.flip.is-grand.aura-off .flip-aura { opacity: 0; }
@keyframes spin-aura { to { filter: hue-rotate(360deg) brightness(1.2); } }
@keyframes pulse-aura { 50% { filter: brightness(1.7); } }

/* ───── Đợt 3b: Huyền thoại / Đặc biệt ───── */
.star-plate-svg { display: block; width: 100%; max-width: none; margin: 0; filter: drop-shadow(0 0 10px #fff9); }
.plate-hue { animation: plate-hue 4s linear infinite; transform-origin: center; }
.plate-SP .plate-hue { animation: plate-pulse 1.6s ease-in-out infinite; }
.plate-glow { animation: plate-pulse 1.8s ease-in-out infinite; }
.star-plate-svg .sp { animation: sp-twinkle 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes plate-hue { to { filter: hue-rotate(360deg); } }
@keyframes plate-pulse { 50% { filter: brightness(1.6); opacity: .8; } }
@keyframes sp-twinkle { 0%, 100% { opacity: .2; transform: scale(.5); } 50% { opacity: 1; transform: scale(1.4); } }
.flip-stars.big { top: auto; bottom: 100%; margin-bottom: 0.1rem; width: 100%; justify-content: center; }
.flip-stars.big .star-plate-svg { opacity: 0; transform: translateY(40%) scale(.3); }
.flip.is-flipped .flip-stars.big .star-plate-svg { animation: plate-in 0.9s 2.3s cubic-bezier(.2,1.3,.4,1) forwards; }
@keyframes plate-in { to { opacity: 1; transform: none; } }

/* Aura sáng tiếp tục toả quanh thẻ sau khi đã lật */
.flip { isolation: isolate; }
.flip-glow { position: absolute; z-index: -1; inset: -14% -18%; border-radius: 1.4rem; opacity: 0; pointer-events: none; filter: blur(9px); }
.flip.is-flipped .flip-glow { opacity: 1; transition: opacity 1.2s 1.6s; animation: glow-hue 3.2s linear infinite, glow-breathe 1.6s ease-in-out infinite; }
.glow-L { background: repeating-linear-gradient(135deg, #ff4d4d, #ffe34d 10%, #58d86a 20%, #3fb6ff 30%, #c35bff 40%, #ff4d4d 50%); background-size: 200% 200%; }
.glow-SP { background: repeating-linear-gradient(135deg, #14090c, #c2262e 12%, #14090c 24%, #7a1018 36%, #14090c 48%); background-size: 200% 200%; }
.glow-L, .glow-SP { animation-name: none; }
.flip.is-flipped .glow-L { animation: glow-hue 3.2s linear infinite, glow-breathe 1.6s ease-in-out infinite, glow-slide 5s linear infinite; }
.flip.is-flipped .glow-SP { animation: glow-breathe 1.4s ease-in-out infinite, glow-slide 5s linear infinite; }
@keyframes glow-hue { to { filter: blur(9px) hue-rotate(360deg); } }
@keyframes glow-breathe { 50% { transform: scale(1.07); } }
@keyframes glow-slide { to { background-position: 200% 200%; } }

/* Xé pack Huyền thoại / Đặc biệt: rung lâu hơn, loé sáng mạnh và lâu hơn */
.pack-tear.grand { animation-duration: 1.25s; }
.pack-tear.grand .half-l { animation-delay: 1.25s; animation-duration: .45s; }
.pack-tear.grand .half-r { animation-delay: 1.25s; animation-duration: .45s; }
.pack-tear .crack-beam { animation: beam 0.62s ease-in forwards, beam-out 0.15s 0.62s ease-out forwards; }
.pack-tear.grand .crack-beam { animation: beam 1.25s ease-in forwards, beam-out 0.2s 1.25s ease-out forwards; filter: drop-shadow(0 0 16px var(--beam)) drop-shadow(0 0 30px var(--beam)); }
.pack-tear.grand .crack-flash { inset: -120%; animation: flash-big 1.1s 1.2s ease-out forwards; }
@keyframes flash-big { 0% { opacity: 1; transform: scale(.3); } 40% { opacity: 1; } 100% { opacity: 0; transform: scale(1.6); } }
.screen-flash { position: absolute; inset: 0; z-index: 30; pointer-events: none; opacity: 0; animation: screen-flash 1.65s 1.1s linear forwards; }
.flash-L { background: radial-gradient(circle at 50% 35%, #fff 0, #ffe9a8 25%, rgb(195 91 255 / .55) 55%, transparent 80%); }
.flash-SP { background: radial-gradient(circle at 50% 35%, #ffb3a7 0, #e0402a 25%, rgb(40 0 6 / .85) 60%, transparent 85%); }
@keyframes screen-flash { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } } /* giữ sáng rồi mờ nhanh ~0,4s ở cuối */

/* Giao diện mở pack gọn: không bao giờ có thanh trượt */
.screen.packs { overflow: hidden; gap: 0.5rem; }
.pack-note { min-height: 0; }
.pack-stage { min-height: 0; row-gap: 1.9rem; padding-top: 1.6rem; }
.pack-stage > .flip { width: min(100%, calc((100dvh - 25rem) / 3)); }
.pack-actions { gap: 0.4rem; margin-top: 0; }
.pack-pity { text-align: center; font-weight: 800; font-size: 0.85rem; color: #ffd9a0; margin: 0; }
.pack-pity.is-next { color: #ff9ad0; text-shadow: 0 0 8px #ff9ad0aa; }
.pack-actions .btn { min-height: 2.75rem; }

/* Bố cục cố định: các khối không đổi chỗ khi lật thẻ / hiện tổng kết */
.pack-note { min-height: 1.4em; line-height: 1.4; }
.pack-pity { min-height: 1.3em; }
.pack-stage { min-height: calc(100dvh - 25rem + 3.5rem); }
.pack-actions > * { flex: none; }
.pack-summary { margin: 0; height: 2.75rem; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 800; font-size: 0.95rem; line-height: 1.2; color: #ffe9b8; overflow: hidden; }
