/* ========================================= */
/* 1. TYPOGRAPHY & THEME                     */
/* ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Lato:wght@400;700&display=swap');

:root {
    /* --- Colors --- */
    --bg-color: #0b0c10;         /* Deep void color */
    --panel-bg: #131419;         /* Dark slate for panels */
    --accent: #d4af37;           /* Metallic Gold */
    --accent-glow: rgba(212, 175, 55, 0.3);
    --skill: #3498db;

    /* --- Status Colors --- */
    --hp-color: #c0392b;
    --hp-gradient: linear-gradient(180deg, #e74c3c, #922b21);

    --enemy-hp-color: #8e44ad;
    --enemy-hp-gradient: linear-gradient(180deg, #9b59b6, #6c3483);

    --exp-color: #f1c40f;
    --exp-gradient: linear-gradient(180deg, #f7dc6f, #b7950b);

    --dungeon-color: #2980b9;
    --dungeon-gradient: linear-gradient(180deg, #5dade2, #1f618d);

    /* --- Text --- */
    --text-main: #ecf0f1;
    --text-muted: #95a5a6;

    /* --- Fonts --- */
    --font-main: 'Lato', sans-serif;
    --font-header: 'Cinzel', serif;
    --font-mono: 'Consolas', monospace;
}

/* ========================================= */
/* 2. GLOBAL LAYOUT                          */
/* ========================================= */
body {
    background-color: #000;
    background-image: radial-gradient(circle at center, #1c1c1c 0%, #000 100%);
    color: var(--text-main);
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }
::-webkit-scrollbar-track { background: #111; }

#game-device {
    width: 100%;
    max-width: 400px;
    height: 95%;
    max-height: 800px;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    position: relative;
    
    /* Magical Border Effect */
    border: 2px solid #333;
    border-radius: 8px;
    box-shadow: 0 0 25px rgba(0,0,0,0.8), 0 0 10px var(--accent-glow);
}

/* ========================================= */
/* 3. VISUAL PANEL (Top Screen)              */
/* ========================================= */
#visual-panel {
    flex: 6;
    position: relative;
    background-color: #000;
    overflow: hidden;
    /* The divider between screens is now a gold bar */
    border-bottom: 4px solid #4a3b22;
    box-shadow: inset 0 -10px 20px rgba(0,0,0,0.8);
    
    /* Strict Layering: Base Layer */
    z-index: 0; 
}

/* Backgrounds */
.bg-image-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1 !important;
}

.bg-image-fit {
    width: 100%; height: 100%;
    object-fit: cover;
    opacity: 0.6;
    transition: opacity 0.3s;
    filter: contrast(1.1) sepia(0.2);
}

/* Placeholders (Missing Assets) */
.missing-asset-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(20, 20, 20, 0.9);
    border: 2px dashed #555;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    padding: 10px;
    box-sizing: border-box;
    overflow-wrap: break-word;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
.bg-image-container .missing-asset-placeholder { width: 100%; height: 100%; opacity: 0.7; }
.sprite-wrapper .missing-asset-placeholder { width: 150px; height: 250px; }

/* ========================================= */
/* 4. SPRITES & ANIMATION                    */
/* ========================================= */
#sprite-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 10 !important;
}

.sprite-wrapper {
    position: absolute;
    bottom: 0;
    display: flex;
    justify-content: center;
    transition: transform 0.3s ease-out, left 0.3s ease-out, bottom 0.3s ease-out, opacity 0.3s;
    transform-origin: bottom center;
}

.character-sprite {
    position: relative;
    width: auto;
    height: 60vh;
    max-height: 300px;
    filter: drop-shadow(0 0 15px rgba(0,0,0,0.8));
}

/* Animation Classes */
.anim-fade-in { opacity: 0; animation: fadeIn 0.8s forwards; }
.anim-fade-out { opacity: 1; animation: fadeOut 0.8s forwards; }
.anim-shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; }
.anim-shake-screen { animation: screen-shake 0.5s ease-in-out; }

