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

/* Chat system enhancements */
.chat-form {
    margin-top: 8px;
}

.chat-input-row {
    display: flex;
    gap: 5px;
    align-items: center;
}

.chat-target-selector,
.chat-player-selector {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 215, 0, 0.3);
    color: #fff;
    padding: 5px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    min-width: 70px;
    height: 30px;
}

.chat-target-selector:hover,
.chat-player-selector:hover {
    border-color: #ffd700;
}

.chat-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 215, 0, 0.3);
    color: #fff;
    padding: 5px 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    height: 30px;
    box-sizing: border-box;
}

.chat-input:focus {
    border-color: #ffd700;
    outline: none;
}

.chat-send-btn {
    background: rgba(255, 215, 0, 0.2);
    border: 2px solid rgba(255, 215, 0, 0.3);
    color: #ffd700;
    padding: 5px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    height: 30px;
    transition: all 0.3s;
    white-space: nowrap;
}

.chat-send-btn:hover {
    background: rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
}

/* Estilos para mensajes según tipo de destinatario */
.chat-message.msg-all {
    color: #fff; /* Global: blanco */
}

.chat-message.msg-visible {
    color: #8bc34a; /* Cercanos: verde claro */
}

.chat-message.msg-group {
    color: #2196f3; /* Grupo: azul */
}

.chat-message.msg-player {
    color: #e91e63; /* Privado: rosa */
}

@media (max-width: 768px) {
    .chat-input-row {
        flex-wrap: wrap;
    }

    .chat-target-selector,
    .chat-player-selector {
        min-width: 60px;
        font-size: 10px;
    }

    .chat-input {
        font-size: 10px;
        min-width: 150px;
    }

    .chat-send-btn {
        padding: 4px 6px;
        font-size: 10px;
        min-width: 50px;
    }
}

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #fff;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.header {
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 15px;
    border-radius: 10px 10px 0 0;
    border: 3px solid #ffd700;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

/* Experience bar */
.exp-container {
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 15px;
    border: 3px solid #ffd700;
    border-top: none;
    border-radius: 0 0 10px 10px;
    margin-bottom: 5px;
    flex-shrink: 0;
}

.exp-label {
    font-size: 11px;
    margin-bottom: 4px;
    color: #ffd700;
}

.exp-bar-bg {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 10px;
    height: 12px;
    overflow: hidden;
}

