:root {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --accent-color: #4CAF50;
    --panel-bg: #2d2d2d;
    --border-color: #404040;
    --bronze: #cd7f32;
    --silver: #c0c0c0;
    --gold: #ffd700;
    --platinum: #e5e4e2;
}

body {
    font-family: 'Courier New', Courier, monospace;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    -webkit-user-select: none; /* Prevent text selection on mobile */
    user-select: none;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 800px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.ad-banner-top {
    width: 100%;
    min-height: 100px; /* Typical banner height */
    background: #222;
    border: 1px solid #444;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

header {
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.status-badge {
    background: #000;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8em;
    color: var(--accent-color);
}

nav {
    display: flex;
    flex-wrap: wrap;       /* Allows buttons to wrap to next line */
    justify-content: center; /* Centers the buttons */
    gap: 5px;              /* Adds consistent spacing between buttons */
    background: #222;      /* Optional: Darker background for the bar */
    padding: 10px;         /* Padding inside the bar */
    border-radius: 5px;    /* Rounded corners for the container */
    margin-bottom: 15px;
    border: 1px solid #444;
}

/* Navigation Buttons */
nav button {
    flex: 1 1 auto;        /* Grow to fill space, shrink if needed */
    min-width: 80px;       /* Minimum width to keep text readable */
    padding: 10px 15px;
    background: #333;
    color: #ccc;
    border: 1px solid #555;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
    margin: 0;             /* Reset margins since we use gap now */
}

@media (hover: hover) {
    nav button:hover {
        background: #444;
        color: #fff;
        border-color: #666;
    }
}

#menu-toggle {
    display: none;
    width: 100%;
    padding: 12px;
    background: #222;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 5px;
    margin-bottom: 10px;
    cursor: pointer;
    font-weight: bold;
}

/* Active Tab Style */
nav button.active {
    background: #4CAF50;
    color: #fff;
    border-color: #4CAF50;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.4); /* Glow effect */
}

.panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 4px;
    display: none;
}

.panel.active { display: block; }

.combat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.health-bar-container {
    width: 100%;
    background: #000;
    height: 10px;
    margin-top: 5px;
}

.health-bar-fill {
    height: 100%;
    background: #d32f2f;
    width: 100%;
    transition: width 0.2s;
}

#combat-log {
    height: 150px;
    overflow-y: auto;
    background: #000;
    padding: 10px;
    font-size: 0.9em;
    margin-top: 20px;
    border: 1px solid var(--border-color);
}

.log-entry { margin-bottom: 4px; }
.log-gain { color: #4CAF50; }
.log-rare { color: #FFD700; }
.log-death { color: #d32f2f; }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border-color); padding: 5px 0; }

.mob-card {
    background: #222;
    border: 1px solid var(--border-color);
    padding: 15px;
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    align-items: center;
    gap: 10px;
}

.grade-text { font-weight: bold; }
.grade-None { color: #555; }
.grade-Bronze { color: var(--bronze); }
.grade-Silver { color: var(--silver); }
.grade-Gold { color: var(--gold); }
.grade-Platinum { color: var(--platinum); }

/* INVENTORY */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.item-card {
    background: #222;
    border: 1px solid #555;
    padding: 10px;
    text-align: center;
    border-radius: 4px;
}

.item-name { color: #FFD700; font-weight: bold; font-size: 0.9em; }
.item-count { color: #aaa; font-size: 0.8em; }

/* END INVENTORY */

/* LOGS LAYOUT */
.logs-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}

.log-box-wrapper h4 {
    margin: 0 0 5px 0;
    font-size: 0.9em;
    color: #888;
    border-bottom: 1px solid #444;
}

.scroll-log {
    height: 150px;
    overflow-y: auto;
    background: #000;
    padding: 10px;
    font-size: 0.85em;
    border: 1px solid var(--border-color);
    font-family: monospace;
    margin-top: 20px;
}

#damage-log {
    color: #aaa;
}

/* Specific Damage Colors */
.dmg-player { color: #fff; }
.dmg-enemy { color: #d32f2f; }

/* Sub Navigation Styles */
.sub-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.sub-nav button {
    background: transparent;
    border: 1px solid #555;
    color: #888;
    padding: 5px 15px;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 15px; /* Rounder buttons */
    transition: all 0.2s;
}

.sub-nav button:hover {
    background: #333;
    color: #fff;
}

.sub-nav button.active {
    background: #4CAF50;
    color: #fff;
    border-color: #4CAF50;
}

/* Boss Card Special Style */
.boss-card {
    border: 1px solid #d32f2f;
    background: #2a1a1a;
}

.enchant-card {
    background: #222;
    border: 1px solid #9c27b0;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
}

.enchant-btn {
    background: #4a148c;
    color: #fff;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.9em;
}

.enchant-btn:disabled {
    background: #333;
    color: #777;
    cursor: not-allowed;
}

.enchant-btn:hover:not(:disabled) {
    background: #7b1fa2;
}


.dmg-player { color: #fff; }
.dmg-enemy { color: #d32f2f; }

.dmg-crit { 
    color: #FFD700; /* Gold */
    font-weight: bold;
    text-shadow: 0px 0px 2px #ff8800;
}

/* FARMING */
.farming-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.plot-card {
    background: #2a2a2a;
    border: 1px solid #555;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
}

.seed-btn {
    display: block;
    width: 100%;
    margin: 5px 0;
    padding: 5px;
    background: #333;
    color: #ccc;
    border: 1px solid #555;
    cursor: pointer;
    font-size: 0.8em;
}

.seed-btn:hover {
    background: #444;
    color: #fff;
}

.seed-btn.harvest {
    background: #2e7d32;
    color: #fff;
    border-color: #4CAF50;
    font-weight: bold;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
}
.loader {
    border: 5px solid #333;
    border-top: 5px solid #4CAF50;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
    body {
        padding: 0;
        font-size: 14px;
    }

    .container {
        gap: 10px;
        width: 100%;
    }

    #menu-toggle {
        display: block;
    }

    /* Stack Grids vertically */
    .combat-grid, 
    .stats-grid, 
    .logs-container {
        grid-template-columns: 1fr;
    }

    .mob-card {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .mob-card div { text-align: center !important; }

    /* Larger Touch Targets for Nav */
    nav button {
        padding: 12px 5px;
        flex: 1 1 30%; /* Allow wrapping 3 per row */
    }
    
    nav.mobile-collapsed {
        display: none;
    }

    #combat-log, .scroll-log {
        height: 120px; /* Save vertical space */
    }
}