:root {
    --bg-primary: #f0f2f5;
    --bg-secondary: #e4e6eb;
    --bg-panel: #ffffff;
    --text-primary: #1c1e21;
    --text-secondary: #65676b;
    --accent-primary: #1877f2; /* Blue */
    --accent-success: #42b72a; /* Green */
    --accent-danger: #ff0000; /* Red */
    --border-color: #ccd0d5;
    --shadow-soft: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
    font-family: 'ZCOOL XiaoWei', serif;
    color: var(--text-primary);
}

#game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

h1 {
    font-size: 1.6em;
    color: #333;
    text-align: center;
    margin: 10px 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

/* --- New 5-Column Layout --- */
.five-column-layout {
    display: grid;
    grid-template-columns: 260px 280px 1fr 260px 280px;
    grid-template-rows: minmax(0, 1fr); /* Constrain row height */
    gap: 10px;
    flex: 1;
    overflow: hidden;
    padding: 0 10px 10px 10px;
    max-width: 2560px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 1600px) {
    .five-column-layout {
        grid-template-columns: 200px 220px 1fr 200px 220px;
    }
}

@media (max-width: 1300px) {
    .five-column-layout {
        /* Reduce side columns further and allow horizontal scroll if really needed, 
           or just accept tight layout. 
           Left: Hero (200), Skills (180) -> 380
           Right: Log (180), Shop (200) -> 380
           Total fixed: 760. On 1280px screen -> ~500px for center. Enough for 450px range. */
        grid-template-columns: 190px 190px 1fr 190px 190px;
        gap: 6px;
    }
    
    /* Adjust internal padding for tighter columns */
    .panel {
        padding: 10px;
    }
}

/* --- Mobile / Tablet Responsive Layout (< 1024px) --- */
@media (max-width: 1024px) {
    .five-column-layout {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: visible;
        padding-bottom: 60px; /* Space for footer/scroll */
    }

    #game-container {
        height: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body {
        overflow-y: auto;
        height: auto;
    }

    .game-column {
        width: 100%;
        height: auto;
        overflow: visible;
        margin-bottom: 10px;
    }

    /* Reorder for Mobile: Battle -> Skills -> Hero -> Inventory -> Shop */
    .col-center { order: 1; }
    .col-skills { order: 2; }
    .col-left   { order: 3; }
    .col-right  { order: 4; }
    .col-shop   { order: 5; }

    #battlefield-container {
        min-height: 280px; /* Slightly smaller on mobile */
    }

    /* Adjust Tower & Hero positions for smaller width */
    #tower-section {
        left: 10px !important;
        transform: scale(0.8);
        transform-origin: bottom left;
    }
    
    #hero-section {
        left: 50% !important;
        transform: translateX(-120%) scale(0.85); /* Center-ish */
        bottom: 60px !important;
    }

    #monster-section {
        right: 20px !important;
        left: auto !important;
        transform: scale(0.85);
        bottom: 60px !important;
    }
    
    /* Bigger touch targets */
    button, .ability-button {
        min-height: 44px; /* Touch friendly */
        font-size: 16px; 
    }
    
    .ability-button.compact {
        padding: 12px 5px;
    }

    /* Grid adjustments for mobile */
    .stats-grid {
        grid-template-columns: 1fr 1fr; /* Keep 2 cols or go 1? 2 is fine usually */
    }
    
    .abilities-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 cols for skills might be better on wide mobile */
    }
    
    .control-buttons-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    #start-button { grid-column: 1 / -1; } /* Full width start */
    
    /* Inventory & Shop */
    #shop-items {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .equipment-slot {
        font-size: 14px;
        padding: 10px;
    }
    
    /* Fix tooltips for mobile (basic position fix) */
    #game-tooltip {
        position: fixed;
        bottom: 10px;
        top: auto !important;
        left: 10px !important;
        right: 10px !important;
        width: auto;
        max-width: none;
        transform: none;
        z-index: 10000;
        pointer-events: none; /* Let touches pass through */
    }

    .victory-banner, .defeat-banner {
        font-size: 40px;
        width: 100%;
        text-align: center;
    }
}

