/* Styles for the Inventory Modal - Adapted from Profile Modal */
:root {
    --inventory-primary-font: 'Roboto Mono', monospace;
    --inventory-accent-font: 'Press Start 2P', cursive;
    --inventory-glow-color: #00FFDC; /* Using same glow as profile for consistency */
    --inventory-text-primary: #E0F0FF;
    --inventory-text-secondary: #A0C0E0;
    --inventory-background-start: rgba(10, 25, 40, 0.97); /* Darker, techy gradient start */
    --inventory-background-end: rgba(20, 35, 55, 0.97);   /* Darker, techy gradient end */
    --inventory-border-color: rgba(0, 255, 220, 0.6);
    --inventory-border-accent-low: rgba(0, 255, 220, 0.2);
    --inventory-border-accent-medium: rgba(0, 255, 220, 0.4);
    --inventory-slot-background: rgba(0,0,0,0.15);
    --inventory-empty-slot-background: rgba(0,0,0,0.25);
    --inventory-empty-slot-border: rgba(0, 255, 220, 0.25);
    --inventory-item-hover-background: rgba(0, 255, 220, 0.15);
    --inventory-drag-over-background: rgba(0, 255, 220, 0.25);
}

.inventory-modal {
    position: fixed;
    z-index: 1000; /* Slightly lower than profile if they can overlap, adjust as needed */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s linear 0.4s;
    backdrop-filter: blur(6px);
}

.inventory-modal.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease;
}

.inventory-modal-content {
    background: linear-gradient(145deg, var(--inventory-background-start), var(--inventory-background-end));
    margin: auto;
    padding: 0; 
    border: 1px solid var(--inventory-border-color);
    border-radius: 15px; 
    width: 90%;
    max-width: 800px; /* Increased max-width to accommodate horizontal layout */
    box-shadow: 0 10px 50px rgba(0, 255, 220, 0.7), 0 0 20px rgba(0,0,0,0.4);
    color: var(--inventory-text-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden; 
    font-family: var(--inventory-primary-font);
    max-height: 85vh;
}

.inventory-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 25px;
    background-color: rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--inventory-border-accent-medium);
}

.inventory-modal-header h3 {
    font-family: var(--inventory-accent-font);
    color: var(--inventory-glow-color);
    margin: 0;
    font-size: 1.4em;
    font-weight: normal;
    text-shadow: 0 0 6px rgba(0, 255, 220, 0.8);
}

.inventory-modal-close-button {
    background: none;
    border: none;
    color: var(--inventory-text-secondary);
    font-size: 2.2em;
    font-weight: bold;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    transition: color 0.2s ease, transform 0.2s ease;
}

.inventory-modal-close-button:hover {
    color: var(--inventory-glow-color);
    transform: scale(1.1);
}

.inventory-modal-tabs {
    display: flex;
    background-color: rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--inventory-border-accent-medium);
}

.inventory-tab-button {
    flex: 1;
    padding: 12px 10px;
    background-color: transparent;
    border: none;
    color: var(--inventory-text-secondary);
    font-family: var(--inventory-primary-font);
    font-size: 0.9em;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
    border-bottom: 3px solid transparent;
}

.inventory-tab-button:hover {
    background-color: rgba(0, 255, 220, 0.1);
}

.inventory-tab-button.active {
    color: var(--inventory-glow-color);
    border-bottom: 3px solid var(--inventory-glow-color);
    font-weight: bold;
}

.inventory-tab-content {
    display: none; /* Hide all tab content by default */
}

.inventory-tab-content.active {
    display: block; /* Display only the active tab content */
}

/* Hide equipment container when crafting tab is active */
.inventory-tab-button#inventory-tab-crafting.active ~ .inventory-modal-body .equipment-slots-container {
    display: none;
}

/* Show equipment container when character tab is active */
.inventory-tab-button#inventory-tab-character.active ~ .inventory-modal-body .equipment-slots-container {
    display: flex;
}

.inventory-modal-body {
    padding: 20px 25px 25px; 
    display: flex;
    flex-direction: column; /* Main body remains column for overall structure */
    gap: 20px; 
    flex: 1; /* Allow body to grow and shrink */
    min-height: 0; /* Important for flex-shrink to work with overflow */
    overflow-y: auto; 
    font-size: 0.9rem;
}

