 
#r-editor-container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

#r-main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    justify-content: center;
    align-items: center;
    padding: 10px ;
  position: absolute;
  height: 5%;
  width: 100%;
  top: 0;
  left: 0;
    flex-shrink: 0;
}
#r-texture-palette {}

#r-map-grid-container {
    position: relative; /* Necesario para posicionar el menú dentro */
}

#r-contextual-menu {
    position: absolute;
    top: 15px;
    left: 15px;
    background-color: rgba(40, 40, 40, 0.8);
    border-radius: 8px;
    z-index: 200;
    display: none; /* Oculto por defecto */
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.brush-size-btn {
    font-weight: bold;
    background-color: #555;
    border: 1px solid #777;
    color: white;
    width: 30px;
    height: 30px;
}
.brush-size-btn.active {
    background-color: #ff0000;
    border-color: #b30000;
}
#r-contextual-menu button {
    background-color: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 5px;
    transition: background-color 0.2s;
}

#r-contextual-menu button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#r-contextual-menu button.active {
    background-color: #ff0000;
    color: white;
}
    
}
#r-map-grid-container  canvas {
    width: 100%;
    height: 100% !important;
    top: 0% !important;
    left: 50% !important;
    position: absolute;
    transform: translateX(-50%) !important;
    background-color: transparent !important;
}

#r-map-grid-container {
    position: absolute;
    top: 4.5%;
    left: 0%;
    width: 100%;
    bottom: 0% ;
padding: 0%;
    flex-grow: 1;
    overflow: auto;
    text-align: center;
    cursor: grab;
}
#r-map-grid {
    display: grid;
    cursor: pointer;
    transition: transform 0.2s ease-out;
    margin: 0px;
    gap: 5px;
}

#r-main-header h1 { margin: 0; font-size: 1.5em; }
#r-main-controls { display: flex; align-items: center; gap: 10px; z-index: 2; }
#r-main-controls button {  
    transition: background-color 0.2s;
}
 

#r-main-content { display: flex; flex-grow: 1; overflow: hidden; }

#r-side-panel {
    position: absolute;
    height: 100%;
     left: -91%;
    top: 8%;
    width: 27%;
 margin-bottom: 5%;
    padding: 15px;
  flex-direction: row;
    padding-bottom: 7%;
    overflow-y: auto;
    border-right: 0px solid #444;
    flex-shrink: 0;
}
    #r-side-panel.desplegado {
        left: 1%; /* Mueve el panel para que sea visible */
    z-index: 5;}



/* Estilos para los inputs del nuevo modal de edición */
.modal-input {
    width: 100%;
    padding: 8px;
    background-color: #444;
    border: 1px solid #666;
    color: white;
    border-radius: 4px;
    box-sizing: border-box; /* Importante para que el padding no afecte el ancho */
    font-size: 14px;
}

.modal-input:focus {
    outline: none;
    border-color: #eb8787;
}
.palette h2 {
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #555;
    padding-bottom: 10px;
    font-size: 1.2em;
}

/* --- INICIO: NUEVOS ESTILOS DE CUADRÍCULA PARA PALETAS --- */
.palette-container {
    display: grid;
    /* Crea una cuadrícula responsiva con columnas de al menos 85px */
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    gap: 10px; /* Espacio entre los elementos */
overflow: hidden;
 
padding-bottom: 5%;
}
 
.palette-item {
    display: flex;
    flex-direction: column; /* Apila la vista previa y el texto verticalmente */
    align-items: center;
    justify-content: flex-start;
    height: 140px; /* Altura fija para cada elemento */
    padding: 8px;
    border: 1px solid #5555554b;
    border-radius: 6px;
    cursor: pointer;
  
    text-align: center;
 
    text-transform: capitalize;
    transition: border-color 0.2s, background-color 0.2s;
    word-break: break-word;
    margin-bottom: 5px;
}

.palette-item:hover { border-color: #a70000; }
 

/* Contenedor para la vista previa (imagen 3D, emoji o color) */
.palette-item-preview {
    width: 70px;
    height: 70px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.2);
}
.palette-item img {
width: 90px;
height: 100%;
object-fit: contain


}
/* Estilo para la imagen de previsualización 3D o sprite */
.palette-item-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Estilo para el icono de emoji */
.palette-item-preview-emoji {
    font-size: 40px;
}

/* Estilo para la muestra de color de la textura */
.color-swatch {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
/* --- FIN: NUEVOS ESTILOS DE CUADRÍCULA --- */

.edit-3d-canvas {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%  !important;
    height: 100% !important;
    display: flex; /* Buena práctica para canvas */
    background-color: transparent; /* Fondo transparente */
    border: none;
    padding: 0;
    margin: 0;
}


#r-map-grid {
    display: grid;
    cursor: pointer;
    transition: transform 0.2s ease-out;
    margin: 20px;
    gap: 1px;
}

/* El resto de tus estilos (modal, grid-cell, etc.) pueden permanecer igual */
.grid-cell {
    position: relative; /* Clave para el posicionamiento libre de entidades */
    width: 125px;
    height: 125px;
    border: 0px solid #444;
    padding: 0px;
}
 

.entity-marker {
    position: absolute;
    transform: translate(-50%, -50%); /* Centra el marcador en el punto exacto del clic */
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    font-size: 16px;
    pointer-events: none; /* Para que el clic atraviese el marcador y vaya al chunk */
}

