:root {
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --icon-hover-bg: rgba(255, 255, 255, 0.2);
    --text-color: #ffffff;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
}

#desktop {
    width: 100%;
    height: 100%;
    background: var(--bg-gradient);
    position: relative;
    /* Transition for background image changes */
    transition: background-image 0.5s;
}

#bgCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    /* Force viewport width */
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    /* Let clicks pass through */
}

/* Control Panel */
/* Control Panel (Floating Dock Style) */
#controls {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 35, 0.85);
    padding: 12px 24px;
    border-radius: 24px;
    display: flex;
    gap: 16px;
    z-index: 2000;
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    align-items: center;
    color: #e0e0e0;
}

/* Control Group Containers */
.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.3s;
}

.control-group:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Button & Inputs Global */
.btn,
.control-group select,
.control-group input {
    font-family: 'Poppins', sans-serif;
    /* Assuming font availability or fallback */
    font-size: 14px;
}

/* Primary Actions */
.btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    border: none;
    color: #002;
    padding: 8px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0, 200, 255, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 200, 255, 0.5);
    filter: brightness(1.1);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
    box-shadow: none;
    border: 1px solid #555;
}

/* Special Button: Start (Danger/Action) */
#btnStart {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(255, 65, 108, 0.4);
    padding: 8px 25px;
}

#btnStart:hover {
    box-shadow: 0 6px 15px rgba(255, 65, 108, 0.6);
}

/* File Upload Special */
.btn-file {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.btn-file input[type=file] {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 100%;
    min-height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Select & Input Styling */
select,
input#spawnIntervalInput {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 6px 10px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    transition: border 0.2s;
}

select:hover,
input:hover {
    border-color: rgba(255, 255, 255, 0.5);
}

select option {
    background: #222;
    color: white;
}

input#spawnIntervalInput {
    width: 60px;
    text-align: center;
    font-weight: bold;
}



select:focus {
    outline: none;
}

/* Icons */
.icon {
    position: absolute;
    width: 80px;
    height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    cursor: grab;
    transition: background 0.2s, transform 0.1s, opacity 0.2s;
    user-select: none;
}

.icon:active {
    cursor: grabbing;
}

.icon:hover {
    background: var(--icon-hover-bg);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.icon-img {
    font-size: 40px;
    margin-bottom: 5px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.icon-label {
    color: var(--text-color);
    font-size: 12px;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

/* Taskbar */
#taskbar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding-left: 10px;
}

.start-btn {
    font-size: 24px;
    padding: 5px 10px;
    cursor: pointer;
    transition: transform 0.1s;
}

.start-btn:hover {
    transform: scale(1.1);
}

/* Character Container */
.character-instance {
    position: absolute;
    bottom: 15%;
    left: -150px;
    width: 0;
    height: 0;
    z-index: 100;
    transition: left 0.1s linear, top 0.1s linear;
}

/* === Human Skin === */
.skin-human .head {
    width: 20px;
    height: 20px;
    background: #FFD700;
    border: 2px solid #000;
    border-radius: 50%;
    position: absolute;
    top: -80px;
    left: 10px;
    z-index: 2;
}

.skin-human .body {
    width: 14px;
    height: 30px;
    background: #333;
    position: absolute;
    top: -58px;
    left: 13px;
    z-index: 1;
}

.skin-human .arm,
.skin-human .leg {
    width: 6px;
    height: 25px;
    background: #333;
    position: absolute;
    transform-origin: top center;
}

.skin-human .left-arm {
    top: -55px;
    left: 8px;
}

.skin-human .right-arm {
    top: -55px;
    left: 26px;
}

.skin-human .left-leg {
    top: -30px;
    left: 13px;
}

.skin-human .right-leg {
    top: -30px;
    left: 21px;
}

.skin-human .hammer {
    position: absolute;
    font-size: 30px;
    top: -90px;
    left: 15px;
    transform-origin: bottom left;
    transform: rotate(0deg);
    display: none;
}

/* Human Animations */
.skin-human.walking .left-leg {
    animation: swing 0.5s infinite ease-in-out alternate;
}

.skin-human.walking .right-leg {
    animation: swing 0.5s infinite ease-in-out alternate-reverse;
}

.skin-human.walking .left-arm {
    animation: swing 0.5s infinite ease-in-out alternate-reverse;
}

.skin-human.walking .right-arm {
    animation: swing 0.5s infinite ease-in-out alternate;
}

.skin-human.attacking .right-arm {
    transform: rotate(-130deg);
    transition: transform 0.2s;
}

.skin-human.attacking .hammer {
    display: block;
    animation: smash 0.4s forwards;
}

@keyframes swing {
    from {
        transform: rotate(-30deg);
    }

    to {
        transform: rotate(30deg);
    }
}

@keyframes smash {
    0% {
        transform: rotate(-45deg);
    }

    50% {
        transform: rotate(-45deg);
    }

    100% {
        transform: rotate(-130deg);
    }
}

/* === Snake Skin === */
.skin-snake {
    width: 60px;
    /* Container size */
    height: 30px;
}

.skin-snake .snake-body-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 5px;
    z-index: 1;
}

.skin-snake .snake-body {
    width: 100%;
    height: 16px;
    background: #4caf50;
    border: 2px solid #2e7d32;
    border-radius: 10px;
    position: absolute;
    top: 0;
    left: -10px;
    transition: transform 0.3s;
}

.skin-snake .snake-lump {
    width: 20px;
    height: 20px;
    background: #388e3c;
    border-radius: 50%;
    position: absolute;
    top: -2px;
    left: 10px;
    opacity: 0;
    transform: scale(0);
}

.skin-snake .snake-head-group {
    position: absolute;
    top: -5px;
    right: -15px;
    width: 35px;
    height: 30px;
    z-index: 2;
    transform-origin: left center;
}

.skin-snake .snake-head-upper,
.skin-snake .snake-head-lower {
    width: 30px;
    height: 12px;
    background: #2e7d32;
    position: absolute;
    left: 0;
    border-radius: 10px;
    transition: transform 0.1s;
}

.skin-snake .snake-head-upper {
    top: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    transform-origin: bottom left;
}

.skin-snake .snake-head-lower {
    top: 12px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    transform-origin: top left;
}

.skin-snake .snake-tongue {
    width: 15px;
    height: 4px;
    background: red;
    position: absolute;
    top: 11px;
    right: -10px;
    display: none;
    z-index: -1;
}

/* Snake Animations */
.skin-snake.walking .snake-body {
    animation: slither 0.5s infinite linear;
}

@keyframes slither {
    0% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(0.85);
    }

    100% {
        transform: scaleY(1);
    }
}

