@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Roboto:wght@400;700&display=swap');

body, html {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    background: #000;
    /* Fonte principal do jogo - Estilo Medieval */
    font-family: 'Cinzel', serif; 
    user-select: none; /* Evita seleção de texto indesejada */
}

/* =========================================
   TELA INICIAL
   ======================================== */
#start-screen {
    position: relative;
    width: 100%; height: 100%;
    background: #000;
    z-index: 10;
}

.sky-background {
    position: absolute;
    width: 3136px; height: 100%;
    background: url('assets/animation/fundo-tras.png') repeat-x;
    background-size: contain;
    animation: moveClouds 120s linear infinite;
    z-index: 1;
    pointer-events: none;
}

@keyframes moveClouds {
    from { transform: translateX(0); }
    to { transform: translateX(-1568px); }
}

.forest-background {
    position: absolute;
    width: 100%; height: 100%;
    background: url('assets/animation/fundo-frente.png') no-repeat center center;
    background-size: cover;
    z-index: 2;
    pointer-events: none;
}

#game-title {
    position: absolute;
    top: 30%; left: 50%;
    transform: translate(-50%, -50%);
    color: #fff; font-size: 80px;
    text-shadow: 0 5px 15px rgba(0,0,0,0.8);
    z-index: 5;
    pointer-events: none;
    animation: floatTitle 4s ease-in-out infinite;
}

@keyframes floatTitle {
    0%, 100% { transform: translate(-50%, -50%); }
    50% { transform: translate(-50%, -55%); }
}

#bottom-menu-bar {
    position: absolute;
    bottom: 0; width: 100%; height: 60px;
    background: rgba(50, 50, 50, 0.9);
    border-top: 2px solid #444;
    z-index: 50;
    display: flex; align-items: center;
}

#btn-entrar-trigger {
    background: #27ae60; color: white;
    border: none; padding: 10px 40px;
    margin-left: 20px; border-radius: 4px;
    font-weight: bold; cursor: pointer;
    font-size: 18px;
    transition: transform 0.2s, background 0.2s;
    pointer-events: auto;
    position: relative;
    z-index: 1001;
}

#btn-entrar-trigger:hover {
    transform: scale(1.05);
    background: #2ecc71;
}

#btn-entrar-trigger:active {
    transform: scale(0.95);
}

/* --- MODAL LOGIN --- */
#auth-modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    background: rgba(0,0,0,0.6); 
    z-index: 1000;
}

.glass-box {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 40px; border-radius: 15px;
    width: 300px; text-align: center; color: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    pointer-events: auto;
}

.glass-box h2 { margin-top: 0; font-family: 'Cinzel', serif; }

.glass-box input {
    width: 100%; padding: 10px; margin: 10px 0;
    background: rgba(0, 0, 0, 0.5); border: 1px solid #555;
    color: white; border-radius: 5px; box-sizing: border-box;
}

.auth-buttons button {
    margin: 5px; padding: 8px 15px;
    cursor: pointer; border: none; border-radius: 3px;
    font-weight: bold;
    pointer-events: auto;
}

#btn-login { background: #2980b9; color: white; }
#btn-register { background: #8e44ad; color: white; }

/* =========================================
   INTERFACE DO JOGO (ESTILO MEDIEVAL)
   ======================================== */

#gameCanvas { 
    display: block; 
    width: 100%; height: 100%; 
    background: #111;
    image-rendering: pixelated; 
}

.hidden { display: none !important; }

/* --- JANELAS FLUTUANTES --- */
.game-window {
    position: absolute;
    background: rgba(20, 15, 10, 0.85); 
    border: 3px double #d4af37;
    color: #e0d0b0;
    padding: 8px;
    z-index: 200;
    box-shadow: 0 10px 20px rgba(0,0,0,0.8);
    border-radius: 4px;
    resize: both; 
    overflow: hidden;
    min-width: 150px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
}

