body {
    margin: 0;
    padding: 0;
    background-color: #050505;
    overflow: hidden;
    touch-action: none;
    font-family: 'Cinzel', serif;
    color: #dcdcdc;
    user-select: none;
}
canvas {
    display: block;
    margin: 0 auto;
}
#ui-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}

.ui-panel {
    pointer-events: auto;
    background: rgba(12, 12, 16, 0.98);
    border: 2px solid #5a4a35;
    box-shadow: 0 0 20px rgba(0, 0, 0, 1), inset 0 0 30px rgba(0,0,0,0.8);
    color: #a8a090;
}

/* SYSTEM MENU (Top Right) */
#system-menu {
    position: absolute;
    top: 10px; right: 10px;
    display: flex; gap: 5px;
    pointer-events: auto;
    z-index: 90;
}
.sys-btn {
    background: #1a1a20;
    border: 1px solid #5a4a35;
    color: #c0b090;
    padding: 5px 12px; 
    cursor: pointer;
    font-size: 13px; 
    font-family: 'Cinzel', serif;
    transition: all 0.2s;
    text-transform: uppercase;
}
.sys-btn:hover { 
    background: #2e2820; border-color: #f1c40f; color: #fff;
}

/* SIDE PANEL (EKWIPUNEK) */
.side-panel {
    position: fixed; /* Zmiana na fixed */
    top: 0; right: -450px;
    width: 400px;
    height: 100vh;
    border-left: 3px solid #f1c40f; /* Jasna ramka do testów */
    background: rgba(20, 20, 25, 1); /* Bardziej nieprzezroczyste */
    transition: right 0.3s ease-in-out;
    display: flex; flex-direction: column;
    z-index: 999; /* Bardzo wysoki z-index */
    pointer-events: auto;
}
.side-panel.open {
    right: 0 !important;
}