.entity-marker img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.grid-cell.texture-grass { background-color: #7C9C4A; }
.grid-cell.texture-sand { background-color: #EDC9AF; }
.grid-cell.texture-stone { background-color: #615953; }
.grid-cell.texture-water { background-color: #3B698B; }
.grid-cell.texture-forest { background-color: #3E7C4F; }
.grid-cell.texture-empty { background-color: #33333333; }

 
 /* r-style.css */

/* Estilos para la cuadrícula del modal de avatares */
#r-avatar-grid {
    display: grid;
    /* Crea columnas que se ajustan automáticamente al tamaño disponible */
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    padding: 1rem;
    justify-items: center;
}

/* Estilos para cada elemento en la cuadrícula */
#r-avatar-grid .palette-item {
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid #444;
    background-color: #333;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

#r-avatar-grid .palette-item:hover {
    background-color: #4a4a4a;
    transform: translateY(-3px);
}

/* Estilos para la previsualización de la imagen del avatar */
#r-avatar-grid .palette-item-preview {
    width: 100px;
    height: 100px;
    background-color: #222;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#r-avatar-grid .palette-item-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Estilos para el nombre del avatar */
#r-avatar-grid .palette-item span {
    font-size: 0.8rem;
    color: #eee;
    text-align: center;
    word-break: break-word;
}


/* --- ESTILOS MODAL DE PREVISUALIZACIÓN --- */
/* EN: r-style.css */

.modal-overlay2 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    /* ▼▼▼ CAMBIOS CLAVE ▼▼▼ */
    background-color: rgba(0, 0, 0, 0.5); /* Añade un fondo oscuro semitransparente */
    z-index: 10000; /* Aumenta la prioridad para que esté por encima de todo */
    /* ▲▲▲ FIN DE LOS CAMBIOS ▲▲▲ */

    display: none;
    justify-content: center;
    align-items: center;
}
 .ruta-paso {
    background-color: #4f4f4f;
    padding: 8px 12px;
    margin-bottom: 5px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}
.ruta-paso button {
    background-color: #a03a3a;
    border: none;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
}


.modal-content4 {
 
  
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
  display: flex;
    flex-direction: column;
    position: relative;
}
 
#r-preview-modal .modal-content4 {
    bottom:1%; 
    left: 1%;
    width: 98%;
    height: 92%;
    position: absolute;
}

.modal-content4 h3 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #555;
    flex-shrink: 0;
}

.modal-close-button1 {
    position: absolute;
    visibility: visible;
    top: 5%;
    left: 0px;
    font-size: 50px;
    font-weight: bold;
    background-color: rgb(253, 58, 24);
    color: #000000;
    cursor: pointer;
    transition: color 0.2s;z-index: 1001101;
}

.modal-close-button:hover {
    color: rgb(0, 0, 0);
    z-index: 10001;
}

#r-game-container {
    flex-grow: 1;
    position: relative;
   
    border-radius: 5px;
    overflow: hidden;
    min-height: 0;
}

#r-game-container canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* --- INICIO: NUEVOS ESTILOS PARA MODAL DE PERSONAJES --- */
#r-character-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

.character-modal-content {
    background-color: #2c2c2c;
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 900px;
    height: 80%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.character-modal-content h3 {
    margin-top: 0;
    border-bottom: 1px solid #555;
    padding-bottom: 10px;
}

.character-modal-close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 15px;
    overflow-y: auto;
    padding: 10px;
    flex-grow: 1;
}
#r-character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    overflow-y: auto;
    padding: 10px;
    flex-grow: 1;
}

.character-grid-item {
    background-color: #3a3a3a;
    border: 2px solid #555;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
}

.character-grid-item:hover {
    border-color: #87ceeb;
    transform: translateY(-3px);
}

.character-grid-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 50%;
    margin-bottom: 10px;
    background-color: #555;
}

.character-grid-item span {
    font-size: 14px;
    text-align: center;
    color: #ddd;
}
/* --- FIN: NUEVOS ESTILOS --- */
/* --- ESTILOS GLOBALES Y DEL EDITOR (ACTUALIZADOS) --- */
 

#r-editor-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

#r-main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px ;
 
    flex-shrink: 0;
}

 
  

 
 
.palette h2 {
    margin-top: 0;
    margin-bottom: 15px;
    
    padding-bottom: 10px;
    font-size: 1.2em;
}

 

.palette-item:hover { border-color: #777; }

.palette-item.selected {
    border-color: #87ceeb;
    
    font-weight: bold;
}

/* Contenedor para la vista previa (imagen 3D, emoji o color) */
.palette-item-preview {
    width: 70px;
    height: 70px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.2);
}

/* Estilo para la imagen de previsualización 3D o sprite */
.palette-item-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Estilo para el icono de emoji */
.palette-item-preview-emoji {
    font-size: 40px;
}

/* Estilo para la muestra de color de la textura */
.color-swatch {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
/* --- FIN: NUEVOS ESTILOS DE CUADRÍCULA --- */


 /* Estilos para el nuevo lienzo de dibujado */
#r-map-canvas {
    background-color: transparent;
    cursor: crosshair;
    /* La transformación para el zoom se aplicará aquí desde JS */
}

/* Estilos para los controles del pincel */
#r-brush-controls {
    border: 1px solid #555;
}
#r-brush-controls label {
    font-size: 20px;
}
#r-brush-size-slider {
    cursor: pointer;
}

/* El resto de tus estilos (modal, grid-cell, etc.) pueden permanecer igual */