/* Keyframes */
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); } 
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); } 
    40%, 60% { transform: translate3d(6px, 0, 0); }
}
@keyframes screen-shake {
    0%, 100% { transform: translate(0, 0); }
    10%, 30%, 50% { transform: translate(-5px, 5px); }
    20%, 40%, 60% { transform: translate(5px, -5px); }
}

/* ========================================= */
/* 5. HUD & OVERLAYS                         */
/* ========================================= */

/* General HUD Container */
#hud-overlay {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    padding: 10px; box-sizing: border-box;
    background: linear-gradient(to bottom, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0) 100%);
    display: flex; flex-direction: column; gap: 5px;
    pointer-events: none; /* Let clicks pass through empty space */
    z-index: 100 !important;
}

#enemy-hud {
    position: absolute; bottom: 0; left: 0;
    width: 100%; padding: 15px; box-sizing: border-box;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0) 100%);
    display: flex; flex-direction: column; gap: 5px;
    pointer-events: none;
    opacity: 0; transition: opacity 0.3s;
    z-index: 20;
}
#enemy-hud.visible { opacity: 1; }

/* HUD Elements */
.hud-row { 
    display: flex; justify-content: space-between; align-items: center; width: 100%; 
    position: relative; z-index: 101 !important; pointer-events: auto !important;
}
.hud-text { font-weight: bold; font-size: 14px; color: #fff; text-shadow: 0 0 3px #000, 0 0 5px #000; letter-spacing: 1px; }

.boss-name { color: #e74c3c; text-shadow: 0 0 5px #c0392b; font-size: 16px; font-family: var(--font-header); }
.boss-name::before { content: "☠ "; color: #fff; }

.hud-btn {
    border: 1px solid #555;
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    background: #222;
    border-radius: 4px;
    color: #eee;
    text-transform: uppercase; font-weight: bold;
    font-family: var(--font-main);
    transition: background 0.2s;
    
    /* Layering */
    position: relative; z-index: 101 !important; pointer-events: auto !important;
}
.hud-btn:hover { background: var(--accent); color: #000; border-color: var(--accent); }

/* Progress Bars */
.bar-container {
    flex-grow: 1; height: 8px;
    background: rgba(30,30,30,0.8);
    border-radius: 2px; overflow: hidden; position: relative;
    border: 1px solid #555; margin-left: 10px;
    box-shadow: inset 0 0 5px #000;
    pointer-events: auto !important; z-index: 101 !important;
}
.bar-fill { height: 100%; width: 100%; transition: width 0.3s ease-out; box-shadow: inset 0 1px 0 rgba(255,255,255,0.3); }

.hp-fill { background: var(--hp-gradient); } 
/* HIDDEN: Old EXP Bar */
.exp-fill { display: none; } 
#hud-exp-bar { display: none; }
.enemy-fill { background: var(--enemy-hp-gradient); }
.dungeon-fill { background: var(--dungeon-gradient); }

#dungeon-progress-row { opacity: 0; transition: opacity 0.5s; }
#dungeon-progress-row.visible { opacity: 1; }

/* Temp Skill Bar Container */
#temp-skill-bar-container {
    width: 50% !important;
    margin: 0 auto !important; 
    background: rgba(0,0,0,0.8) !important; 
    border: 1px solid #777 !important; 
    border-radius: 4px !important; 
    padding: 2px !important;
    margin-top: 380px !important;
}

/* Temp Skill Bar Fill Color */
#temp-skill-fill {
    background: var(--skill) !important; /* Blue */
    transition: width 0.2s;
}

/* Toasts & Location */
#location-pill {
    position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.7); padding: 5px 15px; border-radius: 15px;
    font-size: 12px; text-transform: uppercase; letter-spacing: 2px;
    border: 1px solid var(--accent); color: var(--accent);
    z-index: 100; opacity: 0.0; font-family: var(--font-header);
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
#location-pill.visible{ opacity: 1; }

#toast-container { 
    position: absolute; bottom: 80px; left: 20px; right: 20px;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start;
    pointer-events: none; gap: 5px; height: 30%; overflow: hidden; z-index: 25;
}
.toast {
    background-color: rgba(10, 10, 15, 0.9); color: #fff;
    padding: 8px 12px; border-radius: 2px;
    border-left: 3px solid var(--accent);
    font-size: 12px; font-family: var(--font-mono);
    animation: fadeSequence 2.5s forwards; max-width: 90%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
}
@keyframes fadeSequence { 
    0% { opacity: 0; transform: translateY(10px); } 
    10% { opacity: 1; transform: translateY(0); } 
    80% { opacity: 1; } 
    100% { opacity: 0; display: none; } 
}

