/* =========================================
   1. MASTER CSS VARIABLES
   ========================================= */
:root {
    --bg-dark: #121212;
    --bg-panel: #222222;
    --bg-input: #111111;
    --border-color: #444444;
    
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    
    --accent-primary: #00bcd4; /* Cyan */
    --accent-success: #4CAF50; /* Green */
    --accent-danger: #f44336;  /* Red */
    --accent-warning: #FF9800; /* Orange */
    --accent-gold: #FFD700;    /* Gold */
    --accent-purple: #9c27b0;  /* Purple */
    
    --res-food: #4CAF50;
    --res-wood: #8D6E63;
    --res-stone: #9E9E9E;
    
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* =========================================
   2. GLOBAL STYLES & LAYOUT
   ========================================= */
body {
    font-family: var(--font-main);
    color: var(--text-main);
    background-color: var(--bg-dark);
    margin: 0;
    padding: 0; /* Removed padding to prevent scrollbar misalignment */
    overflow: hidden; 
    user-select: none; 
}

#gameContainer {
    position: fixed;
    top: 44px;     /* Matches Top Header Height */
    bottom: 140px; /* Matches Bottom Dashboard Height */
    left: 0;
    right: 250px;  /* Matches Right Sidebar Width */
    background: #3e2723; /* Classic dirt background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    overflow: hidden;
}

#worldMapCanvas { 
    width: 100%; 
    height: 100%; 
    display: block;
    object-fit: contain; /* FIX: Scales up perfectly but prevents stretching! */
    border: none !important; 
    outline: none !important;
}

input[type="number"], input[type="text"], input[type="password"], select, textarea {
    font-family: var(--font-main);
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    box-sizing: border-box;
}

/* =========================================
   3. TACTILE BUTTONS (PHASE 4)
   ========================================= */
button {
    background: var(--border-color);
    color: var(--text-main);
    border: 1px solid rgba(0,0,0,0.5);
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    transition: filter 0.1s ease, transform 0.1s ease;
    width: 100%;
    margin-top: 5px;
}
button:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-1px); }
button:active:not(:disabled) { filter: brightness(0.9); transform: translateY(1px); }
button:disabled { background-color: #444 !important; color: #888 !important; cursor: not-allowed; transform: none; filter: none; }

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-danger);
    border: none;
    color: white;
    padding: 5px 10px;
    width: auto;
    font-size: 14px;
}
.close-btn:hover { background: #b71c1c; }

/* =========================================
   4. GLASSMORPHISM MODALS (PHASE 3)
   ========================================= */
.game-modal {
    display: none; 
    position: fixed; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    z-index: 2000; 
    background: rgba(34, 34, 34, 0.90); /* Slightly transparent */
    backdrop-filter: blur(8px);         /* Blurs the canvas behind the menu */
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--accent-primary);
    border-radius: 10px; 
    box-shadow: 0 15px 40px rgba(0,0,0,0.8), 0 0 0 100vw rgba(0,0,0,0.7); /* Perfect Backdrop Shadow */
    padding: 20px;
    max-height: 85vh;
    overflow-y: auto;
}

.panel {
    background: transparent;
    border-radius: 8px; 
    display: inline-block; 
    margin: 5px; 
    vertical-align: top; 
}

/* Internal Menu Components */
.building { background-color: var(--bg-panel); padding: 15px; border-radius: 5px; margin-bottom: 15px; text-align: left; border: 1px solid var(--border-color); }
.building h4 { margin: 0 0 10px 0; text-transform: capitalize; }
.troop-counts { display: flex; justify-content: space-around; background: var(--bg-panel); padding: 10px; border-radius: 5px; margin-bottom: 15px; border: 1px solid var(--border-color); }
.troop-counts div { text-align: center; } 
.troop-counts span { display: block; font-size: 20px; color: var(--accent-danger); }
.queue-box { background-color: var(--bg-input); padding: 10px; margin-top: 10px; border-radius: 5px; font-weight: bold; font-size: 14px; border: 1px solid var(--border-color); }