.win-header {
    background: linear-gradient(to bottom, #461111, #2c0b0b);
    color: #f1c40f;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: -8px -8px 8px -8px;
    padding: 6px;
    border-bottom: 2px solid #d4af37;
    text-shadow: 1px 1px 0 #000;
    cursor: grab; 
    user-select: none;
    position: relative;
}

.win-header:active { cursor: grabbing; }

.lock-btn {
    position: absolute;
    right: 8px;
    top: 4px;
    cursor: pointer;
    font-size: 14px;
    filter: grayscale(1);
    transition: transform 0.2s;
}
.lock-btn:hover { transform: scale(1.2); filter: grayscale(0); }
.win-locked .win-header { cursor: default !important; }

/* Posições Iniciais */
#win-inventory { top: 100px; right: 20px; width: 196px; height: 300px; }
#win-skills { top: 100px; left: 20px; width: 220px; }

/* --- INVENTÁRIO GRID --- */
#inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    grid-auto-rows: 42px; 
    gap: 4px; padding: 5px;
    width: 100%; height: calc(100% - 35px);
    overflow-y: auto; box-sizing: border-box;
}

.inv-slot {
    width: 40px; height: 40px;
    background: #1a1510; border: 1px solid #5a4a35;
    box-shadow: inset 0 0 10px #000;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative;
    transition: border-color 0.2s, background-color 0.2s;
}
.inv-slot:hover { border-color: #f1c40f; background-color: #2a2520; }
.inv-slot img { width: 32px; height: 32px; image-rendering: pixelated; filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.5)); }

/* =========================================
   EQUIPAMENTOS (VERSÃO GHOST/FANTASMA)
   ========================================= */

#win-equipment {
    width: 175px; /* Ajuste para caber as 3 colunas */
    height: auto;
    bottom: 120px; right: 20px;
}

.eq-grid {
    display: grid;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(4, 44px);
    gap: 10px;
    padding: 12px;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
}

.eq-slot {
    width: 42px;
    height: 42px;
    background-color: #1a1510;
    border: 1px solid #5a4a35;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative; /* Necessário para o ::before funcionar */
    cursor: pointer;
    box-shadow: inset 0 0 10px #000;
    transition: border-color 0.2s, background-color 0.2s;
}

.eq-slot:hover { border-color: #f1c40f; background-color: #2a2520; }

/* --- ÍCONES FANTASMAS (::before) --- */
.eq-slot::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px;
    
    /* EFEITO FANTASMA */
    opacity: 0.2;            /* Transparência */
    filter: grayscale(100%); /* Preto e branco */
    pointer-events: none;    /* Clique atravessa */
    z-index: 0;
}

/* Definição das imagens (use nomes minúsculos nos arquivos) */
#eq-ring1::before, #eq-ring2::before { background-image: url('assets/hub-icons/anel.png'); }
#eq-head::before     { background-image: url('assets/hub-icons/capacete.png'); }
#eq-weapon::before   { background-image: url('assets/hub-icons/sword.png'); }
#eq-armor::before    { background-image: url('assets/hub-icons/armadura.png'); }
#eq-shield::before   { background-image: url('assets/hub-icons/shield.png'); }
#eq-gloves::before   { background-image: url('assets/hub-icons/luvas.png'); }
#eq-legs::before     { background-image: url('assets/hub-icons/calcas.png'); }
#eq-necklace::before { background-image: url('assets/hub-icons/colar.png'); }
#eq-boots::before    { background-image: url('assets/hub-icons/botas.png'); }

/* Se houver item equipado (<img>), remove o ícone fantasma */
.eq-slot:has(img)::before {
    display: none !important;
}

/* Estilo do item real */
.eq-slot img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    z-index: 2; /* Fica por cima do fundo */
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.5));
}

/* =========================================
   SKILLS & HUD
   ======================================== */

.skill-row {
    margin: 10px 0;
    display: flex; flex-direction: column;
    font-family: 'Roboto', sans-serif; color: #ccc;
}