/* ========================================= */
/* 6. CONTROL PANEL & MENUS                  */
/* ========================================= */
#control-panel { 
    flex: 4; 
    background-color: var(--panel-bg); 
    background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.01) 0, rgba(255,255,255,0.01) 1px, transparent 0, transparent 50%);
    position: relative;
    display: flex; flex-direction: column; overflow: hidden; 
    border-top: 1px solid rgba(255,215,0, 0.1);
}

#menu-list { 
    padding: 15px; overflow-y: auto; 
    display: flex; flex-direction: column; gap: 8px; height: 100%; 
    box-sizing: border-box;
}

/* Standard Menu Items */
.menu-item {
    padding: 12px 15px; 
    background: rgba(255, 255, 255, 0.03); 
    border-radius: 4px; cursor: pointer; transition: all 0.2s;
    display: flex; justify-content: space-between; align-items: center; 
    border: 1px solid rgba(255,255,255,0.05);
    font-family: var(--font-main);
}
.menu-item.active { 
    background: linear-gradient(90deg, rgba(212, 175, 55, 0.15) 0%, transparent 100%);
    color: var(--accent); 
    border-color: var(--accent); 
    transform: translateX(5px); 
    font-weight: bold; 
    box-shadow: -2px 0 5px var(--accent-glow);
}
.menu-item-tag { font-size: 10px; background: #c0392b; color: white; padding: 2px 6px; border-radius: 2px; text-transform: uppercase; font-weight: bold; box-shadow: 1px 1px 3px black; }
.insufficient { font-size: 11px; color: #e74c3c; margin-left: 10px; font-style: italic; }

.equip-slot { 
    background: rgba(0,0,0,0.2); padding: 5px; border-radius: 2px; margin-bottom: 5px; 
    display:flex; justify-content:space-between; align-items:center; 
    border: 1px solid #333; 
}
.inv-btn { background: #333; border: 1px solid #555; color: white; font-size: 10px; padding: 2px 6px; cursor: pointer; margin-left: 8px; border-radius: 2px; }
.inv-btn:hover { background: var(--accent); color: black; border-color: var(--accent); }
.menu-focus-row { 
    border-color: var(--accent) !important; 
    background-color: rgba(212, 175, 55, 0.1) !important; 
    box-shadow: inset 0 0 10px rgba(212, 175, 55, 0.1);
}

/* --- MAIN MENU SCREEN SPECIFICS (Overrides) --- */
.main-menu-screen {
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    height: 100%; width: 100%;
    background: #111; color: #fff;
    font-family: 'Courier New', monospace;
}
.title-text {
    font-size: 24px; color: var(--accent); margin-bottom: 30px;
    text-shadow: 0 0 10px var(--accent); text-align: center;
}

/* Override standard menu items to look like buttons for Main Menu */
.main-menu-screen .menu-item {
    background: linear-gradient(to right, #2c3e50, #1a252f);
    border: 1px solid #5d6d7e;
    color: #ecf0f1;
    width: 70%; margin: 10px auto; padding: 15px;
    justify-content: center; text-align: center;
    border-radius: 4px;
    transform: scale(1);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.main-menu-screen .menu-item.active {
    background: linear-gradient(to right, var(--accent), #b7950b);
    color: #000; border-color: #fff;
    box-shadow: 0 0 15px var(--accent-glow);
    transform: scale(1.05) !important;
    font-weight: bold;
}

/* ========================================= */
/* 7. DIALOGUE SYSTEM                        */
/* ========================================= */
#dialogue-visual-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 50; display: none;
}
#dialogue-visual-layer.active { display: block; }
#dialogue-bg-container { z-index: 1 !important; }

#dialogue-box {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(16, 20, 30, 0.98), rgba(5, 5, 5, 0.98)); 
    padding: 20px; box-sizing: border-box;
    z-index: 100; display: none; flex-direction: column;
    border-top: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    box-shadow: 0 0 20px rgba(0,0,0,1);
    cursor: pointer;
}
#dialogue-box.active { display: flex; }

#speaker-name { 
    font-family: var(--font-header); font-weight: bold; color: var(--accent); font-size: 18px; 
    margin-bottom: 10px; text-transform: uppercase; letter-spacing: 2px;
    text-shadow: 0 0 5px rgba(212, 175, 55, 0.5);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    display: inline-block; width: max-content;
}
#dialogue-text { color: #fff; font-size: 16px; line-height: 1.6; font-family: var(--font-main); flex-grow: 1; text-shadow: 1px 1px 2px #000; }

/* Questions & Choices */
#dialogue-questions {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.9); z-index: 105;
    display: none; flex-direction: column;
    /*justify-content: center;*/
    align-items: center;
    gap: 15px;
    backdrop-filter: blur(2px);
    max-height: 300px;
    overflow-y: auto;
}
#dialogue-questions.active { display: flex; }

.choice-btn {
    background: linear-gradient(to right, #2c3e50, #1a252f);
    border: 1px solid #5d6d7e; color: #ecf0f1; padding: 15px 25px; width: 80%;
    text-align: center; cursor: pointer; border-radius: 2px; transition: all 0.2s; 
    font-family: var(--font-header); letter-spacing: 1px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.choice-btn.selected { 
    background: linear-gradient(to right, var(--accent), #b7950b);
    color: #000; border-color: #fff; 
    transform: scale(1.02); 
    box-shadow: 0 0 15px var(--accent-glow);
}

/* ========================================= */
/* 8. MODALS (Save/Load)                     */
/* ========================================= */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000 !important;
    justify-content: center; align-items: center;
}
.modal-overlay.active { display: flex; }

.modal-content {
    background: #222;
    border: 1px solid #555;
    padding: 20px; width: 80%; max-width: 400px;
    border-radius: 8px;
    text-align: center; color: #fff;
    font-family: 'Courier New', monospace;
}

textarea#save-data-area {
    width: 100%; height: 100px;
    background: #111; color: var(--accent);
    border: 1px solid #444;
    font-family: monospace; font-size: 10px;
    margin-bottom: 10px; resize: none; padding: 5px;
}

.modal-controls { display: flex; justify-content: space-between; gap: 5px; }
.modal-controls button {
    flex: 1; padding: 8px;
    border: none; background: var(--accent); color: white;
    font-family: inherit; font-weight: bold; cursor: pointer; font-size: 11px;
}
.modal-controls button:hover { opacity: 0.8; }
#save-msg { font-size: 10px; margin-top: 5px; height: 12px; color: #aaa; }


/* --- COMBAT LOG PANEL (Mobile Style) --- */
#combat-panel {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30%; /* Occupies bottom 30% of screen (like dialogue box) */
    background: rgba(20, 20, 20, 0.95);
    border-top: 4px solid #444;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    z-index: 200; /* Sit above Dialogue Box (usually z-index 10-50) */
    box-sizing: border-box;
    flex-direction: column;
}

#combat-panel.active {
    display: flex;
}

/* The Container for text lines */
#combat-log-feed {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

/* Individual Log Lines */
.log-entry {
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.8;
}

/* Animation for new lines */
.log-entry.new {
    opacity: 1;
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from { transform: translateY(-5px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --- COMBAT LOG PANEL (Integrated) --- */
#combat-panel {
    display: none;
    position: absolute;
    top: 0;       /* Start at the top of the control panel */
    left: 0;
    width: 100%;  /* Fill width */
    height: 100%; /* Fill height */
    
    /* Solid background to cover the menu/dialogue underneath */
    background: #111; 
    border-top: 2px solid #444; /* Optional visual separation */
    
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    z-index: 200; /* Sit above Dialogue Box (z-index 100) */
    box-sizing: border-box;
    flex-direction: column;
}

#combat-panel.active {
    display: flex;
}

/* The Container for text lines */
#combat-log-feed {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

/* Individual Log Lines */
.log-entry {
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.8;
}

.log-entry.new {
    opacity: 1;
    color: #fff;
    font-weight: bold;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- COMBAT CONTROLS --- */
#combat-panel {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    /* Match the Control Panel Aesthetic */
    background-color: var(--panel-bg); 
    background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.01) 0, rgba(255,255,255,0.01) 1px, transparent 0, transparent 50%);
    
    /* Gold accent top border to separate from visual panel */
    border-top: 2px solid var(--accent);
    
    color: var(--text-main);
    font-family: var(--font-mono); /* Use Consolas/Monospace */
    font-size: 13px;
    z-index: 200;
    box-sizing: border-box;
    flex-direction: column;
}

