/* ===== CHARACTER CUSTOMIZATION MODAL ===== */
#character-customization-modal {
    --rarity-common: #9ba1a6;
    --rarity-rare: #29B6F6;
    --rarity-epic: #AA00FF;
    --rarity-legendary: #FFD700;
}

#character-customization-modal .modal.modal-large {
    width: 900px;
    max-width: 95vw;
    padding: 20px;
    position: relative; /* anchor .modal-close */
    zoom: 0.8; /* Scales everything down by 20% */
}

.customization-container {
    display: grid;
    grid-template-columns: 1.3fr minmax(0, 1fr);
    gap: 20px;
    margin: 20px 0;
}

/* Header row (title + currencies) */
#character-customization-modal .cc-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding-right: 52px; /* reserve space for absolute .modal-close (×) + gap */
}

#character-customization-modal .cc-header-row h3 {
    margin: 0;
}

/* Ensure the close (×) has predictable size and doesn't overlap header content */
#character-customization-modal .modal-close {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 2;
}

#character-customization-modal .cc-currency {
    display: flex;
    align-items: center;
    gap: 10px;
}

#character-customization-modal .cc-currency-badge {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 800;
    font-size: 14px;
    user-select: none;
    transition: var(--trans-fast);
}

#character-customization-modal .cc-currency-badge[onclick] {
    cursor: pointer;
}

#character-customization-modal .cc-currency-badge[onclick]:hover {
    border-color: rgba(255, 165, 0, 0.35);
    background: rgba(255, 165, 0, 0.08);
    transform: translateY(-1px);
}

#character-customization-modal .cc-currency-icon {
    font-size: 13px;
}

#character-customization-modal .cc-currency .c-premium { color: var(--accent); }
#character-customization-modal .cc-currency .c-free { color: var(--team-blue); }

.character-viewer {
    background: #000000;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    min-height: 500px;
}

#character-canvas {
    width: 100%;
    height: 500px;
    display: block;
}

.character-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--primary);
    font-family: 'Rajdhani', sans-serif;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 2px;
}

.character-controls {
    max-height: 500px;
    display: flex;
    flex-direction: column;
    padding-right: 4px;
}

/* TABS */
.customization-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--muted-text);
    padding: 8px 16px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--trans-fast);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tab-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--primary);
    background: rgba(255, 165, 0, 0.1);
    border: 1px solid rgba(255, 165, 0, 0.2);
}

/* INVENTORY GRID */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    padding-right: 6px;
    margin-bottom: 15px;
    align-content: start;
    
    /* Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 165, 0, 0.5) rgba(0, 0, 0, 0.2);
}

.inventory-grid::-webkit-scrollbar {
    width: 6px;
}
.inventory-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}
.inventory-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 165, 0, 0.5);
    border-radius: 3px;
}

.inventory-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top-width: 2px; /* Reserve space for rarity border */
    border-radius: 6px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--trans-fast);
}

.inventory-item:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}

.item-preview {
    width: 100%;
    aspect-ratio: 1;
    background: #222;
    border-radius: 4px;
    position: relative; /* Needed for absolutely positioned child icons */
}

.spinner-preview {
    background: radial-gradient(circle, #444 0%, #222 100%);
}

.skin-preview {
    background: #333;
}

/* Spinner picker (inside customization popup) */
#character-customization-modal .spinner-picker-card {
    grid-column: 1 / -1; /* span full inventory grid width */
}

#character-customization-modal .inventory-item.spinner-item.is-equipped {
    border-color: var(--primary);
    background: rgba(255, 165, 0, 0.08);
}

/* Ensure rarity borders aren't overridden by is-equipped border-color on the top edge */
#character-customization-modal .inventory-item.spinner-item.is-equipped.rarity-common { border-top-color: var(--rarity-common) !important; }
#character-customization-modal .inventory-item.spinner-item.is-equipped.rarity-rare { border-top-color: var(--rarity-rare) !important; }
#character-customization-modal .inventory-item.spinner-item.is-equipped.rarity-epic { border-top-color: var(--rarity-epic) !important; }
#character-customization-modal .inventory-item.spinner-item.is-equipped.rarity-legendary { border-top-color: var(--rarity-legendary) !important; }

