/* ═══════════════════════════════════════════════════════════════════════
   Lootbox Shop — User-facing styles + opening animation
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Grid de lootbox cards ─────────────────────────────────────────── */
.lootbox-shop__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    padding: 0.5rem 0;
}

/* ── Card ──────────────────────────────────────────────────────────── */
.lbshop-card {
    background: rgba(15, 10, 30, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.lbshop-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.3);
}

.lbshop-card__image-wrap {
    position: relative;
    height: 160px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.08) 0%, rgba(56, 189, 248, 0.06) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.lbshop-card__image {
    max-height: 120px;
    max-width: 120px;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
    transition: transform 0.3s ease;
}
.lbshop-card:hover .lbshop-card__image {
    transform: scale(1.08) rotate(-2deg);
}

.lbshop-card__body {
    padding: 1rem 1.25rem 1.25rem;
}
.lbshop-card__name {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    color: #f1f5f9;
}
.lbshop-card__desc {
    font-size: 0.82rem;
    color: #94a3b8;
    margin: 0 0 0.75rem;
    line-height: 1.4;
    min-height: 2rem;
}

.lbshop-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
}
.lbshop-card__price {
    color: #fbbf24;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.lbshop-card__items {
    color: #94a3b8;
}
.lbshop-card__limit {
    color: #fb923c;
}
.lbshop-card__pity {
    color: #c084fc;
}

.lbshop-currency-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    border-radius: 3px;
}

/* ── Buy row: quantity + total ─────────────────────────────────────── */
.lbshop-card__buy-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
}

.lbshop-qty-selector {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #334155;
    border-radius: 6px;
    overflow: hidden;
}

.lbshop-qty-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e293b;
    color: #e2e8f0;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background 0.15s;
}
.lbshop-qty-btn:hover {
    background: #334155;
}

.lbshop-qty-input {
    width: 40px;
    height: 30px;
    text-align: center;
    border: none;
    border-left: 1px solid #334155;
    border-right: 1px solid #334155;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 600;
    -moz-appearance: textfield;
}
.lbshop-qty-input::-webkit-outer-spin-button,
.lbshop-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.lbshop-card__total {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fbbf24;
}

.lbshop-card__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.lbshop-card__actions .sfb-btn--primary {
    flex: 1;
}

/* ── Inventory quantity badge ──────────────────────────────────────── */
.lbshop-card__qty-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(168, 85, 247, 0.9);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 2px 8px;
    border-radius: 12px;
    z-index: 2;
}

.lbshop-card__owned {
    color: #a855f7;
    font-weight: 600;
}

/* ── History ───────────────────────────────────────────────────────── */
.lootbox-shop__history {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.lbshop-history__item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border-left: 3px solid transparent;
    transition: background 0.2s;
}
.lbshop-history__item:hover {
    background: rgba(255, 255, 255, 0.06);
}
.lbshop-history__item.rarity-border-common    { border-left-color: #94a3b8; }
.lbshop-history__item.rarity-border-rare      { border-left-color: #38bdf8; }
.lbshop-history__item.rarity-border-epic      { border-left-color: #a855f7; }
.lbshop-history__item.rarity-border-legendary { border-left-color: #fbbf24; }

.lbshop-history__thumb {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}
.lbshop-history__thumb-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    flex-shrink: 0;
}

.lbshop-history__info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}
.lbshop-history__label {
    font-weight: 600;
    font-size: 0.88rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rarity-badge-common    { color: #94a3b8; font-size: 0.75rem; font-weight: 600; }
.rarity-badge-rare      { color: #38bdf8; font-size: 0.75rem; font-weight: 600; }
.rarity-badge-epic      { color: #a855f7; font-size: 0.75rem; font-weight: 600; }
.rarity-badge-legendary { color: #fbbf24; font-size: 0.75rem; font-weight: 600; }

.lbshop-history__pity {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.lbshop-history__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    font-size: 0.75rem;
    color: #64748b;
    flex-shrink: 0;
    text-align: right;
}
.lbshop-history__box {
    color: #94a3b8;
    font-weight: 500;
}
.lbshop-history__cost {
    color: #fbbf24;
}

/* ═══════════════════════════════════════════════════════════════════════
   Opening Animation — Full-screen overlay
   ═══════════════════════════════════════════════════════════════════════ */
.lootbox-open-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 2, 15, 0.92);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlayFadeIn 0.3s ease;
}
@keyframes overlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.lootbox-open-modal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    max-width: 420px;
    width: 100%;
}

.lootbox-open-stage {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Box phase ─────────────────────────────────────────────────────── */
.lootbox-open-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lootbox-open-box img {
    width: 140px;
    height: 140px;
    object-fit: contain;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
    transition: transform 0.6s ease;
}

.lootbox-open-glow {
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.3), transparent 70%);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}
.lootbox-open-glow.active {
    opacity: 1;
    animation: glowPulse 0.8s ease infinite alternate;
}

/* Shake animation */
.lootbox-open-box.shaking {
    animation: boxShake 0.12s ease-in-out infinite;
}
.lootbox-open-box.shaking img {
    animation: boxPulse 0.4s ease infinite alternate;
}

@keyframes boxShake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-5px) rotate(-2deg); }
    75%      { transform: translateX(5px) rotate(2deg); }
}
@keyframes boxPulse {
    from { filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5)) brightness(1); }
    to   { filter: drop-shadow(0 8px 32px rgba(168, 85, 247, 0.5)) brightness(1.15); }
}
@keyframes glowPulse {
    from { transform: scale(1); opacity: 0.6; }
    to   { transform: scale(1.2); opacity: 1; }
}

