/* Ajustes generales */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #000;
    color: #eceff1;
}

/* Canvas de juego */

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
    outline: none;
}

/* Botón menú */

#menuToggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 20;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: none;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

/* Pantalla completa */

#fullscreenToggle {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 20;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: none;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

/* Menú de juego */

.game-menu {
    position: fixed;
    top: 60px;
    left: 10px;
    width: 200px;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 12px;
    padding: 8px;
    z-index: 19;
    transform: translateY(-15px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.game-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.game-menu-header {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.7;
    margin-bottom: 8px;
}

.game-menu-item {
    width: 100%;
    margin-bottom: 6px;
    padding: 8px 10px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: #eceff1;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.06s ease;
}

.game-menu-item:hover {
    background: rgba(129, 212, 250, 0.25);
    transform: translateY(-1px);
}

.game-menu-online {
    font-size: 12px;
    padding: 6px 8px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    line-height: 1.4;
}

.game-menu-online #onlineCount {
    font-weight: 600;
}

.online-list {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    max-height: 80px;
    overflow-y: auto;
}

.online-list li {
    font-size: 11px;
    opacity: 0.8;
}

/* Editor de mapa (panel derecho) */

.map-editor-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: radial-gradient(circle at top, rgba(22, 29, 35, 0.98), rgba(0, 0, 0, 0.98));
    color: #eceff1;
    z-index: 18;
    display: flex;
    flex-direction: column;
    box-shadow: -12px 0 30px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    transform: translateX(100%);
    transition: transform 0.2s ease-out;
}

.map-editor-panel.open {
    transform: translateX(0);
}

.map-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.9;
}

.map-editor-close {
    border: none;
    background: transparent;
    color: #eceff1;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 999px;
    transition: background 0.12s ease, transform 0.08s ease;
}

.map-editor-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.map-editor-body {
    flex: 1;
    display: flex;
    padding: 8px;
    gap: 8px;
    overflow: hidden;
}

.map-editor-column {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    padding: 6px;
}

.map-editor-folders {
    width: 35%;
}

.map-editor-images {
    flex: 1;
}

/* Títulos de sección */

.map-editor-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.7;
    margin-bottom: 4px;
}

/* Lista de carpetas */

.map-editor-folder-list {
    flex: 1;
    overflow-y: auto;
}

.map-editor-folder {
    width: 100%;
    padding: 6px 8px;
    margin-bottom: 4px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #eceff1;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.12s ease, transform 0.06s ease;
}

.map-editor-folder:hover {
    background: rgba(255, 255, 255, 0.08);
}

.map-editor-folder.active {
    background: radial-gradient(circle at left, rgba(128, 216, 255, 0.4), rgba(0, 0, 0, 0.8));
}

/* Buscador de objetos */

.map-editor-search {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}

.map-editor-search input,
.map-editor-search select {
    font-size: 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.7);
    color: #eceff1;
    padding: 5px 8px;
    outline: none;
}

.map-editor-search input:focus,
.map-editor-search select:focus {
    border-color: #80d8ff;
    box-shadow: 0 0 0 1px rgba(128, 216, 255, 0.5);
}

#objectSearchInput {
    flex: 1;
}

#objectSearchScope {
    flex: 0 0 90px;
}

/* Lista de objetos */

.map-editor-image-list {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 2px;
}

/* Card de objeto (miniaturas pequeñas) */

.map-editor-item {
    position: relative;
    border-radius: 10px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
    width: 72px;
}

.map-editor-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6);
}

.map-editor-item.selected {
    background: radial-gradient(circle at top, rgba(128, 216, 255, 0.5), rgba(0, 0, 0, 0.9));
    box-shadow: 0 0 0 1px rgba(128, 216, 255, 0.9);
}

/* Miniatura del objeto (más pequeña) */

.map-editor-thumb {
    width: 64px;
    height: 64px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 4px;
    transition: transform 0.08s ease, border-color 0.12s ease, background 0.12s ease;
    display: block;
    margin: 0 auto 4px auto;
}

.map-editor-item:hover .map-editor-thumb {
    transform: translateY(-1px);
    border-color: rgba(129, 212, 250, 0.75);
}

/* Respetar la posible clase antigua .selected directamente en el img */
.map-editor-thumb.selected {
    border-color: #80d8ff;
    box-shadow: 0 0 0 1px rgba(128, 216, 255, 0.7);
    background: rgba(128, 216, 255, 0.08);
}

/* Cuando el wrapper está seleccionado, remarcar miniatura también */

.map-editor-item.selected .map-editor-thumb {
    border-color: #80d8ff;
    box-shadow: 0 0 0 1px rgba(128, 216, 255, 0.9);
    background: rgba(128, 216, 255, 0.12);
}

/* Nombre del objeto bajo la miniatura */