/* Player Profile & Equipment Area */
.inventory-player-profile-area {
    display: flex; /* Changed to flex for horizontal layout */
    align-items: center; /* Vertically align items in the flex container */
    gap: 15px; /* Space between avatar, stats block, and equipment slots */
    padding: 15px;
    background-color: var(--inventory-slot-background);
    border-radius: 8px;
    border: 1px solid var(--inventory-border-accent-low);
    justify-content: space-between;
}

.inventory-profile-avatar-area {
    flex-shrink: 0; /* Prevent avatar from shrinking */
    align-self: center; /* Center avatar vertically in the profile area */
}

.inventory-profile-avatar-img {
    width: 60px; /* Adjusted size */
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--inventory-border-accent-medium);
    object-fit: cover;
    margin-left: 30px;
    margin-right: 70px;
}

/* New Bento Stats Grid */
.inventory-bento-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 0 auto; /* Center the grid horizontally */
    max-width: 240px; /* Constrain the width for a more compact look */
}

.bento-stat-item {
    background-color: var(--inventory-slot-background);
    border: 1px solid var(--inventory-border-accent-low);
    border-radius: 8px;
    padding: 8px; /* Reduced padding */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: background-color 0.3s, border-color 0.3s;
}

.bento-stat-item:hover {
    background-color: var(--inventory-item-hover-background);
    border-color: var(--inventory-border-accent-medium);
}

.bento-stat-label {
    font-size: 0.7em; /* Reduced size */
    color: var(--inventory-text-secondary);
    margin-bottom: 4px; /* Reduced margin */
    text-transform: uppercase;
}

.bento-stat-value {
    font-size: 0.9em;
    color: var(--inventory-text-primary);
    font-weight: bold;
    font-family: var(--inventory-primary-font);
}

.equipment-slots-container {
    display: none; /* Hide by default */
    gap: 10px; /* Reduced gap between equipment slots */
    flex-shrink: 0; /* Prevent equipment slots from shrinking too much */
}

/* Only show when the character tab is active */
.character-view .equipment-slots-container {
    display: flex;
}

