/* ===================================
   STORE UI
   =================================== */
.store-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: 1400px;
    margin: auto;
    padding: 1rem;
    overflow-x: hidden;
    gap: 1.5rem;
    overflow-y: auto;
}

.store-header {
    position: sticky;
    top: 0;
    background: rgba(1, 4, 9, 0.8);
    backdrop-filter: blur(8px);
    z-index: 20;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid var(--panel-border);
}
.store-header > div { display: flex; align-items: center; }
.store-header > div:last-child { margin-left: auto; transform: translateY(1px); }
.store-header .menu-btn { padding: 0.25rem 0.75rem; line-height: 1; }
.store-header .title { margin: 0; line-height: 1; display: inline-flex; align-items: center; }
.store-header .title { text-shadow: 0 0 15px var(--accent-glow); }

/* This is the container for the hero items (bundles) */
#store-hero-item {
    display: flex;
    flex-direction: column;
    gap: 1rem; /* Adds space between multiple bundle cards */
}

.store-hero-item-card {
    position: relative;
    border-radius: 1rem;
    overflow: hidden;
    min-height: 220px;
    display: flex;
    border: 1px solid var(--panel-border);
    transition: all 0.3s ease;
}
.store-hero-item-card:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px var(--accent-glow);
}
.hero-gradient-overlay {
    position: absolute;
    inset: 0;
}
.hero-content {
    position: relative;
    z-index: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
    color: white;
}
.store-hero-item-card .name { 
    font-size: 1.75rem;
    font-weight: 900; 
    text-shadow: 0 0 10px var(--accent-glow);
    color: var(--accent-cyan);
    line-height: 1.2;
} 
.store-hero-item-card .description { 
    font-size: 0.875rem; 
    color: var(--text-dark); 
    margin-top: 0.5rem;
    line-height: 1.5;
    max-width: 60ch;
}
.rarity-tag-hero {
    display: inline-block;
    margin-top: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    color: #fff;
}
.rarity-tag-hero.rarity-legendary { background-color: #ff8000; }
.rarity-tag-hero.rarity-epic { background-color: #a335ee; }
.rarity-tag-hero.rarity-rare { background-color: #0070dd; }
.hero-footer { 
    margin-top: 1rem;
    display: flex;
    align-items: flex-end; /* Align items and price along the bottom */
    justify-content: space-between;
    gap: 1rem;
}
.store-hero-item-card .bundle-contents { 
    display: flex; 
    gap: 0.5rem; 
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping if needed, though we limit items */
}
.store-hero-item-card .bundle-contents-title { 
    font-size: 0.75rem; 
    font-weight: 700; 
    color: var(--text-dark); 
    text-transform: uppercase; 
    flex-shrink: 0; /* Prevent title from shrinking */
    margin-right: 0.25rem;
}
.store-hero-item-card .bundle-item { 
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(0,0,0,0.4);
    border-radius: 0.375rem;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}
.bundle-item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.bundle-item-icon {
    font-size: 1.25rem;
    line-height: 1; /* Improve vertical alignment of emojis */
}
.bundle-item-name {
    display: none; /* Hide names on the hero card for a cleaner look */
}
.bundle-item-more {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(0,0,0,0.4);
    border-radius: 0.375rem;
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dark);
}
.hero-content .store-item-price {
    font-size: 1.75rem;
    text-align: right;
}

.store-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--panel-border);
  margin-bottom: 1rem;
}
.store-tab {
    padding: 0.75rem 1rem;
    color: var(--text-dark);
    font-weight: 700;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease-out;
}
.store-tab.active {
    color: var(--accent-cyan);
    border-bottom-color: var(--accent-cyan);
}

.store-tab-content {
    display: none;
}
.store-tab-content.active {
    display: block;
    animation: store-content-fade-in 0.4s ease-out;
}

.store-section-title {
    font-size: 1.25rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
  color: var(--text-light);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--panel-border);
}