.skill-info {
    display: flex; justify-content: space-between;
    width: 100%; margin-bottom: 3px;
    font-size: 11px; text-transform: uppercase;
    font-weight: bold; color: #e0d0b0;
}

.skill-bar {
    width: 100%; height: 6px;
    background: #000;
    border: 1px solid #5a4a35;
    border-radius: 2px;
    position: relative; overflow: hidden;
}

.skill-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    width: 0%; 
    box-shadow: 0 0 5px #27ae60;
    transition: width 0.3s ease-out;
}

/* --- CHAT --- */
#chat-container {
    position: absolute; bottom: 90px; left: 20px;
    width: 350px; height: 200px;
    background: rgba(20, 15, 10, 0.85);
    border: 2px solid #5a4a35; border-radius: 6px;
    display: flex; flex-direction: column;
    box-shadow: 0 0 15px rgba(0,0,0,0.8);
    resize: both; overflow: hidden;
    min-width: 200px; min-height: 100px;
    z-index: 150;
}

#chat-history {
    flex: 1; overflow-y: auto; color: #e0d0b0;
    padding: 10px; font-size: 13px; font-family: 'Roboto', sans-serif;
    text-shadow: 1px 1px 0 #000;
}
#chat-history strong { color: #f1c40f; }
#chat-input {
    background: rgba(0,0,0,0.5); border: none;
    border-top: 1px solid #5a4a35; color: #fff;
    padding: 10px; font-family: 'Roboto', sans-serif;
}
#chat-input:focus { outline: none; background: rgba(0,0,0,0.8); }

/* --- ADMIN --- */
.editor-header { font-weight: bold; margin-bottom: 10px; text-align: center; border-bottom: 1px solid #444; padding-bottom: 5px; color: #e74c3c; }
.editor-section { margin-bottom: 15px; flex-shrink: 0; }
.layer-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }

.layer-buttons button { 
    padding: 5px; cursor: pointer; 
    background: #333; color: white; 
    border: 1px solid #555; 
}
.layer-buttons button.active { background: #2ecc71 !important; border-color: #fff !important; }

#btn-colisao { 
    width: 100%; padding: 10px; 
    cursor: pointer; background: #c0392b; 
    color: white; border: none; font-weight: bold; 
}
#btn-colisao.active { background: #ff4757; box-shadow: 0 0 10px #ff4757; }

#admin-editor {
    position: fixed; top: 10px; right: 10px;
    width: 320px; max-height: 90vh;
    background: rgba(15, 15, 15, 0.98);
    color: white; padding: 15px;
    border: 2px solid #555;
    z-index: 9999;
    display: flex; flex-direction: column;
    font-family: sans-serif;
    box-shadow: 0 0 20px black;
}

#tileset-container {
    flex-shrink: 0; height: 300px; width: 100%;
    overflow: auto; background: #000;
    border: 1px solid #444; position: relative;
    margin: 10px 0; image-rendering: pixelated;
}

#tileset-img {
    display: block; max-width: none !important;
    cursor: crosshair; user-select: none;
    -webkit-user-drag: none;
}

#selector {
    position: absolute;
    border: 2px solid #00faff;
    background: rgba(0, 250, 255, 0.3);
    pointer-events: none; z-index: 5;
    box-sizing: border-box;
}