.map-editor-item-name {
    margin-top: 2px;
    font-size: 11px;
    text-align: center;
    max-height: 2.4em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.85;
}

/* Pie del editor */

.map-editor-footer {
    padding: 6px 10px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 11px;
    opacity: 0.8;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-editor-hint {
    line-height: 1.4;
}

/* Secciones dentro del footer */

.map-editor-section {
    margin-bottom: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}

/* Botones reutilizables del editor */

.map-editor-btn {
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #29b6f6, #80d8ff);
    color: #001018;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    justify-self: flex-end;
    transition: transform 0.08s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.map-editor-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.7);
    filter: brightness(1.05);
}

.map-editor-btn-danger {
    background: linear-gradient(135deg, #ef5350, #ff8a80);
    color: #1b0000;
}

/* Bloque de subida de SVG */

.map-editor-upload {
    display: flex;
    justify-content: flex-start;
    gap: 6px;
}

/* Panel: configuración de asset antes de colocar */

.map-editor-selected {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    font-size: 12px;
}

.map-editor-selected label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    opacity: 0.9;
}

.map-editor-selected input[type="text"],
.map-editor-selected input[type="number"] {
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.8);
    color: #eceff1;
    font-size: 12px;
    padding: 4px 6px;
}

.map-editor-selected input[type="text"]:focus,
.map-editor-selected input[type="number"]:focus {
    outline: none;
    border-color: #80d8ff;
    box-shadow: 0 0 0 1px rgba(128, 216, 255, 0.5);
}

/* Checkbox bloquear casilla */

.map-editor-checkbox {
    grid-column: 1 / -1;
    display: flex;
    align-items: left;
    gap: 6px;
    margin-top: 4px;
}

.map-editor-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

/* Cursor en modo edición de mapa */

body.map-editing #gameCanvas {
    cursor: crosshair;
}

/* ============================= */
/* AJUSTES SOLO PARA MÓVIL */
/* ============================= */

@media (max-width: 768px) {

    /* Escalado general de textos */
    body {
        font-size: 18px;
    }

    /* ---------- LOGIN ---------- */
    .auth-card {
        max-width: 90vw;
        padding: 36px 28px;
        border-radius: 22px;
    }

    .auth-title {
        font-size: 26px;
    }

    .auth-sub {
        font-size: 16px;
    }

    .auth-field label {
        font-size: 16px;
    }

    .auth-field input {
        font-size: 20px;
        padding: 14px 16px;
        border-radius: 14px;
    }

    .auth-actions {
        gap: 14px;
    }

    .auth-btn {
        font-size: 20px;
        padding: 14px 18px;
    }

    .auth-error {
        font-size: 16px;
    }

    /* ---------- BOTONES FLOTANTES ---------- */
    #menuToggle,
    #fullscreenToggle {
        width: 64px;
        height: 64px;
        font-size: 32px;
        border-radius: 50%;
    }

    /* ---------- MENÚ DE JUEGO ---------- */
    .game-menu {
        width: 90vw;
        font-size: 18px;
        border-radius: 18px;
    }

    .game-menu-header {
        font-size: 22px;
    }

    .game-menu-item {
        font-size: 20px;
        padding: 16px;
        border-radius: 14px;
    }

    .game-menu-online {
        font-size: 18px;
    }

    /* ---------- EDITOR DE MAPA ---------- */
    .map-editor-panel {
        width: 100vw;
        font-size: 18px;
    }

    .map-editor-header {
        font-size: 22px;
        padding: 16px;
    }

    .map-editor-close {
        font-size: 26px;
        width: 48px;
        height: 48px;
    }

    .map-editor-section-title {
        font-size: 20px;
    }

    .map-editor-body {
        flex-direction: column;
    }

    .map-editor-folders {
        width: 100%;
        margin-bottom: 8px;
    }

    .map-editor-images {
        width: 100%;
    }

    .map-editor-image-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .map-editor-item-name {
        font-size: 13px;
    }

    .map-editor-footer {
        font-size: 16px;
        padding: 14px;
    }

    .map-editor-section {
        padding: 10px 12px;
    }

    .map-editor-selected {
        grid-template-columns: 1fr;
        font-size: 16px;
    }

    .map-editor-selected input[type="text"],
    .map-editor-selected input[type="number"] {
        font-size: 16px;
        padding: 8px 10px;
    }

    .map-editor-checkbox {
        font-size: 16px;
    }

    .map-editor-btn {
        font-size: 16px;
        padding: 10px 16px;
    }

    .map-editor-upload input[type="number"] {
        font-size: 16px;
        padding: 8px 10px;
    }

    /* ---------- CANVAS (JUEGO) ---------- */
    #gameCanvas {
        touch-action: none;
        image-rendering: pixelated;
    }
}