.equipment-slot {
    position: relative; /* Crucial for absolute positioning */
    width: 75px; /* Adjusted equipment slot size */
    height: 75px; 
    border: 1px solid var(--inventory-border-accent-medium);
    background-color: var(--inventory-empty-slot-background);
    border-radius: 8px;
    display: flex;
    flex-direction: column; /* Stack label and item vertically */
    justify-content: center; /* Center content (label initially, then item) */
    align-items: center;
    text-align: center;
    padding: 5px;
    box-sizing: border-box;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.equipment-slot .equipment-slot-label {
    font-size: 0.75em;
    color: var(--inventory-text-secondary);
    margin-bottom: 5px; /* Space between label and item */
}

/* Style for an item image when placed in an equipment slot */
.equipment-slot .equipped-item-image {
    max-width: 50px; /* Control size of item image in equip slot */
    max-height: 50px;
    object-fit: contain;
    margin-top: 5px; /* Adjust as needed if label is above */
}

.equipment-slot .equipped-item-name {
    display: none; /* Hide the item name inside an equipment slot */
}

/* Tier indicator styling */
.inventory-item-tier {
    position: absolute;
    top: 3px;
    right: 3px;
    z-index: 2; /* To be on top of the item image */
    padding: 2px 6px;
    font-size: 10px; /* A fixed small size */
    font-weight: bold;
    color: var(--profile-glow-color, #00FFDC);
    background-color: rgba(10, 25, 40, 0.9); /* Dark background */
    border: 1px solid var(--profile-glow-color, #00FFDC);
    border-radius: 3px;
    box-shadow: 0 0 8px -2px var(--profile-glow-color, #00FFDC); /* Subtle glow */
    transform: skewX(-15deg); /* Sci-fi slant */
    text-align: center;
}

/* Remove more specific styling that is now handled by the general rule */
/*
.equipment-slot .inventory-item-tier {
    font-size: inherit;
    top: inherit;
    right: inherit;
    padding: inherit;
    min-width: auto;
}
*/

/* Hide the slot label (e.g., "Deck") when an item is equipped in it */
.equipment-slot:has(.equipped-item-image) .equipment-slot-label {
    display: none;
}

/* Style for bonus stats from equipment */
.stat-bonus {
    color: var(--profile-glow-color, #00FFDC);
    font-weight: bold;
    margin-left: 4px; /* Add a little space */
}

/* Highlight for equipment slots on drag over, if compatible */
.equipment-slot.drag-over {
    background-color: var(--inventory-drag-over-background);
    border-color: var(--inventory-glow-color);
}

/* Inventory Items Grid */
.inventory-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    /* grid-template-columns: repeat(4, 1fr); Removed fixed column count for responsiveness */
    gap: 10px; 
    padding: 10px;
    background-color: var(--inventory-slot-background);
    border-radius: 8px;
    border: 1px solid var(--inventory-border-accent-low);
    min-height: 150px; 
}

/* Styles for all slots (items and empty) */
.inventory-slot {
    position: relative; /* Crucial for absolute positioning */
    border: 1px solid var(--inventory-border-accent-low);
    border-radius: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; 
    text-align: center;
    min-height: 60px; 
    box-sizing: border-box;
}

.inventory-slot.inventory-item {
    background-color: rgba(255, 255, 255, 0.05); 
    cursor: grab;
    transition: background-color 0.3s ease, transform 0.2s ease, border-color 0.3s ease;
}

.inventory-slot.inventory-item:hover {
    background-color: var(--inventory-item-hover-background);
    transform: translateY(-2px);
    border-color: var(--inventory-border-accent-medium);
}

.inventory-slot.empty-slot {
    background-color: var(--inventory-empty-slot-background);
    border-style: dashed;
    border-color: var(--inventory-empty-slot-border);
    color: rgba(0, 255, 220, 0.3);
}

.inventory-slot.dragging {
    opacity: 0.5;
    border: 2px dashed var(--inventory-glow-color);
    transform: scale(0.95);
}

.inventory-slot.in-craft-slot {
    /* Add a pseudo-element for the animated glow */
    position: relative;
    z-index: 1; /* Ensure it's above normal slots */
}

.inventory-slot.in-craft-slot::before {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    border-radius: 8px; /* Match the slot's border-radius + border width */
    border: 2px solid transparent;
    z-index: -1;
    animation: pulse-glow 2s infinite;
}

/* Let's make sure the content is not affected */
.inventory-slot.in-craft-slot .inventory-item-image,
.inventory-slot.in-craft-slot .inventory-item-name {
    opacity: 0.6; /* Slightly fade the item to indicate it's 'used' elsewhere */
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 5px rgba(0, 255, 220, 0.2);
        border-color: rgba(0, 255, 220, 0.5);
    }
    50% {
        box-shadow: 0 0 15px 5px rgba(0, 255, 220, 0.5);
        border-color: rgba(0, 255, 220, 1);
    }
    100% {
        box-shadow: 0 0 5px rgba(0, 255, 220, 0.2);
        border-color: rgba(0, 255, 220, 0.5);
    }
}

.inventory-slot.drag-over {
    background-color: var(--inventory-drag-over-background);
    border-color: var(--inventory-glow-color);
}

.inventory-item-image {
    width: 60px; 
    height: 60px;
    object-fit: contain; 
    margin-bottom: 8px;
    border-radius: 4px; 
}

.inventory-item-name {
    font-size: 0.85em;
    color: var(--inventory-text-primary);
    font-weight: 500;
    word-break: break-word;
    margin-bottom: 4px;
}

.inventory-item-quantity {
    font-size: 0.75em;
    color: var(--inventory-text-secondary);
    background-color: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    position: absolute; 
    bottom: 5px;
    right: 5px;
}

/* Messages for different states */
.inventory-empty-message,
.inventory-loading-message,
.inventory-error-message,
.inventory-disconnected-message {
    color: var(--inventory-text-secondary);
    font-style: italic;
    text-align: center;
    padding: 20px;
    width: 100%;
}

.inventory-modal-footer {
    padding: 15px 25px;
    background-color: rgba(0,0,0,0.2);
    border-top: 1px solid var(--inventory-border-accent-medium);
    text-align: center; 
    font-size: 0.8em;
    color: var(--inventory-text-secondary);
}

/* Custom scrollbar for modal body */
.inventory-modal-body::-webkit-scrollbar {
    width: 8px;
}
.inventory-modal-body::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}
.inventory-modal-body::-webkit-scrollbar-thumb {
    background: var(--inventory-border-accent-medium);
    border-radius: 4px;
}
.inventory-modal-body::-webkit-scrollbar-thumb:hover {
    background-color: var(--inventory-glow-color);
}

/* --- Responsive Design for Mobile & Tablet --- */
@media (max-width: 768px) { 
    /* Header */
    .inventory-profile-avatar-img {
        width: 60px; /* Adjusted size */
        height: 60px;
        border-radius: 50%;
        border: 2px solid var(--inventory-border-accent-medium);
        object-fit: cover;
        margin-left: 0px;
        margin-right: 0px;
    }
    .inventory-modal-header h3 {
        font-size: 1.0em;
        text-shadow: 0 0 3px rgba(0, 255, 220, 0.8);
    }
    .inventory-modal-close-button {
        font-size: 1.8em;
    }

    /* Content Body */
    .inventory-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    .inventory-modal-body {
        padding: 10px 10px 15px;
        gap: 10px;
    }

    /* Profile Area */
    .inventory-player-profile-area {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
    }
    .inventory-modal-content.crafting-view .inventory-player-profile-area .inventory-profile-avatar-area {
        display: none;
    }
    .inventory-profile-avatar-img {
        width: 50px; 
        height: 50px;
    }
    
    /* Equipment */
    .equipment-slots-container {
        justify-content: center;
    }
    .equipment-slot {
        width: 70px;
        height: 70px;
    }

    /* INVENTORY GRID (CHARACTER VIEW) */
    .inventory-items-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        max-height: 240px; /* Added to create a scrollable area */
        overflow-y: scroll;
        padding-right: 4px; /* To prevent content from hiding behind the scrollbar */
    }

    /* Added scrollbar styling for the character inventory grid */
    .inventory-items-grid::-webkit-scrollbar {
        width: 8px;
    }
    .inventory-items-grid::-webkit-scrollbar-track {
        background: rgba(0,0,0,0.2);
        border-radius: 4px;
    }
    .inventory-items-grid::-webkit-scrollbar-thumb {
        background-color: var(--inventory-border-accent-medium);
        border-radius: 4px;
    }
    .inventory-items-grid::-webkit-scrollbar-thumb:hover {
        background-color: var(--inventory-glow-color);
    }

    /* General Item Styling in Grid */
    .inventory-slot {
        padding: 4px;
        border-radius: 5px;
        justify-content: flex-start;
    }
    .inventory-item-image {
        width: 40px;
        height: 40px;
        margin-bottom: 3px;
    }
    .inventory-item-name {
        font-size: 0.6em;
        line-height: 1.2;
    }
    .inventory-item-quantity {
        font-size: 0.6em;
        padding: 1px 3px;
        bottom: 2px;
        right: 2px;
    }
    
    /* INVENTORY GRID (CRAFTING VIEW) */
    .inventory-modal-content.crafting-view .inventory-items-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        max-height: 180px;
        overflow-y: scroll;
        padding-right: 4px;
        margin-top: 10px;
        justify-content: flex-start;
    }
    .inventory-modal-content.crafting-view .inventory-items-grid::-webkit-scrollbar {
        width: 8px;
    }
    .inventory-modal-content.crafting-view .inventory-items-grid::-webkit-scrollbar-track {
        background: rgba(0,0,0,0.2);
        border-radius: 4px;
    }
    .inventory-modal-content.crafting-view .inventory-items-grid::-webkit-scrollbar-thumb {
        background-color: var(--inventory-border-accent-medium);
        border-radius: 4px;
    }
    .inventory-modal-content.crafting-view .inventory-items-grid::-webkit-scrollbar-thumb:hover {
        background-color: var(--inventory-glow-color);
    }

    /* Crafting Area Adjustments */
    .inventory-profile-main-craft-area {
        gap: 8px;
        justify-content: center;
        flex-wrap: wrap; /* Allow wrapping if needed */
    }
    .craft-slot, .craft-result-slot-wrapper {
        min-height: 65px;
        flex-basis: 65px; /* Give a base size to each slot */
    }
    .craft-slot .inventory-item-image,
    .craft-result-slot .inventory-item-image {
        width: 35px;
        height: 35px;
    }
    .craft-slot .inventory-item-name,
    .craft-result-slot .inventory-item-name {
        font-size: 0.6em;
    }
    .craft-action-wrapper {
        margin: 8px 0;
        padding: 0 10px;
    }
    .craft-button {
        padding: 8px 10px;
        font-size: 0.8em;
    }
    .craft-timer {
        font-size: 0.8em;
    }

    .all-recipes-button {
        width: 100px;
        height: 28px;
        font-size: 0.55em;
    }

    /* Footer adjustments */
    .inventory-modal-footer {
        padding: 8px;
    }
    .inventory-modal-add-slot-button {
        padding: 8px 12px;
        font-size: 0.8em;
        border-radius: 6px;
    }

    /* Bento stats on mobile */
    .inventory-bento-stats-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 columns, will create 2 rows */
        gap: 5px;
        max-width: 100%; /* Use full available width */
    }

    .bento-stat-item {
        padding: 5px;
    }

    .bento-stat-label {
        font-size: 0.6em;
        margin-bottom: 2px;
    }

    .bento-stat-value {
        font-size: 0.9em;
    }
}