.exp-bar {
    background: linear-gradient(90deg, #10b981 0%, #34d399 50%, #6ee7b7 100%);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.header h1 {
    font-size: 22px;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.stats {
    display: flex;
    gap: 15px;
    font-size: 13px;
}

.stats span {
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 2px;
    /*border-radius: 5px;
    border: 2px solid rgba(255, 255, 255, 0.3);*/
}

/* Chat section at the top */
.chat-section {
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #ffd700;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 5px;
    flex-shrink: 0;
}

.chat-section h3 {
    color: #ffd700;
    margin-bottom: 8px;
    font-size: 14px;
    border-bottom: 2px solid #ffd700;
    padding-bottom: 3px;
}

.chat-log {
    background: rgba(0, 0, 0, 0.5);
    padding: 8px;
    border-radius: 5px;
    height: 70px;
    overflow-y: auto;
    font-size: 11px;
}

.chat-log p {
    margin: 3px 0;
    line-height: 1.3;
}

.chat-log .system {
    color: #ffd700;
    font-weight: bold;
}

.chat-log .player {
    color: #4CAF50;
    font-weight: bold;
}

.chat-log .npc {
    color: #2196f3;
    font-weight: bold;
}

/* Main game area with sidebar */
.game-area {
    display: flex;
    gap: 10px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.main-game {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

#gameCanvas {
    display: block;
    background: #000;
    border: 3px solid #ffd700;
    border-radius: 10px 10px 0 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 100%;
    flex: 1;
    object-fit: contain;
}

.controls {
    background: rgba(0, 0, 0, 0.8);
    padding: 8px;
    border: 3px solid #ffd700;
    border-top: none;
    border-radius: 0 0 10px 10px;
    text-align: center;
    font-size: 11px;
    flex-shrink: 0;
}

/* Sidebar with inventory and quests - IMPROVED FOR BETTER VISIBILITY */
.sidebar {
    width: 250px; /* Reduced from 280px */
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    overflow-y: auto;
    flex-shrink: 0;
    max-height: calc(100vh - 200px); /* Limit max height to improve map visibility */
}

.panel {
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #ffd700;
    border-radius: 10px;
    padding: 8px; /* Reduced padding from 12px to 8px */
    flex-shrink: 0;
}

.panel h3 {
    color: #ffd700;
    margin-bottom: 6px; /* Reduced from 8px */
    font-size: 14px;
    border-bottom: 2px solid #ffd700;
    padding-bottom: 3px;
}

/* Inventory styling - IMPROVED FOR BETTER VISIBILITY */
.inventory {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px; /* Reduced from 6px */
}

.item-slot {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px; /* Reduced from 24px */
    cursor: pointer;
    transition: all 0.3s;
    min-height: 45px; /* Reduced from 50px */
    position: relative;
}

.item-slot.equipped {
    background: rgba(16, 185, 129, 0.3) !important;
    border-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.item-slot:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
    border-color: #ffd700;
}

.item-slot.empty {
    color: rgba(255, 255, 255, 0.3);
    font-size: 12px; /* Reduced from 14px */
}

/* Item quantity display (AO style) */
.item-quantity {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.8);
    color: #ffd700;
    font-size: 9px; /* Reduced from 10px */
    font-weight: bold;
    padding: 1px 2px;
    border-radius: 2px;
    border: 1px solid #ffd700;
    min-width: 10px;
    text-align: center;
}

/* Quest list - IMPROVED FOR BETTER VISIBILITY */
.quest-list {
    list-style: none;
    font-size: 11px; /* Reduced from 12px */
    max-height: 150px; /* Limit height */
    overflow-y: auto; /* Allow scrolling */
}

.quest-list ul {
    list-style-type: none;
    padding-left: 0;
}

.quest-list li {
    padding: 6px; /* Reduced from 8px */
    margin: 3px 0; /* Reduced from 4px */
    background: rgba(255, 255, 255, 0.1);
    border-left: 3px solid #4CAF50;
    border-radius: 3px;
    transition: all 0.3s;
}

.quest-list li:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(5px);
}

/* Character stats panel - IMPROVED FOR BETTER VISIBILITY */
.character-panel {
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #ffd700;
    border-radius: 10px;
    padding: 8px; /* Reduced from 12px */
}

.character-info {
    font-size: 11px; /* Reduced from 12px */
    line-height: 1.5;
}

.character-info p {
    display: flex;
    justify-content: space-between;
    padding: 3px 0; /* Reduced from 4px */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.character-info p:last-child {
    border-bottom: none;
}

.stat-label {
    color: #ffd700;
}

.stat-value {
    color: #fff;
    font-weight: bold;
}

.character-panel .stat-value {
      font-size: 12px; /* Reduced from 14px */    
}

/* Scrollbar styling */
.chat-log::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.quest-list::-webkit-scrollbar {
    width: 4px; /* Reduced from 6px */
}

.chat-log::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.quest-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
}

.chat-log::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.quest-list::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.5);
    border-radius: 2px;
}

.chat-log::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.quest-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.7);
}

/* Responsive design - IMPROVED FOR BETTER VISIBILITY */
@media (max-width: 1200px) {
    .sidebar {
        width: 220px; /* Further reduced from 250px */
    }
    
    .inventory {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }
    
    .item-slot {
        min-height: 40px; /* Reduced from 45px */
        font-size: 18px; /* Reduced from 20px */
    }
}

