/* --- ESTILOS GLOBALES Y DEL EDITOR (ACTUALIZADOS) --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
  
    color: white;
    overflow: hidden;
}

/* Todos los selectores de ID han sido actualizados con el prefijo "r-" */
#r-editor-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

#r-main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
   
    border-bottom: 1px solid #444;
    flex-shrink: 0;
}

#r-main-header h1 {
    margin: 0;
    font-size: 1.5em;
}

#r-main-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

#r-main-controls button {
    padding: 8px 15px;
    font-size: 1em;
    background-color: #4682B4;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#r-main-controls button:hover {
    background-color: #5a9bdc;
}

#r-zoom-controls {
    display: flex;
    gap: 5px;
    border: 1px solid #555;
    border-radius: 5px;
    padding: 2px;
    margin-right: 10px;
}

.zoom-btn {
    width: 35px;
    height: 35px;
    font-size: 20px;
    font-weight: bold;
    padding: 0;
    background-color: #555 !important;
    line-height: 35px;
    text-align: center;
}

.zoom-btn:hover {
    background-color: #666 !important;
}

#r-main-content {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}

#r-side-panel {
    width: 25%;
 
    padding: 15px;
    overflow-y: auto;
    border-right: 1px solid #444;
    flex-shrink: 0;
}

.palette {
    margin-bottom: 25px;
}

.palette h2 {
    margin-top: 0;
    border-bottom: 1px solid #555;
    padding-bottom: 8px;
    font-size: 1.2em;
}

.palette-item {
    display: flex;
    align-items: center;
    width: calc(100% - 20px);
    padding: 10px;
    margin-bottom: 5px;
    border: 2px solid #555;
    border-radius: 4px;
    cursor: pointer;
 
    color: rgb(0, 0, 0);
    font-size: 1em;
    text-align: left;
    text-transform: capitalize;
    transition: border-color 0.2s, background-color 0.2s;
}

.palette-item:hover {
    border-color: #777;
}

.palette-item.selected {
    border-color: #87ceeb;
 
    font-weight: bold;
}

.palette-item .color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    margin-right: 10px;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Estilo para las imágenes de los personajes en la paleta */
.palette-item .entity-image-icon {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    object-fit: cover;
    border-radius: 3px;
}


#r-map-grid-container {
    flex-grow: 1;
    overflow: auto;
 
    text-align: center;
    cursor: grab;
}

#r-map-grid {
    display: grid;
    cursor: pointer;
    transition: transform 0.2s ease-out;
    margin: 20px;
    gap: 5px;
}

.grid-cell {
    width: 125px;
    height: 125px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    border: 1px solid #555;
    padding: 2px;
}

.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; }

.subgrid-cell {
    border: 1px solid rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    transition: background-color 0.2s;
    color: white;
}

.subgrid-cell:hover {
    background-color: rgba(135, 206, 235, 0.5);
    border: 1px solid #87ceeb;
}

/* --- ESTILOS MODAL DE PREVISUALIZACIÓN --- */
.modal-overlay2 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content2 {
  
    padding: 20px;
    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-content2 {
    top: 0%;
    width: 100%;
    height: 96%;
    position: absolute;
}

.modal-content2 h3 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #555;
    flex-shrink: 0;
}

.modal-close-button1 {
    position: absolute;
    visibility: visible;
    top: 30px;
    right: 30px;
    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;
}

#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 --- */
