body { 
    margin: 0; 
    font-family: 'Inter', sans-serif; 
    background-color: #1f1f1f;
    color: #e0e0e0;
    overflow: hidden;
    cursor: url('assets/cursors/default.png'), auto;
}

canvas { display: block; }


/* Apply custom cursor to all interactive elements */
button,
.menu-button,
.base-map-option,
.modal-close-btn,
.delete-btn,
.visibility-icon,
.expand-btn,
#hierarchy-list li,
#spawn-list li,
#hierarchy-toggle,
#map-name-display,
.setting-item select,
.setting-item input[type="number"],
.checkbox-wrapper input[type="checkbox"],
.checkbox-wrapper label {
    cursor: url('assets/cursors/default.png'), auto !important;
}


#main-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#main-menu.hidden { display: none; }


.menu-container {
    background-color: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.menu-container h1 {
    margin: 0 0 30px 0;
    font-size: 2em;
    font-weight: 600;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.menu-section {
    margin-bottom: 30px;
}

.menu-section h2 {
    margin: 0 0 15px 0;
    font-size: 1.2em;
    font-weight: 600;
    color: #aaa;
}

.menu-input {
    width: 100%;
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 12px;
    font-size: 1em;
    box-sizing: border-box;
    margin-bottom: 15px;
}

/* Remove bottom margin when input is in a flex container */
.flex .menu-input {
    margin-bottom: 0;
}

.menu-input:focus {
    outline: none;
    border-color: #667eea;
}

.menu-button {
    width: 100%;
    background-color: #667eea;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.2s;
    margin-bottom: 10px;
}

.menu-button:hover {
    background-color: #5568d3;
}

.menu-button:active {
    transform: scale(0.98);
}

.menu-button.secondary {
    background-color: #4a4a4a;
}

.menu-button.secondary:hover {
    background-color: #5a5a5a;
}


.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal-backdrop.active {
    display: flex;
}

.modal-container {
    background-color: rgba(30, 30, 30, 0.98);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.modal-container h2 {
    margin: 0 0 25px 0;
    font-size: 1.5em;
    font-weight: 600;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close-btn {
    width: 100%;
    background-color: #667eea;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    transition: background-color 0.2s;
    margin-top: 20px;
}

.modal-close-btn:hover {
    background-color: #5568d3;
}


.settings-group {
    margin-bottom: 25px;
}

.settings-group h3 {
    margin: 0 0 12px 0;
    font-size: 1em;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.setting-item label {
    font-weight: 500;
    color: #e0e0e0;
}

.setting-item input[type="number"] {
    width: 80px;
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.95em;
    text-align: center;
}

.setting-item input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

.setting-item select {
    width: 120px;
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.95em;
}

.setting-item select:focus {
    outline: none;
    border-color: #667eea;
}


/* --- NEW & IMPROVED HISTORY LIST STYLES --- */
#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 50vh;
    overflow-y: auto;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid #444;
}

#history-list li {
    padding: 12px 15px;
    border-bottom: 1px solid #444;
    transition: background-color 0.2s;
    font-weight: 500;
}

#history-list li:last-child {
    border-bottom: none;
}

#history-list li:hover {
    background-color: #4f5257;
}

#history-list li.current {
    background-color: #3182CE;
    color: white;
    font-weight: 600;
}
/* --- END NEW STYLES --- */



#editor-container {
    display: none;
}

#editor-container.active {
    display: block;
}


.panel { 
    position: absolute; 
    background-color: rgba(30, 30, 30, 0.85); 
    backdrop-filter: blur(10px); 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-radius: 12px; 
    z-index: 100; 
    user-select: none; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.2); 
    padding: 15px 20px;
}


#top-left-cluster {
    top: 10px;
    left: 10px;
    display: flex;
    gap: 10px;
    padding: 10px;
}

#top-right-cluster {
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
    padding: 10px;
}

#bottom-left-cluster {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    background-color: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    z-index: 101;
    padding: 5px;
}

#bottom-left-cluster #spawn-btn {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

button { 
    background-color: #4a4a4a; 
    color: white; 
    border: 1px solid rgba(255,255,255,0.1); 
    padding: 8px 12px; 
    border-radius: 8px; 
    transition: background-color 0.2s, transform 0.2s; 
    font-weight: 500;
}

button:hover { background-color: #5a5a5a; }

button:active { transform: scale(0.95); }

button.active {
    background-color: #3182CE;
    border-color: #3182CE;
}

button:disabled {
    opacity: 0.5;
    cursor: url('assets/cursors/default.png'), auto !important;
}


#properties-panel {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 300px;
    max-height: 80vh;
    overflow-y: auto;
    display: none;
    margin-bottom: 70px;
    z-index: 100;
}

