:root {
    /* Colors */
    --bg-desktop: #008080;
    --bg-window: #c0c0c0;
    --bg-panel: #dcdcdc;
    --bg-input: #fff;
    --bg-canvas: #f2f2f2;
    --bg-title-start: #000080;
    --bg-title-end: #1084d0;

    --text-main: #000;
    --text-title: #fff;
    --text-header: #000080;

    --border-light: #fff;
    --border-dark: #808080;
    --border-shadow: #000;

    /* Skin Tones - Unified */
    --skin-base: #ffd6a5;
    --skin-shadow: #d4a574;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 20px;
}

body {
    margin: 0;
    padding: 0;
    /* Remove padding */
    background: var(--bg-desktop);
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    /* Prevent scroll */
}

.window {
    width: 900px;
    max-width: 100%;
    background: var(--bg-window);
    border: 3px outset var(--border-light);
    box-shadow: 5px 5px 0 var(--border-shadow);
    box-sizing: border-box;
    /* Ensure borders don't cause overflow */
}

/* ... existing styles ... */

.window.minimized {
    display: none !important;
    /* Override inline display: block */
}

.title-bar {
    background: linear-gradient(to bottom, var(--bg-title-start), var(--bg-title-end));
    color: var(--text-title);
    padding: 4px 6px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.title-buttons span {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    background: var(--bg-window);
    border: 2px outset var(--border-light);
    text-align: center;
    line-height: 14px;
    font-size: 11px;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
}

.title-buttons span:active {
    border-style: inset;
}

.content {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
}

.panel {
    flex: 1;
    background: var(--bg-panel);
    border: 2px inset var(--border-dark);
    padding: var(--spacing-md);
    font-size: 13px;
}

h2 {
    margin: 0 0 var(--spacing-sm);
    font-size: 16px;
    color: var(--text-header);
}

/* Character Canvas */
.character-canvas {
    width: 250px;
    height: 350px;
    margin: 10px auto;
    position: relative;
    background: var(--bg-canvas);
    border: 2px inset var(--border-dark);
    overflow: hidden;
    image-rendering: pixelated;
}

.piece {
    position: absolute;
    image-rendering: pixelated;
}

/* Base Body Parts - Centered using transform */
.head {
    width: 50%;
    height: 25%;
    left: 50%;
    transform: translateX(-50%);
    top: 5%;
    background: var(--skin-base);
    /* Hardcoded */
    border-radius: 50%;
    border: 2px solid var(--skin-shadow);
    /* Hardcoded */
    z-index: 2;
}

.eye {
    width: 8%;
    height: 4%;
    top: 16%;
    background: #000;
    border-radius: 50%;
    z-index: 3;
}

/* Eyes are relative to canvas, need to be centered relative to head (which is at 50%) */
/* Head width is 125px (50% of 250px). Center is 125px. */
/* Eye width is 20px (8% of 250px). */
/* Left eye center should be around -15% from center? */
.eye.left {
    left: 40%;
    transform: translateX(-50%);
}

.eye.right {
    left: 60%;
    transform: translateX(-50%);
}

.mouth {
    width: 16%;
    height: 3%;
    left: 50%;
    transform: translateX(-50%);
    top: 24%;
    background: var(--skin-shadow);
    border-radius: 40%;
    z-index: 3;
}

.neck {
    width: 14%;
    height: 6%;
    left: 50%;
    transform: translateX(-50%);
    top: 28%;
    background: var(--skin-base);
    border-radius: 3px;
    border: 2px solid var(--skin-shadow);
    z-index: 1;
}

.body {
    width: 45%;
    height: 35%;
    left: 50%;
    transform: translateX(-50%);
    top: 34%;
    background: var(--skin-base);
    border-radius: 4px;
    border: 2px solid var(--skin-shadow);
    box-sizing: border-box;
    z-index: 1;
}

.arm {
    width: 10%;
    height: 30%;
    top: 38%;
    background: var(--skin-base);
    border-radius: 4px;
    border: 2px solid var(--skin-shadow);
    box-sizing: border-box;
    z-index: 1;
}

.arm.left {
    left: calc(50% - 22.5% - 10% - 0.5%);
}

.arm.right {
    left: calc(50% + 22.5% + 0.5%);
}

.leg {
    width: 18%;
    height: 30%;
    top: 68%;
    background: var(--skin-base);
    border-radius: 3px;
    border: 2px solid var(--skin-shadow);
    box-sizing: border-box;
    z-index: 1;
}

.leg.left {
    left: 30%;
}

.leg.right {
    left: 52%;
}

/* Clothing Layers */
.layer {
    display: none;
}

#hairLayer {
    z-index: 2;
}

