/* Location View Layout */
.location-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    gap: var(--game-gap-md);
}

.location-view .location-info {
    flex-shrink: 0;
}

.location-view .location-description-box {
    flex-shrink: 0;
}

.location-view .location-messages-log {
    flex-shrink: 0;
}

/* "Show All" card for overflowing entity sections */
.entity-show-more-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--game-border-color);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    color: var(--game-text-secondary);
    gap: 0.3rem;
    min-width: 0;
    width: 100%;
}

.entity-show-more-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--game-text-highlight);
    color: var(--game-text-highlight);
    transform: translateY(-2px);
}

.entity-show-more-card .show-more-count {
    font-size: 1.5rem;
    font-weight: bold;
}

.entity-show-more-card .show-more-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Entity modal - scrollable grid */
.entity-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    grid-auto-rows: max-content;
    align-content: start;
    gap: var(--game-gap-md);
    padding: var(--game-gap-md);
}

/* Grid View Styles */

.entities-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
}

.entity-section {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: calc(50% - 0.25rem);
    max-width: 100%;
    box-sizing: border-box;
}

/* Ground item images */
.ground-item-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Corpse images - grayed out */
.corpse-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: grayscale(100%) brightness(0.6);
}

.entity-list.grid-view {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    align-items: start;
    padding: 0.25rem;
    overflow: hidden;
}

.entity-list.grid-view>* {
    flex: 0 0 auto;
    width: 90px;
    height: 90px;
}

.entity-list.grid-view>.entity-show-more-card {
    width: 90px;
    height: 90px;
}

/* Padded Image for enemies */
.grid-card .entity-image.padded-image {
    padding: 10px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin: 0;
}

.grid-card .entity-image.padded-image img {
    width: 100%;
    height: 100%;
    object-fit: cover !important;
    /* Crop to 1:1 as requested */
    display: block;
    margin: 0;
}



/* Remove old expanded grid styles */
.corpse-container {
    display: contents;
    /* Allows the card to be a direct grid child when not expanded */
}

/* Loot Overlay Modal */
.corpse-loot-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.corpse-loot-modal {
    background: var(--game-bg-app);
    border: 1px solid var(--game-border-color);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.entity-card.grid-card {
    animation: fadeIn 0.2s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-align: center;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--game-border-color);
    border-radius: 0;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-width: 0;
    width: 90px;
    height: 90px;
    box-sizing: border-box;
}

/* Sidebar capacity row */
.sidebar-capacity-row {
    display: flex;
    gap: 0.5rem;
}

.entity-card.grid-card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border-color: var(--game-text-highlight);
    z-index: 5;
}

.grid-card .entity-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.grid-card .entity-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Fill the square 1:1 */
}

/* Overlay for text or stats on hover could be improved, 
   but for now we keep the tooltip */



.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.grid-corpse-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    height: 100%;
    width: 100%;
}

/* Specific Border Colors for Grid Cards */
.enemy-card.grid-card {
    border-color: rgba(244, 67, 54, 0.5);
}

.enemy-card.grid-card:hover {
    border-color: rgba(244, 67, 54, 1);
}

.corpse-card.grid-card {
    border-color: rgba(156, 39, 176, 0.5);
}

.corpse-card.grid-card:hover {
    border-color: rgba(156, 39, 176, 1);
}

.npc-card.grid-card {
    border-color: rgba(107, 185, 240, 0.5);
}

.npc-card.grid-card:hover {
    border-color: rgba(107, 185, 240, 1);
}

.item-card.grid-card {
    border-color: rgba(76, 175, 80, 0.5);
}

.item-card.grid-card:hover {
    border-color: rgba(76, 175, 80, 1);
}

.player-card.grid-card {
    border-color: rgba(66, 153, 225, 0.5);
}

.player-card.grid-card:hover {
    border-color: rgba(66, 153, 225, 1);
}

.corpse-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--game-border-color);
    padding-bottom: 0.5rem;
}

.corpse-details-header h4 {
    margin: 0;
    color: var(--game-text-highlight);
    font-size: 1.2rem;
}

.corpse-items-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 5px;
}

/* Scrollbar for loot list */
.corpse-items-list::-webkit-scrollbar {
    width: 6px;
}

.corpse-items-list::-webkit-scrollbar-thumb {
    background: var(--game-border-color);
    border-radius: 3px;
}

.corpse-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--game-border-color);
    padding: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.corpse-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--game-text-highlight);
}

.corpse-item.locked {
    opacity: 0.6;
    border-style: dashed;
}

.corpse-item-info {
    font-size: 0.9rem;
}

.corpse-item-name {
    font-weight: bold;
    color: var(--game-text-primary);
}

.corpse-item-qty {
    font-size: 0.8rem;
    color: #a0aec0;
}

.corpse-item-tool {
    font-size: 0.8rem;
    color: #e53e3e;
    display: flex;
    align-items: center;
    gap: 4px;
}

.corpse-item-tool.has-tool {
    color: #48bb78;
}

.corpse-item-loot-btn {
    background: var(--game-btn-bg);
    border: 1px solid var(--game-btn-border);
    color: var(--game-btn-text);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.corpse-item-loot-btn:hover:not(:disabled) {
    background: var(--game-btn-bg-hover);
}

.corpse-item-loot-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.loot-all-btn {
    background: #2d3748;
    color: white;
    border: 1px solid #4a5568;
    padding: 0.75rem;
    width: 100%;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    margin-top: auto;
    transition: background 0.2s;
}

.loot-all-btn:hover {
    background: #4a5568;
}

.close-btn {
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: #fff;
}

/* Corpse Loot Count - Bottom Right Badge */
.corpse-loot-count {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.8);
    color: #ce93d8;
    font-size: 0.75rem;
    padding: 2px 6px;
    font-weight: bold;
    border: 1px solid rgba(206, 147, 216, 0.3);
    clip-path: var(--game-clip-path-sm);
    z-index: 5;
    pointer-events: none;
    /* Let clicks pass through to card */
}