.inventory-context-menu {
    position: fixed; /* Use fixed to position relative to viewport */
    z-index: 1010; /* Above modal content */
    background: linear-gradient(145deg, var(--inventory-background-start), var(--inventory-background-end));
    border: 1px solid var(--inventory-border-color);
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 255, 220, 0.5);
    font-family: var(--inventory-primary-font);
    padding: 8px 0;
    min-width: 150px;
    backdrop-filter: blur(10px); /* Add some blur to make it pop */
}

.inventory-modal-add-slot-button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.inventory-modal-add-slot-button {
    background: linear-gradient(145deg, rgba(0, 255, 220, 0.1), rgba(0, 255, 220, 0.2));
    border: 1px solid var(--inventory-border-accent-medium);
    color: var(--inventory-text-primary);
    font-family: var(--inventory-primary-font);
    font-size: 1em;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 0 4px rgba(0, 255, 220, 0.5);
}

.inventory-modal-add-slot-button:hover:not(:disabled) {
    background: linear-gradient(145deg, rgba(0, 255, 220, 0.2), rgba(0, 255, 220, 0.3));
    border-color: var(--inventory-border-color);
    box-shadow: 0 0 15px rgba(0, 255, 220, 0.4);
    transform: translateY(-2px);
}

.inventory-modal-add-slot-button:disabled {
    background: rgba(80, 80, 80, 0.3);
    color: #999;
    cursor: not-allowed;
    border-color: rgba(120, 120, 120, 0.5);
    text-shadow: none;
}