#topLayer {
    z-index: 4;
}

#bottomLayer {
    z-index: 4;
}

#shoesLayer {
    z-index: 4;
}

#accessoryLayer {
    z-index: 5;
}

/* Item Specific Styles */

/* Hair */
.shape-short {
    width: 58%;
    height: 12%;
    left: 50%;
    transform: translateX(-50%);
    top: 3%;
    border-radius: 50% 50% 20% 20%;
    border: 2px solid rgba(0, 0, 0, 0.4);
    background: var(--item-color);
}

.shape-long {
    width: 65%;
    height: 35%;
    left: 50%;
    transform: translateX(-50%);
    top: 3%;
    border-radius: 40% 40% 0 0;
    border: 2px solid rgba(0, 0, 0, 0.4);
    background: var(--item-color);
    z-index: 0 !important;
    /* Behind neck (z-index: 1) */
}

.shape-bob {
    width: 68%;
    /* Wider */
    height: 22%;
    left: 50%;
    transform: translateX(-50%);
    top: 3%;
    border-radius: 50% 50% 20% 20%;
    /* More rounded bottom */
    border: 2px solid rgba(0, 0, 0, 0.4);
    background: var(--item-color);
    /* Add a pseudo-element for the "bangs" or side framing if needed, 
       but for now just making it wider and better shaped */
    clip-path: polygon(0 0, 100% 0, 100% 100%, 90% 90%, 10% 90%, 0 100%);
}

.shape-spiky {
    width: 60%;
    height: 18%;
    left: 50%;
    transform: translateX(-50%);
    top: -5%;
    border-radius: 10% 10% 40% 40%;
    border: 2px solid rgba(0, 0, 0, 0.4);
    background: var(--item-color);
    /* Irregular spikes */
    clip-path: polygon(0% 100%,
            5% 40%, 15% 100%,
            25% 20%, 35% 100%,
            50% 0%,
            65% 100%, 75% 20%,
            85% 100%, 95% 40%,
            100% 100%);
}

/* Tops */
.shape-tshirt {
    width: 45%;
    height: 28%;
    left: 50%;
    transform: translateX(-50%);
    top: 34%;
    border-radius: 8px 8px 0 0;
    border: 2px solid rgba(0, 0, 0, 0.3);
    background: var(--item-color);
    box-sizing: border-box;
}

/* T-Shirt Sleeves */
.shape-tshirt::before,
.shape-tshirt::after {
    content: '';
    position: absolute;
    top: 14%;
    /* Aligns with arm top (38% vs 34%) */
    width: 24%;
    /* Approx 10% of canvas width relative to 45% body width */
    height: 40%;
    /* Short sleeves */
    background: var(--item-color);
    border: 2px solid rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    z-index: -1;
    /* Behind torso */
}

.shape-tshirt::before {
    left: -24%;
    /* Positioned over left arm */
    border-right: none;
    border-radius: 4px 0 0 4px;
}

.shape-tshirt::after {
    right: -24%;
    /* Positioned over right arm */
    border-left: none;
    border-radius: 0 4px 4px 0;
}

.shape-longsleeve {
    width: 45%;
    height: 28%;
    left: 50%;
    transform: translateX(-50%);
    top: 34%;
    border-radius: 8px 8px 0 0;
    border: 2px solid rgba(0, 0, 0, 0.3);
    background: var(--item-color);
    box-sizing: border-box;
}

/* Long Sleeves */
.shape-longsleeve::before,
.shape-longsleeve::after {
    content: '';
    position: absolute;
    top: 14%;
    width: 24%;
    height: 110%;
    /* Covers full arm length */
    background: var(--item-color);
    border: 2px solid rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    z-index: -1;
}

.shape-longsleeve::before {
    left: -24%;
    border-right: none;
    border-radius: 4px 0 0 4px;
}

.shape-longsleeve::after {
    right: -24%;
    border-left: none;
    border-radius: 0 4px 4px 0;
}

/* Long sleeve needs to cover arms, but arms are separate divs.
   We can simulate sleeves by adding pseudo-elements to the top layer
   or by just coloring the arms (which we can't easily do from here).
   For now, just style the torso part. */