#properties-panel h3 { 
    margin: 0 0 15px 0; 
    border-bottom: 1px solid #444; 
    padding-bottom: 10px; 
    font-size: 1.1em; 
    font-weight: 600; 
}

.prop-group { margin-bottom: 12px; }

.prop-group label { 
    font-weight: 500; 
    display: block; 
    margin-bottom: 8px; 
    color: #aaa; 
    font-size:0.9em; 
}

.vec3-input { display: flex; gap: 8px; }

.vec3-input input, .text-input { 
    width: 100%; 
    background-color: #2a2a2a; 
    color: #e0e0e0; 
    border: 1px solid #444; 
    border-radius: 6px; 
    padding: 8px; 
    font-size: 0.95em; 
    box-sizing: border-box; 
    text-align: center;
}

input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}

input[type=number] { -moz-appearance: textfield; }


#snap-ground-btn, #group-btn, #ungroup-btn, #add-to-group-btn { 
    width: 100%; 
    margin-top: 10px; 
}


.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.checkbox-wrapper label {
    margin: 0;
    color: #e0e0e0;
}


#hierarchy-panel { 
    top: 70px;
    right: 0; 
    width: 280px; 
    max-height: calc(100vh - 80px);
    border-radius: 12px 0 0 12px; 
    transform: translateX(100%); 
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1); 
    display: flex; 
    flex-direction: column; 
    padding: 20px 15px;
    box-sizing: border-box; 
    background-color: rgba(35, 35, 35, 0.85); 
}

#hierarchy-panel.open { transform: translateX(0); }

#hierarchy-toggle { 
    position: absolute; 
    top: 50%; 
    left: -30px; 
    transform: translateY(-50%); 
    width: 30px; 
    height: 60px; 
    background: inherit; 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-right: none; 
    border-radius: 8px 0 0 8px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: #aaa; 
    padding: 0;
}

#hierarchy-header { 
    padding-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#hierarchy-header h3 { margin: 0; font-weight: 600; }

#hierarchy-search { margin-bottom: 10px; width: 100%; }

#hierarchy-list { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
    overflow-y: auto; 
    flex-grow: 1; 
}

#hierarchy-list li { 
    padding: 8px 10px; 
    border-radius: 6px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 2px;
}

#hierarchy-list li:hover { background-color: #4f5257; }

#hierarchy-list li.selected { background-color: #3182CE; color: white; }

#hierarchy-list li.group-item { 
    background-color: rgba(147, 51, 234, 0.15); 
    border-left: 3px solid #9333ea;
    padding-left: 7px;
    font-weight: 600;
}

#hierarchy-list li.group-item.selected { 
    background-color: #9333ea;
}

#hierarchy-list li.group-child {
    margin-left: 20px;
    padding-left: 15px;
    border-left: 2px solid #555;
    background-color: rgba(255, 255, 255, 0.03);
}

#hierarchy-list li.group-child.selected {
    background-color: #3182CE;
}

.hierarchy-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
    min-width: 0;
}

.hierarchy-name { 
    flex-grow: 1; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    padding: 2px 0; 
}

.hierarchy-name.editable {
    background-color: #2a2a2a;
    border: 1px solid #3182CE;
    border-radius: 4px;
    padding: 2px 6px;
    outline: none;
}

.expand-btn {
    color: #aaa;
    font-size: 0.8em;
    padding: 0 5px;
    user-select: none;
    min-width: 15px;
}

.expand-btn:hover {
    color: #fff;
}

.visibility-icon {
    color: #aaa;
    font-size: 1.1em;
    padding: 0 5px;
}

.visibility-icon:hover {
    color: #fff;
}

.visibility-icon.hidden {
    color: #666;
}

.delete-btn { 
    color: #aaa; 
    font-weight: bold; 
    padding: 0 5px; 
    border-radius: 3px;
    font-size: 1.2em;
}

.delete-btn:hover { color: #ff5555; }


#spawn-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 199;
    display: none;
}

#spawn-menu {
    position: absolute;
    width: 280px;
    max-height: 400px;
    background-color: rgba(40, 40, 40, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    z-index: 200;
    box-shadow: 0 5px 25px rgba(0,0,0,0.3);
    display: none;
    flex-direction: column;
    padding: 10px;
}

#spawn-search {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background-color: #2a2a2a;
    border: 1px solid #444;
    color: #e0e0e0;
    border-radius: 6px;
    box-sizing: border-box;
}

#spawn-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

