/* === ORIGINAL WORKING CSS STRUCTURE - RESTORED === */

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    overflow-y: auto; /* Allow vertical scroll only when needed */
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    color: #f1f5f9;
}

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#mainContent {
    flex: 1;
    padding: 2rem;
    padding-top: 110px; /* Account for shorter header height (70px + margin) */
    padding-bottom: 120px; /* Space for footer */
    min-height: calc(100vh - 200px);
    position: relative;
    transition: opacity 0.8s ease-out;
    overflow: visible; /* Prevent clipping of elements */
}

/* === PACK SELECTION PAGE === */
.pack-selection-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem; /* Reduced top padding */
    animation: fadeIn 0.6s ease-out forwards;
}

/* === COMBINED HEADER AND TABS LAYOUT === */
.pack-selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem; /* Reduced margin */
    padding-bottom: 1rem; /* Reduced padding */
    border-bottom: 1px solid rgba(75, 85, 99, 0.3);
    flex-wrap: wrap;
    gap: 1rem;
}

.header-content {
    flex: 1;
    text-align: left; /* Changed from center to left */
}

.main-title {
    font-size: clamp(1.8rem, 4vw, 2.5rem); /* Reduced size */
    font-weight: bold;
    margin-bottom: 0.5rem; /* Reduced margin */
    background: linear-gradient(135deg, #fbbf24, #f59e0b, #d97706);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: 'Pirata One', cursive;
    text-shadow: 0 0 30px rgba(251, 191, 36, 0.3);
}

.main-subtitle {
    font-size: clamp(.75rem, 1.5vw, 1rem);
    color: #9ca3af;
    font-weight: 500;
    line-height: 1.2;
    text-align: right;
    flex-shrink: 0;
    margin: 0;
    font-style: italic;
}

/* === TAB NAVIGATION IN HEADER === */
.pack-tabs-container {
    flex-shrink: 0; /* Prevent shrinking */
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.pack-tabs {
    display: flex;
    background: rgba(31, 41, 55, 0.8);
    border-radius: 12px; /* Slightly smaller */
    border: 1px solid rgba(75, 85, 99, 0.4);
    padding: 0.4rem; /* Reduced padding */
    gap: 0.4rem; /* Reduced gap */
    backdrop-filter: blur(15px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); /* Smaller shadow */
    flex-shrink: 0;
}

.pack-tab {
    display: flex;
    align-items: center;
    gap: 0.6rem; /* Reduced gap */
    padding: 0.8rem 1.5rem; /* Reduced padding */
    border: none;
    border-radius: 10px; /* Slightly smaller */
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-weight: 600;
    font-size: 0.9rem; /* Slightly smaller */
    position: relative;
    overflow: hidden;
    min-width: 140px; /* Reduced width */
    justify-content: center;
}

.pack-tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 12px;
}

.pack-tab:hover::before {
    opacity: 1;
}

.pack-tab.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.pack-tab.active::before {
    opacity: 0;
}

.pack-tab i {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.pack-tab:hover i {
    transform: scale(1.1);
}

.tab-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    min-width: 24px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.pack-tab.active .tab-count {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* === TAB CONTENT === */
.pack-tab-content {
    position: relative;
    min-height: 600px;
}

.pack-tab-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
}

.pack-tab-panel.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    position: relative;
}

.pack-category-header {
    text-align: center;
    margin-bottom: 1.5rem; /* Reduced margin */
    padding: 1rem; /* Significantly reduced padding */
    background: rgba(31, 41, 55, 0.4); /* More transparent */
    border-radius: 12px; /* Smaller radius */
    border: 1px solid rgba(75, 85, 99, 0.2); /* More subtle border */
    backdrop-filter: blur(5px);
}

.pack-category-header h2 {
    font-size: clamp(1.2rem, 3vw, 1.6rem); /* Significantly smaller */
    color: #f87171;
    margin-bottom: 0.5rem; /* Reduced margin */
    font-weight: bold;
    text-shadow: 0 0 15px rgba(248, 113, 113, 0.4);
}

.pack-category-header p {
    font-size: clamp(0.8rem, 1.8vw, 0.95rem); /* Smaller text */
    color: #d1d5db;
    line-height: 1.4; /* Tighter line height */
    max-width: 400px; /* Reduced width */
    margin: 0 auto;
}

/* === PACK GRID === */
.pack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    width: 100%;
}

/* === ENHANCED PACK OPTION CARDS === */
.pack-option {
    background: rgba(31, 41, 55, 0.9);
    border: 2px solid rgba(75, 85, 99, 0.5);
    border-radius: 20px;
    padding: 0;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backdrop-filter: blur(15px);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.pack-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.pack-option:hover {
    border-color: var(--pack-primary, rgba(168, 85, 247, 0.8));
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 40px var(--pack-glow, rgba(168, 85, 247, 0.3));
}

.pack-option:hover::before {
    opacity: 1;
}

.pack-image-container {
    position: relative;
    padding: 1.5rem 1.5rem 1rem; /* Reduced padding */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 280px; /* Increased height for rectangular format */
    overflow: hidden;
}

.pack-image {
    /* Fixed dimensions for 610x406 aspect ratio */
    width: 100%;
    max-width: 280px; /* Scaled down from 610px */
    height: auto;
    aspect-ratio: 610/406; /* Maintain exact aspect ratio */
    object-fit: cover; /* Cover to fill the container properly */
    border-radius: 12px;
    transition: transform 0.4s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(75, 85, 99, 0.3);
}

.pack-option:hover .pack-image {
    transform: scale(1.05) rotateY(5deg);
}

.pack-theme-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.pack-info {
    padding: 1.5rem 2rem 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pack-name {
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
    text-shadow: 0 0 10px currentColor;
    text-align: center;
}

.pack-description {
    color: #d1d5db;
    font-size: 0.95rem;
    line-height: 1.5;
    text-align: center;
    flex: 1;
}

.pack-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: auto;
    flex-wrap: wrap;
}

.pack-category-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 2px solid;
}