.item-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: center;
}

.item-name {
    font-size: 10px;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#character-customization-modal .inventory-item.skin-item.is-equipped {
    border-color: var(--primary);
    background: rgba(255, 165, 0, 0.08);
}

.item-btn {
    width: 100%;
    padding: 4px;
    font-size: 10px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
    text-transform: uppercase;
    border: none;
    transition: var(--trans-fast);
}

.item-btn.equipped {
    background: rgba(255, 165, 0, 0.2);
    color: var(--primary);
    border: 1px solid var(--primary);
    cursor: default;
}

.item-btn.purchase {
    background: var(--primary);
    color: #000;
}

.item-btn.purchase:hover {
    background: #ffb31a;
}

.inventory-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted-text);
    gap: 10px;
}

.inventory-empty i {
    font-size: 24px;
    opacity: 0.5;
}

/* COMPACT DEV CONTROLS */
.dev-controls-container {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 10px;
}

.dev-controls-header {
    font-size: 11px;
    color: var(--muted-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    user-select: none;
}

.dev-controls-header:hover {
    color: var(--text);
}

.dev-controls-header i:last-child {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.dev-controls-header.open i:last-child {
    transform: rotate(180deg);
}

.dev-controls-content {
    margin-top: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px;
    border-radius: 4px;
    max-height: clamp(120px, 26vh, 220px);
    overflow-y: auto;
    overflow-x: hidden;
    
    /* Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 165, 0, 0.5) rgba(0, 0, 0, 0.2);
}

.dev-controls-content::-webkit-scrollbar {
    width: 6px;
}
.dev-controls-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}
.dev-controls-content::-webkit-scrollbar-thumb {
    background: rgba(255, 165, 0, 0.5);
    border-radius: 3px;
}

.dev-controls-content.hidden {
    display: none;
}

.compact-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.compact-row:last-child {
    margin-bottom: 0;
}

.compact-row label {
    font-size: 10px;
    color: var(--muted-text);
    width: 25px;
    flex-shrink: 0;
}

.compact-row input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 2px;
    width: 40px;
    text-align: center;
}

.compact-row input[type="color"] {
    width: 20px;
    height: 18px;
    padding: 0;
}

.compact-row input[type="checkbox"] {
    width: auto;
    accent-color: var(--primary);
}

.compact-text {
    font-size: 10px;
    color: var(--muted-text);
    user-select: none;
    white-space: nowrap;
}

.compact-row input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    min-width: 90px;
    flex: 1;
    height: 4px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    accent-color: var(--primary);
    cursor: pointer;
    outline: none;
}

.compact-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.35);
    box-shadow: 0 0 0 3px rgba(255, 165, 0, 0.12);
}

.compact-row input[type="range"]::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.35);
}

.compact-value {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 2px;
    width: 44px;
    text-align: center;
    flex-shrink: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.compact-row input:focus {
    outline: none;
    border-color: var(--primary);
}

.dev-export-png-btn {
    padding: 2px 6px;
    font-size: 10px;
    font-family: inherit;
    color: var(--muted-text);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    min-width: 40px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.dev-export-png-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
    color: var(--text);
}
.dev-export-png-btn:active {
    background: rgba(255, 165, 0, 0.2);
    transform: translateY(1px);
}

.canvas-instructions {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--muted-text);
    font-family: 'Inter', sans-serif;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.canvas-preview-banner {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10;
}

.canvas-preview-banner i {
    font-size: 10px;
    color: var(--primary);
}

.canvas-reset-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text);
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    transition: var(--trans-fast);
    display: flex;
    align-items: center;
    gap: 4px;
}

.canvas-reset-btn:hover {
    background: rgba(255, 165, 0, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

/* Top Up Coins (bottom strip) */
#character-customization-modal .cc-topup-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.10);
}

#character-customization-modal .cc-topup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: nowrap;
}

#character-customization-modal .cc-topup-title {
    margin: 0;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    text-align: left;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 900;
    font-size: 18px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#character-customization-modal .cc-topup-title i {
    color: var(--accent);
    flex-shrink: 0;
}