.shape-tank {
    width: 40%;
    height: 28%;
    left: 50%;
    transform: translateX(-50%);
    top: 34%;
    border-radius: 4px 4px 0 0;
    border: 2px solid rgba(0, 0, 0, 0.3);
    background: var(--item-color);
    box-sizing: border-box;
}

.shape-dress {
    width: 45%;
    height: 28%;
    left: 50%;
    transform: translateX(-50%);
    top: 34%;
    border-radius: 8px 8px 0 0;
    border: 2px solid rgba(0, 0, 0, 0.3);
    background: var(--item-color);
    box-sizing: border-box;
    /* Collar */
    background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.1) 10%, transparent 10%);
}

/* Bottoms */
.shape-pants,
.shape-jeans {
    width: 45%;
    height: 30%;
    top: 62%;
    left: 50%;
    transform: translateX(-50%);
    border: 2px solid rgba(0, 0, 0, 0.3);
    background: var(--item-color);
    box-sizing: border-box;
    border-radius: 0 0 6px 6px;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 52% 100%, 52% 40%, 48% 40%, 48% 100%, 0 100%);
}

.shape-shorts {
    width: 45%;
    height: 18%;
    top: 62%;
    left: 50%;
    transform: translateX(-50%);
    border: 2px solid rgba(0, 0, 0, 0.3);
    background: var(--item-color);
    box-sizing: border-box;
    border-radius: 0 0 8px 8px;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 52% 100%, 52% 40%, 48% 40%, 48% 100%, 0 100%);
}

.shape-skirt {
    width: 48%;
    height: 22%;
    top: 62%;
    left: 50%;
    transform: translateX(-50%);
    border: 2px solid rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    border-radius: 0 0 10px 10px;
    background:
        repeating-linear-gradient(90deg,
            transparent,
            transparent 10px,
            rgba(0, 0, 0, 0.1) 10px,
            rgba(0, 0, 0, 0.1) 12px),
        var(--item-color);
    clip-path: polygon(0 0, 100% 0, 95% 100%, 5% 100%);
}

/* Shoes */
.shape-sneakers {
    width: 45%;
    height: 8%;
    left: 50%;
    transform: translateX(-50%);
    top: 92%;
    border-radius: 4px;
    background:
        radial-gradient(circle at 50% 120%, white 40%, transparent 41%),
        linear-gradient(to bottom, transparent 20%, rgba(0, 0, 0, 0.1) 20%, rgba(0, 0, 0, 0.1) 40%, transparent 40%),
        var(--item-color);
    clip-path: polygon(0 0, 45% 0, 45% 100%, 0 100%, 0 0, 55% 0, 100% 0, 100% 100%, 55% 100%, 55% 0, 0 0);
}

.shape-boots {
    width: 45%;
    height: 12%;
    left: 50%;
    transform: translateX(-50%);
    top: 88%;
    background: linear-gradient(to bottom, var(--item-color) 70%, #333 70%);
    clip-path: polygon(0 0, 45% 0, 45% 100%, 0 100%, 0 0, 55% 0, 100% 0, 100% 100%, 55% 100%, 55% 0, 0 0);
}

.shape-dress {
    width: 45%;
    height: 8%;
    left: 50%;
    transform: translateX(-50%);
    top: 92%;
    background:
        linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.2) 45%, transparent 50%),
        var(--item-color);
    border-radius: 2px;
    clip-path: polygon(0 20%, 45% 0, 45% 100%, 0 100%, 0 20%, 55% 0, 100% 20%, 100% 100%, 55% 100%, 55% 0, 0 20%);
}

/* Accessories */
.shape-hat {
    width: 55%;
    height: 10%;
    left: 50%;
    transform: translateX(-50%);
    top: 1%;
    border-radius: 50% 50% 20% 20%;
    border: 2px solid rgba(0, 0, 0, 0.5);
    background: var(--item-color);
}

.shape-scarf {
    width: 22%;
    height: 12%;
    left: 50%;
    transform: translateX(-50%);
    top: 30%;
    border-radius: 40%;
    border: 2px solid rgba(0, 0, 0, 0.4);
    background: var(--item-color);
}