#combat-panel.active {
    display: flex;
}

/* The Container for text lines */
#combat-log-feed {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    
    /* Inner shadow to give depth */
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

/* Individual Log Lines */
.log-entry {
    margin-bottom: 5px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    transition: all 0.5s;
}

/* New lines highlight in Gold/White */
.log-entry.new {
    opacity: 1;
    color: #fff;
    border-bottom-color: rgba(212, 175, 55, 0.3); /* Gold tint */
    text-shadow: 0 0 5px rgba(0,0,0,0.8);
    animation: slideIn 0.2s ease-out;
}

/* Highlight specific keywords if you add them later, 
   or general emphasis for the latest line */
.log-entry.new::before {
    content: "➤ ";
    color: var(--accent);
    font-size: 10px;
}

@keyframes slideIn {
    from { transform: translateX(-10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- COMBAT CONTROLS (Bottom Bar) --- */
#combat-controls {
    height: 60px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(212, 175, 55, 0.2); /* Faint gold line */
    display: none;
    justify-content: center;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
}

#combat-controls.active {
    display: flex;
}

/* Match the style of .choice-btn and .menu-item */
#btn-combat-end {
    width: 90%;
    height: 100%;
    
    /* Dark Gradient Background */
    background: linear-gradient(to right, #2c3e50, #1a252f);
    border: 1px solid #5d6d7e;
    color: var(--text-main);
    
    /* Typography */
    font-family: var(--font-header); /* Cinzel */
    font-weight: bold;
    font-size: 16px;
    letter-spacing: 2px;
    text-transform: uppercase;
    
    cursor: pointer;
    border-radius: 2px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: all 0.2s;
}

/* Hover/Active State - Gold Glow */
#btn-combat-end:hover, #btn-combat-end:focus {
    background: linear-gradient(to right, var(--accent), #b7950b);
    color: #000;
    border-color: #fff;
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateY(-1px);
}

#btn-combat-end:active {
    transform: translateY(1px);
    box-shadow: 0 0 5px var(--accent-glow);
}