#character-customization-modal .cc-topup-subtitle {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
    color: var(--muted-text);
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
}

#character-customization-modal .cc-topup-powered-by {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
}

#character-customization-modal .cc-topup-powered-by img {
    height: 24px;
    opacity: 0.9;
    flex-shrink: 0;
    display: block;
}

#character-customization-modal .cc-coin-packages {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

#character-customization-modal .cc-topup-loading {
    color: var(--muted-text);
    font-size: 13px;
    padding: 10px 2px;
}

#character-customization-modal .cc-coin-package-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(0, 0, 0, 0.15) 100%);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    padding: 14px 14px 12px;
    text-align: center;
    position: relative;
    transition: var(--trans-fast);
}

#character-customization-modal .cc-coin-package-card:hover {
    border-color: rgba(255, 165, 0, 0.35);
    transform: translateY(-2px);
}

#character-customization-modal .cc-coin-package-card.is-featured {
    border-color: rgba(255, 215, 0, 0.55);
    box-shadow: 0 0 26px rgba(255, 215, 0, 0.08);
}

#character-customization-modal .cc-coin-package-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 165, 0, 0.95);
    color: #1b1300;
    padding: 3px 10px;
    border-radius: 999px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 900;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

#character-customization-modal .cc-coin-package-icon {
    font-size: 28px;
    color: var(--accent);
    margin: 6px 0 10px;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.25));
}

#character-customization-modal .cc-coin-package-amount {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 900;
    font-size: 22px;
    margin: 0 0 2px 0;
    letter-spacing: 0.5px;
}

#character-customization-modal .cc-coin-package-bonus {
    height: 16px;
    font-size: 11px;
    font-weight: 700;
    color: rgba(76, 175, 80, 0.95);
    margin-bottom: 10px;
}

#character-customization-modal .cc-coin-package-meta {
    color: var(--muted-text);
    font-size: 11px;
    margin-top: 8px;
}

#character-customization-modal .cc-coin-package-btn {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 165, 0, 0.95);
    color: #1b1300;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 900;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--trans-fast);
}

#character-customization-modal .cc-coin-package-btn:hover:not(:disabled) {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

#character-customization-modal .cc-coin-package-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Stripe modal (stacked above customization modal) */
.cc-stripe-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 14000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.cc-stripe-modal {
    width: min(500px, 94vw);
    background: var(--surface-elevated);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    zoom: 0.75; /* Slightly smaller footprint while preserving the branded styling */
}

.cc-stripe-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.cc-stripe-modal-header h3 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 21px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.cc-stripe-desc {
    color: var(--muted-text);
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.4;
}

.cc-stripe-payment-element {
    margin: 10px 0 6px 0;
}

.cc-stripe-error {
    color: var(--danger);
    margin-top: 8px;
    font-size: 12px;
}

.cc-stripe-status {
    color: var(--muted-text);
    margin-top: 8px;
    font-size: 12px;
}

.cc-stripe-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 12px;
}

@media (max-width: 900px) {
    .customization-container {
        grid-template-columns: 1fr;
    }
    
    .character-viewer {
        min-height: 400px;
    }
    
    #character-canvas {
        height: 400px;
    }

    #character-customization-modal .cc-topup-header {
        flex-wrap: wrap;
    }

    #character-customization-modal .cc-topup-title,
    #character-customization-modal .cc-topup-subtitle,
    #character-customization-modal .cc-topup-powered-by {
        flex: 1 1 100%;
    }

    #character-customization-modal .cc-topup-subtitle,
    #character-customization-modal .cc-topup-powered-by {
        text-align: left;
        justify-content: flex-start;
    }

    #character-customization-modal .cc-topup-subtitle {
        white-space: normal;
    }
}

/* ===== COIN TOP-UP FLY ANIMATION (Customization Popup) ===== */

.cc-topup-shockwave {
    position: fixed;
    border-radius: 50%;
    border: 4px solid var(--accent);
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
    pointer-events: none;
    z-index: 15000;
    box-shadow: 0 0 20px var(--accent), inset 0 0 20px var(--accent);
    animation: ccTopupShockwaveExpand 0.6s ease-out forwards;
}