.inventory-modal-add-slot-button .add-slot-price {
    font-size: 0.9em;
    color: var(--inventory-text-secondary);
    margin-left: 8px;
    font-weight: normal;
}

.inventory-modal-add-slot-button:hover:not(:disabled) .add-slot-price {
    color: var(--inventory-text-primary);
}

.inventory-context-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.inventory-context-menu li {
    padding: 10px 20px;
    color: var(--inventory-text-primary);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 0.9em;
}

.inventory-context-menu li:hover {
    background-color: var(--inventory-item-hover-background);
    color: var(--inventory-glow-color);
}

/* Assuming profile modal might share or adapt these variables */
/* Or define profile specific ones if they differ significantly */

.profile-stat-row .stat-impact-description {
    font-size: 0.75em; /* Smaller font size */
    color: var(--inventory-text-secondary, #A0C0E0); /* Use inventory secondary text color or a fallback */
    display: block; /* Ensure it takes its own line if needed, or inline-block */
    margin-top: 2px; /* Small space below the stat value */
    margin-left: 5px; /* Align with stat value or adjust as needed */
    font-style: italic;
    font-weight: normal;
    text-align: left; /* Or match alignment of stat value */
}

#inventory-crafting-content {
    display: none; /* Hidden by default, JS will manage display */
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

#inventory-crafting-content.active {
    display: flex;
}

.inventory-profile-main-craft-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0; /* Remove padding if not needed */
}

.craft-slot {
    width: 75px;
    height: 75px;
    border: 1px dashed var(--inventory-empty-slot-border);
    background-color: var(--inventory-empty-slot-background);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.craft-slot.drag-over {
    background-color: var(--inventory-drag-over-background);
    border-color: var(--inventory-glow-color);
}

.craft-result-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-shrink: 0;
}

.craft-result-slot-wrapper {
    position: relative;
    width: 75px;
    height: 75px;
}

.craft-result-slot {
    width: 100%;
    height: 100%;
    border: 1px dashed var(--inventory-glow-color);
    background-color: var(--inventory-empty-slot-background);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
    box-sizing: border-box;
}

.craft-result-label {
    font-size: 0.9em;
    color: var(--inventory-text-secondary);
}

.craft-timer-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
    box-sizing: border-box;
}

.craft-progress-bar {
    width: 90%;
    height: 8px;
    background-color: rgba(0,0,0,0.5);
    border: 1px solid var(--inventory-border-accent-low);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.craft-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--inventory-glow-color), #00A2FF);
    border-radius: 3px;
    transition: width 1s linear; /* Smooth transition for the progress */
}

.craft-countdown-timer {
    font-family: var(--inventory-primary-font);
    font-size: 1.1em;
    font-weight: bold;
    color: var(--inventory-text-primary);
    text-shadow: 0 0 4px var(--inventory-glow-color);
}