/* Small Mobile (< 600px) */
@media (max-width: 600px) {
    .abilities-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    #battlefield-container::before {
        right: 20px;
        width: 40px; 
        height: 40px;
    }
    
    /* Stack controls */
    .settings-row {
        flex-direction: column;
        gap: 10px;
    }
    
    #game-speed-controls {
        width: 100%;
        justify-content: center;
    }
    
    #difficulty-select {
        width: 100%;
    }
}

.game-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    height: 100%;
    min-height: 0; /* Fix for flex scrolling */
    padding-right: 4px; /* Space for scrollbar */
}

.game-column.col-right {
    overflow-y: auto; /* Allow column to scroll */
}

.col-shop, .col-skills {
    background: rgba(255, 255, 255, 0.2); /* Distinctive background */
    border-radius: 12px;
    padding: 5px;
    border: 1px dashed var(--border-color);
}

/* Custom Scrollbar */
.game-column::-webkit-scrollbar, 
#log-messages::-webkit-scrollbar, 
#inventory-list::-webkit-scrollbar, 
#shop-items::-webkit-scrollbar {
    width: 6px;
}
.game-column::-webkit-scrollbar-track { background: transparent; }
.game-column::-webkit-scrollbar-thumb { background: #bdc3c7; border-radius: 3px; }
.game-column::-webkit-scrollbar-thumb:hover { background: #95a5a6; }

.panel {
    background: var(--bg-panel);
    border-radius: 10px;
    padding: 15px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel:hover {
    box-shadow: var(--shadow-hover);
}

/* --- Typography & Generic Elements --- */
h2, h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 5px;
}

p {
    margin: 6px 0;
    line-height: 1.4;
    font-size: 0.95em;
}

/* --- Buttons --- */
button, .ability-button, .compact, .speed-button, .allocate-button {
    background: #fff;
    border: 1px solid #dfe1e5;
    color: #5f6368;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.2s;
    outline: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

button:hover, .ability-button:hover:not(:disabled) {
    background: #f8f9fa;
    border-color: #dadce0;
    color: #202124;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button:active {
    transform: translateY(0);
    background: #f1f3f4;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f1f3f4;
}

.primary-action {
    background: var(--accent-primary) !important;
    color: white !important;
    border: none !important;
}
.primary-action:hover {
    background: #166fe5 !important;
}

.secondary {
    background: #e4e6eb;
    color: #050505;
    border: none;
}

/* --- Specific Panel Styles --- */

/* Hero Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    font-size: 0.9em;
}

.help-cursor {
    cursor: help;
    border-bottom: 1px dotted #aaa;
}

/* Equipment */
.equipment-slot {
    padding: 6px;
    margin: 4px 0;
    border: 1px solid #eee;
    border-radius: 6px;
    background: #fafafa;
    font-size: 0.9em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Abilities */
.abilities-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.ability-button.compact {
    padding: 8px 5px;
    font-size: 0.85em;
    text-align: center;
}

/* Battlefield (Center) */
.battle-hud {
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.95);
    z-index: 5;
    margin-bottom: 10px;
}

#battlefield-container {
    flex: 1;
    min-height: 350px;
    position: relative;
    background: linear-gradient(180deg, #87CEEB 0%, #E0F7FA 70%, #8D6E63 70%, #5D4037 100%); /* Sky to Ground */
    border-radius: 12px;
    border: 2px solid #333;
    overflow: hidden; /* Hide elements that move outside */
    box-shadow: inset 0 0 30px rgba(0,0,0,0.2);
    display: block !important; /* Override potential hides */
}

/* --- SKY ELEMENTS --- */

/* The Sun */
#battlefield-container::before {
    content: '';
    position: absolute;
    top: 30px;
    right: 50px;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, #fff700 30%, #ffcc00 100%);
    border-radius: 50%;
    box-shadow: 0 0 40px #ffcc00, 0 0 80px rgba(255, 204, 0, 0.4);
    z-index: 1;
}

/* Clouds (Animated) */
#battlefield-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%; /* Wider for seamless looping */
    height: 70%; /* Sky area only */
    pointer-events: none;
    z-index: 1;
    background-image: 
        radial-gradient(circle at 10% 40%, #fff 20px, transparent 21px),
        radial-gradient(circle at 13% 35%, #fff 25px, transparent 26px),
        radial-gradient(circle at 17% 40%, #fff 20px, transparent 21px),
        
        radial-gradient(circle at 45% 20%, #fff 15px, transparent 16px),
        radial-gradient(circle at 48% 15%, #fff 22px, transparent 23px),
        radial-gradient(circle at 51% 20%, #fff 15px, transparent 16px),
        
        radial-gradient(circle at 75% 50%, #fff 25px, transparent 26px),
        radial-gradient(circle at 79% 45%, #fff 35px, transparent 36px),
        radial-gradient(circle at 83% 50%, #fff 25px, transparent 26px);
    background-repeat: repeat-x;
    background-size: 50% 100%;
    opacity: 0.8;
    filter: blur(1px);
    animation: cloudsFloat 60s linear infinite;
}

@keyframes cloudsFloat {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* Tower & Visuals Positioning */
#tower-section {
    position: absolute !important;
    left: 40px !important; /* Moved to left side */
    bottom: 40px !important; /* Adjust based on ground level */
    width: 200px !important;
    height: 300px !important; /* Fixed height for visual consistency */
    pointer-events: none;
    z-index: 1 !important;
    transform: none !important;
}

/* Tower Styles (Majestic Castle Turret) */
.tower-base {
    width: 180px; 
    height: 350px;
    background-color: #5D4037;
    position: absolute; 
    bottom: 0; 
    left: 10px;
    border-radius: 10px 10px 0 0;
    border: 3px solid #3e2723;
    box-shadow: inset 15px 0 30px rgba(0,0,0,0.6);
    
    /* Complex Brick Texture */
    background-image: 
        linear-gradient(335deg, rgba(0,0,0,0.3) 23px, transparent 23px),
        linear-gradient(155deg, rgba(0,0,0,0.3) 23px, transparent 23px),
        linear-gradient(335deg, rgba(0,0,0,0.3) 23px, transparent 23px),
        linear-gradient(155deg, rgba(0,0,0,0.3) 23px, transparent 23px);
    background-size: 58px 58px;
    background-color: #795548;
    overflow: visible; /* Allow vines to protrude */
}

/* 3D Vines */
.tower-base::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -10px;
    width: 40px;
    height: 150px;
    background: 
        radial-gradient(circle at 50% 10%, #2e7d32 8px, transparent 9px),
        radial-gradient(circle at 20% 30%, #388e3c 10px, transparent 11px),
        radial-gradient(circle at 80% 50%, #1b5e20 9px, transparent 10px),
        radial-gradient(circle at 40% 70%, #2e7d32 11px, transparent 12px),
        radial-gradient(circle at 10% 90%, #388e3c 8px, transparent 9px);
    border-left: 4px solid #1b5e20;
    border-radius: 20px;
    transform: skewY(-10deg);
    z-index: 4;
}

/* Vertical Banners */
.tower-base::before {
    content: '';
    position: absolute;
    top: 60px; /* Below battlements */
    left: 20px;
    width: 20px;
    height: 120px;
    background: linear-gradient(180deg, #c0392b, #8e44ad);
    border-radius: 0 0 10px 10px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
    z-index: 3;
    background-image: 
        radial-gradient(circle at 50% 20%, #f1c40f 5px, transparent 6px),
        radial-gradient(circle at 50% 50%, #f1c40f 3px, transparent 4px),
        radial-gradient(circle at 50% 80%, #f1c40f 2px, transparent 3px);
}

/* Second Banner (using box-shadow trick to duplicate) */
.tower-middle::after {
    content: '';
    position: absolute;
    top: 80px; /* Relative to middle */
    right: 30px;
    width: 20px;
    height: 120px;
    background: linear-gradient(180deg, #c0392b, #8e44ad);
    border-radius: 0 0 10px 10px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
    z-index: 3;
    background-image: 
        radial-gradient(circle at 50% 20%, #f1c40f 5px, transparent 6px),
        radial-gradient(circle at 50% 50%, #f1c40f 3px, transparent 4px),
        radial-gradient(circle at 50% 80%, #f1c40f 2px, transparent 3px);
}

/* Detailed Tower Door */
.tower-door {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 90px;
    background: linear-gradient(90deg, #3e2723, #5d4037 40%, #4e342e 50%, #5d4037 60%, #3e2723);
    border-radius: 60px 60px 0 0;
    border: 4px solid #271c19;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
    z-index: 2;
    overflow: hidden;
}

/* Door Planks and Iron Banding */
.tower-door::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        linear-gradient(90deg, transparent 45%, rgba(0,0,0,0.5) 50%, transparent 55%),
        repeating-linear-gradient(0deg, transparent, transparent 30px, #271c19 30px, #271c19 35px);
    background-size: 100% 100%, 100% 100%;
}

/* Door Handle */
.tower-door::after {
    content: '';
    position: absolute;
    top: 50px; right: 15px;
    width: 8px; height: 8px;
    border: 3px solid #ffd700;
    border-radius: 50%;
    box-shadow: 1px 1px 2px black;
}

/* Magical Runes Circle */
.tower-runes {
    position: absolute;
    bottom: 100px; /* Above door */
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 140px;
    border: 2px dashed rgba(0, 255, 255, 0.3);
    border-radius: 50%;
    animation: runeSpin 10s linear infinite;
    pointer-events: none;
    z-index: 1;
}

/* Rune Symbols */
.tower-runes::before, .tower-runes::after {
    content: 'ᚠ ᚢ ᚦ ᚨ ᚱ ᚲ';
    position: absolute;
    width: 100%;
    text-align: center;
    color: #00ffff;
    font-size: 14px;
    text-shadow: 0 0 5px #00ffff;
    opacity: 0.7;
}
.tower-runes::before { top: -10px; transform: rotate(0deg); }
.tower-runes::after { bottom: -10px; transform: rotate(180deg); }

@keyframes runeSpin {
    from { transform: translateX(-50%) rotate(0deg); }
    to { transform: translateX(-50%) rotate(360deg); }
}

/* Vines */
.tower-base {
    /* Existing background plus vines */
    background-image: 
        linear-gradient(rgba(0,0,0,0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.1) 1px, transparent 1px),
        radial-gradient(circle at 10% 90%, #2e7d32 10px, transparent 12px),
        radial-gradient(circle at 20% 85%, #2e7d32 8px, transparent 10px),
        radial-gradient(circle at 5% 70%, #2e7d32 12px, transparent 14px);
}

.tower-middle {
    /* Merged into base for cleaner look, reused as parapet */
    width: 200px;
    height: 40px;
    background: #5D4037;
    position: absolute;
    top: -20px;
    left: -10px;
    border-radius: 5px;
    border: 2px solid #3e2723;
    display: flex;
    justify-content: space-around;
    padding: 0 10px;
}

.tower-middle::before { /* Battlements */
    content: '';
    position: absolute;
    top: -15px;
    left: 0;
    width: 100%;
    height: 15px;
    background-image: linear-gradient(90deg, #5D4037 20px, transparent 20px);
    background-size: 40px 100%;
}

.battle-window {
    width: 15px; height: 30px;
    background: #424242;
    border-radius: 15px 15px 0 0;
    margin-top: 50px; 
    position: relative;
    z-index: 2;
    border: 2px solid #3e2723;
    overflow: hidden;
}

/* Warm Inner Light */
.battle-window::after {
    content: '';
    position: absolute;
    top: 5px; left: 2px; right: 2px; bottom: 0;
    background: radial-gradient(circle at 50% 30%, #ffeb3b, #ff9800, #3e2723);
    border-radius: 10px 10px 0 0;
    opacity: 0.8;
    animation: windowFlicker 3s infinite alternate;
}

@keyframes windowFlicker {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.9; }
    20%, 80% { opacity: 0.7; }
}

/* Runes Ring */
.tower-base::after {
    /* Overriding previous doorway pseudo-element here, need to check if I can combine or use another */
    /* Previous doorway was .tower-base::after. I need to keep the doorway. */
    /* I will add runes to .tower-middle or a new element. */
    /* Let's put runes on .tower-middle::after instead of banner? No, banner is there. */
    /* I will create a new pseudo-element for runes on .tower-base using box-shadow for doorway or just a new div? */
    /* Actually, I'll put runes on tower-roof bottom edge or tower-base top edge. */
}

/* Magical Runes on Base Top */
.tower-middle {
    /* ... existing ... */
    /* I will use border-image or background-image for runes on the middle band */
    background-image: 
        repeating-linear-gradient(90deg, transparent, transparent 20px, #00ffff 20px, #00ffff 22px, transparent 22px, transparent 40px);
    background-size: 100% 50%;
    background-position: center bottom;
    background-repeat: no-repeat;
    box-shadow: 0 0 10px #00ffff;
}

/* Tower Roof (Shingled) */
.tower-roof {
    width: 180px; /* Wider overhang */
    height: 120px;
    position: absolute;
    bottom: 350px;
    left: 10px;
    z-index: 5;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    background-color: #2c3e50;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,0.2) 10px, rgba(0,0,0,0.2) 20px),
        linear-gradient(to bottom, #34495e, #2c3e50);
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.5));
}

/* Magic Crystal - Floating & Glowing */
.tower-crystal {
    width: 30px;
    height: 60px;
    background: linear-gradient(135deg, #00ffff, #0099ff);
    position: absolute;
    bottom: 450px; /* Above roof */
    left: 85px; /* Centered relative to tower-section (200px wide) -> 100px center. Crystal 30px -> 85px */
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    z-index: 6;
    animation: crystalFloat 3s ease-in-out infinite;
    box-shadow: 0 0 20px #00ffff, inset 0 0 10px white;
}

/* Crystal Aura Rings */
.tower-crystal::before, .tower-crystal::after {
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 50%;
    animation: crystalRing 2s linear infinite;
}
.tower-crystal::before { width: 40px; height: 40px; animation-duration: 2s; }
.tower-crystal::after { width: 60px; height: 60px; animation-duration: 3s; border-color: rgba(0, 150, 255, 0.3); }

@keyframes crystalFloat {
    0%, 100% { transform: translateY(0); filter: brightness(1); }
    50% { transform: translateY(-10px); filter: brightness(1.3) drop-shadow(0 0 15px #00ffff); }
}

@keyframes crystalRing {
    0% { width: 30px; height: 30px; opacity: 1; transform: translate(-50%, -50%) rotateX(60deg) rotate(0deg); }
    100% { width: 80px; height: 80px; opacity: 0; transform: translate(-50%, -50%) rotateX(60deg) rotate(180deg); }
}

.tower-flag {
    width: 60px;
    height: 40px;
    background: linear-gradient(90deg, #c0392b, #e74c3c);
    position: absolute;
    bottom: 420px; /* Attached to roof peak */
    left: 100px;
    transform-origin: left center;
    animation: flagWave 3s ease-in-out infinite;
    border-radius: 0 10px 10px 0;
    z-index: 4;
}

.tower-flag::before { /* Flag Pole */
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 60px;
    background: #bdc3c7;
}

/* Floating Debris / Magic Rocks */
.tower-debris {
    position: absolute;
    background: #5D4037;
    border: 1px solid #3e2723;
    animation: debrisFloat 4s ease-in-out infinite;
}
.d1 {
    width: 15px; height: 15px;
    bottom: 400px; left: 40px;
    clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
    animation-delay: 0s;
}
.d2 {
    width: 10px; height: 10px;
    bottom: 380px; right: 40px;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    animation-delay: 2s;
}

@keyframes debrisFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(10deg); }
}

@keyframes flagWave {
    0%, 100% { transform: scaleX(1) skewY(0deg); }
    25% { transform: scaleX(0.9) skewY(5deg); }
    50% { transform: scaleX(1) skewY(0deg); }
    75% { transform: scaleX(0.9) skewY(-5deg); }
}

/* Characters */
#hero-section {
    position: absolute !important;
    left: 350px !important; /* Move hero closer to the middle */
    bottom: 75px !important; /* On the ground */
    z-index: 10 !important;
    transform: none !important;
}
#monster-section {
    position: absolute !important;
    bottom: 75px !important;
    z-index: 10 !important;
}

/* Battle Controls */
.control-buttons-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 2fr;
    gap: 10px;
    margin-bottom: 10px;
}

.secondary-controls {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    justify-content: center;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 8px;
}

#game-speed-controls {
    display: flex;
    gap: 4px;
}

/* Right Column Panels */
.log-panel {
    display: flex;
    flex-direction: column;
    max-height: 150px; /* Reduced from 250px to give space to inventory */
    flex-shrink: 0;
}

#log-messages {
    flex: 1;
    overflow-y: auto;
    font-size: 0.85em;
    font-family: monospace;
    padding: 5px;
    background: #fafafa;
    border-radius: 4px;
    border: 1px solid #eee;
}

#inventory-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: none; /* Removed fixed height to show all items */
    overflow-y: visible;
}

#inventory-section {
    flex: 0 0 auto; /* Size to content */
    flex-shrink: 0; /* Do not shrink */
}

#inventory-list li {
    padding: 4px; /* Compact padding */
    margin-bottom: 4px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 6px;
    font-size: 0.9em;
}

#shop-items {
    /* max-height: 300px;  Removed max-height */
    /* overflow-y: auto; Removed overflow */
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.shop-item {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 0; /* Margin handled by grid gap */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.shop-item h4 { margin: 0 0 3px 0; font-size: 0.9em; color: var(--accent-success); border: none; }
.shop-item p { margin: 1px 0; font-size: 0.8em; color: var(--text-secondary); line-height: 1.2; }
.shop-item button { width: 100%; margin-top: 4px; padding: 4px; font-size: 0.85em; }

/* Progress Bars */
.health-bar-container, .xp-bar-container {
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    margin: 5px 0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.health-bar { background: linear-gradient(90deg, #ef5350, #c62828); height: 100%; transition: width 0.3s; }
.xp-bar { background: linear-gradient(90deg, #42a5f5, #1565c0); height: 100%; transition: width 0.3s; }

/* Keep specific visual styles */
/* Imports removed to avoid CSS errors. Files are linked in HTML. */

/* Overrides for imported styles if necessary */
#hero-visual, #monster-visual {
    width: 80px; height: 120px;
    /* Scale down slightly if needed */
    transform: scale(0.9); 
}

.auto-save-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
    z-index: 2000;
}
.auto-save-indicator.show { opacity: 1; }

/* === Tooltips === */
#game-tooltip {
    position: fixed;
    background: rgba(20, 20, 30, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f0f0f0;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9em;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
    max-width: 320px;
    line-height: 1.5;
    opacity: 0;
    transition: opacity 0.15s;
    backdrop-filter: blur(4px);
}

#game-tooltip.visible {
    opacity: 1;
}

#game-tooltip h4 {
    color: #4facfe;
    margin: 0 0 6px 0;
    font-size: 1.05em;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 4px;
}

#game-tooltip .tooltip-stat {
    color: #aaa;
    font-size: 0.85em;
    margin-top: 4px;
    display: block;
}