#spawn-list li {
    padding: 10px 12px;
    border-radius: 6px;
    font-weight: 500;
}

#spawn-list li:hover {
    background-color: #3182CE;
}


#renderCanvas {
    width: 100vw;
    height: 100vh;
    display: block;
    touch-action: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    cursor: url('assets/cursors/default.png'), auto;
}


#selection-badge {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(147, 51, 234, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 500;
    display: none;
    z-index: 100;
}


#map-name-display {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px 20px;
    font-size: 1.1em;
    font-weight: 600;
    z-index: 100;
}


#grid-snap-indicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(102, 126, 234, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 600;
    display: none;
    z-index: 100;
}

#grid-snap-indicator.active {
    display: block;
}


#map-name-edit-input {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2a2a2a;
    border: 1px solid #667eea;
    border-radius: 12px;
    padding: 8px 20px;
    font-size: 1.1em;
    font-weight: 600;
    z-index: 100;
    color: #e0e0e0;
    text-align: center;
    outline: none;
    font-family: 'Inter', sans-serif;
    box-sizing: border-box;
}


/* --- NEW: Loading Screen Styles --- */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    z-index: 2000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #e0e0e0;
    font-size: 1.2em;
    font-weight: 500;
}


#loading-screen.active {
    display: flex;
}


.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #4a4a68;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}


@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


#view-cluster {
    position: absolute;
    top: 70px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    z-index: 101;
}

/* Dark overlay to ensure menu text is readable over the images */
#main-menu::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 0;
}

/* Make sure the menu content appears above the overlay */
#main-menu .menu-container {
    position: relative;
    z-index: 1;
}

/* Slideshow container */
#bg-slideshow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

/* Individual slide styles */
#bg-slideshow .slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}

/* The active slide is visible */
#bg-slideshow .slide.active {
    opacity: 1;
}

@keyframes flash-border {
    0% {
        border-color: #667eea;
        box-shadow: 0 0 10px #667eea;
    }
    100% {
        border-color: #444;
        box-shadow: none;
    }
}

#generate-name-btn {
    position: static;
    transform: none;
    height: 46px;
    width: 46px;
    min-width: 46px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-color: #4a4a4a; 
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 1.5rem;
    transition: all 0.2s;
}

#generate-name-btn:hover {
    transform: scale(1.05);
    background-color: #5a5a5a;
}

#generate-name-btn:active {
    transform: scale(0.95);
}

#minimap-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 200px;
    height: 200px;
    padding: 0;
    border-radius: 8px;
    /* overflow: hidden is critical for the effect */
    overflow: hidden; 
    background-color: #111;
    z-index: 101;
    transform: translateY(0);
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

#minimap-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    /* --- MODIFIED: Size Increased --- */
    width: 240px;
    height: 240px;
    /* --- END MODIFIED --- */
    padding: 0;
    border-radius: 8px;
    /* overflow: hidden is critical for the effect */
    overflow: hidden; 
    background-color: #111;
    z-index: 101;
}


#minimap-image {
    position: absolute; /* Must be absolute to be positioned by JS */
    opacity: 0.7;
    /* Zoom 2x */
    width: 200%; 
    height: 200%;
    /* Prevent image from shrinking */
    max-width: none; 
}


#minimap-camera-indicator {
    position: absolute;
    /* Static pin in the center */
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background-color: #3182CE;
    border: 2px solid white;
    border-radius: 50%;
    /* Use transform to perfectly center the pin */
    transform: translate(-50%, -50%); 
    box-shadow: 0 0 5px 2px rgba(49, 130, 206, 0.7);
    z-index: 102;
}


/* Programmatic grid*/
#minimap-container.minimap-grid-bg {
    background-color: rgba(216, 216, 224, 0.7); /* #d8d8e0 at 70% */
    
    /* --- MODIFIED: Added major/minor grid lines --- */
    background-image:
        /* Minor lines (fainter) */
        linear-gradient(to right, rgba(30, 30, 30, 0.3) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(30, 30, 30, 0.3) 1px, transparent 1px),
        /* Major lines (darker) */
        linear-gradient(to right, rgba(30, 30, 30, 0.7) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(30, 30, 30, 0.7) 1px, transparent 1px);
    
    /* --- MODIFIED: Set 4-to-1 ratio --- */
    background-size:
        /* Minor lines (zoomed 2x from 6.25px) */
        12.5px 12.5px,
        12.5px 12.5px,
        /* Major lines (zoomed 2x from 25px) */
        50px 50px,
        50px 50px; 
    
    /* Position is now controlled by JS */
}

#minimap-container.minimap-grid-bg #minimap-image {
    display: none; /* Hide the image element */
}