body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    overflow: hidden;
    font-family: sans-serif;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    transition: background-color 1s ease;
}

#game-container.world-forest { background-color: #ffffff; }
#game-container.world-grasslands { background-color: #d4f8d4; }
#game-container.world-caves { background-color: #222222; }
#game-container.world-deep_caves { background-color: #0a0a0a; }



.world-option {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 12px;
    padding: 10px;
    border: 2px solid #eee;
    border-radius: 4px;
}

.world-option.active {
    border-color: #44cc44;
    background: #f0fff0;
}

.world-option.locked {
    opacity: 0.6;
    background: #f9f9f9;
}

.world-option button {
    padding: 8px;
    background: #44cc44;
    color: white;
    border: 2px solid #000;
    font-weight: bold;
    cursor: pointer;
}

.world-option button:disabled {
    background: #888;
    cursor: not-allowed;
}

.world-name {
    font-weight: bold;
    font-size: 14px;
}

.world-requirement {
    font-size: 11px;
    color: #666;
}

.decoration {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.tree {
    width: 40px;
    height: 60px;
    background: #8b4513;
    bottom: 0;
}
.tree::after {
    content: '';
    position: absolute;
    top: -40px;
    left: -20px;
    width: 80px;
    height: 80px;
    background: #228b22;
    border-radius: 50%;
}

.grass {
    width: 20px;
    height: 10px;
    background: #32cd32;
    bottom: 0;
    border-radius: 5px 5px 0 0;
}

.dripstone {
    width: 20px;
    height: 30px;
    background: #555;
    clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
}

.boulder {
    width: 30px;
    height: 25px;
    background: #666;
    border-radius: 40% 60% 50% 50%;
    border: 1px solid #333;
}

.sharp-rock {
    width: 20px;
    height: 15px;
    background: #444;
    clip-path: polygon(0% 100%, 50% 0%, 100% 100%);
}

.torch {
    width: 4px;
    height: 12px;
    background: #5c3c10;
    border-radius: 1px;
}
.torch::after {
    content: '';
    position: absolute;
    top: -8px;
    left: -2px;
    width: 8px;
    height: 8px;
    background: #ffaa00;
    border-radius: 50% 50% 20% 20%;
    box-shadow: 0 0 45px 25px rgba(255, 170, 0, 0.6), 0 0 15px 5px rgba(255, 255, 255, 0.3);
    animation: flicker 0.1s infinite alternate;
}

@keyframes flicker {
    from { transform: scale(1); opacity: 0.9; }
    to { transform: scale(1.1); opacity: 1; }
}

.crystal {
    width: 12px;
    height: 20px;
    background: #bc13fe;
    clip-path: polygon(50% 0%, 100% 20%, 100% 80%, 50% 100%, 0% 80%, 0% 20%);
    filter: drop-shadow(0 0 5px #bc13fe);
}

.mineshaft {
    width: 60px;
    height: 50px;
    border-left: 6px solid #4a3121;
    border-right: 6px solid #4a3121;
    border-top: 6px solid #4a3121;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-sizing: border-box;
}

#ui-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.stat-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-label {
    width: 35px;
    font-size: 12px;
    font-weight: bold;
    color: #333;
}

.bar-bg {
    width: 150px;
    height: 12px;
    background: #eee;
    border: 2px solid #000;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    font-weight: bold;
    color: #000;
    pointer-events: none;
    white-space: nowrap;
    text-shadow: 0px 0px 2px rgba(255,255,255,0.8);
}

.bar-fill {
    height: 100%;
    width: 100%;
    transition: width 0.1s ease-out;
}

.bar-fill.hp { background-color: #44cc44; }
.bar-fill.stm { background-color: #ffcc00; }
.bar-fill.exp { background-color: #9933ff; }

.sp-badge {
    background: #ffcc00;
    color: #000;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    border: 1px solid #000;
    display: none;
}

#buff-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    pointer-events: none;
}

.buff-badge {
    background: #00ffff;
    color: #000;
    font-size: 10px;
    padding: 3px 6px;
    border: 1px solid #000;
    font-weight: bold;
    display: inline-block;
    animation: pulse 1s infinite alternate;
    white-space: nowrap;
    width: fit-content;
}

.buff-badge.charm-buff {
    background: #ffcc00;
}

@keyframes pulse {
    from { opacity: 0.8; }
    to { opacity: 1; }
}

#menu-buttons {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 101;
    display: flex;
    gap: 10px;
}

#open-menu-btn, #open-travel-btn, #open-inv-btn, #open-craft-btn {
    padding: 6px 10px;
    font-size: 12px;
    background: #fff;
    border: 2px solid #000;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.1);
}

#stat-menu, #travel-menu, #inventory-menu, #crafting-menu, #abilities-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 3px solid #000;
    padding: 20px;
    z-index: 200;
    min-width: 240px;
    box-shadow: 10px 10px 0px rgba(0,0,0,0.1);
    max-height: 80vh;
    overflow-y: auto;
}