.save-btn { width: 100%; padding: 12px; background: #2980b9; color: white; border: none; cursor: pointer; font-weight: bold; }

/* Slot Count e Drag */
.slot-count {
    position: absolute; bottom: 2px; right: 2px;
    font-family: 'Roboto', sans-serif; font-size: 10px;
    color: #fff; text-shadow: 1px 1px 1px #000;
    pointer-events: none;
}

.drag-icon {
    position: fixed; width: 32px; height: 32px;
    pointer-events: none; z-index: 1000;
    image-rendering: pixelated;
    filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.8));
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1a1510; border-left: 1px solid #3d2e1e; }
::-webkit-scrollbar-thumb { background: #d4af37; border-radius: 0px; border: 1px solid #461111; }
::-webkit-scrollbar-thumb:hover { background: #f1c40f; }
::-webkit-scrollbar-corner { background: #1a1510; }
* { scrollbar-width: thin; scrollbar-color: #d4af37 #1a1510; }

/* --- JANELA DE HOTBAR --- */
#win-hotbar {
    top: 85vh; left: 50%;
    transform: translateX(-50%);
    width: 400px; height: 75px;
}

#hotbar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    grid-auto-rows: 42px; 
    gap: 4px; padding: 5px;
    width: 100%; height: 100%;
    overflow-y: auto; box-sizing: border-box;
}

.hotkey-slot { position: relative; }

.key-number {
    position: absolute; top: 1px; left: 2px;
    font-size: 9px; color: #f1c40f;
    text-shadow: 1px 1px 0 #000;
    pointer-events: none; z-index: 2;
    font-family: 'Roboto', sans-serif;
}

/* --- JANELA DE MENU --- */
#win-menubar {
    bottom: 20px; right: 20px;
    width: auto; height: auto;
    min-width: 60px; min-height: 60px;
    display: flex; flex-direction: column;
}

#win-menubar .menu-content {
    display: flex; gap: 8px; padding: 8px;
    justify-content: center; flex-wrap: wrap;
}

.icon-btn {
    width: 42px; height: 42px;
    background: linear-gradient(to bottom, #4a4036, #2c241b);
    border: 2px solid #d4af37; border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.6);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: transform 0.1s, filter 0.1s;
}
.icon-btn:hover { filter: brightness(1.2); transform: translateY(-2px); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn img { width: 32px; filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.8)); }
.icon-btn span { font-family: 'Cinzel', serif; font-size: 10px; text-shadow: 1px 1px 0 #000; }

/* --- BARRA DE XP GLOBAL --- */
#global-xp-container {
    position: fixed; bottom: 0; left: 0;
    width: 100%; height: 12px;
    background: rgba(0, 0, 0, 0.8);
    border-top: 1px solid #d4af37;
    z-index: 999;
}

#global-xp-bar {
    width: 0%; height: 100%;
    background: linear-gradient(to right, #f1c40f, #e67e22);
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
    transition: width 0.4s ease;
}

#global-xp-text {
    position: absolute; top: -15px; left: 50%;
    transform: translateX(-50%);
    color: #fff; font-size: 10px;
    font-family: 'Roboto', sans-serif;
    text-shadow: 1px 1px 2px #000;
    pointer-events: none; font-weight: bold;
}

/* Tooltip XP */
#xp-tooltip {
    position: absolute; bottom: 25px; left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 10, 5, 0.95);
    border: 2px solid #d4af37;
    padding: 12px; border-radius: 8px;
    width: 200px; box-shadow: 0 0 20px rgba(0,0,0,0.8);
    pointer-events: none; z-index: 1000;
    font-family: 'Roboto', sans-serif;
    animation: slideUp 0.3s ease-out;
}

#xp-tooltip::after {
    content: ""; position: absolute;
    bottom: -10px; left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid #d4af37;
}

#xp-tooltip .tooltip-title {
    font-family: 'Cinzel', serif; color: #f1c40f;
    text-align: center; border-bottom: 1px solid #5a4a35;
    margin-bottom: 8px; padding-bottom: 4px; font-size: 14px;
}

.tooltip-row {
    display: flex; justify-content: space-between;
    font-size: 12px; color: #e0d0b0; margin-bottom: 4px;
}
.tooltip-row strong { color: #fff; }
.tooltip-percentage {
    margin-top: 8px; text-align: center;
    font-size: 16px; font-weight: bold; color: #2ecc71;
    text-shadow: 0 0 5px rgba(46, 204, 113, 0.4);
}

@keyframes slideUp {
    from { opacity: 0; bottom: 15px; }
    to { opacity: 1; bottom: 25px; }
}

/* Mapa Overlay */
#map-overlay:active { cursor: grabbing; }
#map-canvas { image-rendering: pixelated; }