@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&display=swap');

        :root {
            /* -- NEW: Post-Apocalyptic Theme -- */
            --khaki-highlight: #c7b27a;   /* Muted yellow for highlights */
            --rust-border: #7b4a2b;       /* Dark, rusty brown for borders and accents */
            --metal-bg: #2a241e;          /* Very dark metallic background */
            --panel-grad-start: #5c4a3a;  /* Lighter part of panel gradient */
            --panel-grad-end: #3c2a1a;    /* Darker part of panel gradient */
            --text-primary: #e6d5b8;      /* Off-white, tan text color */
            --text-secondary: #a08c6c;    /* Muted tan for secondary text */
        }

        body {
            font-family: 'Cinzel', serif;
            background-color: var(--metal-bg);
            color: var(--text-primary);
            font-size: 15px; /* Makes UI smaller overall */
        }

        /* --- New Thematic UI --- */
        .ryl-panel {
            background: linear-gradient(to bottom, var(--panel-grad-start), var(--panel-grad-end));
            border: 3px solid var(--rust-border);
            border-radius: 8px;
            box-shadow: 0 0 15px rgba(0,0,0,0.5), inset 0 0 10px rgba(0, 0, 0, 0.5);
        }

        .ryl-status-box {
            background-color: rgba(0,0,0,0.3);
            border: 2px solid var(--rust-border);
            border-radius: 8px;
            box-shadow: inset 0 0 8px rgba(0,0,0,0.5);
        }

        .text-gold {
            color: var(--khaki-highlight);
        }
        
        .ryl-button {
            background: linear-gradient(to bottom, #6c5a4a, #4c3a2a);
            border: 2px solid var(--rust-border);
            color: var(--text-primary);
            font-weight: bold;
            border-radius: 0.5rem;
            box-shadow: 0 2px 5px rgba(0,0,0,0.4), inset 0 1px 0px rgba(255, 235, 205, 0.1);
            transition: all 0.2s ease-in-out;
            position: relative; /* For notification badge */
        }
        .ryl-button:hover {
            background: linear-gradient(to bottom, #7c6a5a, #5c4a3a);
            border-color: var(--khaki-highlight);
            box-shadow: 0 4px 10px rgba(0,0,0,0.5);
        }
        .ryl-button:disabled {
            background: #4a4a4a;
            border-color: #6a6a6a;
            cursor: not-allowed;
            opacity: 0.6;
        }
        .ryl-button.primary {
             background: linear-gradient(to bottom, #8a795d, #6a593d);
        }
        .ryl-button.primary:hover {
             background: linear-gradient(to bottom, #9a896d, #7a694d);
        }
        .ryl-button.danger {
             background: linear-gradient(to bottom, #8b2c2c, #6b1c1c);
        }
        .ryl-button.danger:hover {
             background: linear-gradient(to bottom, #9b3c3c, #7b2c2c);
        }

        input, select {
            background-color: #3c2a1a;
            border: 2px solid var(--rust-border);
            color: var(--text-primary);
        }
        input:focus, select:focus {
            outline: none;
            box-shadow: 0 0 0 2px var(--khaki-highlight);
        }

        /* Scrollbar */
        .scroll-container::-webkit-scrollbar, .help-content::-webkit-scrollbar, .shop-content::-webkit-scrollbar, .quest-content::-webkit-scrollbar, .equipment-content::-webkit-scrollbar, .inventory-list::-webkit-scrollbar, .stats-content::-webkit-scrollbar, .blacksmith-content::-webkit-scrollbar, #character-creation-screen::-webkit-scrollbar {
            width: 8px;
        }
        .scroll-container::-webkit-scrollbar-track, .help-content::-webkit-scrollbar-track, .shop-content::-webkit-scrollbar-track, .quest-content::-webkit-scrollbar-track, .equipment-content::-webkit-scrollbar-track, .inventory-list::-webkit-scrollbar-track, .stats-content::-webkit-scrollbar-track, .blacksmith-content::-webkit-scrollbar-track, #character-creation-screen::-webkit-scrollbar-track {
            background: #3c2a1a;
        }
        .scroll-container::-webkit-scrollbar-thumb, .help-content::-webkit-scrollbar-thumb, .shop-content::-webkit-scrollbar-thumb, .quest-content::-webkit-scrollbar-thumb, .equipment-content::-webkit-scrollbar-thumb, .inventory-list::-webkit-scrollbar-thumb, .stats-content::-webkit-scrollbar-thumb, .blacksmith-content::-webkit-scrollbar-thumb, #character-creation-screen::-webkit-scrollbar-thumb {
            background-color: var(--rust-border);
            border-radius: 20px;
        }

        /* --- Skill Bar & Icons --- */
        #skill-bar-wrapper {
            background: linear-gradient(to bottom, var(--panel-grad-start), var(--panel-grad-end));
            border: 3px solid var(--rust-border);
            border-radius: 8px;
            padding: 4px;
            box-shadow: 0 0 15px rgba(0,0,0,0.5), inset 0 0 5px rgba(0, 0, 0, 0.4);
            display: flex;
            justify-content: center;
        }
        #skill-bar-container {
            display: flex;
            flex-direction: row;
            gap: 4px;
        }
        .skill-slot {
            width: 70px;
            height: 70px;
            background-color: #1a1a1a;
            border: 2px solid #5c4a3a;
            border-radius: 4px;
            position: relative;
            box-shadow: inset 0 0 8px rgba(0,0,0,0.6);
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0; /* Prevents shrinking in flex container */
        }
        .skill-slot i {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1rem;
            margin: 0;
        }
        .skill-keybind {
            position: absolute; top: 1px; left: 1px;
            background-color: black; color: white;
            font-size: 0.5rem; font-weight: bold;
            border-radius: 50%; width: 10px; height: 10px;
            display: flex; align-items: center; justify-content: center;
            border: 1px solid white; text-shadow: 1px 1px 2px black;
        }
        .item-quantity-badge {
            position: absolute; bottom: 1px; right: 2px;
            color: white; font-size: 0.8rem; font-weight: bold;
            text-shadow: 1px 1px 2px black, -1px -1px 2px black;
        }
        .skill-cooldown-overlay {
             position: absolute; top: 0; left: 0; right: 0; bottom: 0;
             background-color: rgba(0,0,0,0.7);
             color: white;
             display: flex; align-items: center; justify-content: center;
             font-size: 1rem; border-radius: 2px;
        }

        /* --- Other Component Styling --- */
        .scroll-container { background-color: rgba(0,0,0,0.3); border-radius: 0.5rem; overflow-y: auto; }
        .game-log-message, .character-slot, .modal-animate { animation: fadeIn 0.5s ease-in-out; }
        @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
        .stat-bar-container { height: 1.4rem; background-color: #475569; border-radius: 0.5rem; position: relative; overflow: hidden; border: 1px solid var(--rust-border); }
        .stat-bar { height: 100%; transition: width 0.5s ease-in-out; }
        .stat-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 0.8rem; font-weight: bold; color: white; text-shadow: 1px 1px 2px rgba(0,0,0,0.7); }
        .buff-duration-overlay { position: absolute; bottom: -1px; left: -1px; width: calc(100% + 2px); background-color: rgba(0, 0, 0, 0.75); color: white; font-size: 0.6rem; font-weight: bold; text-align: center; border-bottom-left-radius: 0.5rem; border-bottom-right-radius: 0.5rem; padding: 1px 0; }
        .active-buff-glow { box-shadow: 0 0 8px var(--khaki-highlight); border-color: var(--khaki-highlight); }
        .quest-progress-bar { height: 0.5rem; background-color: #475569; border-radius: 0.25rem; overflow: hidden; }
        
        .damage-text { position: absolute; font-size: 1.4rem; font-weight: bold; text-shadow: 1px 1px 2px rgba(0,0,0,0.8); pointer-events: none; animation: floatUpAndFade 1.5s ease-out forwards; z-index: 100; }
        .damage-text.player-damage { color: #ef4444; } .damage-text.monster-damage { color: #f59e0b; }
        .damage-text.crit { color: #f97316; font-size: 1.8rem; font-weight: 900; animation-duration: 2s; }
        .damage-text.heal { color: #22c55e; } .damage-text.miss { color: #a1a1aa; font-size: 1.15rem; }
        .damage-text.block { color: #3b82f6; font-size: 1.15rem; }
        @keyframes floatUpAndFade { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-70px) scale(1.5); } }
        .victory-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 3.5rem; font-weight: 900; color: var(--khaki-highlight); text-shadow: 2px 2px 4px rgba(0,0,0,0.8); pointer-events: none; animation: flashAndFade 2s ease-out forwards; z-index: 101; }
        @keyframes flashAndFade { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); } 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } }
        
        .equipment-paper-doll { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); gap: 8px; width: 240px; height: 300px; } /* Smaller */
        .equip-slot { background-color: #3c2a1a; border: 2px dashed var(--rust-border); border-radius: 0.5rem; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px; text-align: center; cursor: pointer; }
        .equip-slot[data-slot="helmet"] { grid-area: 1 / 2 / 2 / 3; } .equip-slot[data-slot="weapon"] { grid-area: 2 / 1 / 3 / 2; }
        .equip-slot[data-slot="chest"] { grid-area: 2 / 2 / 3 / 3; } .equip-slot[data-slot="shield"] { grid-area: 2 / 3 / 3 / 4; }
        .equip-slot[data-slot="gloves"] { grid-area: 3 / 1 / 4 / 2; } .equip-slot[data-slot="pants"] { grid-area: 3 / 2 / 4 / 3; }
        .equip-slot[data-slot="accessory"] { grid-area: 3 / 3 / 4 / 4; } .equip-slot[data-slot="boots"] { grid-area: 4 / 2 / 5 / 3; }

        /* --- Socket Styling --- */
        .socket-container { display: flex; gap: 4px; margin-top: 4px; height: 10px; justify-content: center; } /* Smaller */
        .socket { width: 10px; height: 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center; } /* Smaller */
        .socket.empty { background-color: var(--metal-bg); border: 1px solid #5c4a3a; cursor: pointer; }
        .socket.empty:hover { background-color: #3c2a1a; }
        .socket i { font-size: 7px; } /* Smaller */
        .gem-in-inventory.selected-gem { border: 2px solid var(--khaki-highlight); box-shadow: 0 0 10px var(--khaki-highlight); }

        /* --- Inventory Tab Styling --- */
        .inventory-tabs {
            display: flex;
            border-bottom: 2px solid var(--rust-border);
            margin-bottom: 0.5rem;
        }
        .inventory-tab {
            padding: 0.5rem 1rem;
            cursor: pointer;
            border-bottom: 3px solid transparent;
            margin-bottom: -2px;
            transition: all 0.2s ease;
            background-color: rgba(0,0,0,0.2);
        }
        .inventory-tab.active {
            border-bottom-color: var(--khaki-highlight);
            color: var(--khaki-highlight);
            background-color: transparent;
        }
        .inventory-tab:hover:not(.active) {
            background-color: rgba(255,255,255,0.1);
        }

        .inventory-grid {
            align-content: start;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); /* Smaller */
            gap: 8px;
            background-color: rgba(0,0,0,0.4);
            border: 2px solid var(--rust-border);
            padding: 8px;
            border-radius: 8px;
            min-height: 220px; /* Smaller */
        }
        .inventory-slot {
            width: 50px; /* Smaller */
            height: 50px; /* Smaller */
            background-color: #3c2a1a;
            border: 2px solid #5c4a3a;
            border-radius: 4px;
            position: relative;
            box-shadow: inset 0 0 8px rgba(0,0,0,0.6);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        .inventory-slot:hover {
            border-color: var(--khaki-highlight);
        }
        .inventory-slot.selected {
            border-color: var(--khaki-highlight);
            box-shadow: 0 0 10px var(--khaki-highlight);
            background-color: #5c4a3a;
        }
        .inventory-slot i {
            font-size: 1.6rem; /* Slightly smaller */
        }
        .inventory-item-quantity {
            position: absolute;
            bottom: 2px;
            right: 4px;
            color: white;
            font-size: 0.75rem;
            font-weight: bold;
            text-shadow: 1px 1px 2px black, -1px -1px 2px black;
        }

        #passive-skills-display .skill-slot { 
            width: 20px; 
            height: 20px; 
        }
        #passive-skills-display .skill-slot i { 
            font-size: 0.5rem; 
        }
        #passive-skills-display .skill-level-badge { 
            position: absolute; 
            width: 10px; 
            height: 10px; 
            font-size: 0.4rem; 
            bottom: -2px; 
            right: -2px; 
            background-color: var(--rust-border); 
            color: black; 
            border-radius: 50%; 
            display: flex; 
            align-items: center; 
            justify-content: center; 
            border: 1px solid black; 
        }
    
        /* --- Notification System --- */
        #notification-container {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            width: 90%;
            max-width: 400px;
            z-index: 1000;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .notification-popup {
            min-width: unset;
            width: 100%;
            padding: 1rem;
            animation: slideInDown 0.5s ease-out forwards, fadeOut 0.5s ease-in forwards 4.5s;
        }
        @keyframes slideInDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
        @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

        /* --- Custom Tooltip --- */
        #custom-tooltip {
            position: fixed;
            display: none;
            padding: 0.75rem;
            z-index: 1100;
            pointer-events: none;
            max-width: 230px; /* Smaller */
            font-size: 0.8rem; 
            line-height: 1.5;
        }
        
        /* --- Quest Notification Badge --- */
        .notification-badge {
            position: absolute;
            top: -5px;
            right: -5px;
            background-color: #ef4444; /* red-500 */
            color: white;
            border-radius: 50%;
            width: 18px; /* Smaller */
            height: 18px; /* Smaller */
            font-size: 0.7rem;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            border: 2px solid var(--metal-bg);
        }

        /* --- Daily Reward --- */
        .daily-reward-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 1rem; }
        .reward-card { background-color: rgba(0,0,0,0.3); border: 2px solid var(--rust-border); border-radius: 8px; padding: 1rem; text-align: center; }
        .reward-card.claimed { background-color: rgba(123, 74, 43, 0.3); border-color: var(--rust-border); }
        .reward-card.today { box-shadow: 0 0 15px var(--khaki-highlight); }

        /* Blacksmith Tabs */
        .blacksmith-tabs {
            display: flex;
            border-bottom: 2px solid var(--rust-border);
            margin-bottom: 1rem;
        }
        .blacksmith-tab {
            padding: 0.75rem 1.5rem;
            cursor: pointer;
            border-bottom: 3px solid transparent;
            margin-bottom: -2px;
            transition: all 0.2s ease;
        }
        .blacksmith-tab.active {
            border-bottom-color: var(--khaki-highlight);
            color: var(--khaki-highlight);
            background-color: rgba(0,0,0,0.2);
        }
        .blacksmith-tab:hover:not(.active) {
            background-color: rgba(255,255,255,0.1);
        }
        .blacksmith-tab-content {
            display: none;
        }
        .blacksmith-tab-content.active {
            display: block;
        }
        

        /* ------- MOBILE OPTIMIZATION STYLES (START) ------- */
        @media (max-width: 640px) {
            /* General Layout & Sizing */
            body {
                padding: 0;
            }
            #game-container {
                padding: 1rem;
                height: 100vh; /* Full screen height */
                max-height: 100vh;
                border-radius: 0;
                border-width: 0;
            }

            #game-screen {
                padding-bottom: 124px; /* Make space for fixed bottom bars (Adjusted) */
            }

            h1 { font-size: 1.4rem; } /* Slightly smaller */
            h2 { font-size: 1.15rem; } /* Slightly smaller */
            h3 { font-size: 1.0rem; } /* Slightly smaller */

            /* Character Selection & Creation */
            #character-creation-screen {
                 padding-right: 0; /* Remove padding for scrollbar */
            }
            .race-button, .class-button {
                padding: 1rem;
            }

            /* Player Status Box */
            #player-status-box .flex.justify-between {
                flex-direction: column;
                align-items: stretch;
                gap: 0.5rem;
                margin-bottom: 0.5rem;
            }
            #player-status-box .text-right {
                display: flex;
                justify-content: space-between;
                align-items: center;
            }
            #player-name-display {
                font-size: 1.4rem; /* Smaller */
                text-align: center;
            }
            #player-level-display, #player-race-display, #player-class-display {
                font-size: 0.85rem; /* Smaller */
            }
            #player-status-box p.text-text-dark {
                text-align: center;
            }
            #passive-skills-display {
                justify-content: center; /* Center the passive icons */
                margin-top: 0.5rem;
                padding: 0;
            }
            #player-quick-stats {
                grid-template-columns: repeat(2, 1fr);
                gap: 0.25rem;
            }

            /* Main Navigation Icons (Bottom Bar) */
            #top-icon-buttons {
                position: fixed;
                bottom: 0;
                left: 0;
                right: 0;
                display: flex;
                justify-content: space-around;
                align-items: center;
                background: linear-gradient(to top, var(--panel-grad-start), var(--panel-grad-end));
                border-top: 2px solid var(--rust-border);
                padding: 0.5rem;
                z-index: 200;
                gap: 0.25rem;
            }
            #top-icon-buttons .ryl-button {
                width: auto;
                flex-grow: 1; /* Make buttons fill space */
                height: 46px; /* Smaller */
            }
            #top-icon-buttons .ryl-button i {
                font-size: 1.15rem; /* Smaller */
            }
             #player-gold-display {
                font-size: 0.9rem; /* Smaller */
            }
            
            /* Action Buttons & Monster Select */
            #game-screen > .flex.sm\:flex-row {
                flex-direction: column;
            }
            #action-buttons {
                grid-template-columns: repeat(2, 1fr);
                gap: 0.5rem;
            }
            #action-buttons .ryl-button {
                padding: 0.75rem;
                font-size: 1.0rem; /* Smaller */
            }
            
            /* Skill Bar */
            #skill-bar-wrapper {
                position: fixed;
                bottom: 61px; /* Position above the nav bar (Adjusted for 46px height + padding) */
                left: 0;
                right: 0;
                width: 100%;
                border-radius: 0;
                border-left: 0;
                border-right: 0;
                z-index: 150;
                padding: 0.5rem;
                overflow-x: auto; /* Make it scrollable */
                justify-content: flex-start; /* Align skills to the left */
            }
            #skill-bar-container-1, #skill-bar-container-2 {
                flex-wrap: nowrap; /* Prevent wrapping */
            }
            #skill-bar-container-2 {
                display: flex; /* Always show second container content */
            }
            /* Hide keybinds on mobile as they aren't relevant */
            .skill-keybind {
                display: none;
            }

            /* Modals */
            .modal-animate {
                width: 100%;
                max-width: 100%;
                height: 95vh;
                max-height: 95vh;
            }
            #equipment-modal-content > div {
                flex-direction: column;
            }
            #paper-doll-container {
                margin: 0 auto; /* Center the paper doll */
            }

            /* Blacksmith Tabs */
             .blacksmith-tabs {
                overflow-x: auto;
                flex-wrap: nowrap;
             }
             .blacksmith-tab {
                flex-shrink: 0; /* Prevent tabs from shrinking */
                padding: 0.5rem 1rem;
             }
        }
        /* ------- MOBILE OPTIMIZATION STYLES (END) ------- */