/* Opening flash */
.lootbox-open-box.opening img {
    animation: boxOpen 0.7s ease forwards;
}
@keyframes boxOpen {
    0%   { transform: scale(1); opacity: 1; }
    50%  { transform: scale(1.3); opacity: 1; filter: brightness(2); }
    100% { transform: scale(0); opacity: 0; }
}

/* ── Result phase ──────────────────────────────────────────────────── */
.lootbox-open-result {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.lootbox-result-burst {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
}
.lootbox-result-burst.active {
    animation: burstIn 0.8s ease forwards;
}
.lootbox-result-burst.common    { background: radial-gradient(circle, rgba(148, 163, 184, 0.2), transparent 65%); }
.lootbox-result-burst.rare      { background: radial-gradient(circle, rgba(56, 189, 248, 0.25), transparent 65%); }
.lootbox-result-burst.epic      { background: radial-gradient(circle, rgba(168, 85, 247, 0.3), transparent 65%); }
.lootbox-result-burst.legendary { background: radial-gradient(circle, rgba(251, 191, 36, 0.35), transparent 65%); }

@keyframes burstIn {
    0%   { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    60%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
}

.lootbox-result-image {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border-radius: 12px;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.5));
}

.lootbox-open-result.reveal .lootbox-result-image {
    animation: itemReveal 0.6s ease;
}
@keyframes itemReveal {
    0%   { transform: scale(0) rotate(15deg); opacity: 0; }
    60%  { transform: scale(1.15) rotate(-3deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.lootbox-result-rarity {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    position: relative;
    z-index: 2;
}
.lootbox-result-rarity.rarity-common    { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.lootbox-result-rarity.rarity-rare      { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.lootbox-result-rarity.rarity-epic      { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.lootbox-result-rarity.rarity-legendary { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }

.lootbox-result-label {
    font-size: 1.25rem;
    font-weight: 700;
    color: #f1f5f9;
    text-align: center;
    position: relative;
    z-index: 2;
}
.lootbox-result-qty {
    font-size: 1rem;
    color: #94a3b8;
    position: relative;
    z-index: 2;
}
.lootbox-result-pity {
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.25);
    color: #c084fc;
    padding: 0.3rem 0.75rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    position: relative;
    z-index: 2;
    animation: pityPulse 1s ease infinite alternate;
}
@keyframes pityPulse {
    from { box-shadow: 0 0 10px rgba(168, 85, 247, 0.2); }
    to   { box-shadow: 0 0 20px rgba(168, 85, 247, 0.5); }
}

/* ── Action buttons ────────────────────────────────────────────────── */
.lootbox-open-actions {
    display: flex;
    gap: 0.75rem;
    animation: actionsSlideUp 0.4s ease;
}
@keyframes actionsSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .lootbox-shop__grid {
        grid-template-columns: 1fr;
    }
    .lbshop-card__image-wrap {
        height: 120px;
    }
    .lootbox-open-stage {
        width: 160px;
        height: 160px;
    }
    .lootbox-open-box img {
        width: 100px;
        height: 100px;
    }
    .lbshop-history__meta {
        display: none;
    }
}