.store-item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.store-item-card {
    background: rgba(1, 4, 9, 0.7);
    border: 1px solid var(--panel-border);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    position: relative; /* For positioning child elements like the music button */
    transition: all 0.3s ease;
    cursor: pointer;
}
.store-item-card.rarity-legendary { border-color: #ff8000; background: radial-gradient(ellipse at center, rgba(255,128,0,0.1), transparent 70%), rgba(1, 4, 9, 0.7); }
.store-item-card.rarity-epic { border-color: #a335ee; background: radial-gradient(ellipse at center, rgba(163,53,238,0.1), transparent 70%), rgba(1, 4, 9, 0.7); }
.store-item-card.rarity-rare { border-color: #0070dd; background: radial-gradient(ellipse at center, rgba(0,112,221,0.1), transparent 70%), rgba(1, 4, 9, 0.7); }
.store-item-card.rarity-uncommon { border-color: #1AF7AF; background: radial-gradient(ellipse at center, rgba(26,247,175,0.1), transparent 70%), rgba(1, 4, 9, 0.7); }

.store-item-card.rarity-legendary:hover { box-shadow: 0 0 20px #ff800080; }
.store-item-card.rarity-epic:hover { box-shadow: 0 0 20px #a335ee80; }
.store-item-card.rarity-rare:hover { box-shadow: 0 0 20px #0070dd80; }
.store-item-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px var(--accent-glow);
}

.store-item-preview {
    position: relative;
    width: 100%;
    height: 120px;
    background: rgba(0,0,0,0.3);
    border-radius: 0.5rem;
    font-size: 3rem; /* text-5xl. A bit smaller to better fit compound emojis. */
    margin-bottom: 1rem;
    /* Add flex properties to center the icon/emoji */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Clip any part of an emoji that is too large */
}

.store-item-name {
    font-weight: 800;
    font-size: 1.05rem; /* Slightly larger */
    color: var(--text-light);
    text-align: center;
    margin: 0.25rem 0;
}

.store-item-rarity {
    margin-bottom: 0.25rem; /* Added margin to push price/owned down */
    text-align: center;
    font-weight: 700;
    text-transform: uppercase;
}

.store-item-card .store-item-desc {
    font-size: 0.75rem;
    color: var(--text-dark);
    padding: 0 0.5rem;
    margin: 0.5rem 0;
    flex-grow: 1; /* This will push the price down */
    min-height: 4rem; /* Give it some space */
}

.store-item-price {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
}
.store-item-price .icon { font-size: 1.25rem; }
.price-creds { color: var(--accent-cyan); }
.price-cores { color: var(--accent-gold); }

/* Rarity text colors for quick visual identification */
.store-item-rarity.common { color: #9CA3AF; } /* gray */
.store-item-rarity.uncommon { color: #34D399; } /* teal/green */
.store-item-rarity.rare { color: #60A5FA; } /* blue */
.store-item-rarity.epic { color: #A78BFA; } /* purple */
.store-item-rarity.legendary { color: #F59E0B; } /* orange/gold */

/* Center-align price and make it pop */
.store-item-price { justify-content: center; font-size: 1.05rem; }
.store-item-card .store-item-info { display: flex; flex-direction: column; align-items: center; }
.store-item-card.owned {
    cursor: default;
    filter: grayscale(50%) brightness(0.7);
    pointer-events: none;
}
.store-item-card.owned:hover {
    transform: none;
    box-shadow: none;
}
.store-item-card.not-available {
    filter: grayscale(100%) brightness(0.5);
    cursor: not-allowed;
    pointer-events: none;
}

.store-item-card.not-available:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--panel-border);
}
.store-item-card.owned.rarity-legendary:hover { border-color: #ff8000; }
.store-item-card.owned.rarity-epic:hover { border-color: #a335ee; }
.store-item-card.owned.rarity-rare:hover { border-color: #0070dd; }
.store-item-card.owned.rarity-uncommon:hover { border-color: #1AF7AF; }
.store-item-price.purchased {
    color: var(--price-green);
    font-weight: 700;
    text-transform: uppercase;
}

.store-item-price.not-for-sale {
    color: var(--text-dark);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.875rem;
}

.currency-pack-card {
    background: rgba(1, 4, 9, 0.7);
    border: 1px solid var(--panel-border);
    border-radius: 0.75rem;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative; /* For positioning child elements like the music button */
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}
.currency-pack-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px var(--accent-glow);
}
.pack-icon {
    font-size: 3rem;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}
.pack-icon.cores { background: rgba(255, 215, 0, 0.1); border: 2px solid var(--accent-gold); }
.pack-icon.creds { background: rgba(0, 229, 255, 0.1); border: 2px solid var(--accent-cyan); }

.pack-name { font-weight: 700; font-size: 1.125rem; color: var(--text-light); }
.pack-amount {
    font-family: 'Roboto Mono', monospace;
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 1.5rem;
}
.pack-buy-button {
    background: var(--price-green);
    color: var(--bg-color);
    font-weight: 900;
    padding: 0.5rem 2rem;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.currency-pack-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(60%);
}
.currency-pack-card.disabled:hover {
    transform: none;
    border-color: var(--panel-border);
    box-shadow: none;
}
.pack-buy-button.disabled,
.currency-pack-card.disabled .pack-buy-button {
    background: #4b5563; /* gray-600 */
}

/* --- Payment Modal --- */
.payment-modal-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.payment-order-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255,255,255,0.05);
    padding: 1rem;
    border-radius: 0.5rem;
}
.payment-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.payment-input {
    background: rgba(1, 4, 9, 0.7);
    border: 1px solid var(--panel-border);
    color: var(--text-light);
    padding: 0.75rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease-out;
}
.payment-input::placeholder { color: var(--text-dark); }
.payment-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-glow);
    outline: none;
}
.payment-confirm-btn {
    background: var(--price-green);
    color: var(--bg-color);
    font-weight: 900;
    padding: 0.75rem;
    border-radius: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: center;
}


.ability-btn.legendary {
    border-color: #ff8000; background: radial-gradient(ellipse at center, rgba(255,128,0,0.2), transparent 70%), rgba(1, 4, 9, 0.7); color: #ff8000;
}

/* --- Music Preview Buttons --- */

/* For Store Card */
.store-music-preview-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    border-radius: 0.375rem; /* Rounded square */
    background: rgba(1, 4, 9, 0.7);
    border: 1px solid var(--panel-border);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}
.store-item-card:hover .store-music-preview-btn {
    color: var(--text-light);
    background: var(--accent-glow);
    border-color: var(--accent-cyan);
}
.store-music-preview-btn.is-playing {
    color: var(--bg-color);
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}
.store-item-card.owned .store-music-preview-btn {
    /* Re-enable pointer events for the preview button on owned items */
    pointer-events: auto;
}

/* For Purchase Confirmation Screen */
.purchase-music-preview-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem; /* Place near the top-right inside the preview container */
    width: 40px;
    height: 40px;
    border-radius: 0.375rem; /* Rounded square */
    background: rgba(1, 4, 9, 0.7);
    border: 1px solid var(--panel-border);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}
.purchase-music-preview-btn:hover {
    color: var(--text-light);
    background: var(--accent-glow);
    border-color: var(--accent-cyan);
}
.purchase-music-preview-btn.is-playing {
    color: var(--bg-color);
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

@media (max-width: 639px) {
    .store-container {
        padding: 0.5rem;
        gap: 1rem;
    }
    .hero-content {
        padding: 1rem 0.75rem;
    }
    .store-header {
        /* Mobile: keep a single row with left (back+title) and right (balances) */
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0; /* Compact header on mobile */
    }
    .store-header .title {
        font-size: 1.5rem;
        line-height: 1; /* keep row height tight */
        text-align: left !important; /* Ensure title is on the left on mobile */
    }
    .store-header > div { /* Header groups */
        gap: 0.5rem;
    }
    .store-header > div:last-child { /* Right group (balances) pinned to right */
        margin-left: auto;
    }
    .currency-display {
        padding: 0.25rem 0.5rem;
    }
    .currency-display .icon { font-size: 1rem; }
    .currency-display span { font-size: 0.875rem; }
    /* Match currency pill height for back button */
    .store-header .menu-btn { padding: 0.25rem 0.75rem; font-size: 0.875rem; }
    /* Ensure currency pills and button visually align */
    .store-header .currency-display,
    .store-header .menu-btn { align-self: center; }
    .store-item-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.5rem;
    }
    .store-hero-item { min-height: 180px; }
    .store-hero-item .name {
        font-size: 1.125rem; /* text-lg */
        word-break: break-word;
    }
    .hero-content .store-item-price { font-size: 1.25rem; }

    #purchase-preview-container {
        height: 160px; /* Slightly reduce height for mobile */
    }

    .purchase-bundle-item {
        width: 70px; /* Adjust item width for smaller screens */
    }

    .purchase-bundle-item img,
    .purchase-bundle-item div[class*="w-8 h-8"] {
        width: 50px; /* Adjust icon/image size for smaller screens */
        height: 50px;
        font-size: 1.8rem; /* Adjust emoji size */
    }
}

/* Make store tabs scrollable on smaller screens */
@media (max-width: 767px) { /* md breakpoint */
    .store-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* For momentum scrolling on iOS */
        flex-wrap: nowrap; /* Ensure tabs stay in a single line for scrolling */
        scroll-snap-type: x mandatory; /* Improve swipe experience */
        padding-bottom: 0.5rem; /* Add space for the scrollbar if visible */
        -ms-overflow-style: none;  /* IE and Edge */
        scrollbar-width: none;  /* Firefox */
    }
    .store-tabs::-webkit-scrollbar { display: none; } /* Safari and Chrome */
    .store-tab { flex-shrink: 0; scroll-snap-align: start; } /* Prevent tabs from shrinking and align for snap */
}

.owned-overlay {
    /* Removed absolute positioning */
    background: rgba(0, 0, 0, 0.8);
    color: var(--price-green);
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
    margin-top: 0.25rem; /* Add margin to separate from rarity */
}

.bundle-mini-preview {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.bundle-mini-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-dark);
}

.bundle-item-name {
    font-weight: 600;
    color: var(--text-light);
}

/* For the purchase confirmation screen bundle preview */
.purchase-bundle-contents {
    display: flex;
    flex-direction: row; /* Horizontal display */
    gap: 1rem; /* Space between items */
    overflow-x: auto; /* Enable horizontal scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scrollbar-width: none; /* Hide scrollbar for Firefox */
    white-space: nowrap; /* Prevent items from wrapping */
    padding: 0.5rem; /* Padding for scrollbar and visual spacing */
    align-items: center; /* Vertically center items */
    height: 100%; /* Take full height of parent */
}

/* Keep scrollbars visible so they inherit profile screen styling */

.purchase-bundle-item {
    flex-shrink: 0; /* Prevent items from shrinking */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.25rem;
    width: 80px; /* Fixed width for each item, adjust as needed */
}

.purchase-bundle-item .name {
    font-size: 0.75rem;
    color: var(--text-dark);
    white-space: normal; /* Allow name to wrap */
    word-break: break-word;
}

.purchase-bundle-item img,
.purchase-bundle-item div[class*="w-8 h-8"] { /* Target the icon div */
    width: 60px; /* Make icons/images larger in the preview */
    height: 60px;
    object-fit: contain;
    border-radius: 0.5rem;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem; /* For emoji icons */
}

#purchase-preview-container {
    display: flex; /* Add flex display */
    align-items: center; /* Vertically center content */
    justify-content: center; /* Horizontally center content */
    overflow: auto !important; /* Allow scrolling bundle contents inside */
}

/* In the purchase preview, show bundle items in a vertical-scrolling grid */
#purchase-preview-container .purchase-bundle-contents {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
    padding: 0.5rem;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: normal;
    -webkit-overflow-scrolling: touch; /* Momentum scrolling on iOS */
}
/* Let profile.css define the look for scrollbars to match profile screen */