/* Panel Border Accents */
.military-panel { border: 2px solid var(--accent-danger); } 
.academy-panel { border: 2px solid var(--accent-primary); } 
.ally-panel { border: 2px solid var(--accent-primary); width: 250px; text-align: left; }
.reports-panel { border: 2px solid var(--accent-purple); text-align: left; overflow-y: auto; height: 150px; }
.report-item { background: #4a148c; margin-bottom: 5px; padding: 10px; border-radius: 4px; font-size: 13px; }

/* =========================================
   5. TOP HUD & BOTTOM HUD (PHASE 2 & 4)
   ========================================= */
#top-header, #hud-bar {
    position: fixed;
    left: 0;
    width: 100%;
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-sizing: border-box;
    box-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

#top-header {
    top: 0;
    height: 44px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 15px;
}

#hud-bar {
    bottom: 0;
    justify-content: center;
    padding: 10px 0;
    border-top: 1px solid var(--border-color);
    z-index: 1200 !important;
}

.res-pill { display: inline-flex; align-items: center; background: var(--bg-input); padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border-color); font-size: 13px; font-weight: bold; margin-left: 8px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); }
.res-rate { font-size: 10px; color: var(--text-muted); margin-left: 4px; font-weight: normal; }

.hud-btn { background: linear-gradient(to bottom, #444, #222); border: 1px solid #111; border-top: 1px solid #555; padding: 8px 16px; margin: 0 5px; color: #fff; border-radius: 4px; text-transform: uppercase; width: auto; font-size: 13px; }
.hud-btn:hover { background: linear-gradient(to bottom, var(--accent-success), #2E7D32); border-color: #1B5E20; }
.action-btn { background: linear-gradient(to bottom, var(--accent-warning), #f57c00); border-color: #e65100; color: #000; text-shadow: none; }
.action-btn:hover { background: linear-gradient(to bottom, #ffb74d, var(--accent-warning)); }
.hud-divider { width: 1px; height: 30px; background: var(--border-color); margin: 0 15px; }

/* =========================================
   6. ALERTS & NOTIFICATIONS
   ========================================= */
#notification { visibility: hidden; min-width: 250px; background-color: var(--accent-danger); color: #fff; text-align: center; border-radius: 5px; padding: 16px; position: fixed; z-index: 3000; left: 50%; top: 20px; transform: translateX(-50%); font-weight: bold; box-shadow: 0px 4px 6px rgba(0,0,0,0.5); opacity: 0; transition: 0.3s; }
#notification.show { visibility: visible; opacity: 1; top: 60px; }

.notif-badge { display: inline-block; width: 10px; height: 10px; background-color: var(--accent-danger); border-radius: 50%; position: absolute; top: -3px; right: -3px; border: 1px solid #111; }

@keyframes flash-siren { 0% { background-color: #b71c1c; box-shadow: 0 0 10px #b71c1c; } 50% { background-color: #ff5252; box-shadow: 0 0 20px #ff5252; } 100% { background-color: #b71c1c; box-shadow: 0 0 10px #b71c1c; } }
.incoming-alert { animation: flash-siren 1s infinite; color: white; font-weight: bold; padding: 15px; border-radius: 5px; margin-bottom: 15px; border: 2px solid #fff; text-transform: uppercase; }
@keyframes flash-btn-danger { 0% { background-color: #3b3b3b; } 50% { background-color: var(--accent-danger); box-shadow: 0 0 15px var(--accent-danger); } 100% { background-color: #3b3b3b; } }
.hud-btn-alert { animation: flash-btn-danger 1s infinite !important; border-color: var(--accent-gold) !important; }
.incoming-item { background: #b71c1c; border: 1px solid #ff5252; padding: 10px; margin-bottom: 5px; border-radius: 4px; font-size: 13px; font-weight: bold; }

/* =========================================
   7. PROGRESS OVERLAYS & SMART TRACKER
   ========================================= */
.progress-box { 
    background: rgba(20, 20, 20, 0.85); 
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid var(--border-color); 
    border-radius: 4px; 
    padding: 8px 10px; 
    font-size: 12px; 
    pointer-events: auto; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.progress-bar-bg { 
    background: var(--bg-dark); 
    width: 100%; 
    height: 4px; 
    border-radius: 2px; 
    margin-top: 6px; 
    overflow: hidden; 
}
.progress-bar-fill { 
    height: 100%; 
    width: 100%; 
    animation: pulse-bar 1.5s infinite; 
}
@keyframes pulse-bar { 0% { opacity: 0.4; } 50% { opacity: 1; } 100% { opacity: 0.4; } }

/* =========================================
   8. MINI-CHAT OVERLAY
   ========================================= */
#mini-chat { position: fixed; bottom: 58px; left: 0; width: 100%; background: rgba(15, 15, 15, 0.85); border-top: 1px solid var(--border-color); z-index: 990; display: flex; height: 60px; pointer-events: none; }
.mini-chat-tabs { display: flex; flex-direction: column; width: 100px; background: var(--bg-input); border-right: 1px solid var(--border-color); pointer-events: auto; }
.mini-tab { flex: 1; background: transparent; border: none; border-bottom: 1px solid #222; color: var(--text-muted); padding: 5px; font-size: 11px; text-transform: uppercase; cursor: pointer; transition: 0.2s; margin-top: 0; }
.mini-tab.active { color: #fff; background: var(--bg-panel); border-left: 4px solid var(--accent-primary); }
.mini-chat-box { flex-grow: 1; padding: 4px 15px; font-size: 13px; text-align: left; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; pointer-events: auto; }
.mini-chat-msg { width: 100%; margin-bottom: 2px; text-shadow: 1px 1px 1px black; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }

/* =========================================
   9. MISCELLANEOUS (LOGIN, CHAT MODAL, MAP DOTS)
   ========================================= */
#loginOverlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 3000; display: flex; justify-content: center; align-items: center; }
.login-box { background: var(--bg-panel); padding: 40px; border-radius: 10px; border: 2px solid var(--accent-success); width: 300px; }

.chat-panel { border: 2px solid var(--accent-primary); width: 350px; display: flex; flex-direction: column; }
.chat-tabs { display: flex; margin-bottom: 10px; }
.chat-tab-btn { flex: 1; margin: 0 2px; }
.chat-box-container { flex-grow: 1; background: var(--bg-input); border-radius: 5px; padding: 10px; overflow-y: auto; text-align: left; height: 200px; margin-bottom: 10px; font-size: 13px; border: 1px solid var(--border-color); }
.chat-msg { margin-bottom: 5px; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }
.chat-input-area { display: flex; gap: 5px; } 

.city-dot { position: absolute; width: 4%; height: 4%; border-radius: 50%; transform: translate(10%, 10%); cursor: pointer; transition: transform 0.2s; }
.city-dot:hover { transform: translate(10%, 10%) scale(1.5); z-index: 10; }
.city-mine { background-color: var(--accent-success); border: 2px solid #fff; } 
.city-enemy { background-color: var(--accent-danger); border: 2px solid #000; } 
.city-war { background-color: #b71c1c; border: 2px solid #fff; box-shadow: 0 0 10px #ff5252;} 
.city-ally { background-color: var(--accent-primary); border: 2px solid #fff; } 
.city-shielded { box-shadow: 0 0 15px 5px var(--accent-primary); border-color: var(--accent-primary) !important; }

/* =========================================
   10. CONTEXTUAL MAP MENU
   ========================================= */
.context-menu {
    position: absolute;
    display: none;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    z-index: 1500;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    /* Transforms it so the arrow points down to the click perfectly */
    transform: translate(-50%, -120%); 
    pointer-events: auto;
}

.context-menu::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: rgba(20, 20, 20, 0.95) transparent transparent transparent;
    display: block;
    width: 0;
}

.ctx-btn {
    padding: 6px 10px;
    font-size: 12px;
    margin: 0;
    width: auto;
    border-radius: 4px;
}

/* =========================================
   11. SLIDE-OUT SIDE PANELS
   ========================================= */
.slide-modal {
    display: block; /* Always rendered, just hidden off-screen */
    position: fixed;
    top: 44px; /* Starts exactly below your top HUD */
    right: -100%; /* Hidden off the right edge */
    width: 350px;
    max-width: 90vw; /* Responsive for smaller screens */
    height: calc(100vh - 44px); /* Full height minus the header */
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-left: 1px solid var(--accent-primary);
    z-index: 2000;
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); /* Buttery smooth slide */
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    box-shadow: -5px 0 25px rgba(0,0,0,0.8);
}

.slide-modal.active {
    right: 0; /* Slides into view! */
}

/* =========================================
   EVONY-STYLE MODERN LAYOUT
   ========================================= */
.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    font-weight: bold;
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: 0.2s;
}

.nav-tab:hover {
    color: #fff;
}

.nav-tab.active-nav {
    color: var(--accent-gold);
    border-bottom: 3px solid var(--accent-gold);
}

.evony-panel {
    position: fixed;
    top: 55px; /* Sits right under the header */
    right: 10px;
    width: 220px;
    background: rgba(20, 20, 20, 0.90);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--accent-gold);
    border-radius: 4px;
    z-index: 1000;
    box-shadow: -2px 5px 15px rgba(0,0,0,0.8);
    pointer-events: auto;
}

.lord-profile {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.5);
}

.lord-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.res-list {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.res-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: bold;
}

.res-item span:first-child {
    color: var(--text-muted);
    width: 60px;
    text-align: left;
}

/* =========================================
   12. CLASSIC EVONY BOTTOM DASHBOARD
   ========================================= */
#bottom-dashboard {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 140px;
    background: #e6d5b8; /* Parchment base */
    border-top: 3px solid #8b5a2b;
    display: flex;
    z-index: 1200;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.5);
    font-family: Arial, sans-serif;
}

/* Left Panel: Action Grid */
.bottom-action-panel {
    width: 320px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    border-right: 2px solid #8b5a2b;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect width="100" height="100" fill="%23e6d5b8"/><path d="M0 0l100 100M100 0L0 100" stroke="%23dccba9" stroke-width="1"/></svg>'); /* Faint parchment texture */
}

.action-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 5px;
}

.action-tab {
    flex: 1;
    background: #fdf5e6;
    color: #5c3a21;
    border: 1px solid #8b5a2b;
    border-radius: 4px 4px 0 0;
    padding: 4px 0;
    font-size: 12px;
    margin: 0;
    box-shadow: inset 0 -2px 5px rgba(0,0,0,0.1);
}

.action-tab.active {
    background: #b24124; /* Classic dark red */
    color: #fff;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 5px;
    flex-grow: 1;
}

.grid-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    background: transparent;
    border: none;
}

.grid-btn:hover .grid-icon {
    transform: scale(1.05);
    filter: brightness(1.2);
}

.grid-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #fff8dc, #deb887);
    border: 2px solid #a0522d;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.3), inset -2px -2px 4px rgba(0,0,0,0.2);
    transition: 0.1s;
}

.grid-label {
    background: #fdf5e6;
    border: 1px solid #8b5a2b;
    border-radius: 2px;
    font-size: 10px;
    padding: 1px 6px;
    margin-top: -6px; /* Overlaps the circle slightly like the screenshot */
    color: #3e2723;
    z-index: 2;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

/* Notification Badges */
.notif-badge {
    position: absolute;
    top: 0px;
    right: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid #fff;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    z-index: 3;
}
.evony-badge-red { background: #d32f2f; }
.evony-badge-green { background: #388e3c; }
.evony-badge-blue { background: #1976d2; }

/* Middle Filter Strip */
.bottom-filter-strip {
    width: 30px;
    background: #d7c4a3;
    border-right: 2px solid #8b5a2b;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 5px 0;
}

.filter-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid #5c3a21;
    margin: 0;
    padding: 0;
    box-shadow: inset -1px -1px 3px rgba(0,0,0,0.4), 1px 1px 2px rgba(0,0,0,0.2);
}

/* Right Panel: Integrated Chat */
.bottom-chat-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 5px;
    background: #e6d5b8;
}

.classic-chat-box {
    flex-grow: 1;
    background: #fff;
    border: 1px solid #a0522d;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 5px;
    overflow-y: auto;
    padding: 5px;
    font-size: 12px;
    color: #b71c1c; /* Default red text from screenshot */
}

/* Update these in styles.css */

.classic-chat-input-row {
    display: flex;
    gap: 2px; /* Reduced gap to save horizontal space */
    height: 26px; /* Slightly taller for better clickability */
    align-items: center;
}

.chat-channel-toggle {
    flex: 0 0 auto; /* Prevents the button from growing */
    width: 60px;    /* Forced small width */
    padding: 0 2px; /* Minimal internal padding */
    font-size: 10px; /* Smaller font to fit the tiny button */
    height: 100%;
    white-space: nowrap;
    overflow: hidden;
    background: #fdf5e6;
    border: 1px solid #8b5a2b;
    color: #b24124;
    font-weight: bold;
}

.chat-text-input {
    flex: 1 1 auto; /* This tells the box to grow and grab all remaining space */
    min-width: 0;   /* Essential for flexbox behavior */
    height: 100%;
    padding: 0 8px;
    font-size: 12px;
}

.chat-send-icon, .chat-menu-icon {
    width: 24px;
    background: #fdf5e6;
    border: 1px solid #8b5a2b;
    color: #b24124;
    font-weight: bold;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    flex: 0 0 auto;
    height: 100%;
}

/* =========================================
   14. EVONY DYNAMIC TRACKERS
   ========================================= */
.tracker-item {
    position: relative;
    height: 24px;
    margin-bottom: 2px;
    background: #5c3a21; /* Dark wood base */
    border: 1px solid #3e2723;
    overflow: hidden;
    border-radius: 2px;
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.5);
}

.tracker-bg {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%; /* Default full width for construction */
    z-index: 1;
    border-right: 1px solid rgba(0,0,0,0.3);
}

.tracker-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 5px;
    font-size: 11px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 1px #000;
}

.tracker-icon { margin-right: 5px; font-size: 12px; }
.tracker-title { flex-grow: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tracker-time { color: #FFD700; width: 55px; text-align: right; margin-right: 5px; font-family: monospace; font-size: 12px; }

.tracker-speedup {
    background: linear-gradient(to bottom, #8BC34A, #388E3C) !important;
    border: 1px solid #1B5E20 !important;
    color: #fff !important;
    padding: 2px 5px !important;
    margin: 0 !important;
    height: 18px;
    font-size: 9px !important;
    text-shadow: none !important;
    border-radius: 3px !important;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.5) !important;
    width: auto !important;
}
.tracker-speedup:hover { filter: brightness(1.2) !important; }

/* =========================================
   15. CLASSIC EVONY RIGHT DASHBOARD
   ========================================= */
.classic-sidebar {
    background: #faebd7 !important; /* Antique white / Parchment */
    /* Simulating the golden/stone pillars on the edges */
    border-left: 4px solid #d2b48c !important; 
    border-right: 4px solid #d2b48c !important;
    border-top: none !important;
    border-bottom: none !important;
    border-radius: 0 !important; 
    box-shadow: -4px 4px 10px rgba(0,0,0,0.5) !important;
    color: #3e2723;
    padding: 0;
    overflow: hidden;
    top: 44px !important;     
    bottom: 140px !important; 
    height: auto !important;  
    width: 270px !important;  /* Wider to fit the Scroll + Avatar */
    display: flex;
    flex-direction: column;
    box-sizing: border-box !important; 
}

/* The Lord Profile Area */
.evony-profile-container {
    display: flex;
    padding: 8px 5px;
    background: #fdf5e6;
    border-bottom: 2px solid #deb887;
    gap: 5px;
}

.evony-avatar-col {
    display: flex;
    flex-direction: column;
    width: 85px;
}

.evony-avatar-col img {
    border: 2px solid #c8a165;
    width: 81px;
    height: 81px;
    box-sizing: border-box;
}

.evony-btn-small {
    background: #fff8dc;
    border: 1px solid #c8a165;
    border-radius: 3px;
    color: #5c3a21;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    font-size: 11px;
    padding: 2px 0;
    margin-top: 3px;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}
.evony-btn-small:hover { background: #ffe4b5; }

/* The Paper Scroll */
.evony-scroll {
    flex: 1;
    background: #fff8dc; /* Lighter inner parchment */
    border: 1px solid #d2b48c;
    border-radius: 2px;
    padding: 5px 8px;
    font-size: 12px;
    color: #3e2723;
    box-shadow: inset 0 0 10px rgba(210, 180, 140, 0.3);
}

.evony-scroll-name {
    text-align: center;
    font-weight: bold;
    font-size: 13px;
    border-bottom: 1px solid #deb887;
    padding-bottom: 3px;
    margin-bottom: 5px;
}

.evony-scroll-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 3px;
}

/* Resource Rows */
.evony-res-row {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px dashed #d2b48c;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    color: #3e2723;
}

.evony-res-val {
    flex-grow: 1;
    text-align: right;
    padding-right: 15px;
    font-size: 13px;
    color: #b71c1c; /* Classic red numbers for total */
}

.evony-res-rate {
    width: 45px;
    text-align: right;
    font-size: 11px;
    padding-right: 5px;
    color: #388E3C; /* Green production */
}

.evony-plus-btn {
    width: 16px; height: 16px;
    background: linear-gradient(to bottom, #8BC34A, #388E3C);
    color: white; border: 1px solid #1B5E20;
    border-radius: 2px; display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: bold; cursor: pointer; padding: 0; margin: 0;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}
.evony-plus-btn:hover { filter: brightness(1.2); }

.sidebar-profile {
    display: flex;
    align-items: center;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect width="100" height="100" fill="%23e6d5b8"/><path d="M0 0l100 100M100 0L0 100" stroke="%23dccba9" stroke-width="1"/></svg>');
    padding: 10px;
    border-bottom: 2px solid #8b5a2b;
    position: relative;
}

.sidebar-profile-info { margin-left: 10px; text-align: left; flex-grow: 1; }

.logout-btn {
    position: absolute; top: 5px; right: 5px; background: #b71c1c; border: 1px solid #fff;
    padding: 4px 8px; font-size: 16px; width: auto; margin: 0;
}

.sidebar-status-bar {
    background: #3e2723; display: flex; justify-content: space-around;
    padding: 8px 0; font-size: 14px; font-weight: bold; border-bottom: 2px solid #8b5a2b;
}

.sidebar-tabs { display: flex; background: #dccba9; border-bottom: 2px solid #8b5a2b; }

.side-tab {
    flex: 1; background: transparent; border: none; border-right: 1px solid #8b5a2b;
    padding: 6px 0; margin: 0; font-size: 20px; border-radius: 0; color: #5c3a21; box-shadow: none;
}
.side-tab:last-child { border-right: none; }
.side-tab.active { background: #fdf5e6; box-shadow: inset 0 3px 5px rgba(0,0,0,0.1); }

.side-content {
    padding: 10px;
    flex-grow: 1; /* Automatically stretches to fill the empty vertical space */
    overflow-y: auto; /* Adds a scrollbar if the player has too many resources/troops */
    background: #fdf5e6;
}

.res-row {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 14px; font-weight: bold; margin-bottom: 8px;
    border-bottom: 1px dashed #dccba9; padding-bottom: 4px;
}
.res-icon { font-size: 18px; width: 25px; text-align: center; }
.res-val { color: #b71c1c; flex-grow: 1; text-align: right; margin-right: 10px; font-size: 14px; }
.res-rate { color: #388E3C; width: 40px; text-align: right; font-size: 12px; }

/* --- HIDE MOBILE UI ON DESKTOP --- */
.mobile-ui { display: none !important; }

/* --- MOBILE RESPONSIVE OVERRIDES --- */
@media (max-width: 800px) {
    /* Hide Desktop HUDs */
    #top-header, #bottom-dashboard, #smart-tracker { display: none !important; }
    
    /* Show Mobile HUDs */
    .mobile-ui { display: flex !important; }

    /* Expand Canvas */
    #gameContainer { 
        width: 100vw !important; 
        top: 40px !important; 
        bottom: 60px !important; 
        right: 0 !important; 
    }
    #worldMapCanvas { width: 100% !important; height: 100% !important; }

    /* Mobile Top Bar */
    #mobile-top-bar {
        position: fixed; top: 0; left: 0; width: 100%; height: 40px;
        background: rgba(15, 15, 15, 0.95); border-bottom: 2px solid #8b5a2b;
        align-items: center; justify-content: space-between; padding: 0 5px;
        z-index: 1500; box-sizing: border-box; font-size: 11px; font-weight: bold;
    }
    .mob-res, .mob-vip { display: flex; align-items: center; gap: 2px; }
    .mob-btn { padding: 4px; background: #3e2723; border: 1px solid #8b5a2b; border-radius: 4px; font-size: 14px; }

    /* Mobile FAB Tray (Left Side Action Buttons) */
    #mobile-fab-tray {
        position: fixed; left: 10px; bottom: 80px; flex-direction: column; gap: 10px; z-index: 1500;
    }
    .mob-fab {
        width: 45px; height: 45px; background: #3e2723; border: 2px solid #FFD700;
        border-radius: 50%; display: flex; align-items: center; justify-content: center;
        font-size: 20px; box-shadow: 0 4px 8px rgba(0,0,0,0.6); position: relative; overflow: hidden;
    }
    .fab-progress {
        position: absolute; bottom: 0; left: 0; width: 100%; background: rgba(76, 175, 80, 0.4); z-index: -1;
    }

    /* Mobile Bottom Navigation */
    #mobile-bottom-nav {
        position: fixed; bottom: 0; left: 0; width: 100%; height: 60px;
        background: #e6d5b8; border-top: 3px solid #8b5a2b;
        align-items: center; justify-content: space-around; z-index: 1500;
    }
    #mobile-bottom-nav button {
        background: transparent; border: none; color: #5c3a21; box-shadow: none; margin: 0;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        font-size: 20px; flex: 1; padding: 5px 0;
    }
    #mobile-bottom-nav button span { font-size: 10px; font-weight: bold; margin-top: 2px; }
    
    /* Center "World" Button Call-out */
    .nav-center-btn {
        transform: translateY(-15px); background: #b71c1c !important; color: white !important;
        border: 3px solid #FFD700 !important; border-radius: 50% !important;
        width: 65px !important; height: 65px !important; flex: none !important;
        box-shadow: 0 5px 15px rgba(0,0,0,0.5) !important;
    }
    .nav-center-btn span { color: #FFD700 !important; }

    /* The Drawer Fixes */
    #right-dashboard {
        position: fixed !important; top: 0 !important; right: -280px !important; bottom: auto !important;
        width: 260px !important; height: 100vh !important; z-index: 3000 !important;
        transition: right 0.3s ease-in-out !important;
    }
    #right-dashboard.drawer-open { right: 0 !important; }

    /* Mobile Drawer Overlay */
    #mobile-drawer-overlay {
        position: fixed;
        top: 0; 
        left: 0;
        width: 100vw; 
        height: 100vh;
        background: rgba(0, 0, 0, 0.6); /* Darkens the game behind the drawer */
        z-index: 2999; /* Sits exactly one layer below the drawer (3000) */
    }

    /* Mobile Close Button */
    #closeDrawerBtn {
        position: absolute;
        top: 5px;
        left: 5px;
        width: 30px; 
        height: 30px;
        background: #f44336;
        color: white;
        border: 2px solid #fff;
        border-radius: 5px;
        font-weight: bold;
        font-size: 16px;
        z-index: 3005;
        cursor: pointer;
        display: flex !important;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    }
}

/* Inventory Grid Overhaul */
.inv-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns for better fit on small panels */
    gap: 8px;
    padding: 10px;
    background: #fdf5e6; /* Cream background from screenshot */
}

.inv-card {
    background: #fdf5e6;
    border: 1px solid #8b5a2b;
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.inv-card-header {
    background: #e6d5b8;
    color: #3e2723;
    font-size: 11px;
    font-weight: bold;
    padding: 3px;
    text-align: center;
    border-bottom: 1px solid #8b5a2b;
}

.inv-card-body {
    display: flex;
    padding: 5px;
    gap: 8px;
    align-items: center;
}

.inv-icon-box {
    width: 45px;
    height: 45px;
    border: 1px solid #8b5a2b;
    background: #dccba9;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    flex-shrink: 0;
}

.inv-details {
    flex-grow: 1;
    font-size: 11px;
    color: #5c3a21;
}

.inv-btn-use {
    background: #fdf5e6;
    border: 1px solid #8b5a2b;
    color: #3e2723;
    font-size: 11px;
    padding: 2px 0;
    cursor: pointer;
    font-weight: bold;
    width: 90%;
    margin: 0 auto 5px auto;
}

.inv-btn-use:hover { background: #e6d5b8; }