@media (max-width: 1024px) {
    .game-container {
        padding: 5px;
    }
    
    .game-area {
        /* Keep side-by-side layout but make sidebar smaller */
        flex-direction: row;
    }
    
    .sidebar {
        width: 180px; /* Reduced even more */
        max-height: none; /* Allow full height */
    }
    
    .inventory {
        grid-template-columns: repeat(2, 1fr); /* Reduce to 2 columns */
    }
    
    /* Reduce chat height */
    .chat-log {
        height: 60px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 8px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .stats {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        font-size: 11px;
    }
    
    /* Use a collapsible sidebar approach */
    .game-area {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 200px; /* Limit height for better map visibility */
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    .panel {
        flex: 0 0 auto;
        min-width: 180px;
        max-width: 200px;
    }
    
    .inventory {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .chat-log {
        height: 50px;
        font-size: 10px;
    }
    
    /* Make game canvas take more space */
    .main-game {
        flex: 1;
        min-height: 50vh; /* Ensure it takes at least half of viewport height */
        position: relative; /* Para contener barras absolutas */
    }

    /* Main game con position relative para contener barras absolutas */
    .main-game {
        position: relative;
    }

    /* Contenedor de barras inferiores sobre el canvas */
    .mobile-bottom-bars {
        position: absolute;
        bottom: 10px;
        left: 10px;
        right: 10px;
        z-index: 10;
        display: flex;
        gap: 10px;
        justify-content: space-between;
        pointer-events: none;
    }

    .mobile-bottom-bars > * {
        pointer-events: all;
    }

    /* Inventario móvil reposicionado */
    .inventory-bottom {
        position: static !important;
        background: rgba(0, 0, 0, 0.85) !important;
        border: 2px solid #ffd700 !important;
        border-radius: 6px !important;
        padding: 4px 6px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
        margin: 0 !important;
        /*flex: 1;
        max-width: calc(50% - 5px);*/
        display: flex;
        align-items: center;
        gap: 5px;
    }

    .inventory-bottom .inventory {
        display: flex !important;
        gap: 5px !important;
        justify-content: flex-start;
        flex: 1;
    }

    .inventory-bottom .item-slot {
        width: 32px !important;
        height: 32px !important;
        min-height: 32px !important;
        font-size: 16px !important;
    }

    .inventory-bottom .item-slot.empty {
        font-size: 12px !important;
    }

    /* Botones de paginación del inventario móvil */
    .inventory-bottom .inventory-pagination {
        display: flex !important;
        flex-direction: column;
        gap: 2px;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
    }

    .inventory-bottom .inv-page-btn {
        padding: 2px 6px !important;
        font-size: 10px !important;
        height: 15px !important;
    }

    .inventory-bottom .page-indicator {
        display: none !important;
    }

    /* Contenedor de hechizos con paginación */
    .mobile-spells-container {
        position: static;
        flex: 0 0 auto;
        margin-left: auto;
        display: flex;
        align-items: center;
        gap: 5px;
    }

    /* Barra de hechizos móvil */
    .mobile-spells-bar {
        background: rgba(0, 0, 0, 0.85);
        border: 2px solid #8b5cf6;
        border-radius: 6px;
        padding: 4px 6px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
        display: flex;
        gap: 5px;
    }

    /* Paginación de hechizos */
    .spells-pagination {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .spell-page-btn {
        background: #4a5568;
        color: white;
        border: none;
        padding: 2px 6px;
        border-radius: 3px;
        cursor: pointer;
        font-size: 10px;
        height: 15px;
        transition: all 0.3s;
    }

    .spell-page-btn:hover:not(:disabled) {
        background: #6b7280;
    }

    .spell-page-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .spell-slot {
        position: relative;
        width: 32px;
        height: 32px;
        background: rgba(0, 0, 0, 0.5);
        border: 2px solid rgba(139, 92, 246, 0.3);
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        cursor: pointer;
        transition: all 0.3s;
    }

    .spell-slot:hover {
        background: rgba(139, 92, 246, 0.2);
        border-color: #8b5cf6;
        transform: scale(1.05);
    }

    .spell-slot.active {
        background: rgba(139, 92, 246, 0.3);
        border-color: #8b5cf6;
        box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    }

    .spell-slot.empty {
        color: rgba(255, 255, 255, 0.2);
        font-size: 14px;
        cursor: default;
    }

    .spell-slot.empty:hover {
        transform: none;
        background: rgba(0, 0, 0, 0.5);
        border-color: rgba(139, 92, 246, 0.3);
    }

    .spell-slot .spell-mana-cost {
        position: absolute;
        bottom: 1px;
        right: 1px;
        background: rgba(37, 99, 235, 0.9);
        color: white;
        font-size: 8px;
        font-weight: bold;
        padding: 1px 3px;
        border-radius: 2px;
        border: 1px solid #2563eb;
    }
}

/* Animation effects */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px #ffd700;
    }
    50% {
        box-shadow: 0 0 15px #ffd700, 0 0 25px #ffd700;
    }
}

.panel:hover {
    animation: glow 2s infinite;
}

/* Tooltip effect */
.item-slot[title]:hover::after {
    content: attr(title);
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: #ffd700;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 1000;
    margin-top: -40px;
    border: 2px solid #ffd700;
}

/* Minimap styles */
.minimap-toggle {
    width: 100%;
    padding: 8px;
    background: rgba(255, 215, 0, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.3);
    color: #ffd700;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    transition: all 0.3s;
}

.minimap-toggle:hover {
    background: rgba(255, 215, 0, 0.2);
    border-color: #ffd700;
}

.minimap-container {
    margin-top: 10px;
    display: none;
}

/* Para manejo seguro de canvas - referencia lazy */
#minimapCanvas {
    display: block;
    border: 2px solid #ffd700;
    border-radius: 5px;
    background: #000;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 100%;
}

.minimap-legend {
    margin-top: 8px;
    font-size: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 3px 0;
}

.legend-color {
    width: 12px;
    height: 12px;
    margin-right: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: inline-block;
}

/* World map styles */
.world-map-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    box-sizing: border-box;
    display: none;
}