.pack-category-badge.official {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(16, 185, 129, 0.2));
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.5);
}

.pack-category-badge.meta {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(124, 58, 237, 0.2));
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, 0.5);
}

.pack-card-count {
    color: #9ca3af;
    font-size: 0.85rem;
    font-weight: 500;
}

.pack-creator {
    color: #a855f7;
    font-size: 0.85rem;
    font-weight: 500;
    font-style: italic;
}

/* === META PACKS EMPTY STATE === */
.meta-packs-empty {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    padding: 3rem;
}

.empty-state {
    text-align: center;
    max-width: 500px;
    padding: 3rem;
    background: rgba(31, 41, 55, 0.8);
    border-radius: 20px;
    border: 2px dashed rgba(139, 92, 246, 0.3);
    backdrop-filter: blur(10px);
}

.empty-state i {
    font-size: 4rem;
    color: #8b5cf6;
    margin-bottom: 1.5rem;
    opacity: 0.7;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: #e5e7eb;
    margin-bottom: 1rem;
    font-weight: 600;
}

.empty-state p {
    color: #9ca3af;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.coming-soon-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.2));
    color: #f59e0b;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    border: 2px solid rgba(245, 158, 11, 0.3);
    font-weight: 600;
    font-size: 0.9rem;
}

.coming-soon-badge i {
    font-size: 1rem;
    color: #f59e0b;
    margin: 0;
}

/* === DYNAMIC THEMING SUPPORT === */
:root {
    --pack-primary: #8b5cf6;
    --pack-secondary: #a78bfa;
    --pack-accent: #7c3aed;
    --pack-background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --pack-glow: rgba(139, 92, 246, 0.6);
    --pack-text-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

/* Pack-specific theme overrides will be injected dynamically */

/* === RESPONSIVE DESIGN === */
@media (max-width: 1024px) {
    .pack-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
    }
    
    .pack-option {
        min-height: auto;
    }
    
    .pack-image-container {
        height: 280px;
        padding: 1.5rem;
    }
    
    .pack-image {
        min-height: 180px;
        min-width: 120px;
    }
}

@media (max-width: 768px) {
    .pack-selection-container {
        padding: 1.5rem;
    }

    .pack-tabs-container {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .pack-tabs {
        flex-direction: column;
        gap: 0.25rem;
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }
    
    .pack-tab {
        padding: 0.8rem 1.5rem;
        min-width: auto;
        width: 100%;
    }

    .main-subtitle {
        text-align: center;
        font-size: 0.85rem;
    }

    .pack-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        max-width: 400px;
        margin: 0 auto;
    }
    
    .pack-category-header {
        padding: 1.5rem;
    }
    
    .pack-image-container {
        height: 250px;
        padding: 1rem;
    }
    
    .pack-image {
        min-height: 160px;
        min-width: 110px;
    }
    
    .pack-info {
        padding: 1.2rem 1.5rem 1.5rem;
    }
    
    .pack-meta {
        gap: 0.8rem;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .main-title {
        font-size: 2rem;
    }
    
    .main-subtitle {
        font-size: 0.95rem;
    }
    
    .pack-tab {
        padding: 0.7rem 1rem;
        font-size: 0.9rem;
    }
    
    .pack-tab i {
        font-size: 1rem;
    }
    
    .tab-count {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
    
    .pack-image {
        width: 110px;
        height: 154px;
    }
    
    .pack-name {
        font-size: 1.2rem;
    }
    
    .pack-description {
        font-size: 0.85rem;
    }
}

/* === HEADER SECTION === */
.header-section {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
    border-bottom: 1px solid rgba(75, 85, 99, 0.3);
}

.header-title {
    font-size: clamp(1.8rem, 5vw, 2.5rem); /* Responsive title */
    font-weight: bold;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #fbbf24, #f59e0b, #d97706);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: 'Pirata One', cursive;
}

.header-controls {
    display: flex;
    gap: clamp(0.5rem, 2vw, 1rem); /* Responsive gap */
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    align-items: center;
    max-width: 100%;
    padding: 0 1rem; /* Prevent edge overflow */
}

/* === PACK OPENING PAGE === */
.pack-opening-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 300px);
    padding: 2rem;
}

.pack-opening-header {
    text-align: center;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 600px;
    padding: 0 1rem; /* Prevent edge overflow */
}

.pack-opening-header h2 {
    font-size: clamp(1.5rem, 4vw, 2rem); /* Responsive */
    color: #fbbf24;
    margin-bottom: 1rem;
    font-weight: bold;
}

.pack-instruction {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem); /* Responsive */
    color: #9ca3af;
    margin-bottom: 1rem;
    font-style: italic;
}

.pack-controls {
    display: flex;
    justify-content: center;
    gap: clamp(0.5rem, 2vw, 1rem); /* Responsive gap */
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    max-width: 500px; /* Prevent over-stretching */
    margin: 0 auto; /* Center the container */
    padding: 0 1rem; /* Prevent edge overflow */
}

