:root {
    --bg-color: #e0f7fa;
    --forest-green: #a5d6a7;
    --xp-color: #fff176;
    --text-color: #37474f;
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100vw;
    max-width: 800px;
    height: 100vh;
    max-height: 600px;
    background: var(--forest-green);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 8px solid white;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

@media (max-width: 800px) {
    #game-container {
        border-radius: 0;
        border: none;
        max-width: 100vw;
        max-height: 100vh;
    }
}

#gameCanvas {
    width: 100%;
    height: 100%;
}

/* --- TELA DE MENU INICIAL --- */
#main-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* O usuário salvará a imagem que ele enviou com esse nome: */
    background-image: url('menu_bg.jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.menu-content {
    background: var(--glass-bg);
    backdrop-filter: blur(5px);
    border: 3px solid var(--glass-border);
    padding: 40px 60px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#class-selection-menu {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#class-selection-menu.hidden,
#lobby-menu.hidden,
#waiting-room.hidden,
#shop-menu.hidden {
    display: none;
}

#lobby-menu, #waiting-room {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: auto;
}

.lobby-inputs {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 250px;
    margin: 0 auto;
}

.lobby-input {
    padding: 12px;
    border-radius: 8px;
    border: 2px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.9);
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-color);
}

.players-list {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 15px;
    min-height: 150px;
    width: 250px;
    margin: 0 auto;
    text-align: left;
    color: white;
    font-weight: bold;
}

.player-item {
    padding: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    display: flex;
    justify-content: space-between;
}

.game-title {
    color: white;
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 30px;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.8);
    letter-spacing: 2px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.menu-btn {
    padding: 12px 20px;
    font-size: 1.2rem;
    font-family: inherit;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.85);
    color: var(--text-color);
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.menu-btn:hover {
    transform: scale(1.05);
    background: white;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.primary-btn {
    background: #ffeb3b;
    /* Amarelo tipo bluey super vivo */
    color: #333;
    font-size: 1.4rem;
    padding: 15px 25px;
    border: 2px solid #fbc02d;
    margin-bottom: 10px;
}

.primary-btn:hover {
    background: #fff176;
}


#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    padding: 20px;
}

.hud-top {
    display: flex;
    align-items: center;
    gap: 15px;
}

.xp-bar-container {
    flex-grow: 1;
    height: 16px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid white;
}

#xp-bar {
    width: 0%;
    height: 100%;
    background: var(--xp-color);
    transition: width 0.3s ease;
}

#level-display {
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

#class-display {
    position: absolute;
    bottom: 20px;
    left: 20px;
    padding: 8px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: 30px;
    color: var(--text-color);
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

#instructions {
    position: absolute;
    bottom: 20px;
    right: 20px;
    color: white;
    font-size: 0.9rem;
    opacity: 0.7;
}

#shop-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: auto; /* IMPORTANTE - PERMITIR CLIQUE NA LOJA! */
    width: 90%;
    max-width: 400px;
    z-index: 150;
    display: flex;
    justify-content: center;
    align-items: center;
}

#shop-menu .menu-content {
    width: 100%;
    padding: 20px;
    max-height: 90vh; /* Se celular for pequeno, não estoura a tela */
    overflow-y: auto; /* Adiciona rolagem se a loja ficar muito alta */
}

#shop-menu.hidden {
    display: none !important;
}

#shop-menu h2 {
    color: var(--text-color);
    margin-bottom: 5px;
}

#shop-menu p {
    color: var(--text-color);
    margin-bottom: 20px;
}

.evolution-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.evo-btn {
    padding: 10px 20px;
    border: none;
    background: white;
    color: var(--text-color);
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    font-family: inherit;
    font-size: 1rem;
}

.evo-btn:hover {
    transform: scale(1.05);
    background: var(--xp-color);
}

.shop-item-btn {
    padding: 10px;
    border: 2px solid gold;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    font-family: inherit;
    text-align: center;
    width: 160px;
}

.shop-item-btn:hover {
    transform: scale(1.05);
    background: rgba(255, 215, 0, 0.2);
}

.shop-item-btn strong {
    font-size: 1.1rem;
    color: #fff;
    display: block;
    margin-bottom: 5px;
}

.shop-item-btn small {
    color: #ccc;
    display: block;
    margin-bottom: 5px;
}

/* --- MOBILE CONTROLS --- */
#mobile-controls {
    display: none;
    position: absolute;
    bottom: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    pointer-events: none; /* Deixa cliques através das div transparentes, pega só nos botões */
}

/* Painel lateral direito para os botões de armas no mobile */
#mobile-weapons {
    position: absolute;
    right: 10px;
    top: 50px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto; /* Permite clicar aqui */
}

.mobile-weapon-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    border: 3px solid rgba(0, 0, 0, 0.3);
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.mobile-weapon-btn.active-weapon {
    border-color: gold;
    background: rgba(255, 215, 0, 0.5);
    transform: scale(1.1);
}

@media (max-width: 800px), (hover: none) and (pointer: coarse) {
    #mobile-controls {
        display: block;
    }
    #instructions {
        display: none;
    }
    .hud-top {
        margin-top: 10px;
    }
}

#joystick-base {
    position: absolute;
    bottom: 40px;
    left: 20px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    pointer-events: auto;
    touch-action: none;
}

#joystick-knob {
    position: absolute;
    top: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    pointer-events: none;
    transition: transform 0.05s ease-out;
}

#attack-btn {
    position: absolute;
    bottom: 50px;
    right: 20px;
    width: 90px;
    height: 90px;
    background: rgba(244, 67, 54, 0.6);
    border: 4px solid rgba(244, 67, 54, 0.9);
    border-radius: 50%;
    color: white;
    font-size: 1.1rem;
    font-family: 'Outfit', sans-serif;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    touch-action: none;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

#attack-btn:active {
    background: rgba(244, 67, 54, 0.9);
    transform: scale(0.95);
}