.skin-snake.attacking .snake-head-upper {
    transform: rotate(-45deg);
}

.skin-snake.attacking .snake-head-lower {
    transform: rotate(45deg);
}

.skin-snake.attacking .snake-tongue {
    display: block;
    animation: tongue-flick 0.3s infinite;
}

@keyframes tongue-flick {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(5px);
    }
}

.skin-snake.swallowing .snake-lump {
    animation: swallow-lump 1s forwards;
}

@keyframes swallow-lump {
    0% {
        opacity: 1;
        transform: scale(1) translateX(20px);
    }

    100% {
        opacity: 0;
        transform: scale(0.5) translateX(-20px);
    }
}

/* === Animal Skin === */
.skin-animal .animal-body {
    width: 50px;
    height: 30px;
    background: #795548;
    border-radius: 15px;
    position: absolute;
    top: -30px;
    left: 0;
}

.skin-animal .animal-head {
    width: 30px;
    height: 28px;
    background: #5d4037;
    border-radius: 40%;
    position: absolute;
    top: -8px;
    right: -12px;
}

.skin-animal .animal-ear {
    width: 8px;
    height: 8px;
    background: #3e2723;
    border-radius: 50%;
    position: absolute;
    top: -4px;
}

.skin-animal .animal-ear.left {
    left: 2px;
}

.skin-animal .animal-ear.right {
    right: 5px;
}

.skin-animal .animal-snout {
    width: 12px;
    height: 8px;
    background: #000;
    border-radius: 50%;
    position: absolute;
    bottom: 5px;
    right: -2px;
}

.skin-animal .animal-leg {
    width: 10px;
    height: 20px;
    background: #5d4037;
    position: absolute;
    top: 20px;
}

.skin-animal .leg-fl {
    left: 5px;
}

.skin-animal .leg-fr {
    right: 5px;
}

.skin-animal .leg-bl {
    left: 5px;
    z-index: -1;
    opacity: 0.8;
    transform: translateY(-2px);
}

.skin-animal .leg-br {
    right: 5px;
    z-index: -1;
    opacity: 0.8;
    transform: translateY(-2px);
}

.skin-animal .animal-claw {
    display: none;
    position: absolute;
    right: -20px;
    top: 5px;
    font-size: 24px;
    color: white;
}

/* Animal Animations */
.skin-animal.walking .animal-leg {
    animation: run 0.2s infinite alternate;
}

.skin-animal.walking .animal-head {
    animation: bob 0.4s infinite alternate;
}

@keyframes bob {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(2px);
    }
}

.skin-animal.attacking {
    animation: pounce 0.5s;
}

@keyframes pounce {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.1) translateY(-15px);
    }

    100% {
        transform: scale(1);
    }
}

.skin-animal.eating .animal-head {
    animation: chew 0.2s infinite;
}

@keyframes chew {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1) rotate(5deg);
    }

    100% {
        transform: scale(0.9) rotate(-5deg);
    }
}

/* Particles */
.particle {
    position: absolute;
    width: 5px;
    height: 5px;
    background: white;
    pointer-events: none;
    border-radius: 50%;
    z-index: 200;
}