/* === PACK CONTAINERS - UNIFIED RESPONSIVE SCALING === */
.pack-container {
    position: relative;
    width: calc(min(350px, 90vw) * 0.85);
    height: calc(min(350px, 90vw) * 0.85 * 1.4);
    margin: 2rem auto;
    cursor: pointer;
    border-radius: 15px;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pack-container:hover {
    transform: translateY(-8px) scale(1.05);
    filter: brightness(1.1);
}

.pack-main, .pack-bottom, .pack-top {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 12px;
    object-fit: cover;
}

.pack-main {
    z-index: 3;
}

.pack-bottom {
    z-index: 2;
    display: none;
}

.pack-top {
    z-index: 4;
    display: none;
}

.pack-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* === CARD BACKS - EXACT WORKING VERSION FROM MAIN BRANCH === */
.card-backs {
    position: absolute;
    top: min(60px, 12vh); /* Responsive positioning */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1; /* Behind everything */
    opacity: 0;
    transition: opacity 1.2s ease-out;
    pointer-events: none;
    width: min(220px, 50vw); /* Responsive width */
    height: min(180px, 20vh); /* Responsive height */
    overflow: visible;
}

.card-backs.visible {
    opacity: 1;
}

.card-back-img {
    position: absolute;
    /* Cards should be about 75% of pack width for better proportions */
    width: calc(min(350px, 90vw) * 0.85 * 0.75); /* 75% of pack width */
    height: calc((min(350px, 90vw) * 0.85 * 0.75) * 1.4); /* Maintain proper aspect ratio */
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    object-fit: cover;
    top: 10px; /* Fixed: added missing px units */
    left: 50%;
    margin-left: calc((min(350px, 90vw) * 0.85 * 0.75) / -2); /* Dynamic centering based on actual width */
    opacity: 0;
    transform: rotate(0deg) translateX(0px) translateY(60px); /* Move cards further out */
    transition: all 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* === PACK OPENING CONTROLS === */
.pack-opening-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    width: 100%;
}

.control-button {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    border-radius: 8px;
    padding: clamp(0.4rem, 1.5vw, 0.75rem) clamp(0.8rem, 3vw, 1.5rem); /* Responsive padding */
    font-size: clamp(0.75rem, 2vw, 0.9rem); /* Responsive font size */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: clamp(100px, 25vw, 150px); /* Responsive minimum width */
    justify-content: center;
    white-space: nowrap; /* Prevent text wrapping */
    flex-shrink: 0; /* Prevent shrinking below min-width */
}

.control-button:hover {
    background: linear-gradient(135deg, #5b52f0, #4338ca);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.control-button:disabled {
    background: #6b7280;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* === BOARD HEADER CONTROLS - UNIFIED RESPONSIVE LAYOUT === */
.board-header {
    text-align: center;
    margin-bottom: 1.5rem;
    width: 100%;
    padding: 0 0.5rem; /* Prevent edge overflow */
}

.board-header h3 {
    color: #f87171;
    font-size: clamp(1rem, 3vw, 1.3rem); /* Responsive */
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap; /* Allow wrapping on very small screens */
}

/* UNIFIED BOARD CONTROLS CONTAINER */
.board-controls, .combined-controls {
    display: flex;
    gap: clamp(0.4rem, 1.5vw, 0.75rem); /* Responsive gap */
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    max-width: 400px; /* Prevent over-stretching */
    margin: 0 auto; /* Center the container */
    padding: 0 0.5rem; /* Prevent edge overflow */
}

/* FLIP BUTTONS - SAME STYLING AS CONTROL BUTTONS */
.flip-button {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    border-radius: 8px;
    padding: clamp(0.4rem, 1.5vw, 0.75rem) clamp(0.8rem, 3vw, 1.5rem); /* Responsive padding */
    font-size: clamp(0.75rem, 2vw, 0.9rem); /* Responsive font size */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: clamp(100px, 25vw, 150px); /* Responsive minimum width */
    justify-content: center;
    white-space: nowrap; /* Prevent text wrapping */
    flex-shrink: 0; /* Prevent shrinking below min-width */
}

.flip-button:hover {
    background: linear-gradient(135deg, #5b52f0, #4338ca);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.flip-button:disabled {
    background: #6b7280;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* === PACK CONTAINER === */
.pack-container-interactive {
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 12px;
    overflow: hidden;
    width: 320px;
    height: 570px;
    margin: 1rem auto;
    display: block;
}

.pack-container-interactive:hover {
    transform: none;
    box-shadow: none;
}

.pack-image {
    display: block;
    width: min(240px, 60vw); /* Responsive to viewport */
    height: min(420px, 60vw * 1.75); /* Maintain aspect ratio */
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

/* === RARITY GLOW EFFECTS - CONTAINED === */
.glow-rare {
    box-shadow: 
        inset 0 0 15px rgba(255, 215, 0, 0.4), 
        0 0 20px rgba(255, 215, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.5);
}

.glow-ultra-rare {
    box-shadow: 
        inset 0 0 18px rgba(138, 43, 226, 0.5), 
        0 0 25px rgba(138, 43, 226, 0.4);
    border: 2px solid rgba(138, 43, 226, 0.6);
}

.glow-secret-rare {
    box-shadow: 
        inset 0 0 20px rgba(255, 20, 147, 0.6), 
        0 0 30px rgba(255, 20, 147, 0.5);
    border: 2px solid rgba(255, 20, 147, 0.7);
}

/* Pack container glow effects - CONTAINED TO PACK SIZE */
.pack-container.glow-rare,
.pack-container:has(.pack-main.glow-rare) {
    box-shadow: 
        0 0 calc(min(350px, 90vw) * 0.1) rgba(255, 215, 0, 0.3), 
        0 0 calc(min(350px, 90vw) * 0.15) rgba(255, 215, 0, 0.2),
        inset 0 0 calc(min(350px, 90vw) * 0.08) rgba(255, 215, 0, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.4);
}

.pack-container.glow-ultra-rare,
.pack-container:has(.pack-main.glow-ultra-rare) {
    box-shadow: 
        0 0 calc(min(350px, 90vw) * 0.12) rgba(138, 43, 226, 0.4), 
        0 0 calc(min(350px, 90vw) * 0.18) rgba(138, 43, 226, 0.3),
        inset 0 0 calc(min(350px, 90vw) * 0.1) rgba(138, 43, 226, 0.1);
    border: 2px solid rgba(138, 43, 226, 0.5);
}

.pack-container.glow-secret-rare,
.pack-container:has(.pack-main.glow-secret-rare) {
    box-shadow: 
        0 0 calc(min(350px, 90vw) * 0.14) rgba(255, 20, 147, 0.5), 
        0 0 calc(min(350px, 90vw) * 0.2) rgba(255, 20, 147, 0.4),
        inset 0 0 calc(min(350px, 90vw) * 0.12) rgba(255, 20, 147, 0.1);
    border: 2px solid rgba(255, 20, 147, 0.6);
}

/* === BACK BUTTON === */
.back-button {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    position: fixed;
    top: clamp(90px, 12vh, 110px); /* Adjusted for shorter header */
    left: clamp(1rem, 3vw, 2rem); /* Responsive left position */
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    min-width: clamp(80px, 20vw, 120px); /* Responsive width */
    padding: clamp(0.4rem, 1.5vw, 0.75rem) clamp(0.6rem, 2vw, 1rem); /* Responsive padding */
    font-size: clamp(0.7rem, 2vw, 0.9rem); /* Responsive font size */
}

.back-button:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4);
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes cardSlideUp {
    from { 
        transform: translateY(150px) scale(0.8);
        opacity: 0;
    }
    to { 
        transform: translateY(0px) scale(1);
        opacity: 1;
    }
}

@keyframes cardFlip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg) scale(1.1); }
    100% { transform: rotateY(180deg); }
}

@keyframes cardFlipLarge {
    0% { 
        transform: rotateY(0deg) scale(1);
        width: 120px;
        height: 168px;
        margin-left: -60px;
        margin-top: -84px;
    }
    50% { 
        transform: rotateY(90deg) scale(1.5);
        width: 200px;
        height: 280px;
        margin-left: -100px;
        margin-top: -140px;
    }
    100% { 
        transform: rotateY(180deg) scale(1.5);
        width: 200px;
        height: 280px;
        margin-left: -100px;
        margin-top: -140px;
    }
}

@keyframes moveToCollection {
    0% {
        transform: rotateY(180deg) scale(1.5);
        opacity: 1;
    }
    100% {
        transform: rotateY(180deg) scale(0.8);
        opacity: 0.7;
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* === RESPONSIVE DESIGN - MOBILE OPTIMIZED === */
@media (max-width: 1200px) {
    .pack-opening-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        min-height: auto;
        gap: clamp(1rem, 4vw, 2rem);
        padding: clamp(0.5rem, 2vw, 1rem);
    }
    
    .pack-side, .card-pile-center, .cards-side {
        width: 100%;
        max-width: min(600px, 90vw);
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    #mainContent {
        padding: clamp(0.5rem, 2vw, 1rem);
        padding-top: 100px; /* Adjusted for shorter header */
    }
    
    .pack-opening-layout {
        padding: clamp(0.5rem, 2vw, 1rem);
        gap: clamp(0.5rem, 3vw, 1rem);
    }
    
    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(clamp(60px, 12vw, 100px), 1fr));
        gap: clamp(0.25rem, 1vw, 0.5rem);
        max-width: 95vw;
    }
    
    .card-slot {
        min-height: clamp(80px, 15vw, 120px);
        max-height: clamp(120px, 20vw, 160px);
    }
    
    .control-button {
        padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.8rem, 3vw, 1rem);
        font-size: clamp(0.75rem, 2vw, 0.8rem);
        min-width: clamp(100px, 25vw, 120px);
    }
    
    .session-stats-drawer {
        width: min(300px, 85vw);
        right: calc(-1 * min(300px, 85vw) - 10px);
    }
    
    .session-stats-drawer-toggle.open {
        right: calc(min(300px, 85vw) + 10px);
    }
}