@keyframes ccTopupShockwaveExpand {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; border-width: 10px; }
    100% { transform: translate(-50%, -50%) scale(3); opacity: 0; border-width: 0px; }
}

.cc-topup-sparkle {
    position: fixed;
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
    pointer-events: none;
    z-index: 14999;
    animation: ccTopupSparkleFade 0.5s linear forwards;
}

@keyframes ccTopupSparkleFade {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

.cc-topup-flying-coin {
    position: fixed;
    font-size: 24px;
    color: var(--accent);
    pointer-events: none;
    z-index: 15001;
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.cc-balance-bump {
    display: inline-block;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
    transform: scale(1.1);
    transition: all 0.05s;
}

/* Highlight the wallet badge while coins are being received */
#character-customization-modal .cc-currency-badge.cc-receiving,
.currency-badge.cc-receiving {
    border-color: rgba(255, 215, 0, 0.7);
    box-shadow: 0 0 30px var(--accent-glow);
    background: linear-gradient(to right, rgba(255, 255, 255, 0.03), rgba(255, 215, 0, 0.10));
    transform: scale(1.05);
}

/* ===== SHOP TAB (Embedded in Character Customization) ===== */

#tab-shop {
    position: relative; /* anchor overlay (absolute inset:0) */
    --free-coin: #4FC3F7;
}

/* Shop grid: match POC behavior - natural content sizing with scrolling */
#tab-shop.inventory-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    grid-auto-rows: min-content; /* Ensure rows size tightly to content */
    gap: 8px;
    overflow-y: auto;
    padding-right: 6px;
    margin-bottom: 15px;
    align-content: start;  /* Critical: align grid content to start, not stretch */
    position: relative;    /* Anchor the purchase overlay */
    max-height: 420px;     /* Cap height for scrolling */
}

/* Disable scrolling while overlay is active (keeps overlay in view) */
#tab-shop.shop-overlay-active {
    overflow: hidden;
}

/* Shop items: prevent grid from stretching them to fill row height */
#tab-shop .inventory-item {
    position: relative;
    overflow: hidden;
    align-self: start;  /* Critical fix: don't stretch to fill grid row */
    height: auto !important; /* Force natural height */
    min-height: 0;
}

#tab-shop .inventory-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Rarity borders */
#character-customization-modal #tab-spinners .inventory-item.spinner-item.rarity-common,
#character-customization-modal #tab-shop .inventory-item.rarity-common { border-top-color: var(--rarity-common); }
#character-customization-modal #tab-spinners .inventory-item.spinner-item.rarity-rare,
#character-customization-modal #tab-shop .inventory-item.rarity-rare { border-top-color: var(--rarity-rare); }
#character-customization-modal #tab-spinners .inventory-item.spinner-item.rarity-epic,
#character-customization-modal #tab-shop .inventory-item.rarity-epic { border-top-color: var(--rarity-epic); }
#character-customization-modal #tab-spinners .inventory-item.spinner-item.rarity-legendary,
#character-customization-modal #tab-shop .inventory-item.rarity-legendary {
    border-top-color: var(--rarity-legendary);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.10);
}
#character-customization-modal #tab-spinners .inventory-item.spinner-item.rarity-legendary:hover,
#character-customization-modal #tab-shop .inventory-item.rarity-legendary:hover {
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.25);
}

/* Tiny type icon */
#tab-shop .item-type-icon {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 8px;
    color: var(--text);
    background: rgba(0, 0, 0, 0.6);
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    z-index: 2;
}

/* Shop preview: maintain aspect ratio like POC */
#tab-shop .item-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1 !important; /* Force square aspect ratio */
    height: auto !important;
}

#tab-shop .item-preview.shop-preview {
    background: radial-gradient(circle, #444 0%, #222 100%);
}

#tab-shop .item-preview i.main-icon {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* Actions row (Tags + Coins) */
#tab-shop .shop-actions {
    width: 100%;
}

#tab-shop .shop-actions-row {
    width: 100%;
    display: flex;
    gap: 4px;
}

#tab-shop .shop-actions-row .item-btn {
    flex: 1;
    padding: 4px 0;
}