/* ========================================= */
/*     VISUAL MAP OVERLAY                    */
/* ========================================= */

#mini-map-overlay {
    position: absolute;
    /* User Request: Map sits between 30% and 80% of screen height */
    top: 30%; 
    height: 50%; /* 30% + 50% = 80% */
    left: 0; width: 100%;
    
    pointer-events: auto; /* This re-enables clicking on the nodes */
    cursor: pointer;
    z-index: 5; 
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

#mini-map-overlay.visible {
    opacity: 1;
}

#map-lines {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}

.map-line {
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 2;
    transition: opacity 0.2s; /* Quick fade out */
}

.map-node {
    position: absolute;
    border-radius: 50%;
    background: #222;
    border: 2px solid #555;
    transform: translate(-50%, -50%);
    
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* UPDATED: Typography for Emoji/Text */
    color: #fff;
    font-size: 20px; /* Larger for emoji */
    font-weight: bold;
    line-height: 1;
    
    font-family: var(--font-main);
    
    z-index: 2;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1); 
    box-shadow: 0 0 10px rgba(0,0,0,0.5);

    /* UPDATED: Enable clicking on the node itself */
    pointer-events: auto; 
    cursor: pointer;
}

/* Hover effect for nodes */
.map-node:hover {
    border-color: #fff;
    transform: translate(-50%, -50%) scale(1.1);
    z-index: 10;
}