/* === UTILITY CLASSES === */
.hidden {
    display: none;
}

.visible {
    display: block;
}

.fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

/* Error container styling */
.error-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    padding: 2rem;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    max-width: 500px;
    backdrop-filter: blur(10px);
}

.error-message i {
    font-size: 3rem;
    color: #ef4444;
    margin-bottom: 1rem;
}

.error-message h3 {
    color: #ef4444;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.error-message p {
    color: #f3f4f6;
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === MULTI-PANEL APP DRAWER WITH FLOATING ACTION BUTTONS === */
.app-drawer {
    position: fixed;
    top: 80px;
    right: -400px; /* Hidden by default, wider for better content */
    width: 390px;
    height: calc(100vh - 100px);
    background: linear-gradient(135deg, rgba(31, 41, 55, 0.96), rgba(15, 23, 42, 0.98));
    backdrop-filter: blur(15px);
    border: 1px solid rgba(75, 85, 99, 0.4);
    border-radius: 20px 0 0 20px; /* More rounded for modern look */
    transition: right 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1500;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(99, 102, 241, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-drawer.open {
    right: 0;
}

/* === FLOATING ACTION BUTTONS CONTAINER === */
.fab-container {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 1600;
}

/* === INDIVIDUAL FLOATING ACTION BUTTONS === */
.fab-container .fab {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: white;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.fab-container .fab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.fab-container .fab:hover::before {
    opacity: 1;
}

.fab-container .fab i {
    position: relative;
    z-index: 2;
    transition: transform 0.3s ease;
}

.fab-container .fab:hover {
    transform: scale(1.1) translateX(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.fab-container .fab:hover i {
    transform: scale(1.1);
}

.fab-container .fab:active {
    transform: scale(0.95) translateX(-5px);
}

/* === STATS FAB - Blue Theme === */
.fab-container .stats-fab {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border: 2px solid rgba(59, 130, 246, 0.3);
}

.fab-container .stats-fab:hover {
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.5);
}

.fab-container .stats-fab.active {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.6), inset 0 0 20px rgba(255, 255, 255, 0.1);
    transform: scale(1.15) translateX(-8px);
}

/* === HISTORY FAB - Purple Theme === */
.fab-container .history-fab {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    border: 2px solid rgba(139, 92, 246, 0.3);
}

.fab-container .history-fab:hover {
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5);
}

.fab-container .history-fab.active {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.6), inset 0 0 20px rgba(255, 255, 255, 0.1);
    transform: scale(1.15) translateX(-8px);
}

/* === SETTINGS FAB - Orange Theme === */
.fab-container .settings-fab {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: 2px solid rgba(245, 158, 11, 0.3);
}

.fab-container .settings-fab:hover {
    box-shadow: 0 8px 30px rgba(245, 158, 11, 0.5);
}

.fab-container .settings-fab.active {
    background: linear-gradient(135deg, #d97706, #b45309);
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.6), inset 0 0 20px rgba(255, 255, 255, 0.1);
    transform: scale(1.15) translateX(-8px);
}

/* === FAB LABELS (Show on hover) === */
.fab-container .fab::after {
    content: attr(title);
    position: absolute;
    right: 75px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateY(-50%) translateX(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.fab-container .fab:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* === DRAWER CONTENT === */
.drawer-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    padding: 0; /* Remove default padding */
}

.tab-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 1.5rem;
    opacity: 0;
    transform: translateX(30px);
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
}

.tab-panel.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* === ENHANCED PANEL TRANSITIONS === */
.tab-panel.slide-in-right {
    animation: slideInRight 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.tab-panel.slide-in-left {
    animation: slideInLeft 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.tab-panel.slide-out-right {
    animation: slideOutRight 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.tab-panel.slide-out-left {
    animation: slideOutLeft 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

/* === EXISTING STATS STYLES (enhanced) === */
.session-stats-header {
    text-align: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(75, 85, 99, 0.3);
    padding-bottom: 1rem;
    position: relative;
}

.session-stats-header::before {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.6), transparent);
}

.session-stats-header h3 {
    color: #f87171;
    font-size: 1.3rem;
    margin-bottom: 1rem;
    text-shadow: 0 0 10px rgba(248, 113, 113, 0.3);
}

.session-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.session-controls .control-button {
    background: linear-gradient(135deg, #374151, #4b5563);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-width: auto;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(75, 85, 99, 0.3);
}

.session-controls .control-button:hover {
    background: linear-gradient(135deg, #4b5563, #6b7280);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(75, 85, 99, 0.4);
}

.session-controls .control-button.danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-color: rgba(239, 68, 68, 0.3);
}

.session-controls .control-button.danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.session-stats-section {
    margin-bottom: 2rem;
    background: rgba(31, 41, 55, 0.3);
    border-radius: 12px;
    padding: 1.2rem;
    border: 1px solid rgba(75, 85, 99, 0.2);
    backdrop-filter: blur(5px);
}

.session-stats-section h4 {
    color: #a855f7;
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-shadow: 0 0 8px rgba(168, 85, 247, 0.3);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-item {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 10px;
    padding: 1.2rem;
    text-align: center;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.stat-item:hover {
    background: rgba(59, 130, 246, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.2);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: bold;
    color: #3b82f6;
    margin-bottom: 0.3rem;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.stat-label {
    font-size: 0.8rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.pack-breakdown {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 10px;
    padding: 1.2rem;
    margin-top: 1rem;
    backdrop-filter: blur(5px);
}

.pack-breakdown h5 {
    color: #22c55e;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    text-shadow: 0 0 8px rgba(34, 197, 94, 0.3);
}

.pack-list {
    list-style: none;
    padding: 0;
}

.pack-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.85rem;
    color: #e5e7eb;
    border-bottom: 1px solid rgba(34, 197, 94, 0.1);
}

.pack-list li:last-child {
    border-bottom: none;
}

.session-time {
    text-align: center;
    padding: 1.2rem;
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 10px;
    margin-top: 1rem;
    backdrop-filter: blur(5px);
}

.session-time-label {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.session-time-value {
    font-size: 1.2rem;
    color: #a855f7;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

/* === HISTORY TAB STYLES (enhanced) === */
.history-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-select {
    flex: 1;
    background: rgba(31, 41, 55, 0.9);
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 8px;
    color: #e5e7eb;
    padding: 0.6rem;
    font-size: 0.8rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.filter-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.history-list {
    max-height: calc(100vh - 350px);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.history-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(31, 41, 55, 0.4);
    border-radius: 4px;
    border: 1px solid rgba(75, 85, 99, 0.2);
}

.history-list::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.7), rgba(124, 58, 237, 0.8));
    border-radius: 4px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    transition: all 0.3s ease;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(124, 58, 237, 1));
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.history-list::-webkit-scrollbar-corner {
    background: rgba(31, 41, 55, 0.4);
}

/* Firefox scrollbar styling */
.history-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.7) rgba(31, 41, 55, 0.4);
}

.history-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.history-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
    color: #8b5cf6;
}

.history-empty p {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.history-empty small {
    font-size: 0.9rem;
    opacity: 0.7;
}

.history-item {
    background: rgba(31, 41, 55, 0.7);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.7rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    position: relative;
    overflow: hidden;
}

.history-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.history-item:hover::before {
    opacity: 1;
}

.history-item:hover {
    background: rgba(31, 41, 55, 0.9);
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateX(5px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.2);
}

.history-card-thumbnail {
    width: 50px;
    height: 70px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(75, 85, 99, 0.3);
    transition: all 0.3s ease;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.history-item:hover .history-card-thumbnail {
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
    border-color: rgba(139, 92, 246, 0.6);
    transform: scale(1.05);
}

.history-card-info {
    flex: 1;
    min-width: 0;
}

.history-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    gap: 0.5rem;
}

.history-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e5e7eb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.history-quantity-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    min-width: 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    border: 1px solid rgba(245, 158, 11, 0.5);
    flex-shrink: 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { 
        box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    }
    50% { 
        box-shadow: 0 2px 12px rgba(245, 158, 11, 0.5), 0 0 20px rgba(245, 158, 11, 0.2);
    }
}

.history-card-details {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    font-size: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.3rem;
}

.history-card-timestamp {
    color: #6b7280;
    font-size: 0.7rem;
    line-height: 1.3;
    margin-top: 0.2rem;
}

.history-pack-name {
    color: #a855f7;
    font-weight: 500;
}

.history-rarity {
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
}

.history-rarity.common {
    background: rgba(75, 85, 99, 0.4);
    color: #9ca3af;
}

.history-rarity.uncommon {
    background: rgba(34, 197, 94, 0.4);
    color: #22c55e;
}

.history-rarity.rare {
    background: rgba(251, 191, 36, 0.4);
    color: #fbbf24;
}

/* === SETTINGS TAB STYLES (enhanced) === */
.settings-section {
    margin-bottom: 2rem;
    background: rgba(31, 41, 55, 0.5);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 12px;
    padding: 1.3rem;
    backdrop-filter: blur(5px);
}

.settings-section h4 {
    color: #f87171;
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-shadow: 0 0 8px rgba(248, 113, 113, 0.3);
}

.setting-item {
    margin-bottom: 1rem;
    padding: 0.9rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(75, 85, 99, 0.2);
}

.setting-label {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    cursor: pointer;
}

.setting-name {
    color: #e5e7eb;
    font-weight: 600;
    font-size: 0.9rem;
}

.setting-description {
    color: #9ca3af;
    font-size: 0.75rem;
    line-height: 1.4;
}

.setting-checkbox {
    width: 20px;
    height: 20px;
    accent-color: #f59e0b;
    border-radius: 4px;
}

.setting-select {
    background: rgba(31, 41, 55, 0.9);
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 8px;
    color: #e5e7eb;
    padding: 0.6rem;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.setting-select:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.setting-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.setting-buttons .control-button {
    width: 100%;
    justify-content: center;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    background: linear-gradient(135deg, #374151, #4b5563);
    border: 1px solid rgba(75, 85, 99, 0.3);
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .app-drawer {
        width: min(350px, 85vw);
        right: calc(-1 * min(350px, 85vw) - 10px);
    }
    
    .app-drawer.open {
        right: 0;
    }
    
    .fab-container {
        right: 15px;
        gap: 12px;
    }
    
    .fab-container .fab {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .fab-container .fab::after {
        display: none; /* Hide labels on mobile */
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .history-card-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }
}

/* === PACK SIDE STYLING - FIXED PACK SCALING === */
.pack-side .pack-container-interactive {
    /* Use same responsive system as other pack containers */
    width: min(350px, 90vw); /* Responsive width */
    height: min(500px, 70vh); /* Responsive height */
    margin: 0 auto 1rem;
    position: relative;
    background: transparent;
    border-radius: 12px;
    border: none;
    overflow: hidden;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pack-side .pack-container-interactive:hover {
    transform: none;
    box-shadow: none;
}

/* PACK IMAGE IN PACK SIDE - SAME SCALING SYSTEM */
.pack-side .pack-image {
    /* Use same scaling as other pack images */
    width: calc(min(350px, 90vw) * 0.75); /* 75% of container width */
    height: calc((min(350px, 90vw) * 0.75) * 1.75); /* Maintain aspect ratio */
    object-fit: cover;
    border-radius: 12px;
    display: block;
    margin: 0 auto;
    position: relative;
    left: auto;
    top: auto;
    transform: none;
}

.pack-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(34, 197, 94, 0.15);
    backdrop-filter: blur(3px);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    padding: 1rem;
    border: 2px solid rgba(34, 197, 94, 0.4);
    /* Scale overlay proportionally to pack */
    width: calc((min(350px, 90vw) * 0.75) * 0.8); /* 80% of pack width */
    height: calc(((min(350px, 90vw) * 0.75) * 1.75) * 0.4); /* 40% of pack height */
}

.pack-side .pack-container-interactive.opened .pack-overlay {
    display: flex;
}

.pack-overlay i {
    font-size: clamp(1rem, 3vw, 1.5rem); /* Responsive icon */
    color: #22c55e;
    margin-bottom: 0.5rem;
}

.pack-overlay span {
    font-size: clamp(0.8rem, 2vw, 0.9rem); /* Responsive text */
    color: #f3f4f6;
}

/* === RESPONSIVE PACK OPENING LAYOUT === */
.pack-opening-layout {
    display: grid;
    grid-template-columns: 
        minmax(clamp(250px, 25vw, 350px), 1fr) 
        minmax(clamp(200px, 20vw, 280px), auto) 
        minmax(clamp(250px, 25vw, 400px), 2fr); /* Responsive columns with proper minimums */
    gap: clamp(1rem, 3vw, 2rem); /* Responsive gap */
    width: 100%;
    max-width: 1600px;
    min-height: calc(100vh - 300px);
    margin: 0 auto;
    padding: clamp(0.5rem, 2vw, 1rem) clamp(1rem, 3vw, 2rem) clamp(1rem, 3vw, 2rem) clamp(1rem, 3vw, 2rem); /* Responsive padding */
    box-sizing: border-box;
    position: relative;
    overflow: visible;
    align-items: start;
}

.pack-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-height: clamp(300px, 40vh, 400px); /* Responsive height */
    min-width: clamp(250px, 25vw, 350px); /* Responsive width */
}

.card-pile-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    padding: 0;
    background: transparent;
    border: none;
    min-height: auto;
    max-height: none;
    min-width: clamp(200px, 20vw, 280px); /* Responsive width */
    width: 100%; /* Ensure it takes full grid space */
}

.cards-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-height: clamp(400px, 50vh, 600px); /* Responsive height */
    min-width: clamp(250px, 25vw, 400px); /* Responsive width */
}

.pile-card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.pile-card-back {
    background: #1f2937;
    z-index: 2;
}

.pile-card-front {
    background: #fff;
    transform: rotateY(180deg);
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    image-rendering: -webkit-optimize-contrast; /* Better image quality */
    image-rendering: crisp-edges; /* Better image quality */
    image-rendering: pixelated; /* Prevent blurriness on scale */
}

/* === PACK SELECTION STYLES === */
.pack-option {
    background: rgba(31, 41, 55, 0.8);
    border: 2px solid rgba(75, 85, 99, 0.5);
    border-radius: 1.5rem;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pack-option:hover {
    border-color: rgba(168, 85, 247, 0.8);
    transform: translateY(-10px);
    box-shadow: 0 12px 25px rgba(168, 85, 247, 0.25);
}

.pack-option:hover .pack-image {
    transform: scale(1.05);
}

.pack-name {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.pack-description {
    color: #9ca3af;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Fix stats grid for both mobile and desktop */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* === REDUCED MOTION SUPPORT === */
.reduced-motion * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transform: none !important;
}

.reduced-motion .pack-container:hover {
    transform: none !important;
}

.reduced-motion .history-quantity-badge {
    animation: none !important;
}

.reduced-motion .history-item:hover {
    transform: none !important;
}

.reduced-motion .history-item:hover .history-card-thumbnail {
    transform: none !important;
}

.reduced-motion .fab-container .fab:hover {
    transform: none !important;
}

.reduced-motion .fab-container .fab:hover i {
    transform: none !important;
}

/* === INSTRUCTION TOOLTIPS === */
.pile-instructions,
.collection-instructions {
    text-align: center;
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    color: #93c5fd;
    font-size: 0.8rem;
    transition: all 0.5s ease;
}

.pile-instructions i,
.collection-instructions i {
    color: #3b82f6;
    margin-right: 0.5rem;
}

.collection-instructions.glow-instructions {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.6);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    animation: instructionPulse 2s ease-in-out infinite;
}

@keyframes instructionPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 30px rgba(59, 130, 246, 0.6);
    }
}

/* === COLLECTION BOARD GLOW === */
.collection-board-glow {
    position: relative;
    border-radius: 12px;
    animation: collectionBoardGlow 3s ease-in-out infinite;
}

.collection-board-glow::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.6), rgba(147, 197, 253, 0.4));
    border-radius: 14px;
    z-index: -1;
    animation: collectionBorderGlow 2s ease-in-out infinite;
}

@keyframes collectionBoardGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(59, 130, 246, 0.6);
    }
}