/* Outlined purchase buttons (POC style) */
#tab-shop .item-btn.purchase {
    background: transparent;
    color: var(--primary);
    border: 1px solid rgba(255, 165, 0, 0.4);
    box-shadow: inset 0 0 0 1px transparent;
}

#tab-shop .item-btn.purchase:hover:not(:disabled) {
    color: #fff;
    border-color: var(--primary);
    background: rgba(255, 165, 0, 0.08);
    box-shadow: 0 0 12px rgba(255, 165, 0, 0.2);
}

/* Button icon coloring */
#tab-shop .btn-price-icon-coins { color: var(--accent); }
#tab-shop .btn-price-icon-tags { color: var(--free-coin); }

/* Shop empty/loading message should span all columns */
#tab-shop .inventory-empty {
    grid-column: 1 / -1;
}

/* ===== PURCHASE OVERLAY (Shop tab only) ===== */

#tab-shop .purchase-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow: hidden;
}

#tab-shop .purchase-overlay.active {
    opacity: 1;
    pointer-events: all;
}

#tab-shop .purchase-reveal-box {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.5) translateY(-50px);
    opacity: 0;
}

/* Tier drop animations (ported from shop-poc) */
#tab-shop .purchase-overlay.tier-common.active .purchase-reveal-box {
    animation: ccDropCommon 0.4s ease-out forwards;
    animation-delay: 0.1s;
}
@keyframes ccDropCommon {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

#tab-shop .purchase-overlay.tier-rare.active .purchase-reveal-box {
    animation: ccDropRare 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 0.1s;
}
@keyframes ccDropRare {
    0% { transform: scale(0.8) translateY(-50px); opacity: 0; }
    60% { transform: scale(1.05) translateY(5px); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

#tab-shop .purchase-overlay.tier-epic.active .purchase-reveal-box {
    animation: ccDropEpic 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 0.1s;
}
@keyframes ccDropEpic {
    0% { transform: scale(0.5) translateY(-100px); opacity: 0; }
    50% { transform: scale(1.1) translateY(10px); opacity: 1; }
    70% { transform: scale(0.95) translateY(-5px); }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

#tab-shop .purchase-overlay.tier-legendary.active .purchase-reveal-box {
    animation: ccDropLegendary 0.9s cubic-bezier(0.5, 0, 0.2, 1) forwards;
    animation-delay: 0.1s;
}
@keyframes ccDropLegendary {
    0% { transform: scale(0.1) translateY(-200px) rotate(-10deg); opacity: 0; }
    40% { transform: scale(1.2) translateY(20px) rotate(5deg); opacity: 1; }
    55% { transform: scale(0.9) translateY(-10px) rotate(-2deg); }
    75% { transform: scale(1.05) translateY(2px) rotate(1deg); }
    100% { transform: scale(1) translateY(0) rotate(0deg); opacity: 1; }
}

#tab-shop .reveal-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--reward-color, #fff) 0%, transparent 70%);
    opacity: 0.3;
    filter: blur(15px);
    z-index: 0;
    animation: ccPulseGlow 4s infinite alternate;
}

#tab-shop .purchase-overlay.tier-epic .reveal-glow {
    width: 250px;
    height: 250px;
    opacity: 0.5;
    animation: ccPulseGlowEpic 3s infinite alternate;
}

#tab-shop .purchase-overlay.tier-legendary .reveal-glow {
    width: 400px;
    height: 400px;
    opacity: 0.7;
    background: radial-gradient(circle, #FFD700 0%, #FF4500 40%, transparent 70%);
    animation: ccPulseGlowLegendary 2.5s infinite alternate;
}

@keyframes ccPulseGlow {
    from { opacity: 0.2; transform: translate(-50%, -50%) scale(0.9); }
    to { opacity: 0.4; transform: translate(-50%, -50%) scale(1.1); }
}
@keyframes ccPulseGlowEpic {
    from { opacity: 0.3; transform: translate(-50%, -50%) scale(0.95); }
    to { opacity: 0.5; transform: translate(-50%, -50%) scale(1.15); }
}
@keyframes ccPulseGlowLegendary {
    from { opacity: 0.4; transform: translate(-50%, -50%) scale(0.95) rotate(0deg); }
    to { opacity: 0.7; transform: translate(-50%, -50%) scale(1.15) rotate(5deg); }
}