.shape-glasses {
    width: 38%;
    height: 6%;
    left: 50%;
    transform: translateX(-50%);
    top: 16%;
    background: transparent;
    border: none;
    border-radius: 0;
    /* Bridge */
    background: linear-gradient(to right, transparent 42%, #333 42%, #333 58%, transparent 58%);
    background-size: 100% 2px;
    background-repeat: no-repeat;
    background-position: center;
}

.shape-glasses::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 42%;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid #333;
    border-radius: 50%;
    box-sizing: border-box;
}

.shape-glasses::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 42%;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid #333;
    border-radius: 50%;
    box-sizing: border-box;
}

/* Controls */
input {
    width: 90%;
    padding: 5px;
    border: 2px inset var(--border-dark);
    background: var(--bg-input);
    margin-top: var(--spacing-sm);
    font-size: 13px;
    font-family: inherit;
}

.name-display {
    margin-top: var(--spacing-sm);
    font-weight: bold;
    color: var(--text-header);
    min-height: 20px;
    text-align: center;
}

button {
    margin-top: 10px;
    padding: 6px 14px;
    border: 2px outset var(--border-light);
    background: var(--bg-window);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
}

button:active {
    border-style: inset;
}

/* Wardrobe */
.category {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm);
    border: 2px outset var(--border-light);
    background: #e0e0e0;
}

.category h3 {
    margin: 0 0 6px;
    font-size: 13px;
    color: var(--text-header);
}