.craft-action-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    /* width: 100%; REMOVED - This was breaking the layout */
    /* margin-right: 15px; REMOVED - Replaced by gap */
}

.craft-button {
    position: relative;
    overflow: hidden;
    width: 120px; /* Reduced width */
    height: 40px;
    padding: 0; /* Remove padding to let text span control it */
    font-family: var(--inventory-accent-font);
    font-size: 0.7em;
    font-weight: normal;
    text-shadow: 0 0 6px rgba(0, 255, 220, 0.8);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s, transform 0.2s;
    border: 1px solid var(--inventory-glow-color);
    background-color: transparent;
    color: var(--inventory-glow-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

.craft-button:hover:not(:disabled) {
    background-color: rgba(0, 255, 220, 0.2);
    box-shadow: 0 0 10px rgba(0, 255, 220, 0.4);
    transform: translateY(-2px);
}

.craft-button:disabled {
    border-color: rgba(160, 192, 224, 0.3);
    background-color: rgba(160, 192, 224, 0.1);
    color: rgba(160, 192, 224, 0.4);
    cursor: not-allowed;
    text-shadow: none;
    opacity: 1; /* Override my previous opacity setting for a custom disabled style */
}

.craft-button-text {
    position: relative;
    z-index: 2;
}

.craft-button-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--inventory-glow-color), #00A2FF);
    opacity: 0.6; 
    z-index: 1;
    transition: width 0.5s ease-in-out, background-color 0.3s;
}

.craft-button:disabled .craft-button-progress {
    background: var(--inventory-glow-color); /* Make progress more visible when disabled */
    opacity: 0.4;
}

.all-recipes-button {
    width: 120px;
    height: 30px;
    padding: 0;
    font-family: var(--inventory-primary-font);
    font-size: 0.6em;
    font-weight: normal;
    text-shadow: 0 0 4px rgba(0, 255, 220, 0.6);
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s, transform 0.2s;
    border: 1px solid var(--inventory-glow-color);
    background: linear-gradient(145deg, rgba(0, 255, 220, 0.05), rgba(0, 255, 220, 0.15));
    color: var(--inventory-glow-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

.all-recipes-button:hover {
    background: linear-gradient(145deg, rgba(0, 255, 220, 0.15), rgba(0, 255, 220, 0.25));
    box-shadow: 0 0 8px rgba(0, 255, 220, 0.3);
    transform: translateY(-1px);
}

/* Animation for 'In progress...' dots */
.craft-button .dot-1, .craft-button .dot-2, .craft-button .dot-3 {
    animation: blink 1.4s infinite;
}
.craft-button .dot-1 { animation-delay: 0s; }
.craft-button .dot-2 { animation-delay: 0.2s; }
.craft-button .dot-3 { animation-delay: 0.4s; }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- MOBILE STYLES --- */
@media (max-width: 768px) {
    .inventory-player-profile-area {
        flex-direction: column; /* Stack profile area vertically on smaller screens */
        align-items: center; /* Center items on mobile */
        gap: 20px;
    }

    #inventory-crafting-content.active {
        flex-direction: column;
        align-items: center; /* Explicitly center items horizontally */
        gap: 20px;
    }

    .inventory-profile-main-craft-area {
        gap: 8px;
        justify-content: center;
        flex-wrap: wrap; /* Allow wrapping if needed */
    }
    .craft-slot, .craft-result-slot-wrapper {
        min-height: 65px;
        flex-basis: 65px; /* Give a base size to each slot */
    }
    .craft-slot .inventory-item-image,
    .craft-result-slot .inventory-item-image {
        width: 35px;
        height: 35px;
    }
    .craft-slot .inventory-item-name,
    .craft-result-slot .inventory-item-name {
        font-size: 0.6em;
    }
    .craft-action-wrapper {
        margin: 8px 0;
        padding: 0 10px;
    }
    .craft-button {
        padding: 8px 10px;
        font-size: 0.8em;
    }
    .craft-timer {
        font-size: 0.8em;
    }

    /* Footer adjustments */
    .inventory-modal-footer {
        padding: 8px;
    }
    .inventory-modal-add-slot-button {
        padding: 8px 12px;
        font-size: 0.8em;
        border-radius: 6px;
    }
}

/* --- Media Query pour Desktop --- */
@media (min-width: 1024px) {
    /* ... (règles existantes) ... */
    .inventory-profile-avatar-area, .equipment-slots-container {
        flex-shrink: 0;
    }
}