#tab-shop .reveal-icon-wrapper {
    width: 80px;
    height: 80px;
    background: var(--surface-elevated);
    border: 2px solid var(--reward-color, #fff);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

#tab-shop .reveal-icon-wrapper i {
    font-size: 42px;
    color: var(--reward-color, #fff);
    filter: drop-shadow(0 0 8px var(--reward-color, #fff));
}

#tab-shop .flash-overlay {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

#tab-shop .purchase-overlay.tier-epic.active .flash-overlay {
    animation: ccFlashEpic 0.8s ease-out forwards;
    animation-delay: 0.4s;
}

#tab-shop .purchase-overlay.tier-legendary.active .flash-overlay {
    animation: ccFlashLegendary 1.2s ease-out forwards;
    animation-delay: 0.45s;
}

@keyframes ccFlashEpic {
    0% { opacity: 0; background: #fff; }
    10% { opacity: 0.8; background: #AA00FF; }
    100% { opacity: 0; }
}
@keyframes ccFlashLegendary {
    0% { opacity: 0; background: #fff; }
    15% { opacity: 1; background: #FFD700; }
    100% { opacity: 0; }
}

#tab-shop .legendary-rays {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200vmax;
    height: 200vmax;
    background: repeating-conic-gradient(
        from 0deg,
        rgba(255, 215, 0, 0.08) 0deg 5deg,
        transparent 5deg 15deg
    );
    animation: ccSpinRays 60s linear infinite;
    z-index: 0;
    display: none;
    pointer-events: none;
}

#tab-shop .purchase-overlay.tier-legendary .legendary-rays { display: block; }

@keyframes ccSpinRays {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

#tab-shop .reveal-info {
    margin-top: 16px;
    text-align: center;
    z-index: 1;
}

#tab-shop .reveal-rarity {
    font-size: 14px;
    font-weight: 800;
    font-family: 'Rajdhani', sans-serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--reward-color, #fff);
    margin-bottom: 4px;
    opacity: 0;
}

#tab-shop .reveal-name {
    font-size: 24px;
    font-weight: 800;
    font-family: 'Rajdhani', sans-serif;
    text-transform: uppercase;
    color: #fff;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    opacity: 0;
}

#tab-shop .purchase-overlay.active .reveal-rarity {
    animation: ccSlideUpFade 0.4s forwards 0.4s;
}
#tab-shop .purchase-overlay.active .reveal-name {
    animation: ccSlideUpFade 0.4s forwards 0.5s;
}

@keyframes ccSlideUpFade {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#tab-shop .reveal-actions {
    margin-top: 24px;
    display: flex;
    gap: 10px;
    opacity: 0;
    z-index: 1;
}

#tab-shop .purchase-overlay.active .reveal-actions {
    animation: ccSlideUpFade 0.4s forwards 0.6s;
}

#tab-shop .btn-equip-reveal {
    background: #fff;
    color: #000;
    border: none;
    padding: 8px 22px;
    font-weight: 900;
    font-family: 'Rajdhani', sans-serif;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--trans-fast);
    font-size: 14px;
    text-transform: uppercase;
}

#tab-shop .btn-equip-reveal:hover {
    background: #e0e0e0;
    transform: scale(1.04);
}

#tab-shop .btn-continue-reveal {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.75);
    padding: 8px 16px;
    font-weight: 800;
    font-family: 'Rajdhani', sans-serif;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--trans-fast);
    font-size: 13px;
    text-transform: uppercase;
}

#tab-shop .btn-continue-reveal:hover {
    border-color: #fff;
    color: #fff;
}

/* Confetti */
#tab-shop .confetti-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 50;
}

#tab-shop .confetti {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--reward-color, #fff);
    top: 50%;
    left: 50%;
    opacity: 0;
}

#tab-shop .purchase-overlay.active .confetti {
    animation: ccPopConfetti 1s ease-out forwards;
}

@keyframes ccPopConfetti {
    0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0) rotate(var(--rot));
    }
}