.map-node.center-node {
    width: 60px; height: 60px;
    background: radial-gradient(circle, #444, #222);
    border-color: #fff;
    z-index: 3;
}

.map-node.sub-node {
    width: 40px; height: 40px;
    background: #111;
}

.map-node.active {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translate(-50%, -50%) scale(1.2);
    background: #2c2c2c;
}

/* --- ANIMATION CLASSES --- */

/* 1. Siblings Fade Out */
.map-node.fade-out {
    opacity: 0 !important;
    transform: translate(-50%, -50%) scale(0);
}

/* 2. Target becomes new Center (Unchanged) */
.map-node.anim-to-center {
    top: 70% !important;
    left: 50% !important;
    width: 60px !important;
    height: 60px !important;
    border-color: #fff !important;
    z-index: 10 !important;
}

/* 3. Old Center moves Away (Generic Class) */
/* We will set 'top' and 'left' via JS, so we only define the visual fade here */
.map-node.anim-leave {
    width: 40px !important;
    height: 40px !important;
    opacity: 0.5;
    border-color: #777 !important;
    z-index: 1 !important;
}



/* --- UNIFIED COMBAT HUD BARS --- */
#unified-combat-hud {
    position: absolute;
    top: 100px; /* <--- INCREASE THIS VALUE TO PUSH IT FURTHER DOWN */
    left: 10px;
    right: 10px;
    display: none; /* Managed by JS */
    justify-content: space-between;
    z-index: 150;
    pointer-events: none;
}

.combat-bar-wrapper {
    background: rgba(0,0,0,0.8);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #555;
    width: 100%;
    margin-bottom: 4px;
    pointer-events: auto;
    box-sizing: border-box;
}

.combat-bar-header {
    top: 70% !important;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 2px;
}

.combat-bar-track {
    height: 6px;
    background: #222;
    border-radius: 3px;
    overflow: hidden;
    width: 100%;
}

.combat-bar-fill {
    height: 100%;
    transition: width 0.3s ease-out;
}


/* ========================================= */
/* --- COMBAT HUD ANIMATIONS ---             */
/* ========================================= */

.anim-combat-attack {
    animation: combatBump 0.3s ease-out;
    border-color: #f1c40f !important; /* Gold highlight */
}
.anim-combat-hit {
    animation: combatShake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    border-color: #e74c3c !important; /* Red highlight */
}
.anim-combat-miss {
    animation: combatDodge 0.4s ease-out;
    border-color: #3498db !important; /* Blue highlight */
}

@keyframes combatBump {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); background: rgba(241, 196, 15, 0.2); }
    100% { transform: scale(1); }
}
@keyframes combatShake {
    0% { transform: translate3d(0, 0, 0); background: rgba(231, 76, 60, 0.3); }
    20%, 80% { transform: translate3d(-3px, 0, 0); }
    40%, 60% { transform: translate3d(3px, 0, 0); }
    100% { transform: translate3d(0, 0, 0); }
}
@keyframes combatDodge {
    0% { transform: translateX(0); }
    50% { transform: translateX(10px); background: rgba(52, 152, 219, 0.2); }
    100% { transform: translateX(0); }
}

/* --- COMBAT SPRITE ANIMATION --- */
.anim-combat-flash {
    /* Fast 0.5s animation applied directly to the image */
    animation: combatSpriteFlash 1.0s ease-out forwards;
}

@keyframes combatSpriteFlash {
    0% { 
        opacity: 0; 
        transform: scale(0.9) translateY(0px); 
        filter: brightness(1) drop-shadow(0 0 0px transparent); 
    }
    10% { 
        opacity: 1; 
        transform: scale(1.1) translateY(0px); 
        filter: brightness(1.5) drop-shadow(0 0 15px transparent); 
    }
    100% { 
        opacity: 0; 
        transform: scale(0.9) translateY(0px); 
        filter: brightness(0.5); 
    }
}