@keyframes collectionBorderGlow {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

.reduced-motion .collection-instructions.glow-instructions {
    animation: none !important;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4) !important;
}

.reduced-motion .collection-board-glow {
    animation: none !important;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3) !important;
}

.reduced-motion .collection-board-glow::before {
    animation: none !important;
    opacity: 0.6 !important;
}

/* === PACK SELECTION PREVIEW IMAGES === */
.pack-image-container .pack-image {
    /* Fixed dimensions for 610x406 aspect ratio preview images */
    width: 100%;
    max-width: 280px; /* Scaled down from 610px */
    height: auto;
    aspect-ratio: 610/406; /* Maintain exact aspect ratio */
    object-fit: cover; /* Cover to fill the container properly */
    border-radius: 12px;
    transition: transform 0.4s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(75, 85, 99, 0.3);
}

/* === PACK OPENING SCREEN IMAGES === */
.pack-side .pack-image,
.pack-container .pack-main,
.pack-container .pack-bottom,
.pack-container .pack-top {
    /* Pack opening screen - use original responsive sizing */
    width: calc(min(350px, 90vw) * 0.75); /* 75% of container width */
    height: calc((min(350px, 90vw) * 0.75) * 1.75); /* Maintain proper pack aspect ratio */
    object-fit: cover;
    border-radius: 12px;
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    max-width: none; /* Override preview restrictions */
    aspect-ratio: auto; /* Override preview aspect ratio */
}