/* Para manejo seguro de canvas - referencia lazy */
#worldMapCanvas {
    display: block;
    border: 2px solid #ffd700;
    border-radius: 5px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: pointer;
    max-width: 100%;
}

.world-map-info {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #ffd700;
    padding: 15px;
    border-radius: 10px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    margin-top: 20px;
}

.world-map-info p {
    margin: 4px 0;
    color: #ffd700;
}

.world-map-details {
    background: rgba(0, 0, 0, 0.5);
    padding: 6px;
    border-radius: 3px;
    margin-top: 6px;
    font-size: 10px;
    min-height: 40px;
}

/* Quest toggle styles - IMPROVED FOR BETTER VISIBILITY */
#questList {
    display: none; /* Start collapsed by default */
}

.quest-toggle {
    background: none !important;
    border: 1px solid #ffd700 !important;
    color: #ffd700 !important;
    font-size: 12px !important;
    padding: 2px 6px !important;
    cursor: pointer !important;
    margin-left: 10px;
    float: right;
}

.quest-toggle:hover {
    background: rgba(255, 215, 0, 0.1) !important;
}

/* Menú de contexto para items */
.context-menu {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #ffd700;
    padding: 5px 0;
    border-radius: 5px;
    z-index: 1000;
    min-width: 150px;
    display: none;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.7);
}

.context-menu-item {
    padding: 8px 15px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    color: white;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    font-family: 'Courier New', monospace;
}

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

.context-menu-item:hover {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
}

.context-menu-item .icon {
    margin-right: 8px;
    font-size: 14px;
    color: #ffd700;
}

/* Modal de cantidad */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 900;
    display: none;
}