.panel-header {
    background: #151515;
    border-bottom: 2px solid #5a4a35;
    padding: 15px;
    display: flex; justify-content: space-between; align-items: center;
}
.panel-title { font-size: 20px; color: #d4af37; letter-spacing: 2px; text-transform: uppercase; }
.close-btn { 
    cursor: pointer; color: #888; font-size: 24px; font-weight: bold; line-height: 1;
}
.close-btn:hover { color: #f1c40f; }

.scroll-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* CHARACTER SECTION */
.char-section {
    position: relative;
    height: 420px; /* Miejsce na sloty */
    background: #101012;
    border: 1px solid #333;
    margin-bottom: 15px;
    box-shadow: inset 0 0 50px #000;
}

.char-silhouette {
    width: 140px; height: 300px;
    position: absolute;
    top: 20px; left: 50%; transform: translateX(-50%);
    border: 1px dashed #333;
    border-radius: 60px 60px 20px 20px;
    opacity: 0.2;
    background: #080808;
}

.slot-col {
    position: absolute;
    top: 20px;
    display: flex; flex-direction: column; gap: 10px;
}
.left-col { left: 20px; }
.right-col { right: 20px; }

.hands-row {
    position: absolute;
    bottom: 20px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 40px; align-items: flex-end;
}

/* Slot Styles */
.item-slot {
    width: 48px; height: 48px;
    background: #050505;
    border: 1px solid #444;
    box-shadow: inset 0 0 10px #000;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
    position: relative;
}
.item-slot:hover { border-color: #d4af37; background: #1a1a1a; }
.item-icon { width: 38px; height: 38px; pointer-events: none; }

.big-slot { width: 64px; height: 96px; } /* Broń */
.bag-slot { border-style: dashed; opacity: 0.5; color: #555; font-size: 24px; }
.bag-slot:hover { opacity: 1; color: #f1c40f; }

/* STATS ROW */
.stats-compact {
    display: flex; justify-content: space-between;
    background: #1a1a1d;
    padding: 10px;
    border: 1px solid #333;
    margin-bottom: 15px;
}
.stat-box { font-size: 14px; color: #aaa; }
.stat-box span { color: #f1c40f; font-weight: bold; }

/* BACKPACK */
.backpack-section {
    background: #08080a;
    border: 1px solid #333;
    padding: 10px;
}
.backpack-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px;
    color: #8a6d3b; font-size: 14px; text-transform: uppercase;
}
.backpack-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* 6 kolumn dla węższego panelu */
    gap: 4px;
}


/* GÓRNY HUD (Status) - zachowany, ale lekko przyciemniony */
#top-hud {
    position: absolute;
    top: 0; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 15px; padding: 10px 30px;
    border-radius: 0 0 5px 5px;
    background: linear-gradient(to bottom, #1a1a1d, #0d0d10);
    border: 1px solid #5a4a35; border-top: 0;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    z-index: 80;
}

.bar-container {
    width: 200px; height: 16px; background: #0a0a0a; border: 1px solid #333; position: relative;
}
.bar-fill { height: 100%; transition: width 0.2s; position: relative; }
.bar-fill::after { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 50%; background: rgba(255,255,255,0.15); }
#hp-bar .bar-fill { background: linear-gradient(to right, #600000, #a00000); }
#mp-bar .bar-fill { background: linear-gradient(to right, #000050, #0000a0); }
.bar-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 11px; font-weight: bold; color: #fff; z-index: 2; }

#level-badge {
    width: 36px; height: 36px; border: 2px solid #5a4a35; border-radius: 50%;
    background: #111; display: flex; justify-content: center; align-items: center;
    font-weight: bold; font-size: 16px; color: #f1c40f;
}

#skills { display: flex; gap: 8px; margin-left: 20px; }
.skill-btn { 
    width: 44px; 
    height: 44px; 
    background: linear-gradient(to bottom, #1a1a20, #0a0a10);
    border: 2px solid #444; 
    border-radius: 6px;
    position: relative;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.15s ease;
    overflow: hidden;
}
.skill-btn:hover {
    border-color: #f1c40f;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.3);
}
.skill-btn.active {
    border-color: #f1c40f;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.6), inset 0 0 10px rgba(241, 196, 15, 0.2);
}
.skill-btn.on-cooldown {
    opacity: 0.7;
}
.skill-icon {
    font-size: 22px;
    z-index: 2;
    pointer-events: none;
}
.skill-key {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 10px;
    color: #888;
    font-weight: bold;
    z-index: 2;
}
.skill-cooldown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1;
    transition: height 0.1s linear;
}
.skill-no-mana-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(50, 50, 100, 0.5);
    z-index: 1;
    opacity: 0;
    pointer-events: none;
}
.skill-btn.no-mana .skill-no-mana-overlay {
    opacity: 1;
}
.skill-btn.no-mana .skill-icon {
    filter: grayscale(80%);
}

/* PRZYCISK MENU POSTACI (Prawy Dół) */
#btn-character {
    position: absolute; bottom: 20px; right: 20px;
    width: 50px; height: 50px; background: #1a1a20; border: 2px solid #5a4a35;
    border-radius: 4px; transform: rotate(45deg); cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    box-shadow: 0 0 15px #000; z-index: 100;
}
#btn-character span { transform: rotate(-45deg); font-size: 20px; color: #f1c40f; }

/* Save/Load Window & Loot Window - unchanged mostly but z-index adjustments */
#loot-window { width: 250px; top: 40%; left: 60%; z-index: 150; position: absolute; background: rgba(10, 10, 15, 0.95); border: 2px solid #8a6d3b; padding: 10px; }
#save-load-window { width: 400px; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 250; position: absolute; background: rgba(10, 10, 15, 0.95); border: 2px solid #8a6d3b; padding: 20px; }

.window-header { display: flex; justify-content: space-between; margin-bottom: 10px; color: #f1c40f; border-bottom: 1px solid #444; padding-bottom: 5px; }
.save-slot { background: rgba(0,0,0,0.5); border: 1px solid #444; margin-bottom: 5px; padding: 10px; display: flex; justify-content: space-between; }
.btn-save, .btn-load { background: #333; color: #ddd; border: 1px solid #555; padding: 5px 10px; cursor: pointer; }

#autosave-indicator { position: absolute; bottom: 20px; left: 20px; color: #f1c40f; opacity: 0; pointer-events: none; }