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

body {
    font-family: 'Nunito', sans-serif;
    background-color: #1a0a0a; /* Horror background */
    overflow: hidden;
    user-select: none; /* Prevent text selection while dragging */
}

#game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Room Area */
#room-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Budget UI */
#budget-ui {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #2d0000;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 20px;
    font-weight: bold;
    color: #ff4d4d;
    box-shadow: 0 4px 6px rgba(255,0,0,0.2);
    z-index: 100;
}

/* Action Buttons */
#action-buttons {
    position: absolute;
    top: 70px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.btn-action {
    background: #5c0000;
    color: #ffcccc;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
    transition: transform 0.2s, background 0.2s;
    font-family: 'Nunito', sans-serif;
    text-align: right;
}

.btn-action:hover {
    transform: translateY(-2px);
    background: #8a0000;
}

#btn-screenshot {
    background: #004000;
}

#btn-screenshot:hover {
    background: #006600;
}

#btn-reset {
    background: #400000;
}

#btn-reset:hover {
    background: #660000;
}

/* Toast Notification */
#toast {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff5252;
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#toast.show {
    opacity: 1;
}

/* Client UI */
#client-ui {
    position: absolute;
    bottom: 140px; /* Above inventory */
    right: 0;
    width: 400px;
    z-index: 50; /* Below budget UI but above room */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none; /* Let clicks pass through if needed */
}

#client-img-container {
    width: 350px;
    height: 200px;
    /* Red glowing border effect */
    background: #ff0000;
    clip-path: polygon(15% 0, 100% 0, 100% 100%, 0 100%);
    padding-left: 5px; /* Creates the left border */
    padding-top: 5px;  /* Creates the top border */
    position: relative;
    filter: drop-shadow(0 0 8px #ff0000);
}

#client-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    clip-path: polygon(15% 0, 100% 0, 100% 100%, 0% 100%);
    background-color: #000;
}

#client-dialog-wrapper {
    background: #b30000;
    color: white;
    padding: 15px 20px 15px 40px;
    font-size: 18px;
    text-align: right;
    clip-path: polygon(8% 0, 100% 0, 100% 100%, 0% 100%);
    margin-top: -30px; /* Overlap the image */
    z-index: 10;
    width: 380px;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.8));
    position: relative;
}

#room {
    position: relative;
    /* Grid background is created by JS dynamically to support irregular shapes */
}

.floor-cell {
    position: absolute;
    width: 64px;
    height: 64px;
    background-color: #221111;
    border: 1px dashed rgba(255, 0, 0, 0.3);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
    border-radius: 4px; /* Slightly rounded floor tiles */
    background-size: cover;
    background-position: center;
}

/* Category Tabs */
#category-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.category-tab {
    padding: 8px 16px;
    background: #331111;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    color: #ff9999;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    transition: all 0.2s;
    border: 2px solid transparent;
}

.category-tab:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.7);
}

.category-tab.active {
    background: #8a0000;
    color: white;
    border-color: #ff4d4d;
}

/* Inventory UI */
#inventory {
    height: 120px;
    background: rgba(20, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    border-top: 2px solid #5c0000;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 0 20px;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.5);
}

.item-box {
    width: 80px;
    height: 80px;
    background: #222;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5), inset 0 2px 4px rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.item-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(255,0,0,0.2);
    border-color: #8a0000;
}

.item-box.selected-brush {
    border-color: #ff0000;
    box-shadow: 0 0 10px #ff0000;
    transform: scale(1.05);
}

.item-box.empty {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.item-box img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
    pointer-events: none; /* Let the box handle clicks */
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.item-count {
    position: absolute;
    bottom: -8px;
    right: -8px;
    background-color: #8a0000;
    color: white;
    font-size: 14px;
    font-weight: bold;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.item-name {
    position: absolute;
    top: -25px;
    font-size: 12px;
    color: #ff9999;
    font-weight: bold;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    background: rgba(40,0,0,0.9);
    padding: 2px 8px;
    border-radius: 12px;
}

.item-price {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 10px;
    font-weight: bold;
    color: #ff4d4d;
    background: rgba(0,0,0,0.9);
    padding: 2px 4px;
    border-radius: 4px;
    z-index: 10;
}

.item-box:hover .item-name {
    opacity: 1;
}

/* Dragging state */
.drag-ghost {
    position: fixed;
    pointer-events: none; /* Let mouse events pass through to underlying elements */
    z-index: 1000;
    opacity: 0.6; /* Lower opacity as requested */
    transform-origin: center center;
    transition: transform 0.1s ease-out; /* Smooth rotation */
}

.drag-ghost img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.3));
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Placed Items in Room */
.placed-item {
    position: absolute;
    z-index: 10;
    /* transition: top 0.2s, left 0.2s; Snapping animation */
}

.placed-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(2px 5px 5px rgba(0,0,0,0.2));
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 8px;
    pointer-events: none;
    z-index: 2;
}

/* Animations */
@keyframes squish {
    0% { transform: scale(1, 1); }
    25% { transform: scale(1.2, 0.8); }
    50% { transform: scale(0.9, 1.1); }
    75% { transform: scale(1.05, 0.95); }
    100% { transform: scale(1, 1); }
}

.anim-squish {
    animation: squish 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes squishFloor {
    0% { transform: scale(1); }
    50% { transform: scale(0.8); }
    100% { transform: scale(1); }
}

.anim-squish-floor {
    animation: squishFloor 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Particle VFX */
#vfx-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.star-particle {
    position: absolute;
    width: 15px;
    height: 15px;
    background: #ff1a1a;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: star-pop 0.8s ease-out forwards;
}

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