.quantity-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid #ffd700;
    padding: 20px;
    border-radius: 10px;
    z-index: 1200;
    display: none;
    flex-direction: column;
    gap: 15px;
    min-width: 250px;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    font-family: 'Courier New', monospace;
}

.quantity-modal-title {
    font-size: 16px;
    color: #ffd700;
    margin-bottom: 10px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 215, 0, 0.5);
    padding-bottom: 8px;
}

.quantity-modal-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quantity-modal-input input {
    flex: 1;
    padding: 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 5px;
    color: white;
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

.quantity-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.quantity-modal-btn {
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    font-family: 'Courier New', monospace;
}

.quantity-modal-btn.confirm {
    background: rgba(76, 175, 80, 0.7);
    color: white;
    border: 2px solid #4CAF50;
}

.quantity-modal-btn.confirm:hover {
    background: rgba(76, 175, 80, 0.9);
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.7);
}

.quantity-modal-btn.cancel {
    background: rgba(244, 67, 54, 0.7);
    color: white;
    border: 2px solid #f44336;
}

.quantity-modal-btn.cancel:hover {
    background: rgba(244, 67, 54, 0.9);
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.7);
}

/* Dialogue system styles */
.dialogue-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.dialogue-box {
    background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
    border: 4px solid #ffd700;
    border-radius: 15px;
    padding: 20px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    animation: dialogue-appear 0.3s ease-out;
}

@keyframes dialogue-appear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.dialogue-speaker {
    color: #ffd700;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    border-bottom: 2px solid #ffd700;
    padding-bottom: 8px;
}

.dialogue-text {
    color: #ffffff;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    border: 2px solid rgba(255, 215, 0, 0.3);
}