.inventory-item {
    display: flex;
    flex-direction: column;
    padding: 12px 10px;
    border-bottom: 1px solid #eee;
    gap: 8px;
}

.inventory-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.sell-section {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f9f9f9;
    padding: 6px;
    border-radius: 4px;
}

.sell-input {
    width: 45px;
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 12px;
}

.sell-btn {
    padding: 4px 10px;
    font-size: 11px;
    background: #ffcc00;
    color: #000;
    border: 1px solid #000;
    cursor: pointer;
    font-weight: bold;
}

.sell-btn:hover {
    background: #e6b800;
}

.equip-btn {
    padding: 4px 8px;
    font-size: 11px;
    background: #fff;
    border: 1px solid #000;
    cursor: pointer;
}

.equip-btn.active {
    background: #44cc44;
    color: white;
}

.craft-item {
    padding: 10px;
    border: 1px solid #eee;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.craft-name { font-weight: bold; }
.craft-desc { font-size: 11px; color: #666; }
.craft-ingredients { font-size: 10px; margin-top: 4px; }
.craft-ingredients span.met { color: #44cc44; }
.craft-ingredients span.unmet { color: #ff4444; }

.craft-item button {
    padding: 6px 12px;
    background: #44cc44;
    color: white;
    border: 1px solid #000;
    cursor: pointer;
}

.craft-item button:disabled {
    background: #eee;
    color: #888;
    cursor: not-allowed;
}

.ability-item {
    padding: 10px;
    border: 1px solid #eee;
    margin-bottom: 10px;
}

.abil-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.abil-cost {
    font-size: 11px;
    color: #9933ff;
    font-weight: bold;
}

.abil-actions {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.abil-actions button {
    flex: 1;
    padding: 6px;
    font-size: 11px;
    cursor: pointer;
}

.buy-abil-btn {
    background: #9933ff;
    color: white;
    border: 1px solid #000;
}

.assign-btn {
    background: #eee;
    color: #333;
    border: 1px solid #000;
}

.assign-btn.active {
    background: #44cc44;
    color: white;
}

.abil-cooldown-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0,0,0,0.6);
    height: 0%;
    pointer-events: none;
    transition: height 0.1s linear;
}

.ability-icon-inner {
    font-size: 14px;
    font-weight: bold;
    color: #ffcc00;
}

.inventory-item:last-child {
    border-bottom: none;
}

.item-name {
    font-weight: bold;
    text-transform: capitalize;
}

.item-count {
    background: #eee;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.hidden {
    display: none !important;
}

#stat-menu h3, #travel-menu h3, #inventory-menu h3, #crafting-menu h3 {
    margin: 0 0 15px 0;
    text-transform: uppercase;
    border-bottom: 2px solid #eee;
}

.skill-points-display {
    margin-bottom: 15px;
    font-weight: bold;
    color: #9933ff;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.stat-info {
    display: flex;
    justify-content: space-between;
    flex-grow: 1;
    margin-right: 15px;
    font-size: 14px;
    color: #333;
}

.stat-val {
    font-weight: bold;
    color: #9933ff;
}

.stat-row button {
    width: 30px;
    height: 30px;
    cursor: pointer;
    background: #44cc44;
    border: 2px solid #000;
    color: white;
    font-weight: bold;
}

.close-menu {
    margin-top: 15px;
    width: 100%;
    padding: 8px;
    background: #eee;
    border: 2px solid #000;
    cursor: pointer;
    font-weight: bold;
}

.reset-btn {
    margin-top: 8px;
    width: 100%;
    padding: 4px;
    background: transparent;
    border: none;
    color: #ff0000;
    text-decoration: underline;
    cursor: pointer;
    font-size: 11px;
}

.square {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #000000;
    box-sizing: border-box;
    will-change: transform;
    z-index: 10;
}

.hand {
    position: absolute;
    width: 8px;
    height: 8px;
    border: 2px solid #000;
    background: #fff;
    border-radius: 50%;
    top: 8px;
    box-sizing: border-box;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hand-left {
    left: -6px;
}

.hand-right {
    right: -6px;
}

/* Punching Animations */
.punching-left .hand-left {
    transform: translateX(var(--punch-dist, -15px));
}

.punching-right .hand-right {
    transform: translateX(var(--punch-dist, 15px));
}

.charge-meter {
    position: absolute;
    top: -15px;
    left: 0;
    width: 100%;
    height: 4px;
    background: #eee;
    border: 1px solid #000;
    box-sizing: border-box;
    display: none;
}

.charge-fill {
    height: 100%;
    width: 0%;
    background: #ff0000;
}

.platform {
    position: absolute;
    height: 6px;
    background-color: #000000;
    border-radius: 3px;
    z-index: 5;
}

.enemy {
    position: absolute;
    width: 20px;
    height: 34px;
    border: 2px solid var(--enemy-color, #ff0000);
    background: var(--enemy-bg, rgba(255, 0, 0, 0.1));
    box-sizing: border-box;
    will-change: transform;
    z-index: 8;
    transition: filter 0.2s, opacity 0.2s;
}

/* Human-like head */
.enemy::before {
    content: '';
    position: absolute;
    top: -14px;
    left: 2px;
    width: 12px;
    height: 12px;
    border: 2px solid var(--enemy-color, #ff0000);
    border-radius: 50%;
    box-sizing: border-box;
    background: #fff;
}

.enemy-health-bar {
    position: absolute;
    top: -24px;
    left: -5px;
    width: 30px;
    height: 4px;
    background: #333;
    border: 1px solid #000;
}

.enemy-health-fill {
    height: 100%;
    width: 100%;
    background: #00ff00;
    transition: width 0.2s;
}

/* Visual Degradation */
.enemy.damaged-1 { filter: saturate(0.8) brightness(0.9); }
.enemy.damaged-2 { filter: saturate(0.6) brightness(0.8); border-style: dashed; }
.enemy.damaged-3 { filter: saturate(0.4) brightness(0.7); border-style: dotted; opacity: 0.8; }
.enemy.damaged-4 { filter: saturate(0.2) brightness(0.5); border-style: dotted; opacity: 0.6; }

.enemy.hit-flash {
    animation: hit-flash-anim 0.1s linear;
}

#hotbar-container {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hotbar-sub {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px;
    border-radius: 6px;
    border: 1.5px solid #000;
    pointer-events: auto;
}

#charms-hotbar {
    padding: 4px;
}

.hotbar-slot {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: 1.5px solid #444;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.hotbar-slot.charm-slot {
    width: 28px;
    height: 28px;
}

.hotbar-slot.active {
    border-color: #ffcc00;
    background: rgba(255, 204, 0, 0.1);
}

.hotbar-slot.empty {
    opacity: 0.5;
}

.hotbar-icon {
    font-size: 16px;
    pointer-events: none;
}

.charm-icon.stone-charm {
    background: #888;
    border-radius: 20%;
    clip-path: none;
}

.hotbar-label {
    position: absolute;
    bottom: 0px;
    right: 1px;
    font-size: 8px;
    color: #fff;
    font-weight: bold;
    text-shadow: 1px 1px 1px #000;
}

.charm-icon {
    width: 18px;
    height: 18px;
    background: #ffcc00;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    border: 1px solid #000;
}

@keyframes hit-flash-anim {
    0% { background: #fff; }
    100% { background: rgba(255, 0, 0, 0.1); }
}