.card-pile {
    position: relative;
    width: calc(min(350px, 90vw) * 0.65);
    height: calc(min(350px, 90vw) * 0.65 * 1.4);
    margin: 0 auto;
    perspective: 1000px;
    background: rgba(31, 41, 55, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(75, 85, 99, 0.3);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
}

.card-pile.visible {
    animation: cardSlideUp 0.8s ease-out forwards;
}

.pile-card-3d {
    position: absolute;
    width: calc(min(350px, 90vw) * 0.65 * 0.85);
    height: calc(min(350px, 90vw) * 0.65 * 0.85 * 1.4);
    cursor: pointer;
    transition: all 0.3s ease;
    transform-style: preserve-3d;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    overflow: hidden;
}

.pile-card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.pile-card-back {
    background: #1f2937;
    z-index: 2;
}

.pile-card-front {
    background: #fff;
    transform: rotateY(180deg);
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

/* Stacked card positions */
.pile-card-3d:nth-child(1) { z-index: 10; transform: translate(-50%, -50%) rotate(-1deg); }
.pile-card-3d:nth-child(2) { z-index: 9; transform: translate(-50%, -50%) rotate(0.5deg) translateY(-1px); }
.pile-card-3d:nth-child(3) { z-index: 8; transform: translate(-50%, -50%) rotate(-0.5deg) translateY(-2px); }
.pile-card-3d:nth-child(4) { z-index: 7; transform: translate(-50%, -50%) rotate(1deg) translateY(-3px); }
.pile-card-3d:nth-child(5) { z-index: 6; transform: translate(-50%, -50%) rotate(-0.3deg) translateY(-4px); }
.pile-card-3d:nth-child(6) { z-index: 5; transform: translate(-50%, -50%) rotate(0.8deg) translateY(-5px); }
.pile-card-3d:nth-child(7) { z-index: 4; transform: translate(-50%, -50%) rotate(-0.7deg) translateY(-6px); }
.pile-card-3d:nth-child(8) { z-index: 3; transform: translate(-50%, -50%) rotate(0.2deg) translateY(-7px); }
.pile-card-3d:nth-child(9) { z-index: 2; transform: translate(-50%, -50%) rotate(-0.4deg) translateY(-8px); }
.pile-card-3d:nth-child(10) { z-index: 1; transform: translate(-50%, -50%) rotate(0.6deg) translateY(-9px); }

.pile-card-3d.flipping {
    animation: cardFlipLarge 0.8s ease-in-out forwards;
    z-index: 1000;
    position: fixed;
    left: 50%;
    top: 50%;
    width: 300px;
    height: 420px;
    margin-left: -150px;
    margin-top: -210px;
}

.pile-card-3d.flipped {
    transform: rotateY(180deg);
    z-index: 50;
}

.pile-card-3d.flipped:hover {
    transform: rotateY(180deg) scale(1.1) translateY(-10px);
    z-index: 100;
}

.pile-card-3d.moving-to-collection {
    animation: moveToCollection 0.8s ease-out forwards;
    z-index: 200;
}

.card-flip-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.card-flip-overlay.active {
    display: flex;
}

.overlay-card-image {
    width: 400px;
    height: 560px;
    border-radius: 16px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7);
    cursor: pointer;
    transition: transform 0.3s ease;
    animation: zoomIn 0.3s ease-out;
}

.overlay-card-image:hover {
    transform: scale(1.05);
}

.overlay-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(80px, 15vw, 120px), 1fr));
    gap: clamp(0.5rem, 2vw, 1.5rem);
    width: 100%;
    max-width: clamp(400px, 80vw, 700px);
    margin: 1rem auto;
}

.card-slot {
    aspect-ratio: 2.5/3.5;
    background: rgba(31, 41, 55, 0.4);
    border: 2px dashed rgba(75, 85, 99, 0.5);
    border-radius: clamp(8px, 2vw, 12px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    min-height: clamp(100px, 20vw, 180px);
    cursor: pointer;
    overflow: hidden;
}

.card-slot.empty {
    border-color: rgba(75, 85, 99, 0.3);
}

.card-slot.empty:hover {
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(168, 85, 247, 0.1);
}

.slot-placeholder {
    text-align: center;
    color: #6b7280;
    font-size: clamp(0.7rem, 2vw, 0.8rem);
}

.slot-placeholder i {
    font-size: clamp(1rem, 3vw, 1.5rem);
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.card-slot.filled {
    border-color: rgba(34, 197, 94, 0.5);
    border-style: solid;
}

.card-slot.filled:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.card-slot.filled .card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}