.items {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.items.colors {
    display: none;
    /* Hidden, replaced by palette container inside shapes/items */
}

.item.palette-container {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 2px;
    padding: 2px;
    background: #d0d0d0;
    cursor: default;
}

.item.palette-container:hover {
    background: #d0d0d0;
    /* No hover effect on container */
    filter: none;
    /* Remove brightness filter */
}

.item.palette-container:active {
    border-style: outset;
    /* No active effect on container */
}

.mini-swatch {
    width: 17px;
    height: 17px;
    border: 1px solid rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    cursor: pointer;
}

.mini-swatch:hover {
    transform: scale(1.1);
    z-index: 1;
    border-color: #fff;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.mini-swatch.selected {
    border: 2px solid #000;
    box-shadow: inset 0 0 0 1px #fff;
    z-index: 2;
}

.item {
    width: 65px;
    height: 65px;
    background: #bbb;
    border: 2px outset var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    text-align: center;
    padding: 2px;
    box-sizing: border-box;
    user-select: none;
}

.item:hover {
    filter: brightness(1.1);
}

.item:active {
    border-style: inset;
}

.item.shape-item.selected {
    border: 2px inset var(--border-dark);
    background: #999;
}

.status-bar {
    border-top: 2px inset var(--border-dark);
    padding: 4px 8px;
    font-size: 11px;
    background: var(--bg-window);
    display: flex;
    justify-content: space-between;
}

@media (max-width: 768px) {
    .content {
        flex-direction: column;
    }
}

/* Room Styles */
.room {
    position: relative;
    width: 100%;
    height: 500px;
    background: #333;
    border: 2px inset var(--border-dark);
    overflow: hidden;
    display: none;
    /* Toggled by JS */
}

.room-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(to bottom, #dcdcdc 0%, #dcdcdc 70%, #8b4513 70%, #8b4513 100%);
    /* Add some perspective lines for the floor */
    background-image:
        linear-gradient(to bottom, #dcdcdc 0%, #dcdcdc 70%, transparent 70%),
        repeating-linear-gradient(90deg, transparent 0, transparent 40px, rgba(0, 0, 0, 0.1) 40px, rgba(0, 0, 0, 0.1) 42px),
        linear-gradient(to bottom, transparent 70%, #8b4513 70%);
}

.character-container {
    position: absolute;
    bottom: 30px;
    /* On the floor */
    left: 50%;
    width: 150px;
    /* Smaller scale for room */
    height: 210px;
    transform: translateX(-50%);
    transition: left 0.1s linear;
}

/* Reuse character canvas styles but reset some positioning */
.character-container .character-canvas {
    width: 100%;
    height: 100%;
    margin: 0;
    border: none;
    background: transparent;
}

/* Walking Animation */
@keyframes bob {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.walking .character-canvas {
    animation: bob 0.3s infinite;
}

/* Direction Flip */
.facing-left .character-canvas {
    transform: scaleX(-1);
}

.controls-hint {
    position: absolute;
    top: 10px;
    left: 10px;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

/* Desktop Environment */
body {
    overflow: hidden;
    /* Prevent scroll */
}

#desktop-icons {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 0;
}

.desktop-icon {
    width: 80px;
    text-align: center;
    cursor: pointer;
    color: #fff;
    text-shadow: 1px 1px 1px #000;
}

.desktop-icon .icon-img {
    font-size: 32px;
    margin-bottom: 4px;
}

.desktop-icon:hover {
    background: rgba(0, 0, 0, 0.2);
    border: 1px dotted #fff;
}

/* Window Positioning */
.window {
    width: 900px;
    max-width: 100%;
    background: var(--bg-window);
    border: 3px outset var(--border-light);
    box-shadow: 5px 5px 0 var(--border-shadow);
    box-sizing: border-box;
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.window.active {
    z-index: 20;
}

.window.dragging {
    user-select: none;
    opacity: 0.9;
}

.window.minimized {
    display: none !important;
}

.window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100% - 34px) !important;
    /* Minus taskbar */
    transform: none !important;
    border: none;
    box-shadow: none;
}

#taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30px;
    background: #c0c0c0;
    border-top: 2px outset #fff;
    display: flex;
    align-items: center;
    padding: 2px;
    box-sizing: border-box;
    z-index: 1000;
    user-select: none;
}

.taskbar-item {
    width: 160px;
    height: 22px;
    background: #c0c0c0;
    border: 2px outset #fff;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
    font-size: 12px;
    cursor: pointer;
    margin-right: 4px;
}

.taskbar-item.active {
    background: #dcdcdc;
    border-style: inset;
    font-weight: bold;
}

.taskbar-clock {
    margin-left: auto;
    padding: 2px 8px;
    border: 2px inset #808080;
    background: #c0c0c0;
    font-size: 12px;
    margin-right: 2px;
}

/* Furniture */
.furniture {
    position: absolute;
    image-rendering: pixelated;
    z-index: 1;
    /* Behind character */
}

/* Character Container needs higher z-index */
.character-container {
    z-index: 10;
}

/* Picture */
.furniture.picture {
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 60px;
}

.picture-frame {
    width: 100%;
    height: 100%;
    background: #8b4513;
    border: 2px outset #a0522d;
    box-sizing: border-box;
    padding: 4px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
}

.picture-content {
    width: 100%;
    height: 100%;
    background: #87ceeb;
    /* Sky blue */
    border: 1px inset #5c3317;
    position: relative;
    overflow: hidden;
}

.picture-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: #228b22;
    /* Grass green */
}

.picture-content::before {
    content: '';
    position: absolute;
    top: 10%;
    right: 10%;
    width: 10px;
    height: 10px;
    background: #ffd700;
    /* Sun */
    border-radius: 50%;
}

/* Lamp */
.furniture.lamp {
    bottom: 15%;
    right: 15%;
    width: 40px;
    height: 160px;
    /* Taller */
    z-index: 5;
    /* Behind character */
}

.lamp-shade {
    width: 40px;
    height: 30px;
    background: #fff;
    border: 1px solid #ccc;
    border-bottom: 5px solid #e0e0e0;
    border-radius: 5px 5px 0 0;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
}

.lamp-stand {
    width: 4px;
    height: 120px;
    /* Taller */
    background: #333;
    position: absolute;
    top: 30px;
    left: 18px;
    z-index: 1;
}

.lamp-base {
    width: 30px;
    height: 10px;
    background: #333;
    border-radius: 50%;
    position: absolute;
    bottom: 0;
    left: 5px;
    z-index: 1;
}

/* Couch */
.furniture.couch {
    bottom: 15%;
    left: 10%;
    width: 180px;
    /* Bigger */
    height: 90px;
    /* Bigger */
    z-index: 5;
}

.couch-back {
    width: 100%;
    height: 50px;
    /* Bigger */
    background: #800000;
    /* Maroon */
    border: 2px solid #500000;
    border-radius: 5px 5px 0 0;
    position: absolute;
    top: 0;
    left: 0;
}

.couch-seat {
    width: 100%;
    height: 40px;
    /* Bigger */
    background: #a52a2a;
    /* Brown */
    border: 2px solid #500000;
    border-top: none;
    position: absolute;
    bottom: 0;
    left: 0;
}

.couch-arm {
    width: 25px;
    /* Bigger */
    height: 50px;
    /* Bigger */
    background: #800000;
    border: 2px solid #500000;
    border-radius: 5px;
    position: absolute;
    bottom: 0;
}

.couch-arm.left {
    left: -12px;
}

.couch-arm.right {
    right: -12px;
}