/* Basic Reset */
body {
    margin: 0;
    font-family: 'Cinzel', 'Georgia', serif; 
    background-color: #000;
    color: #fff;
    overflow: hidden; 
}

/* 1. Interface Layout (Flexbox) - Wood Grain Background for Outer Frame */
#interface-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    
    /* Use the wood tile as the main background, repeating it */
    background-image: url('images/wood_frame_tile.png'); 
    background-repeat: repeat; 
    background-color: #38240f; 
    
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.9);
}

/* 2. Map Area (Left Side) - ANIMATED */
#map-area {
    flex: 3;
    padding: 15px;
    position: relative;
    overflow: hidden;
    
    /* ADDED MAP LOAD ANIMATION */
    transform: translateX(-10%); /* Start slightly off-screen to the left */
    opacity: 0;
    animation: map-load 0.8s ease-out forwards;
    animation-delay: 0.1s; 
}

/* Map Placeholder (Fills entire map area) */
.map-image-placeholder {
    width: 100%;
    height: 100%; 
    
    /* Map image set as background to guarantee full coverage */
    background-image: url('images/map.jpg');
    background-size: cover; 
    background-position: center center;
    background-repeat: no-repeat;
    
    border: 5px solid #1e130a; 
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
    
    display: block; 
    color: transparent; /* Hides placeholder text */
    
    animation: subtle-pulse 10s ease-in-out infinite alternate; 
}

/* 3. Sidebar Container (Right Side) - The Wooden Frame - ANIMATED */
#sidebar {
    flex: 1;
    margin: 15px 15px 15px 0; 
    background-image: url('images/wood_frame_tile.png'); 
    background-repeat: repeat; 
    background-color: #38240f; 
    transform: translateX(100%); 
    opacity: 0;
    animation: sidebar-load 0.8s ease-out forwards;
    animation-delay: 0.1s; 
    box-shadow: -5px 0 10px rgba(0, 0, 0, 0.5);
    overflow-y: hidden; 
    position: relative; 
}

/* Inner Content Container (The Parchment Layer) */
#character-info {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    background-color: #fffbe2; 
    color: #38240f; 
    padding: 20px 15px; /* Reduced padding */
    overflow-y: auto;
    
    font-size: 0.9em; /* Reduced base font size */
    
    background-image: radial-gradient(circle at 10% 10%, rgba(0,0,0,.05) 1px, transparent 1px),
                      radial-gradient(circle at 90% 90%, rgba(0,0,0,.05) 1px, transparent 1px);
    background-size: 50px 50px;
}

/* Character Info Styling */
#character-info h2 {
    text-align: center;
    color: #1e130a;
    margin-top: 0;
    border-bottom: 2px solid #38240f;
    padding-bottom: 5px;
    
    font-size: 1.2em; /* Reduced name font size */
}

#character-info h3 {
    color: #5d3f1d;
    margin-top: 10px; 
    margin-bottom: 5px;
    
    font-size: 0.95em; /* Reduced heading font size */
}

/* Character Portrait Size Increased */
#char-picture {
    width: 150px; 
    height: 150px; 
    border-radius: 50%;
    background-color: #999;
    border: 4px solid #38240f;
    display: block;
    margin: 0 auto 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* List Styling */
ul {
    list-style-type: '📜'; 
    padding-left: 15px; 
    margin-top: 0;
}

li {
    margin-bottom: 3px; 
}

/* --- MARKER STYLING (IMAGE ICONS) --- */
.player-marker {
    /* FIX: Ensure markers are positioned correctly on the map */
    position: absolute; 
    
    width: 60px; 
    height: 60px; 
    
    border-radius: 0; 
    background-color: transparent; 
    border: none;
    
    background-size: contain; 
    background-repeat: no-repeat;
    background-position: center;
    
    color: transparent; /* Hide text label */
    
    font-weight: bold;
    cursor: pointer;
    box-shadow: none; 
    z-index: 10;
    font-size: 1.1em;
    
    /* Initial drop shadow for prominence */
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.7)); 
    
    transition: transform 0.2s ease-out, filter 0.2s ease-out; 
}

/* NEW: Nameplate Styling (ALWAYS VISIBLE) */
.player-nameplate {
    position: absolute;
    bottom: 100%; 
    left: 50%;
    
    /* Always show in final position */
    transform: translateX(-50%) translateY(0); 
    
    padding: 3px 8px;
    white-space: nowrap; 
    
    /* Look and Feel */
    background-color: #38240f; 
    color: #fffbe2; 
    border: 1px solid #fffbe2;
    border-radius: 3px;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 1px;
    
    /* Always visible */
    opacity: 1;
    pointer-events: auto; 
    transition: none; 
    z-index: 20;
} 


/* Marker Hover Effect (Refined Glow) */
.player-marker:hover {
    transform: scale(1.25); 
    
    /* Only use drop-shadow for the glow to respect image shape */
    filter: drop-shadow(0 0 8px var(--marker-color, #ffffff)) drop-shadow(0 0 12px rgba(255, 255, 255, 0.5)); 
    box-shadow: none; 
}

/* DYNAMIC CLASS DEFINITIONS (Set the Image Background) */
.engineer { 
    background-image: url('images/markers/marker_engineer.png'); 
    --marker-color: #007bff; 
}
.strategist { 
    background-image: url('images/markers/marker_strategist.png'); 
    --marker-color: #dc3545;
}
.prototyper { 
    background-image: url('images/markers/marker_prototyper.png'); 
    --marker-color: #28a745;
}

/* --- LOADING OVERLAY STYLES --- */

#sidebar-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.95);
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #1e130a;
    font-size: 1.2em;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#sidebar-loader.hidden {
    display: none;
}

.loader-spinner {
    border: 4px solid #f3f3f3; 
    border-top: 4px solid #8B4513;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

/* --- KEYFRAME ANIMATIONS --- */

/* Map Load Animation */
@keyframes map-load {
    from {
        transform: translateX(-10%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Sidebar Load Animation */
@keyframes sidebar-load {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes subtle-pulse {
    0% {
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
    }
    100% {
        box-shadow: 0 0 18px rgba(0, 0, 0, 0.9);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- LEVEL PROGRESS BAR STYLES --- */

#level-container {
    text-align: center;
    margin: 15px 0 10px;
    padding: 5px 0;
    border-top: 1px solid #d4c098;
    border-bottom: 1px solid #d4c098;
    background-color: rgba(0, 0, 0, 0.05);
}

#level-container p {
    margin: 3px 0;
    font-size: 0.85em;
}

.progress-bar-shell {
    width: 90%;
    height: 12px;
    background-color: #5d3f1d; /* Dark wood color */
    border: 1px solid #38240f;
    margin: 5px auto;
    overflow: hidden;
    border-radius: 2px;
}

#progress-bar-fill {
    height: 100%;
    width: 0%; /* Initial state handled by JS */
    background-color: #28a745; /* Green or progress color */
    transition: width 0.5s ease-out; /* Smooth animation when progress changes */
    
    /* Subtle texture on the fill bar */
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%, 
        transparent 25%, 
        transparent 50%, 
        rgba(255, 255, 255, 0.15) 50%, 
        rgba(255, 255, 255, 0.15) 75%, 
        transparent 75%, 
        transparent
    );
    background-size: 15px 15px;
}