.dialogue-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.dialogue-option {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border: 2px solid #66bb6a;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    text-align: left;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dialogue-option:hover {
    background: linear-gradient(135deg, #66bb6a 0%, #4CAF50 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.dialogue-option:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dialogue-close {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    border: 2px solid #ef5350;
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    align-self: center;
    transition: all 0.3s;
}

.dialogue-close:hover {
    background: linear-gradient(135deg, #ef5350 0%, #f44336 100%);
    transform: translateY(-1px);
}

/* Responsive dialogue */
@media (max-width: 600px) {
    .dialogue-box {
        padding: 15px;
        max-width: 95%;
    }

    .dialogue-speaker {
        font-size: 16px;
    }

    .dialogue-text {
        font-size: 13px;
        padding: 12px;
    }

    .dialogue-option {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* Mobile-specific styles - Responsive design without affecting desktop */
@media (max-width: 768px) {
    /* Header hidden by default in mobile */
    .header {
        display: none;
    }

    /* Ultra-compact stats bar - single line */
    .stats-compact {
        display: flex;
        justify-content: center;
        gap: 2px;
        font-size: 9px;
        font-weight: bold;
        padding: 2px 0;
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .stats-compact span {
        background: rgba(0, 0, 0, 0.7);
        padding: 1px 3px;
        border-radius: 2px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        display: flex;
        align-items: center;
        gap: 2px;
        white-space: nowrap;
    }

    /* NUEVO: Minimalist Mobile HUD - Single row */
    .minimalist-hud {
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 100;
        display: none;
        background: rgba(0, 0, 0, 0.85);
        border: 2px solid #ffd700;
        border-radius: 6px;
        padding: 4px 6px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    }

    /* Fila única con todos los stats */
    .mini-stats-row {
        display: flex;
        gap: 5px;
        align-items: center;
    }

    /* Stats con barras (HP, Mana, EXP) */
    .mini-stat {
        position: relative;
        min-width: 60px;
        height: 22px;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 4px;
        overflow: hidden;
    }

    .mini-stat-bar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        transition: width 0.3s ease;
    }

    .mini-stat-bar.hp-bar {
        background: linear-gradient(90deg, #dc2626 0%, #ef4444 100%);
        box-shadow: 0 0 8px rgba(220, 38, 38, 0.5);
    }

    .mini-stat-bar.mana-bar {
        background: linear-gradient(90deg, #2563eb 0%, #3b82f6 100%);
        box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
    }

    .mini-stat-bar.exp-bar {
        background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
        box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    }

    .mini-stat-text {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        font-size: 9px;
        font-weight: bold;
        color: #ffffff;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
        z-index: 1;
    }

    /* Stats simples (Nivel, Oro, Mapa, Pos) */
    .mini-stat-simple {
        display: flex;
        align-items: center;
        gap: 3px;
        background: rgba(255, 255, 255, 0.05);
        padding: 3px 5px;
        border-radius: 4px;
        border: 1px solid rgba(255, 215, 0, 0.2);
        height: 22px;
    }

    .mini-stat-label {
        font-size: 12px;
    }

    .mini-stat-value {
        font-size: 9px;
        color: #ffd700;
        font-weight: bold;
        white-space: nowrap;
    }

    /* Barra de hechizos móvil - Posicionada sobre el canvas */
    .mobile-spells-bar {
        position: absolute;
        right: 5px;
        z-index: 10;
        display: none;
        background: rgba(0, 0, 0, 0.85);
        border: 2px solid #8b5cf6;
        border-radius: 6px;
        padding: 4px 6px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
        display: flex;
        gap: 5px;
    }

    .spell-slot {
        position: relative;
        width: 32px;
        height: 32px;
        background: rgba(0, 0, 0, 0.5);
        border: 2px solid rgba(139, 92, 246, 0.3);
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        cursor: pointer;
        transition: all 0.3s;
    }

    .spell-slot:hover {
        background: rgba(139, 92, 246, 0.2);
        border-color: #8b5cf6;
        transform: scale(1.05);
    }

    .spell-slot.active {
        background: rgba(139, 92, 246, 0.3);
        border-color: #8b5cf6;
        box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    }

    .spell-slot.empty {
        color: rgba(255, 255, 255, 0.2);
        font-size: 14px;
        cursor: default;
    }

    .spell-slot.empty:hover {
        transform: none;
        background: rgba(0, 0, 0, 0.5);
        border-color: rgba(139, 92, 246, 0.3);
    }

    .spell-slot .spell-mana-cost {
        position: absolute;
        bottom: 1px;
        right: 1px;
        background: rgba(37, 99, 235, 0.9);
        color: white;
        font-size: 8px;
        font-weight: bold;
        padding: 1px 3px;
        border-radius: 2px;
        border: 1px solid #2563eb;
    }

    /* Ocultar exp-container en móvil */
    .exp-container {
        display: none;
    }

    .stat-hp { color: #ef4444; }
    .stat-gold { color: #f59e0b; }
    .stat-level { color: #8b5cf6; }

    /* Chat adjustments for mobile */
    .chat-section {
        padding: 8px;
    }

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

    .chat-toggle {
        background: rgba(255, 215, 0, 0.1);
        border: 2px solid rgba(255, 215, 0, 0.3);
        color: #ffd700;
        padding: 4px 8px;
        border-radius: 5px;
        cursor: pointer;
        font-size: 12px;
        transition: all 0.3s;
        position: relative;
    }

    .chat-toggle:hover {
        background: rgba(255, 215, 0, 0.2);
        border-color: #ffd700;
    }

    .chat-notification {
        position: absolute;
        top: -2px;
        right: -2px;
        background: #ef4444;
        color: white;
        border-radius: 50%;
        width: 12px;
        height: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 8px;
        font-weight: bold;
        border: 2px solid #000;
    }

    .chat-log {
        height: 50px;
        font-size: 10px;
        transition: all 0.3s;
    }

    /* Hide sidebar in mobile */
    .sidebar {
        display: none;
    }

    /* Bottom inventory bar for mobile */
    .inventory-bottom {
        background: rgba(0, 0, 0, 0.9);
        border: 3px solid #ffd700;
        border-radius: 10px;
        padding: 8px;
        margin-top: 5px;
        flex-shrink: 0;
    }

    .inventory-bottom .inventory {
        display: grid;
        grid-template-columns: repeat(9, 1fr);
        gap: 4px;
    }

    .inventory-bottom .item-slot {
        min-height: 35px;
        font-size: 16px;
        aspect-ratio: 1;
    }

    .inventory-bottom .item-slot.empty {
        font-size: 10px;
    }

    /* Mobile menu modal */
    .mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 10000;
        display: none;
    }

    .menu-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.8);
    }

    .menu-content {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.95);
        border: 3px solid #ffd700;
        border-radius: 15px 15px 0 0;
        padding: 20px;
        max-height: 70vh;
        overflow-y: auto;
    }

    .menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15px;
        border-bottom: 2px solid #ffd700;
        padding-bottom: 10px;
    }

    .menu-header h3 {
        color: #ffd700;
        margin: 0;
        font-size: 18px;
    }

    .menu-close {
        background: rgba(244, 67, 54, 0.8);
        border: 2px solid #f44336;
        color: white;
        padding: 5px 10px;
        border-radius: 5px;
        cursor: pointer;
        font-size: 14px;
        transition: all 0.3s;
    }

    .menu-close:hover {
        background: rgba(244, 67, 54, 1);
    }

    .menu-items {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .menu-item {
        display: flex;
        align-items: center;
        gap: 15px;
        background: rgba(255, 255, 255, 0.1);
        border: 2px solid rgba(255, 215, 0, 0.3);
        padding: 15px;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.3s;
        font-size: 14px;
        color: white;
    }

    .menu-item:hover {
        background: rgba(255, 215, 0, 0.1);
        border-color: #ffd700;
        transform: translateY(-2px);
    }

    .menu-icon {
        font-size: 20px;
        color: #ffd700;
        min-width: 25px;
        text-align: center;
    }

    /* Game area adjustments for mobile */
    .game-area {
        flex: 1;
        min-height: 200px;
    }

    #gameCanvas {
        min-height: 200px;
    }

    /* Controls adjustments for mobile */
    .controls {
        display: none;
    }
}

/* Hide mobile-specific elements on desktop */
@media (min-width: 769px) {
    .inventory-bottom {
        display: none;
    }

    .mobile-menu {
        display: none !important;
    }

    /* Hide mobile HUD toggle and HUD on desktop */
    .mobile-hud-toggle,
    .mobile-hud,
    .minimalist-hud {
        display: none !important;
    }

    /* Hide mobile header elements on desktop */
    .header-top,
    .menu-button,
    .stats-compact,
    .chat-header,
    .chat-toggle,
    .chat-notification {
        display: none !important;
    }

    /* Show original desktop header elements */
    .stats {
        display: flex;
    }
}

/* Trading system styles - Inspired by Argentum Online */
.trade-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.trade-box {
    background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
    border: 4px solid #ffd700;
    border-radius: 15px;
    padding: 20px;
    padding-bottom: 70px; /* Espacio para el botón de cerrar */
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.6);
    animation: slideIn 0.3s ease-out;
    position: relative;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.trade-header {
    margin-bottom: 20px;
}

.trade-title {
    color: #ffd700;
    font-size: 24px;
    text-align: center;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    border-bottom: 3px solid #ffd700;
    padding-bottom: 10px;
}

.trade-tabs {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.trade-tab {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.3);
    color: #ffffff;
    padding: 10px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
}

.trade-tab:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #ffd700;
}

.trade-tab.active {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border-color: #66bb6a;
    color: white;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
}

.trade-content {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    margin-bottom: 20px;
}

.trade-list {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.trade-item {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 215, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s;
    display: grid;
    grid-template-columns: 60px 1fr 100px;
    gap: 15px;
    align-items: center;
}

.trade-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #ffd700;
    transform: translateX(5px);
}

.trade-item.selected {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4CAF50;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
}

.trade-item .item-icon {
    font-size: 36px;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 8px;
    border: 2px solid rgba(255, 215, 0, 0.2);
}

.trade-item .item-details {
    flex: 1;
}

.trade-item .item-name {
    color: #ffd700;
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 5px;
}

.trade-item .item-price {
    color: #f59e0b;
    font-size: 13px;
}

.trade-item .item-stock {
    text-align: right;
    color: #ffffff;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px 10px;
    border-radius: 5px;
}

.trade-info {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.trade-item-details {
    flex: 1;
}

.trade-item-details h3 {
    color: #ffd700;
    font-size: 18px;
    margin-bottom: 10px;
    text-align: center;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3);
    padding-bottom: 8px;
}

.trade-item-details p {
    color: #ffffff;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 15px;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    min-height: 60px;
}

.trade-item-details .item-price {
    color: #f59e0b;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 15px;
    background: rgba(0, 0, 0, 0.4);
    padding: 10px;
    border-radius: 5px;
    border: 2px solid rgba(245, 158, 11, 0.3);
}

.item-quantity {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.trade-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quantity-btn {
    background: rgba(255, 215, 0, 0.2);
    border: 2px solid rgba(255, 215, 0, 0.4);
    color: #ffd700;
    width: 35px;
    height: 35px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-btn:hover {
    background: rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
    transform: scale(1.1);
}

.quantity-btn:active {
    transform: scale(0.95);
}

.quantity-input {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 215, 0, 0.3);
    color: #ffffff;
    text-align: center;
    width: 80px;
    padding: 8px;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
}

.quantity-input:focus {
    border-color: #ffd700;
    outline: none;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.trade-gold {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(245, 158, 11, 0.4);
    border-radius: 8px;
    padding: 15px;
}

.trade-gold > div {
    color: #f59e0b;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 15px;
}

.trade-gold .player-gold {
    color: #ffd700;
    font-size: 18px;
}

.trade-action-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border: 2px solid #66bb6a;
    color: white;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    width: 100%;
    transition: all 0.3s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.trade-action-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #66bb6a 0%, #4CAF50 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.trade-action-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.trade-action-btn:disabled {
    background: rgba(128, 128, 128, 0.5);
    border-color: rgba(128, 128, 128, 0.3);
    cursor: not-allowed;
    opacity: 0.5;
}

.trade-close {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    border: 2px solid #ef5350;
    color: white;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: bold;
    width: calc(100% - 40px);
    transition: all 0.3s;
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
}

.trade-close:hover {
    background: linear-gradient(135deg, #ef5350 0%, #f44336 100%);
    transform: translateY(-1px);
}

/* Scrollbar para lista de trading */
.trade-list::-webkit-scrollbar {
    width: 8px;
}

.trade-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.trade-list::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.5);
    border-radius: 4px;
}

.trade-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.7);
}

/* Responsive trading */
@media (max-width: 900px) {
    .trade-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }

    .trade-info {
        order: 2;
    }

    .trade-list {
        max-height: 250px;
    }
}

@media (max-width: 600px) {
    .trade-box {
        padding: 15px;
        width: 95%;
    }

    .trade-title {
        font-size: 20px;
    }

    .trade-tabs {
        flex-direction: column;
        gap: 8px;
    }

    .trade-tab {
        padding: 8px 20px;
        font-size: 13px;
    }

    .trade-item {
        grid-template-columns: 50px 1fr;
        grid-template-rows: auto auto;
        gap: 10px;
    }

    .trade-item .item-icon {
        font-size: 30px;
        grid-row: 1 / 3;
    }

    .trade-item .item-stock {
        grid-column: 2;
        text-align: left;
        font-size: 11px;
    }

    .quantity-input {
        width: 60px;
        font-size: 14px;
    }

    .quantity-btn {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
}
