    /* --- MYSTIC IRON THEME (Rich Texture + Depth) --- */
    @import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Crimson+Pro:wght@400;600;700&display=swap');

    :root {
        /* Palette: Gunmetal, Bronze, Parchment */
        --bg-dark: #121418;         /* Deepest shadow */
        --bg-light: #1f2329;        /* Lighter surface */
        --panel-bg: rgba(30, 34, 40, 0.95); /* Semi-transparent slate */
        
        --text-main: #e3e5e8;       /* Bright White-Grey */
        --text-muted: #9fa6b2;      /* Soft Grey */
        
        /* Accents - Neon/Magic feel */
        --accent-gold: #eebb4d;     /* Rich Gold */
        --accent-glow: rgba(238, 187, 77, 0.15); 
        
        --danger: #ff5c5c;          /* Bright Red */
        --safe: #4cd137;            /* Emerald Green */
        --magic: #c56cf0;           /* Runestone Purple */
        --fury: #ff9f1a;            /* Fire Orange */
        
        --border-color: #3a404a;    /* Visible Iron Border */
        --border: 1px solid var(--border-color);
        
        /* Fonts */
        --font-head: 'Cinzel', serif;
        --font-body: 'Crimson Pro', serif;
    }
	/* --- HARD MODE THEME OVERRIDES --- */
body.hard-mode {
    /* Override the Main Heroic Gold with a Hostile Red */
    --accent-gold: #ff4d4d; 
    
    /* Change the glow from warm gold to bloody mist */
    --accent-glow: rgba(255, 77, 77, 0.15);
    
    /* Make the borders slightly sharper/brighter to look like raw iron */
    --border-color: #554444;

    /* Optional: Tint the background slightly red */
    background: radial-gradient(circle at 50% 10%, #2a1a1a 0%, #050505 90%) !important;
}

/* Optional: Make the buttons look more aggressive in Hard Mode */
body.hard-mode .btn-action {
    border-style: double; /* Changes from solid to double lines */
}

    * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

    body {
        margin: 0; padding: 0; height: 100dvh; width: 100%;
        overflow: hidden; 
        /* Torchlight Gradient Background */
        background: radial-gradient(circle at 50% 10%, #2c313a 0%, #121418 90%);
        color: var(--text-main);
        font-family: var(--font-body);
        font-size: 16px;
        display: flex; flex-direction: column;
        line-height: 1.5;
            /* [ANDROID FIX] Prevents long-press selecting text or opening menus */
    -webkit-user-select: none; /* Chrome/Safari/Android */
    user-select: none;         /* Standard */
    -webkit-touch-callout: none; /* Prevents "Copy/Save Image" menu on long press */
    
    /* Prevent "pull to refresh" behavior in some WebViews */
    overscroll-behavior: none;
    }
    
    /* Allow text selection ONLY in specific areas where needed (like the Save Export box) */
#data-io-area {
    -webkit-user-select: text;
    user-select: text;
}

    /* --- ANIMATIONS --- */
    @keyframes holy-pulse {
        0% { text-shadow: 0 0 5px var(--accent-gold); transform: scale(1); }
        50% { text-shadow: 0 0 20px var(--accent-gold); transform: scale(1.02); }
        100% { text-shadow: 0 0 5px var(--accent-gold); transform: scale(1); }
    }
    .sanctuary-mode { animation: holy-pulse 4s infinite ease-in-out; color: #fff !important; }

    @keyframes spawn-in {
        0% { opacity: 0; transform: scale(0.9) translateY(10px); }
        100% { opacity: 1; transform: scale(1) translateY(0); }
    }
    .anim-spawn { animation: spawn-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

    @keyframes death-fade {
        0% { opacity: 1; filter: grayscale(0); transform: scale(1); }
        100% { opacity: 0; filter: grayscale(1); transform: scale(0.9); }
    }
    .anim-death { animation: death-fade 0.5s ease-in forwards; pointer-events: none; }



    /* --- LAYOUT --- */
    #game-interface {
        flex: 1; width: 100%; max-width: 600px; margin: 0 auto;
        display: flex; flex-direction: column; position: relative; height: 100%; z-index: 1;
    }

    .panel {
        flex: 1; display: flex; flex-direction: column;
        padding: 15px; overflow-y: auto;
        /* Glassy Panel Look */
        background: var(--panel-bg);
        margin-bottom: 70px;
        box-shadow: 0 0 20px rgba(0,0,0,0.2); 
    }

    /* If the body contains a #nav-dock that is NOT hidden, add margin to the panel */
    body:has(#nav-dock:has([style*="display: none"])) .panel {
        margin-bottom: 70px;
    }

    .panel:not(.active) { display: none; }

    h3 { 
        color: var(--accent-gold); margin: 0 0 15px 0; 
        text-transform: uppercase; font-size: 15px; letter-spacing: 3px; 
        font-family: var(--font-head); 
        border-bottom: 2px solid var(--border-color); 
        padding-bottom: 8px;
        text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    }

    /* --- CARDS (Rich Depth) --- */
    .combat-card {
        background: linear-gradient(145deg, #252a30, #1e2227);
        border: 1px solid #3a404a;
        padding: 15px; margin-bottom: 12px; 
        position: relative; 
        box-shadow: 0 4px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
        border-radius: 6px;
    }
    .card-header {
        display: flex; justify-content: space-between; align-items: center;
        font-size: 11px; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px;
        font-family: var(--font-head); font-weight: bold;
    }
    .card-header b { color: var(--text-main); font-size: 15px; text-shadow: 0 1px 2px #000; }

    /* TARGET CARD */
    #card-target { min-height: 200px; display: flex; flex-direction: column; justify-content: center; align-items: center; background: linear-gradient(180deg, #1e2227 0%, #15181c 100%); }
    .enemy-icon { font-size: 80px; padding-top: 10px; filter: drop-shadow(0 10px 10px rgba(0,0,0,0.5)); transition: transform 0.1s; }

    /* BARS (Glossy) */
    .bar-container { width: 100%; margin-bottom: 6px; }
    .bar-track { background: #0f1114; height: 12px; width: 100%; border: 1px solid #2d323a; position: relative; border-radius: 3px; box-shadow: inset 0 1px 3px rgba(0,0,0,0.5); }
    .bar-fill { height: 100%; transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 2px; position: relative; overflow: hidden; }
    
    /* Add shine to bars */
    .bar-fill::after {
        content: ''; position: absolute; top:0; left:0; right:0; height: 50%;
        background: rgba(255,255,255,0.1);
    }

    .fill-hp-enemy { background: linear-gradient(90deg, #c0392b, #e74c3c); }
    .fill-hp-player { background: linear-gradient(90deg, #27ae60, #2ecc71); }
    .fill-fury { background: linear-gradient(90deg, #d35400, #e67e22); }
    .fill-xp { background: linear-gradient(90deg, #f39c12, #f1c40f); }
    
    @keyframes alarm-pulse {
        0% { background: #c0392b; box-shadow: 0 0 5px #c0392b; }
        50% { background: #ff0000; box-shadow: 0 0 20px #ff0000; }
        100% { background: #c0392b; box-shadow: 0 0 5px #c0392b; }
    }
    .bar-low { animation: alarm-pulse 0.6s infinite ease-in-out !important; }

    /* CONTROLS (Tactile Buttons) */
    .control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; }
    .btn-action {
        padding: 10px; 
        background: linear-gradient(to bottom, #3a404a, #2c313a);
        color: #dcdde1; 
        border: 1px solid #48505c; cursor: pointer;
        font-family: var(--font-head); font-size: 13px; font-weight: bold; text-transform: uppercase;
        border-radius: 6px;
        box-shadow: 0 4px 0 #1e2227; /* 3D Clicky Effect */
        transition: transform 0.1s, box-shadow 0.1s, color 0.2s;
    }
    .btn-action:hover:not(:disabled) { 
        border-color: var(--accent-gold); color: #fff; 
        background: linear-gradient(to bottom, #48505c, #3a404a);
    }
    .btn-action:active:not(:disabled) {
        transform: translateY(4px); box-shadow: 0 0 0 #1e2227; /* Press down */
    }
    .btn-action:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); box-shadow: none; transform: translateY(2px); }
    .btn-action small { display: block; font-size: 10px; color: #9fa6b2; margin-top: 5px; font-weight: normal; font-family: var(--font-body); text-transform: none; }

    /* LIMIT BREAK (Glowing) */
    #btn-limit {
        grid-column: span 2; 
        background: linear-gradient(45deg, #4b2c20, #6d3625);
        border-color: var(--fury); color: #ffbcbc; 
        /*visibility: hidden; */
        box-shadow: 0 0 10px rgba(255, 69, 0, 0.3);
        animation: pulse 1.5s infinite;
    }
    /*.limit-ready { visibility: visible !important; }*/
    @keyframes pulse { 50% { border-color: #ffaa00; box-shadow: 0 0 20px rgba(255, 100, 0, 0.5); } }

    /* LOG */
    #log-feed {
        font-size: 13px; color: #dcdde1; line-height: 1.6;
        height: 110px; overflow-y: auto;
        border: 1px solid var(--border-color); 
        background: rgba(0,0,0,0.3);
        padding: 10px; margin: 12px 0;
        display: flex; flex-direction: column; gap: 5px;
        border-radius: 6px;
        box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
    }
    .c-win { color: var(--safe); }
    .c-lose { color: var(--danger); }
    .c-rare { color: var(--accent-gold); font-weight: bold; }
    .c-crit { color: #fff; text-shadow: 0 0 8px var(--danger); font-weight: bold; }
    .c-combo { color: var(--fury); }

    /* HERO STAT BLOCKS */
    .stat-block { background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); padding: 12px; margin-bottom: 8px; border-radius: 6px; }
    .stat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
    .stat-title { color: var(--text-main); font-weight: bold; font-size: 13px; font-family: var(--font-head); }
    
    .stat-val.buffed { color: var(--safe); font-weight: bold; text-shadow: 0 0 5px rgba(76, 209, 55, 0.4); }
    .stat-btn { background: none; border: 1px solid var(--safe); color: var(--safe); width: 24px; height: 24px; cursor: pointer; margin-left:10px; display: none; border-radius: 50%; font-weight: bold; }
    .stat-btn:hover { background: var(--safe); color: #000; }
    
    /* CLASS OVERVIEW */
    .class-moves-summary {
        margin-top: 15px; border: 1px solid var(--accent-gold); 
        background: var(--accent-glow);
        padding: 12px; margin-bottom: 12px; border-radius: 6px;
    }
    .class-moves-summary h4 { color: #fff; font-size: 12px; margin: 0 0 10px 0; text-transform: uppercase; font-family: var(--font-head); letter-spacing: 1px; }
    .move-item { margin-bottom: 8px; border-bottom: 1px dashed rgba(255,255,255,0.2); padding-bottom: 8px; }
    .move-item b { color: var(--accent-gold); font-size: 13px; display: block; margin-bottom: 2px; }
    .move-item small { color: #ccc; font-size: 12px; line-height: 1.3; display: block; }

    /* LEGACY STATS */
    .legacy-stats {
        margin-top: 20px;
        background: rgba(0,0,0,0.2); border: 1px solid var(--border-color);
        padding: 15px; border-radius: 6px;
    }
    .legacy-row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 8px; color: var(--text-muted); }
    .legacy-row span { color: var(--text-main); font-weight: bold; }

    /* NAVIGATION */
    #nav-dock {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0;
        background: #191c21; border-top: 2px solid var(--border-color); height: 70px; z-index: 100;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    }
    .dock-item {
        flex: 1; background: none; border: none; color: #636e72;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        font-size: 11px; text-transform: uppercase; cursor: pointer; font-family: var(--font-head); letter-spacing: 1px;
        transition: color 0.2s;
    }
    .dock-item:hover { color: #b2bec3; }
    .dock-item.active { color: var(--accent-gold); background: #22262e; border-top: 2px solid var(--accent-gold); margin-top: -2px; }
    .dock-icon { font-size: 24px; margin-bottom: 5px; }

    /* LOCATIONS */
    .location-card {
        background: #23272e; border: 1px solid #353b45; padding: 0px; cursor: pointer;
        display: flex; justify-content: space-between; align-items: center; border-radius: 6px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        transition: transform 0.1s, border-color 0.2s;
    }
    .location-card:hover { border-color: var(--accent-gold); background: #2c313a; transform: translateX(5px); }
    .location-card.locked { opacity: 0.5; pointer-events: none; filter: grayscale(1); background: #15181c; }
    .location-card.active { background: linear-gradient(90deg, rgba(238, 187, 77, 0.1), transparent); }

/* In style.css */

/* MODALS */
#overlay, #confirm-overlay, #levelup-overlay {
    position: fixed; inset: 0; 
    /* [BETA CHANGE] Removed backdrop-filter:blur for mobile performance */
    background: rgba(10, 12, 16, 0.98); 
    display: flex; align-items: center; justify-content: center; z-index: 999; 
    overflow-y: auto; padding: 20px 0; 
}
#overlay:not(.active), #confirm-overlay:not(.active), #levelup-overlay:not(.active) { display: none; }

.modal-box { 
    background: #1e2227; border: 1px solid var(--accent-gold); 
    padding: 30px; width: 90%; max-width: 420px; text-align: center; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.8); 
    margin: auto; 
    height: auto; max-height: 90dvh; overflow-y: auto;
    border-radius: 8px;
}
    
    /* SELECT BUTTONS */
    .select-btn { 
        width: 100%; background: #2c313a; border: 1px solid var(--border-color); color: var(--text-muted); 
        padding: 16px; margin: 10px 0; cursor: pointer; text-align: left; 
        min-height: 100px; border-radius: 6px;
        transition: all 0.2s;
    }
    .select-btn:hover { border-color: var(--accent-gold); color: #fff; background: #353b45; transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
    .select-btn b { color: var(--accent-gold); display: block; margin-bottom: 6px; font-size: 16px; font-family: var(--font-head); letter-spacing: 1px; }
    .select-details { font-size: 12px; color: #aab; line-height: 1.5; margin-top: 5px; }
    .select-formula { color: #fff; font-weight: bold; }

    .confirm-btn-group { display: flex; gap: 10px; margin-top: 20px; }
    .confirm-btn { flex: 1; padding: 18px; cursor: pointer; text-transform: uppercase; font-weight: bold; font-family: var(--font-head); border-radius: 6px; box-shadow: 0 4px 0 rgba(0,0,0,0.3); }
    .c-yes { background: #6b2e2e; color: #ffcccc; border: 1px solid #e15f5f; }
    .c-yes:hover { background: #853333; }
    .c-no { background: #2c313a; color: #fff; border: 1px solid var(--border-color); }
    .c-no:hover { background: #3a404a; }

    /* ICONS */
    .enemy-icon { width: 100px; object-fit: contain; image-rendering: pixelated; margin:auto; margin-top:0px; align-items: center; justify-content: center; display:flex; }
    .enemy-icon.boss { width:140px; }

    .legacy-btn { cursor: pointer; padding: 6px 12px; border: none; border-radius: 4px; font-weight: bold; transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
    .legacy-btn:hover { opacity: 0.9; transform: translateY(-1px); }
 
    /* HERO DASHBOARD */
    .hero-group {
        background: #23272e; border: 1px solid var(--border-color);
        padding: 15px; margin-bottom: 15px; position: relative; border-radius: 6px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }

    .hero-group-title {
        color: var(--accent-gold); font-size: 12px; text-transform: uppercase; letter-spacing: 2px;
        margin-bottom: 12px; border-bottom: 1px solid var(--border-color); padding-bottom: 6px;
        font-family: var(--font-head);
    }

    /* Compact Stats Grid */
    .stat-grid-container { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-compact {
        background: rgba(255,255,255,0.02); border: 1px solid var(--border-color);
        padding: 10px; display: flex; flex-direction: column; justify-content: center; border-radius: 4px;
    }
    .stat-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
    .stat-label { color: #9fa6b2; font-size: 12px; font-weight: bold; font-family: var(--font-head); }
    .stat-tiny-desc { font-size: 10px; color: #636e72; line-height: 1.1; }

    .xp-container { background: #15181c; height: 8px; width: 100%; margin: 10px 0; border: 1px solid var(--border-color); position: relative; border-radius: 4px; }

    /* SANCTUARY */
    #sanctuary-ui {
        height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
        border: 2px solid var(--accent-gold);
        background: radial-gradient(circle at center, #2e281e 0%, #15120e 100%);
        box-shadow: inset 0 0 80px rgba(238, 187, 77, 0.1);
        border-radius: 8px; padding: 30px;
        animation: fadeIn 0.5s ease-out;
    }
    .sanctuary-icon {
        font-size: 70px; margin-bottom: 20px;
        filter: drop-shadow(0 0 30px rgba(238, 187, 77, 0.6));
        animation: breathe 4s infinite ease-in-out;
    }
    .sanc-title { font-size: 28px; color: var(--accent-gold); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 5px; font-family: var(--font-head); text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
    .sanc-desc { color: #bcaaa4; font-size: 14px; margin-bottom: 30px; font-style: italic; }

    .sanc-stat-box {
        display: flex; gap: 20px; margin-bottom: 30px;
        background: rgba(0,0,0,0.4); padding: 12px 25px; border-radius: 30px; border: 1px solid #5d4037;
    }

    .sanc-btn {
        width: 100%; max-width: 300px; padding: 22px; margin-bottom: 15px;
        background: rgba(238, 187, 77, 0.05); border: 1px solid var(--accent-gold);
        color: #f5f5f5; cursor: pointer;
        font-family: var(--font-head); font-size: 15px; text-transform: uppercase; letter-spacing: 2px;
        transition: all 0.2s; border-radius: 6px; box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    }
    .sanc-btn:hover { background: var(--accent-gold); color: #12100e; transform: translateY(-3px); box-shadow: 0 10px 20px rgba(238, 187, 77, 0.2); }
    .sanc-btn small { display: block; font-size: 11px; opacity: 0.8; margin-top: 6px; text-transform: none; font-family: var(--font-body); letter-spacing: 0; }
    .sanc-btn:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(1); border-color: #555; transform: none; box-shadow: none; }

    @keyframes breathe { 0% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); opacity: 0.8; } }
    @keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

    /* LOCATION THEMES (Glows) */
    .location-card { transition: all 0.3s ease; border-left-width: 5px; }
    .loc-theme-0 { border-left-color: var(--accent-gold); }
    .loc-theme-1 { border-left-color: #8d6e63; }
    .loc-theme-2 { border-left-color: var(--safe); }
    .loc-theme-3 { border-left-color: #74c0fc; }
    .loc-theme-4 { border-left-color: var(--danger); }
    .loc-theme-5 { border-left-color: var(--magic); }

    .icon-preview { width: 32px; height: 32px; object-fit: contain; vertical-align: middle; margin-right: 12px; display: inline-block; filter: sepia(0.3) drop-shadow(0 2px 2px rgba(0,0,0,0.5)); }

    /* DYNAMIC ZONES (Background Tints) */
    .zone-theme-0 { --z-col: var(--accent-gold); --z-bg: rgba(238, 187, 77, 0.1); }
    .zone-theme-1 { --z-col: #bcaaa4; --z-bg: rgba(141, 110, 99, 0.1); }
    .zone-theme-2 { --z-col: #4cd137; --z-bg: rgba(76, 209, 55, 0.1); }
    .zone-theme-3 { --z-col: #74c0fc; --z-bg: rgba(116, 192, 252, 0.1); }
    .zone-theme-4 { --z-col: #ff5c5c; --z-bg: rgba(255, 92, 92, 0.1); }
    .zone-theme-5 { --z-col: #c56cf0; --z-bg: rgba(197, 108, 240, 0.1); }

    #view-combat[class*="zone-theme-"] { 
        background: radial-gradient(circle at 50% 30%, var(--z-bg), transparent 70%); 
        transition: background 0.8s ease; 
    }
    #view-combat[class*="zone-theme-"] .combat-card { border-color: var(--z-col); box-shadow: 0 0 15px var(--z-bg); }
    #view-combat[class*="zone-theme-"] .card-header b { color: var(--z-col); }

    /* BUTTON DELAY */
    .btn-busy { position: relative; pointer-events: none; opacity: 0.7; overflow: hidden; }
    .btn-busy::after {
        content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 0%;
        background: rgba(255, 255, 255, 0.2); animation: loadBar var(--duration) linear forwards; z-index: 1;
    }
    @keyframes loadBar { from { width: 0%; } to { width: 100%; } }

    /* TEXT ADJUSTMENTS */
    #st-class-big { color: var(--text-main); font-family: var(--font-head); letter-spacing: 1px; text-shadow: 0 2px 2px #000; }
    #select-prompt { color: var(--text-muted); font-family: var(--font-body); }
    #modal-legacy { color: var(--text-main); line-height: 1.6; }
    
    /* --- COMBAT FX --- */
    @keyframes impact-player { 
        0% { box-shadow: inset 0 0 0 transparent; transform: translate(0,0); }
        15% { box-shadow: inset 0 0 80px var(--danger); transform: translate(0, 4px); } 
        30% { transform: translate(0, -3px); }
        50% { transform: translate(0, 2px); }
        100% { box-shadow: inset 0 0 0 transparent; transform: translate(0,0); } 
    }
    .fx-damage-player { animation: impact-player 0.4s ease-out; }

    @keyframes impact-enemy {
        0% { transform: scale(1); filter: none; }
        10% { transform: scale(0.9) translateX(-4px); filter: sepia(1) saturate(5) hue-rotate(-50deg) brightness(1.2); }
        25% { transform: scale(0.95) translateX(4px); }
        40% { transform: scale(1) translateX(-2px); filter: none; }
        60% { transform: translateX(2px); }
        100% { transform: scale(1) translateX(0); }
    }
    .fx-damage-enemy { animation: impact-enemy 0.5s ease-out; }
    
    /* --- PROLOGUE MODAL --- */
    #intro-overlay {
        position: fixed; inset: 0; background: #121418; 
        display: flex; align-items: center; justify-content: center; z-index: 2000;
        display: none; animation: fadeIn 2s ease-in;
    }
    #intro-overlay.active { display: flex; }
    
    /* --- VISIBILITY CONTROL --- */
    #game-interface, #nav-dock { display: none !important; }
    body.game-running #game-interface { display: flex !important; }
    body.game-running #nav-dock { display: flex !important; }

    /* --- SETTINGS MODAL --- */
    #settings-overlay {
        position: fixed; inset: 0; background: rgba(0, 0, 0, 0.95);
        display: none; align-items: center; justify-content: center; z-index: 3000;
    }
    #settings-overlay.active { display: flex; }
    
    #data-io-area:focus { outline: none; border-color: var(--accent-gold); color: var(--accent-gold); }
    
    /* --- LOCKED BUTTON STYLE --- */
    .btn-locked {
        opacity: 0.6; border: 1px dashed var(--border-color); background: rgba(0,0,0,0.2);
        color: #636e72; cursor: not-allowed; text-align: left;
        padding: 15px; margin: 8px 0; width: 100%; border-radius: 4px;
    }
    .btn-locked b { display: block; margin-bottom: 4px; font-size: 14px; font-family: var(--font-head); }
    .btn-locked small { font-style: italic; font-size: 11px; }

    /* --- BOSS AURA FX --- */
    @keyframes boss-pulse {
        0% { filter: drop-shadow(0 0 2px var(--glow-col)) brightness(1); transform: scale(1); }
        50% { filter: drop-shadow(0 0 25px var(--glow-col)) brightness(1.3); transform: scale(1.05); }
        100% { filter: drop-shadow(0 0 2px var(--glow-col)) brightness(1); transform: scale(1); }
    }
    .boss-aura { animation: boss-pulse 2s infinite ease-in-out !important; }

    /* --- HALL OF FAME STYLES --- */
    #records-overlay {
        position: fixed; inset: 0; background: rgba(18, 20, 24, 0.95);
        display: none; align-items: center; justify-content: center; z-index: 4000;
    }
    #records-overlay.active { display: flex; }

    #records-list {
        max-height: 300px; overflow-y: auto;
        background: rgba(0,0,0,0.2); border: 1px solid var(--border-color); border-radius: 4px;
        box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
    }

    .record-row {
        display: flex; align-items: center;
        padding: 12px; border-bottom: 1px solid var(--border-color);
        font-size: 13px; color: var(--text-muted);
    }
    .record-row:last-child { border-bottom: none; }
    .record-row:nth-child(even) { background: rgba(255,255,255,0.02); }

    /* Rank Colors */
    .rank-badge { font-family: var(--font-head); font-weight: bold; font-size: 14px; }
    .rank-S { color: var(--accent-gold); text-shadow: 0 0 5px rgba(238, 187, 77, 0.5); }
    .rank-God { color: var(--magic); text-shadow: 0 0 10px var(--magic); }
    .rank-A { color: var(--safe); }
    .rank-B { color: #fff; }
    .rank-C { color: #636e72; }

    /* Scrollbar styling for the list */
    #records-list::-webkit-scrollbar { width: 6px; }
    #records-list::-webkit-scrollbar-track { background: var(--bg-dark); }
    #records-list::-webkit-scrollbar-thumb { background: var(--border-color); }
        
    /* --- DESKTOP DASHBOARD TRANSFORMATION (OPTIMIZED FIT) --- */
@media (min-width: 1024px) {
    
    /* 1. RESET BODY LAYOUT */
    body.game-running {
        padding: 0;
        overflow: hidden; 
        background-image: radial-gradient(circle at 50% 10%, #3a404a 0%, #1c2026 100%);
    }

    /* 2. GRID LAYOUT */
    body.game-running #game-interface {
        max-width: 1400px; 
        width: 100%;
        height: 100dvh;
        display: grid !important; 
        /* 3 Columns: Map | Combat | Hero */
        grid-template-columns: 280px 1fr 340px; 
        grid-template-rows: 1fr;
        gap: 20px;
        padding: 20px;
        margin: 0 auto;
    }

    /* 3. PANEL CARDS */
    body.game-running .panel {
        display: flex !important;
        flex-direction: column;
        height: 100%;
        padding: 0;
        background: rgba(33, 37, 43, 0.85);
        border: 1px solid var(--border-color);
        box-shadow: 0 15px 40px rgba(0,0,0,0.4);
        overflow: hidden; 
        border-radius: 8px;
        position: relative;
        backdrop-filter: blur(10px);
    }
    
    /* Headers */
    body.game-running .panel h3 {
        margin: 0;
        padding: 15px;
        background: #191c21;
        border-bottom: 2px solid var(--border-color);
        font-size: 15px;
        text-align: center;
        flex-shrink: 0; 
        letter-spacing: 2px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }

    /* 4. SCROLLING CONTAINERS */
    /* Map & Hero panels need internal scrolling */
    body.game-running #loc-container, 
    body.game-running #view-hero .hero-group, 
    body.game-running .legacy-stats {
        padding: 15px; 
    }
	body.game-running .hero-group {		
		border-radius: 0;
		border-left: 0;
		border-right: 0;
	}

    body.game-running #loc-container {
        overflow-y: auto;
        height: 100%;
        padding-bottom: 30px;
    }

    body.game-running #view-hero {
        overflow-y: auto; 
    }

    /* 5. COMBAT PANEL SPECIFICS (THE FIX) */
    body.game-running #view-combat {
        background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.02), rgba(0,0,0,0.4));
        border: 1px solid var(--accent-gold); 
        padding: 0; /* Remove padding here, apply to inner container if needed */
        display: flex;
        flex-direction: column;
        /* FIX: Allow scrolling if height is too small */
        overflow-y: auto; 
        justify-content: flex-start;
    }

    body.game-running #combat-ui {
        max-width: 550px;
        width: 100%;
        /* FIX: Margin auto centers vertically BUT is safe (won't clip top) */
        margin: auto; 
        padding: 20px;
        display: flex;
        flex-direction: column;
        /* FIX: Ensure it takes up vertical space if needed */
        min-height: min-content;
    }

    /* FIX: Make the Log Flexible */
    body.game-running #log-feed {
        /* Allow it to shrink to 80px or grow to 200px based on screen space */
        flex: 1 1 auto;
        min-height: 80px; 
        max-height: 200px;
        overflow-y: auto;
    }
    
    /* Tighten up target card slightly on desktop */
    body.game-running #card-target {
        min-height: 180px;
    }

    /* 6. HIDE MOBILE NAV */
    body.game-running #nav-dock {
        display: none !important;
    }

    /* 7. MODAL FIXES */
    body.game-running .modal-box {
        max-width: 500px;
        border: 1px solid var(--accent-gold);
        box-shadow: 0 0 100px rgba(0,0,0,0.7);
    }
    
    /* 8. VISUAL POLISH */
    body.game-running .location-card {
        padding: 15px;
        flex-direction: row;
        align-items: flex-start;
        gap: 10px;
    }
    body.game-running .location-card > div:first-child {
        margin-bottom: 5px;
    }
    
    /* Scrollbars */
    ::-webkit-scrollbar { width: 8px; }
    ::-webkit-scrollbar-track { background: #121418; }
    ::-webkit-scrollbar-thumb { background: #48505c; border-radius: 4px; }
    ::-webkit-scrollbar-thumb:hover { background: var(--accent-gold); }
}

@media (min-width: 1024px) {
    body.game-running .desktop-only-header { display: block !important; }
    body.game-running #sanctuary-ui { border-top-left-radius:0px; border-top-right-radius:0px; }
}

/* --- MAP SELECTION UPDATES --- */

/* The selected state for a location card */
.location-card.loc-selected {
    border-color: #fff;
    background: linear-gradient(90deg, #2c3e50, #23272e);
    transform: translateX(10px);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
}

/* The warning/confirm text container - hidden by default */
.loc-confirm-msg {
    display: none;
    font-size: 11px;
    margin-top: 0px;
    padding-top: 0px;
    border-top: 1px dashed rgba(255,255,255,0.2);
    font-style: italic;
    animation: fadeIn 0.3s ease;
}

/* Show it when the parent card is selected */
.location-card.loc-selected .loc-confirm-msg {
    display: block;
}

/* Text Colors */
.warn-danger { color: var(--danger); font-weight: bold; }
.warn-safe { color: var(--safe); }
.warn-neutral { color: var(--accent-gold); }

/* Header styling */
.story-header {
    display: block; /* Makes the span act like a div */
    text-transform: uppercase;
    font-size: 0.85em;
    opacity: 0.7;
    margin-bottom: 15px;
    letter-spacing: 1px;
    font-weight: bold;
}

/* Item styling */
.story-point {
    display: block; /* Makes the span act like a div */
    margin-bottom: 15px;
}

/* Remove margin from the last item */
.story-point:last-child {
    margin-bottom: 0;
}

/* Hard Mode Theme: Slightly red/sepia tint, higher contrast */
body.hard-mode #view-combat {
    filter: sepia(0.3) contrast(1.1) hue-rotate(-10deg);
}

/* Make the background darker/redder */
body.hard-mode {
    background-image: radial-gradient(circle at 50% 10%, #2c0e0e 0%, #0a0a0a 100%) !important;
}

	/* Standard Enemy */
.enemy-icon { transition: all 0.5s; }

/* HARD MODE: The Void Filter */
body.hard-mode .enemy-icon {
    /* Shift colors to purple/blue spectrum & boost contrast */
    filter: hue-rotate(240deg) saturate(1.5) drop-shadow(0 0 5px #8e6ead);
    /* Make them "breathe" slightly */
    animation: void-pulse 3s infinite ease-in-out;
}

@keyframes void-pulse {
    0% { transform: scale(1); filter: hue-rotate(240deg) saturate(1.5) drop-shadow(0 0 5px #8e6ead); }
    50% { transform: scale(1.05); filter: hue-rotate(260deg) saturate(2) drop-shadow(0 0 15px #c56cf0); }
    100% { transform: scale(1); filter: hue-rotate(240deg) saturate(1.5) drop-shadow(0 0 5px #8e6ead); }
}
	
/* Make sure this Keyframe exists! */
@keyframes qte-fill-anim {
    from { width: 0%; }
    to { width: 100%; }
}

/* This class MUST have the animation property */
.qte-active-anim {
    animation: qte-fill-anim 1.0s ease-in forwards; 
}

/* Ensure the bar has a color and height even if animation fails (for testing) */
#qte-bar-fill {
    height: 100%;
    /* Gradient: Dark Red -> Bright Orange -> White Hot Tip */
    background: linear-gradient(90deg, #800000 0%, #ff4500 80%, #fff 100%);
    box-shadow: 0 0 20px rgba(255, 69, 0, 0.6);
    border-right: 2px solid #fff;
    width: 0%; /* Starts at 0 */
    position: relative;
    z-index: 2;
}
/* --- QTE GAUGE: MOLTEN CHARGE THEME --- */

/* The Container (The Barrel of the Gun / Hilt of the Sword) */
.qte-track-styled {
    width: 100%; 
    height: 30px; 
    background: #0a0a0a; /* Pure black backing */
    position: relative; 
    border: 2px solid #444; 
    border-radius: 4px; /* Sharp corners look more aggressive */
    overflow: hidden; 
    cursor: pointer;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.9); /* Deep depth */
}

/* Background Grid Lines (Tactical Feel) */
.qte-track-styled::before {
    content: ''; position: absolute; inset: 0;
    background-image: linear-gradient(90deg, transparent 95%, rgba(255,255,255,0.1) 95%);
    background-size: 10% 100%; /* Tick marks every 10% */
    pointer-events: none;
    z-index: 1;
}

/* The Bar (The Energy) */
#qte-bar-fill {
    height: 100%;
    /* Gradient: Dark Red -> Bright Orange -> White Hot Tip */
    background: linear-gradient(90deg, #800000 0%, #ff4500 80%, #fff 100%);
    box-shadow: 0 0 20px rgba(255, 69, 0, 0.6); /* Glow */
    border-right: 2px solid #fff; /* The Leading Edge */
    width: 0%;
    position: relative;
    z-index: 2;
}

/* The Animation (Accelerating) */
.qte-active-anim {
    animation: qte-fill-anim 1.0s ease-in forwards; 
}

/* The Target Zone (The Sweet Spot) */
.qte-zone-styled {
    position: absolute; 
    top: 0; bottom: 0; 
    left: 70%; width: 20%; 
    /* Glassy Green look */
    background: rgba(46, 204, 113, 0.15); 
    border-left: 1px solid rgba(46, 204, 113, 0.8); 
    border-right: 1px solid rgba(46, 204, 113, 0.8); 
    z-index: 3;
    display: flex; 
    justify-content: center;
}

/* The "Perfect" Center Line */
.qte-center-line {
    width: 2px; 
    height: 100%; 
    background: rgba(255, 255, 255, 0.6); 
    box-shadow: 0 0 8px #fff;
}
	
	@keyframes shake-hard {
    0% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-2px, -2px) rotate(-1deg); }
    20% { transform: translate(2px, 2px) rotate(1deg); }
    30% { transform: translate(-4px, 2px) rotate(0deg); }
    40% { transform: translate(4px, -2px) rotate(1deg); }
    50% { transform: translate(-2px, 2px) rotate(-1deg); }
    60% { transform: translate(2px, -2px) rotate(0deg); }
    70% { transform: translate(-1px, 1px) rotate(0deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

.anim-shake {
    animation: shake-hard 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

/* --- PARTICLE EFFECTS --- */
.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%; /* Make it 2px for square pixels if you prefer retro */
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    animation: particle-pop 0.6s ease-out forwards;
}

/* Colors for different effects */
.p-blood { background-color: #ff4d4d; box-shadow: 0 0 4px #b33939; }
.p-gold { background-color: var(--accent-gold); box-shadow: 0 0 4px #ffd700; }
.p-magic { background-color: var(--magic); box-shadow: 0 0 4px #8e44ad; }
.p-ice { background-color: #00bcd4; box-shadow: 0 0 4px #fff; }

@keyframes particle-pop {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        /* Move to the dynamic destination set in JS */
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* --- IMPROVED FLOATING TEXT --- */
.float-txt {
    position: absolute;
    top: 30%; /* Start lower so it floats up through the sprite */
    left: 50%;
    font-weight: 900; /* Extra bold */
    font-size: 26px;
    pointer-events: none;
    z-index: 1000;
    /* White text with heavy black outline for readability on any background */
    color: #fff;
    text-shadow: 
        -1px -1px 0 #000,  
         1px -1px 0 #000,
        -1px  1px 0 #000,
         1px  1px 0 #000,
         0 2px 5px rgba(0,0,0,0.8);
    
    /* Slower animation (1.5s) */
    animation: float-pop 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;
}

/* Specific styles for Entities to separate them visually */
.float-player {
    color: #ff6b6b; /* Light Red/Pink for damage taken */
    /* Player text floats slightly to the LEFT */
    margin-left: -40px; 
}

.float-enemy {
    color: #fff; /* White for standard damage dealt */
    /* Enemy text floats slightly to the RIGHT */
    margin-left: 40px;
}

.float-crit { 
    color: #ffeb3b; /* Gold/Yellow for Crits */
    font-size: 38px; 
    /* REPLACED WHITE BOX WITH GLOW */
    text-shadow: 
        0 0 5px #ff0000, 
        0 0 10px #ff0000, 
        -2px -2px 0 #000,
        2px 2px 0 #000;
    z-index: 1001; /* Show crits on top of normal damage */
}

.float-gold { 
    color: var(--accent-gold); /* Green */
    font-size: 28px;
}

.float-heal { 
    color: var(--safe); /* Green */
    font-size: 28px;
}

.float-miss { 
    color: #aaa; 
    font-size: 20px;
    font-style: italic;
}

@keyframes float-pop {
    0% { 
        opacity: 0; 
        transform: translate(-50%, 10px) scale(0.5); 
    }
    10% { 
        opacity: 1; 
        transform: translate(-50%, -10px) scale(1.2); /* Pop Big */
    }
    20% {
        transform: translate(-50%, -15px) scale(1.0); /* Settle slightly */
    }
    70% { 
        opacity: 1; /* STAY VISIBLE LONGER */
        transform: translate(-50%, -50px) scale(1.0); /* Float up slowly */
    }
    100% { 
        opacity: 0; /* Fade out at the very end */
        transform: translate(-50%, -80px) scale(0.9);
    }
}

/* --- 2. IMPACT FLASHES --- */
/* When the enemy gets hit, they should flash bright white/red */
.fx-damage-enemy {
    animation: flash-hit 0.25s ease-out;
}

/* When the player gets hit, the UI shakes slightly */
.fx-damage-player {
    animation: shake-small 0.3s ease-in-out;
}

@keyframes flash-hit {
    0% { filter: brightness(5) sepia(1) saturate(5) hue-rotate(-50deg); transform: scale(1.1); }
    50% { filter: brightness(2) sepia(1) hue-rotate(-50deg); transform: scale(1.05); }
    100% { filter: none; transform: scale(1); }
}

@keyframes shake-small {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* --- 3. SCREEN SHAKE (Heavy) --- */
/* For Critical Hits or Big Boss Attacks */
.anim-shake {
    animation: shake-hard 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake-hard {
    10%, 90% { transform: translate3d(-4px, 0, 0); }
    20%, 80% { transform: translate3d(8px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-8px, 0, 0); }
    40%, 60% { transform: translate3d(8px, 0, 0); }
}

/* --- 4. TACTILE BUTTONS --- */
/* Make buttons feel like they are actually being pressed */
.btn-action {
    transition: transform 0.05s, box-shadow 0.05s;
}
.btn-action:active {
    transform: translateY(2px);
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.5);
}


/* [NEW CSS] Add to bottom of style.css */

/* Screen flash when passive triggers */
.anim-pulse-green {
    animation: pulse-green 0.3s ease-out;
}
@keyframes pulse-green {
    0% { box-shadow: inset 0 0 0 transparent; }
    50% { box-shadow: inset 0 0 50px var(--safe); } /* Flash Green borders */
    100% { box-shadow: inset 0 0 0 transparent; }
}

/* Color for the passive progress bar */
#combo-bar-fill {
    background: var(--safe); /* Green */
    box-shadow: 0 0 5px var(--safe);
}

/* [NEW CSS] Add to bottom of style.css */

/* Screen flash when passive triggers */
.anim-pulse-green {
    animation: pulse-green 0.3s ease-out;
}
@keyframes pulse-green {
    0% { box-shadow: inset 0 0 0 transparent; }
    50% { box-shadow: inset 0 0 50px var(--safe); } /* Flash Green borders */
    100% { box-shadow: inset 0 0 0 transparent; }
}

/* Color for the passive progress bar */
#combo-bar-fill {
    background: var(--safe); /* Green */
    box-shadow: 0 0 5px var(--safe);
}

#combo-display {
    position: absolute;
    /* Move it near the bottom-right of the ENEMY card */
    bottom: 10px; 
    right: 10px; 
    text-align: right;
    pointer-events: none;
    z-index: 1000;
    
    /* Keep existing styles */
    transform: skewX(-15deg) rotate(-5deg);
    filter: drop-shadow(4px 4px 0px rgba(0,0,0,0.8));
    animation: combo-pop 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- BOOK / GRIMOIRE THEME (Consolidated & Fixed) --- */

/* 1. The Main Container (Visuals + Layout + Animation) */
.modal-box.book-theme {
    /* --- VISUALS (The Grimoire Look) --- */
    background-color: #f4e4bc !important;
    background-image: radial-gradient(circle, rgba(0,0,0,0) 40%, rgba(139, 69, 19, 0.15) 100%) !important;
    border: 8px solid #5d4037 !important; /* Leather Frame */
    border-radius: 4px !important;
    box-shadow: inset 0 0 60px rgba(93, 64, 55, 0.3), 0 20px 50px rgba(0,0,0,0.9) !important;
    color: #2c0e0e !important;
    text-align: left !important;
    
    /* --- LAYOUT (The Scroll Fix) --- */
    display: flex;
    flex-direction: column; /* Stacks Header, Text, Button vertically */
    max-height: 85vh;       /* Prevents off-screen overflow */
    box-sizing: border-box; 
    padding: 40px !important;

    /* --- ANIMATION (The Scroll Opening) --- */
    animation: bookOpen 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0; /* Start hidden */
}

/* 2. Headers (Softer Book Style) */
.book-theme h1, .book-theme h2 {
    color: #800000 !important;
    font-family: 'Cinzel', serif;
    text-shadow: none !important;
    letter-spacing: 2px !important;
    text-align: center !important;
    padding-bottom: 15px !important;
    margin-bottom: 0px;
    background-position: bottom center !important;
    background-size: 100% 1px !important;
    background-repeat: no-repeat !important;
    border: none !important; /* Remove default borders */
}
.book-theme h2 {
    

    margin-bottom: 25px !important;
}

/* 3. The Text Container (Scrollable & Fading) */
#story-text-container {
    /* --- SCROLLING BEHAVIOR --- */
    overflow-y: auto;        
    min-height: 250px;       
    max-height: 50vh;        
    flex-grow: 1;            
    padding-right: 15px;     
    margin: 15px 0;          

    /* --- TYPOGRAPHY --- */
    background: transparent !important;
    border: none !important;
    font-family: 'Crimson Pro', serif;
    font-size: 1.1rem !important;
    line-height: 1.6 !important;
    font-weight: 600;
    color: #3e2723 !important;

    /* --- ANIMATION (The Fade In) --- */
    opacity: 1; 
    transition: opacity 1s ease-in;
}

/* The class JS adds to trigger the text fade */
#story-text-container.visible {
    opacity: 1;
}

/* Custom Scrollbar for the Book */
#story-text-container::-webkit-scrollbar { width: 8px; }
#story-text-container::-webkit-scrollbar-track { background: transparent; }
#story-text-container::-webkit-scrollbar-thumb { background-color: rgba(93, 64, 55, 0.4); border-radius: 4px; }

/* 4. Drop Cap Styling */
.book-theme #story-text-container::first-letter {
    font-family: 'Cinzel', serif;
    font-size: 3.5em !important;
    float: left;
    line-height: 0.8 !important;
    margin-right: 12px;
    margin-top: -2px; 
    color: #800000;
}

/* 5. Buttons (Paper/Ink Style) */
#modal-action-btn.confirm-btn {
    flex-shrink: 0; /* Ensures button is never squashed */
    width: 100%;
    margin-top: auto;
    background: transparent !important;
    border: 2px solid #5d4037 !important;
    color: #5d4037 !important;
    box-shadow: none !important;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    transition: all 0.2s ease;
}
.book-theme .confirm-btn:hover {
    background: #5d4037 !important;
    color: #f4e4bc !important;
}

/* 6. Animations Definitions */
@keyframes bookOpen {
    from { opacity: 0; transform: translateY(40px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- MOBILE OPTIMIZATION --- */
@media (max-width: 600px) {
    .modal-box.book-theme {
        padding: 20px !important;
        border-width: 4px !important;
        width: 95% !important;
        max-height: 85dvh;
    }
    .book-theme h1 { font-size: 22px !important; margin-bottom: 10px !important; }
    .book-theme h2 { font-size: 16px !important; margin-bottom: 15px !important; }
    #story-text-container { font-size: 14px !important; }
    .book-theme #story-text-container::first-letter { font-size: 2.8em !important; }
}

/* --- 1. ANIMATIONS --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeInUp 0.3s ease-out forwards;
}

/* --- 2. LAYOUT CONTAINER --- */
.journal-layout {
    display: flex;
    width: 100%;
    height: 100%;
    background: #151515; /* Dark bg */
    border-top: 1px solid #333;
    overflow: hidden; 
}

/* --- 3. SIDEBAR (Dense List) --- */
.journal-sidebar {
    width: 240px; 
    min-width: 240px;
    background: #0f0f0f;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    overflow-y: auto; 
}

/* Scrollbar Styling */
.journal-sidebar::-webkit-scrollbar,
.journal-page-container::-webkit-scrollbar { width: 6px; }
.journal-sidebar::-webkit-scrollbar-track,
.journal-page-container::-webkit-scrollbar-track { background: #000; }
.journal-sidebar::-webkit-scrollbar-thumb,
.journal-page-container::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* Act Separator (Visual Break) */
.sidebar-separator {
    font-size: 0.7rem;
    color: #555;
    background: #080808;
    padding: 8px 12px;
    font-weight: bold;
    letter-spacing: 1px;
    border-top: 1px solid #222;
    border-bottom: 1px solid #222;
    margin-top: 0; 
    position: sticky; /* Keeps Act Header visible while scrolling */
    top: 0;
    z-index: 2;
}

/* Chapter Button */
.journal-chapter-btn {
    width: 100%;
    padding: 12px 15px; 
    background: transparent;
    border: none;
    border-bottom: 1px solid #1a1a1a;
    color: #777;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem; 
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.2;
}

.journal-chapter-btn:hover {
    background: #1a1a1a;
    color: #ccc;
}

.journal-chapter-btn.active {
    background: #1f1f1f;
    color: var(--accent-gold, #ffd700);
    border-left: 3px solid var(--accent-gold, #ffd700);
    padding-left: 12px; 
}

.toc-num {
    font-weight: bold;
    min-width: 25px;
    color: #444;
}
.journal-chapter-btn.active .toc-num { color: var(--accent-gold, #ffd700); }
.toc-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- 4. RIGHT SIDE (Reader) --- */
.journal-page-container {
    flex: 1; 
    overflow-y: auto;
    background: #181818;
    padding: 40px 50px;
    position: relative;
    scroll-behavior: smooth;
}

.journal-header h3 {
    margin-top: 0;
    font-size: 1.8rem;
    font-family: 'Cinzel', serif;
    color: var(--accent-gold, #ffd700);
    border-bottom: 1px solid #333;
    padding-bottom: 15px;
    margin-bottom: 25px;
}

.journal-body {
    font-family: 'Crimson Pro', serif;
    font-size: 1.1rem;
    line-height: 1.8;
    color: #ccc;
}
.journal-body p { margin-bottom: 20px; }

/* Outline Box */
.journal-footer {
    margin-top: 40px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed #333;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #888;
}

/* Next/Prev Controls */
.journal-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #333;
}

.nav-btn {
    background: transparent;
    border: 1px solid #444;
    color: #888;
    padding: 10px 20px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    transition: all 0.2s;
    border-radius: 4px;
}

.nav-btn:hover {
    border-color: var(--accent-gold, #ffd700);
    color: var(--accent-gold, #ffd700);
    background: rgba(255, 255, 255, 0.05);
}

/* --- 5. MOBILE RESPONSIVENESS (Slim Mode) --- */
@media (max-width: 800px) {
    .journal-sidebar { width: 60px; min-width: 60px; }
    .toc-text, .sidebar-separator { display: none; } /* Hide text */
    .journal-chapter-btn { justify-content: center; padding: 15px 5px; }
    .toc-num { font-size: 1.1rem; }
    .journal-page-container { padding: 25px; }
    .journal-controls { flex-direction: column; gap: 10px; }
    .nav-btn { width: 100%; text-align: center; }
}

/* Sidebar: Darker, almost black leather feel */
.journal-sidebar {
    background: #0b0b0b; 
    border-right: 1px solid #2a2a2a;
}

/* Page Container: Deep charcoal, slightly lighter than sidebar */
.journal-page-container {
    background: #141414; 
    box-shadow: inset 10px 0 20px -10px rgba(0,0,0,0.5); /* Shadow near the binding */
}

/* The actual text color: slightly warm off-white, easier to read than pure gray */
.journal-body {
    color: #dcdcdc; 
    font-family: 'Crimson Pro', serif;
}

/* Make the active button glow subtle gold */
.journal-chapter-btn.active {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.05) 0%, transparent 100%);
    border-left: 3px solid var(--accent-gold, #ffd700);
}

/* Improve the "Key Points" box to look like a footnote area */
.journal-footer {
    background: #0f0f0f;
    border: 1px solid #333;
    border-left: 2px solid #555; /* Accent line */
    color: #888;
}

/* --- 1. ANIMATIONS --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeInUp 0.3s ease-out forwards;
}

/* --- 2. LAYOUT CONTAINER --- */
.journal-layout {
    display: flex;
    width: 100%;
    height: 100%;
    background: #151515; 
    border-top: 1px solid #333;
    overflow: hidden; 
}

/* --- 3. SIDEBAR (Dark Leather Look) --- */
.journal-sidebar {
    width: 240px; 
    min-width: 240px;
    background: #0b0b0b; 
    border-right: 1px solid #2a2a2a;
    display: flex;
    flex-direction: column;
    overflow-y: auto; 
}

/* Scrollbars */
.journal-sidebar::-webkit-scrollbar,
.journal-page-container::-webkit-scrollbar { width: 6px; }
.journal-sidebar::-webkit-scrollbar-track,
.journal-page-container::-webkit-scrollbar-track { background: #000; }
.journal-sidebar::-webkit-scrollbar-thumb,
.journal-page-container::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* ACT SEPARATORS (Gold Headers) */
.sidebar-separator {
    font-size: 0.7rem;
    color: var(--accent-gold, #ffd700);
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.08) 0%, transparent 100%);
    padding: 10px 15px;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-top: 1px solid #222;
    border-bottom: 1px solid #222;
    margin-top: 5px; 
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    position: sticky;
    top: 0;
    z-index: 2;
}

/* CHAPTER BUTTONS */
.journal-chapter-btn {
    width: 100%;
    padding: 12px 15px; 
    background: transparent;
    border: none;
    border-bottom: 1px solid #1a1a1a;
    color: #777;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem; 
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.2;
}

.journal-chapter-btn:hover {
    background: #1a1a1a;
    color: #ccc;
}

/* Active State (Glow) */
.journal-chapter-btn.active {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.05) 0%, transparent 100%);
    color: var(--accent-gold, #ffd700);
    border-left: 3px solid var(--accent-gold, #ffd700);
    padding-left: 12px; 
}

.toc-num {
    font-weight: bold;
    min-width: 25px;
    color: #444;
    text-align: center;
}
.journal-chapter-btn.active .toc-num { color: var(--accent-gold, #ffd700); }
.toc-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- SPECIAL BUTTON STYLES --- */
/* Interludes (Purple/Magic) */
.journal-chapter-btn.is-interlude .toc-num {
    color: #a89fce; /* Lavender */
    font-size: 1.1rem;
    font-weight: normal;
}
.journal-chapter-btn.is-interlude .toc-text {
    font-style: italic;
    color: #a89fce;
    opacity: 0.8;
}

/* Final/Boss (Red) */
.journal-chapter-btn.is-final .toc-num { color: #ff5252; }
.journal-chapter-btn.is-final .toc-text { color: #ff8a80; }


/* --- 4. RIGHT SIDE (Reader Page) --- */
.journal-page-container {
    flex: 1; 
    overflow-y: auto;
    background: #141414; /* Deep Charcoal */
    padding: 40px 50px;
    position: relative;
    scroll-behavior: smooth;
    box-shadow: inset 10px 0 20px -10px rgba(0,0,0,0.5); /* Book binding shadow */
}

.journal-header h3 {
    margin-top: 0;
    font-size: 1.8rem;
    font-family: 'Cinzel', serif;
    color: var(--accent-gold, #ffd700);
    border-bottom: 1px solid #333;
    padding-bottom: 15px;
    margin-bottom: 25px;
}

.journal-body {
    font-family: 'Crimson Pro', serif;
    font-size: 1.15rem; /* Slightly larger for reading */
    line-height: 1.8;
    color: #dcdcdc; /* Warm off-white */
}
.journal-body p { margin-bottom: 20px; }

/* Footer (Key Points) */
.journal-footer {
    margin-top: 40px;
    padding: 20px;
    background: #0f0f0f;
    border: 1px solid #333;
    border-left: 2px solid #555;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #888;
}

/* Nav Controls */
.journal-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #333;
}

.nav-btn {
    background: transparent;
    border: 1px solid #444;
    color: #888;
    padding: 10px 20px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    transition: all 0.2s;
    border-radius: 4px;
}

.nav-btn:hover {
    border-color: var(--accent-gold, #ffd700);
    color: var(--accent-gold, #ffd700);
    background: rgba(255, 255, 255, 0.05);
}

/* --- 5. MOBILE RESPONSIVENESS --- */
@media (max-width: 800px) {
    .journal-sidebar { width: 60px; min-width: 60px; }
    .toc-text, .sidebar-separator { display: none; } /* Hide text */
    .journal-chapter-btn { justify-content: center; padding: 15px 5px; }
    .toc-num { font-size: 1.2rem; }
    .journal-page-container { padding: 25px; }
    .journal-controls { flex-direction: column; gap: 10px; }
    .nav-btn { width: 100%; text-align: center; }
}

/* --- SPECIAL BUTTON STYLES --- */

/* 1. ACT HEADER BUTTON (Clickable, looks like a banner) */
.journal-chapter-btn.is-act {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.1) 0%, transparent 100%);
    border-bottom: 1px solid var(--accent-gold, #ffd700);
    padding: 15px;
    margin-top: 15px;
    margin-bottom: 5px;
}
.journal-chapter-btn.is-act .toc-num {
    display: none; /* Hide number column for Acts, let text expand */
}
.journal-chapter-btn.is-act .toc-text {
    color: var(--accent-gold, #ffd700);
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 0.85rem;
    white-space: normal; /* Allow wrapping */
    text-align: center;
    width: 100%;
}

/* 2. INTERLUDE / PRELUDE / PROLOGUE */
.journal-chapter-btn.is-interlude .toc-num {
    color: #a89fce; /* Lavender */
    font-size: 1.2rem; 
    font-family: serif;
}
.journal-chapter-btn.is-interlude .toc-text {
    color: #a89fce;
    font-style: italic;
    font-family: 'Crimson Pro', serif;
}

/* 3. FINAL CHAPTER (Optional) */
.journal-chapter-btn.is-final .toc-num { color: #ff5252; }
.journal-chapter-btn.is-final .toc-text { color: #ff8a80; }
/* 1. ACT HEADER BUTTON (Clickable, Gold) */
.journal-chapter-btn.is-act {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.1) 0%, transparent 100%);
    border-bottom: 1px solid var(--accent-gold, #ffd700);
    padding: 15px 12px;
    margin-top: 20px; /* Extra spacing above new Acts */
    margin-bottom: 5px;
}

/* Ensure the Number/Symbol IS visible for Acts now */
.journal-chapter-btn.is-act .toc-num {
    display: block; 
    color: var(--accent-gold, #ffd700);
    font-size: 1.4rem; /* Larger than normal chapters */
    font-weight: bold;
    font-family: 'Cinzel', serif;
    min-width: 40px; /* Give it space */
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
}

.journal-chapter-btn.is-act .toc-text {
    color: var(--accent-gold, #ffd700);
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 0.9rem;
    white-space: normal;
}

/* --- 5. MOBILE RESPONSIVENESS (Slim Mode) --- */
@media (max-width: 800px) {
    /* Shrink sidebar width */
    .journal-sidebar { 
        width: 70px; 
        min-width: 70px; 
    }

    /* 1. Hide Title Text for Regular Chapters and Interludes */
    .journal-chapter-btn:not(.is-act) .toc-text { 
        display: none; 
    }

    /* 2. Center the Numbers for Regular Chapters */
    .journal-chapter-btn { 
        justify-content: center; 
        padding: 15px 5px; 
    }
    .toc-num { 
        font-size: 1.2rem; 
    }

    /* 3. MOBILE ACT STYLING (The Fix) */
    .journal-chapter-btn.is-act {
        background: #222; /* Darker bg to separate */
        border-bottom: 2px solid var(--accent-gold, #ffd700);
        margin-top: 10px;
        padding: 10px 0;
        flex-direction: column; /* Stack vertically if needed */
        align-items: center;
        text-align: center;
    }

    /* Show the Roman Numeral (I, II) Large and Gold */
    .journal-chapter-btn.is-act .toc-num {
        display: block;
        font-size: 1.4rem;
        color: var(--accent-gold, #ffd700);
        margin-bottom: 2px;
    }

    /* Show the word "ACT" beneath the number using a pseudo-element */
    .journal-chapter-btn.is-act .toc-num::after {
        content: "ACT";
        display: block;
        font-size: 0.5rem;
        letter-spacing: 1px;
        color: #888;
        font-family: sans-serif;
        margin-top: -2px;
    }

    /* Still hide the long title text ("The Ashen Legend") on mobile */
    .journal-chapter-btn.is-act .toc-text {
        display: none;
    }

    /* 4. Adjust Controls and Padding */
    .journal-page-container { padding: 25px; }
    .journal-controls { flex-direction: column; gap: 10px; }
    .nav-btn { width: 100%; text-align: center; }
}

/* --- 5. MOBILE RESPONSIVENESS (Slim Mode & Readable Text) --- */
@media (max-width: 800px) {
    /* 1. Sidebar adjustments (Keep existing logic) */
    .journal-sidebar { 
        width: 70px; 
        min-width: 70px; 
    }
    .journal-chapter-btn:not(.is-act) .toc-text { display: none; }
    .journal-chapter-btn { justify-content: center; padding: 15px 5px; }
    .toc-num { font-size: 1.2rem; }

    /* Act Button Styling for Mobile */
    .journal-chapter-btn.is-act {
        background: #222;
        border-bottom: 2px solid var(--accent-gold, #ffd700);
        margin-top: 10px;
        padding: 10px 0;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .journal-chapter-btn.is-act .toc-num {
        display: block;
        font-size: 1.4rem;
        color: var(--accent-gold, #ffd700);
        margin-bottom: 2px;
    }
    .journal-chapter-btn.is-act .toc-num::after {
        content: "ACT";
        display: block;
        font-size: 0.5rem;
        letter-spacing: 1px;
        color: #888;
        font-family: sans-serif;
        margin-top: -2px;
    }
    .journal-chapter-btn.is-act .toc-text { display: none; }

    /* --- 2. TEXT READABILITY FIXES (New) --- */
    
    .journal-page-container { 
        padding: 20px 15px; /* Reduce padding significantly (was 40px 50px) */
    }

    .journal-header h3 {
        font-size: 1.4rem; /* Smaller header so it doesn't wrap awkwardly */
        margin-bottom: 15px;
        padding-bottom: 10px;
        line-height: 1.3;
    }

    .journal-body {
        font-size: 1rem; /* slightly smaller body text */
        line-height: 1.6; /* tighter line height for small screens */
    }

    .journal-body p {
        margin-bottom: 15px; /* Less space between paragraphs */
    }

    .journal-footer {
        margin-top: 25px;
        padding: 15px;
        font-size: 0.85rem;
    }

    /* Controls: Stack them */
    .journal-controls { 
        flex-direction: column; 
        gap: 12px; 
        margin-top: 30px;
    }
    .nav-btn { 
        width: 100%; 
        text-align: center; 
        padding: 12px; /* Easier to tap with fingers */
    }
}
/* --- IMPROVED CHRONICLE SIDEBAR --- */

/* 1. The ACT HEADER (Distinct from chapters) */
.journal-act-header {
    width: 100%;
    background: #1a1a1a; /* Darker background */
    border: none;
    border-top: 1px solid #333;
    border-bottom: 2px solid var(--accent-gold); /* Gold underline */
    color: var(--accent-gold);
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 5px;
    margin-top: 15px; /* Spacing between acts */
    
    /* Layout */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.journal-act-header:hover {
    background: #252525;
}

.journal-act-header.active {
    background: #222;
    border-left: 4px solid var(--accent-gold);
}

.act-roman {
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 4px;
}

.act-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.8;
}

/* 2. REGULAR CHAPTERS (Indented) */
.journal-chapter-btn {
    /* Existing styles plus: */
    border-left: 2px solid transparent; /* Prepare for active state */
    padding-left: 15px; /* Slight indentation */
}

/* 3. MOBILE ADJUSTMENTS */
@media (max-width: 800px) {
    /* ACT Header on Mobile: Compact but clear */
    .journal-act-header {
        padding: 10px 5px;
        margin-top: 10px;
    }
    
    .act-roman {
        font-size: 1.2rem;
    }
    
    .act-title {
        display: none; /* Hide text title on sidebar to save space */
    }

    /* Keep Chapter Numbers visible */
    .journal-chapter-btn {
        justify-content: center;
        padding: 15px 0;
    }
    .journal-chapter-btn .toc-num {
        font-size: 1.1rem;
        text-align: center;
        width: 100%;
    }
    .journal-chapter-btn .toc-text {
        display: none; /* Hide chapter text on mobile */
    }
}

/* --- SPRITE SHEET SYSTEM --- */
:root {
    --icon-size: 32px; /* The size of one icon in the grid */
    --sheet-url: url('assets/sprites.png'); /* Rename your file to this for simplicity */
    --sheet-url2: url('assets/sprites2.png');
}

/* Base Icon Class */
.pixel-icon {
    display: inline-block;
    width: var(--icon-size);
    height: var(--icon-size);
    background-image: var(--sheet-url2);
    background-repeat: no-repeat;
    image-rendering: pixelated; /* Keeps it crisp */
    vertical-align: middle;
    
    /* Calculate position based on row/col index */
    /* format: --x (column), --y (row) */
    background-position: calc(var(--x) * -1 * var(--icon-size)) calc(var(--y) * -1 * var(--icon-size));
}

/* Size Modifiers */
.icon-sm { transform: scale(0.75); } /* For text inlines */
.icon-lg { transform: scale(1.5); }  /* For headers */
.icon-xl { transform: scale(2.5); }  /* For main combat display if used for enemies */

/* Button integration fix */
.btn-action .pixel-icon {
    margin-right: 6px;
    margin-top: -2px; /* Visual alignment fix */
}

/* Align icons in the bottom navigation dock */
.dock-item .pixel-icon {
    display: block;      /* Stack icon above text */
    margin: 0 auto 4px;  /* Center horizontally, add space below */
    transform: scale(1.2); /* Make them slightly larger */
}

/* Ensure the text is still visible and nice */
.dock-item {
    font-size: 10px; /* Adjust text size if needed */
}

/* Add to src/style.css */

/* Giant Icon for Sanctuary */
.icon-giant {
    transform: scale(3); 
    margin: 10px;
}

/* Fix alignment for icons inside text buttons */
.btn-action .pixel-icon {
    vertical-align: middle;
    margin-top: -4px;
    margin-right: 8px;
}

/* --- MOBILE-FIRST MAP PROGRESSION --- */

/* 1. Flip the order so ID 0 (Sanctuary) is at the bottom */
#loc-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 30px; /* Space for the bottom nav */
}

/* 2. Distinct Style for Sanctuary (Home Base) */
.location-card[data-id="0"] {
    background: linear-gradient(90deg, rgba(76, 209, 55, 0.15), rgba(0, 0, 0, 0.4)) !important;
    border: 2px solid var(--safe) !important;
    border-left: 8px solid var(--safe) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 15px rgba(76, 209, 55, 0.2) !important;
    margin-top: 20px; /* Separates Home from the combat zones */
    border-radius: 12px !important;
}

/* 3. Combat Zone Styling (The Dangerous Path) */
.location-card:not([data-id="0"]) {
    border-left-width: 4px;
    /* Optional: Slight slant to make combat nodes look more aggressive
    clip-path: polygon(0% 0%, 100% 0%, 98% 100%, 0% 100%);*/
}

/* 4. Desktop Fix: Maintain the layout inside the grid */
@media (min-width: 1024px) {
    body.game-running #loc-container {
        display: flex !important;
        flex-direction: column;
        padding: 15px;
    }
}

/* --- STATUS EFFECT LABELS --- */
.status-container {
    display: flex;
    gap: 8px;
    margin-top: 5px;
    justify-content: center;
}

.status-poison {
    color: var(--safe);
    font-weight: bold;
    font-size: 12px;
    text-shadow: 0 0 5px rgba(76, 209, 55, 0.8);
    animation: poison-pulse 2s infinite ease-in-out;
}

.status-bleed {
    color: var(--danger);
    font-weight: bold;
    font-size: 12px;
    text-shadow: 0 0 5px rgba(255, 92, 92, 0.8);
}

@keyframes poison-pulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* --- SCATTERED FLOATING TEXT --- */
.float-txt {
    position: absolute;
    /* We now use JS to set random left/top offsets to "scatter" these */
    pointer-events: none;
    z-index: 1000;
    font-family: var(--font-head);
    transition: all 0.1s ease-out;
}

/* Poison-specific floating text color */
.float-poison {
    color: #a2ff86 !important; /* Bright Toxic Green */
    text-shadow: 0 0 10px #2ecc71, 2px 2px 0 #000;
    font-size: 24px;
}

/* --- THE CHRONICLE PATH FIX --- */
#loc-container {
    position: relative; 
    display: flex;
    flex-direction: column; /* Puts Sanctuary at the bottom */
    gap: 12px;
    padding: 20px;
    width: 100%;
}

/* 3. Location Cards (Z-Index 2) */
.location-card {
    position: relative;
    z-index: 2; /* MUST be higher than path (1) to block it */
    
    /* MANDATORY: Solid background to prevent line peeking through */
    background: #1e2227 !important; 
    
    border-radius: 6px;
    width: 100%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* Sanctuary Specific Override */
.location-card[data-id="0"] {
    /* 1. Add a solid background color BEFORE the gradient to block the line */
    background-color: #121418 !important; 
    background-image: linear-gradient(90deg, rgba(76, 209, 55, 0.15), #1e2227) !important;
    
    /* 2. Higher z-index to ensure it stays above the path line */
    z-index: 5 !important; 
    
    border: 2px solid var(--safe) !important;
    border-left: 8px solid var(--safe) !important;
    
    /* 3. Give it a stronger shadow to separate it from the "path" visually */
    box-shadow: 0 10px 20px rgba(0,0,0,0.6) !important;
}
/* --- THE CHRONICLE PATH (REFINED) --- */
#loc-container {
    position: relative; 
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    width: 100%;
    /* Ensure the container height doesn't shift wildly when cards expand */
    min-height: 500px; 
}

/* Ensure selected cards don't change their vertical footprint */
.location-card.loc-selected {
    /* Use transform for the "pop" effect instead of margins */
    transform: scale(1.02); 
    z-index: 10;
    /* Do NOT add margin-top or padding changes here */
}

/* --- MAP VIEW SPECIFIC FIX --- */

/* Target only the location container inside the Map panel */
#view-map #loc-container {
    display: flex !important;
    /*flex-direction: column-reverse !important;*/ /* Keep Sanctuary at bottom */
    gap: 12px;
    padding: 20px;
    /*padding-top: 60px; */   /* Buffer so Zone 6 doesn't hit the header */
    overflow-y: auto;     /* Allow scrolling only here */
    height: 100%;
}

/* Ensure the Map header stays fixed while cards scroll under it */
#view-map h3 {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg-dark); /* Match your background to hide scrolling cards */
    margin: 0;
    padding: 15px;
}

/* Fix the Sanctuary spacing without affecting combat */
#view-map .location-card[data-id="0"] {
    margin-top: 0 !important;
    margin-bottom: 25px !important; /* Pushes it away from the dock */
}
#command-crest .btn-action {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: left !important;
    text-align: left;
    line-height: 1.1;
    white-space: normal; /* Allows the <br> to work */
    overflow: hidden;
    padding:0px !important;
}
#command-crest .btn-action > * {
    flex:1;
}
#command-crest .btn-action .ui-static-icon {
    flex:1;
    width:100%;
    max-width: 50px;
    height: 100%;
}
#log-feed {
    /* Adding a subtle fade effect to the top of the log */
    mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
}

#btn-salve {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
}

#btn-salve:active {
    transform: scale(0.9) translateY(2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

/* Make sure the main crest buttons align text correctly */
#ctrl-combat .btn-action {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Stance Auras */
.aura-dawn { box-shadow: 0 0 15px var(--fury) !important; border-color: var(--fury) !important; }
.aura-twilight { box-shadow: 0 0 15px #dcdde1 !important; border-color: #dcdde1 !important; }
.aura-eclipse { box-shadow: 0 0 15px var(--magic) !important; border-color: var(--magic) !important; }

/* Animation for switching */
.btn-resonance:active { transform: scale(0.95); }

#death-curtain {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle, #1a1a1a 0%, #000 100%);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 2.5s ease-in-out; /* Slow fade for gravitas */
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-main);
}

#death-curtain.curtain-active {
    display: flex;
    opacity: 1;
    pointer-events: all;
}
/* [UPDATE] Add these styles to style.css */
#death-curtain {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.5s ease-in-out; /* Smooth fade */
    display: none; /* Controlled by JS */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

#death-curtain.curtain-active {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

#death-text-container {
    animation: fadeIn 3s ease-in; /* Text fades in slightly slower than the black */
}
#death-curtain {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle, #1a1a1a 0%, #000 100%);
    z-index: 9999; /* Higher than all other UI elements */
    opacity: 0;
    pointer-events: none;
    display: none; /* Controlled by JavaScript flex logic */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 2s ease-in-out;
}

#death-curtain.curtain-active {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

#death-text-container {
    text-align: center;
    animation: fadeIn 3.5s ease-in;
}

/* Show stat buttons only when the AP alert is active */
#ap-alert[style*="display: block"] ~ .stat-grid-container .stat-btn,
#ap-alert[style*="display: block"] ~ .hero-group .stat-btn {
    display: inline-block;
}

.res-timer {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.85em;
    font-family: monospace; /* Monospace prevents button width "jitter" as numbers change */
    opacity: 0.8;
}

.active-res {
    background: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 0 10px var(--accent-glow);
    transform: scale(1.05);
}

.active-res .res-timer {
    color: #fff;
    font-weight: bold;
    animation: pulse 1s infinite;
}

.btn-resonance .pixel-icon {
    transform: scale(0.8); /* Slightly smaller for combat buttons */
    vertical-align: middle;
    margin-right: 4px;

}

.btn-resonance {
    font-size:0.75em;
}







/* --- BULLETPROOF SANCTUARY UI --- */
#sanctuary-ui {
    display: none; 
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important;
    background: var(--bg-dark) !important;
    overflow: hidden !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* FIX: The Icon Overflow */
#ui-sanc-icon {
    display: block !important;
    margin: 10px auto !important;
    max-width: 90% !important; /* Forces it to stay inside the screen */
    height: auto !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

#sanctuary-ui .sanc-header {
    width: 100%;
    padding: 15px;
    text-align: center;
    background: rgba(0,0,0,0.4);
    border-bottom: 2px solid var(--border-color);
    box-sizing: border-box;
}

#sanctuary-ui .sanc-scroll-body {
    flex: 1;
    overflow-y: auto !important;
    padding: 10px 15px 50px 15px !important;
    -webkit-overflow-scrolling: touch;
    width:100%;
}

/* FIX: Ensuring Descriptions and Labels are Visible */
#sanctuary-ui .sanc-section-label {
    display: block !important;
    color: var(--accent-gold) !important;
    font-family: var(--font-head);
    font-size: 11px;
    text-transform: uppercase;
    padding: 20px 0 10px 0;
}

#sanctuary-ui .sanc-row-btn {
    display: flex !important;
    width: 100% !important;
    background: #1e2227 !important; /* Force a solid visible dark grey */
    border: 1px solid var(--border-color) !important;
    margin-bottom: 12px !important;
    padding: 15px !important;
    border-radius: 8px;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    color: white !important;
}

/* FIX: The Missing Text */
#sanctuary-ui .sanc-row-info {
    display: flex !important;
    flex-direction: column !important;
    pointer-events: none;
}

#sanctuary-ui .sanc-row-name {
    color: #ffffff !important;
    font-weight: bold !important;
    font-size: 14px !important;
    display: block !important;
}

#sanctuary-ui .sanc-row-desc {
    color: #b0b0b0 !important; /* Explicit light grey */
    font-size: 11px !important;
    display: block !important; /* Forces it to show */
    margin-top: 4px !important;
    line-height: 1.4 !important;
}

#sanctuary-ui .sanc-row-price {
    color: var(--accent-gold) !important;
    font-family: var(--font-head);
    font-size: 13px;
    padding-left: 15px;
    border-left: 1px solid #333;
    min-width: 70px;
    text-align: right;
}

/* Disabled State: Kill all interactions */
#sanctuary-ui .sanc-row-btn:disabled {
    opacity: 0.3 !important;
    filter: grayscale(1);
    pointer-events: none !important;
    border-color: #222 !important;
}

/* Align the icon and the text block on the left */
.sanc-row-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

/* Ensure the inline icon doesn't blow up in size */
.sanc-icon-inline {
    width: 24px !important;
    height: 24px !important;
    flex-shrink: 0;
}

/* --- BUTTON HOVER & ACTIVE SEQUENCING --- */

/* 1. Base State Transition */
#sanctuary-ui .sanc-row-btn {
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease !important;
}

/* 2. Hover State: Lift and Glow */
/* Triggered when mouse is over or finger is touching (before release) */
#sanctuary-ui .sanc-row-btn:not(:disabled):hover {
    border-color: var(--accent-gold) !important;
    background: rgba(255, 255, 255, 0.05) !important;
    transform: translateY(-2px); /* Slight lift effect */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
    cursor: pointer;
}

/* 3. Active State: Press and Recede */
/* Triggered during the actual click/press */
#sanctuary-ui .sanc-row-btn:not(:disabled):active {
    transform: translateY(1px) scale(0.98) !important; /* Pushes down below the hover height */
    background: rgba(0, 0, 0, 0.3) !important;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6) !important;
    transition: transform 0.05s !important; /* Fast response for the click */
}

/* 4. Disabled State: Reset All */
#sanctuary-ui .sanc-row-btn:disabled {
    pointer-events: none !important;
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.25 !important;
    filter: grayscale(1) !important;
}

/* Title Screen Button Glow */
#title-screen-overlay .btn-action {
    background: radial-gradient(circle at 50% 10%, #2c313a 0%, #121418 90%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#title-screen-overlay .btn-action:hover:not(:disabled) {
    background: radial-gradient(circle at 50% 10%, #222 0%, #111 90%);
    letter-spacing: 1px;
    box-shadow: 0 0 20px var(--accent-glow);
}

/* Cinematic Title Fade */
@keyframes title-glow {
    0%, 100% { text-shadow: 0 0 20px rgba(238, 187, 77, 0.2); }
    50% { text-shadow: 0 0 40px rgba(238, 187, 77, 0.5); }
}

#title-screen-overlay h1 {
    animation: title-glow 4s infinite ease-in-out;
}
@media (max-width: 800px) {
#title-screen-overlay h1 {
    font-size: 28px !important;
}
}
#title-screen-overlay {
    background-image: url('assets/ui/wallpaper1.jpg') !important;
    filter: brightness(150%);
    background-size: cover !important;
}

/* Fix for the Modal Scrollbar double-up */
#beginner-guide-overlay .modal-box {
    display: flex;
    flex-direction: column;
    max-height: 85vh; /* Prevents the box from leaving the screen */
    padding: 0; /* We will handle padding inside for better scroll control */
    overflow: hidden;
}

.guide-content-scroll {
    overflow-y: auto;
    padding: 25px;
    flex-grow: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-gold) transparent;
}

/* Custom scrollbar for Webkit (Chrome/Safari) */
.guide-content-scroll::-webkit-scrollbar { width: 5px; }
.guide-content-scroll::-webkit-scrollbar-thumb { background: var(--accent-gold); border-radius: 10px; }

/* Cinematic Transition Curtain */
#transition-curtain {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999; /* Highest priority */
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.8s ease-in-out;
}

#transition-curtain.active {
    opacity: 1;
    pointer-events: all;
}

/* Optional: Ember Pulse Effect */
.ember-pulse {
    box-shadow: inset 0 0 100px rgba(238, 187, 77, 0.2);
    background: radial-gradient(circle, #1a1c22 0%, #000 100%);
}

.sanc-footer {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2); /* Slight background to separate it */
    width:100%;
}
#sanctuary-ui #btn-retire {
    margin-bottom: 0px !important;
}
#ui-sanc-icon{
    display: none !important;
}




/* --- CINEMATIC STORY OVERLAY --- */
#intro-overlay {
    position: fixed;
    inset: 0;
    background: #000; /* Solid black background for cinematic feel */
    z-index: 2000;
    
    /* The Magic Sauce: Transitions */
    opacity: 0;
    visibility: hidden;
    transition: opacity 1.2s ease-in-out, visibility 1.2s;
    
    display: flex !important; /* Keep it as flex, controlled by visibility */
    align-items: center;
    justify-content: center;
}

#intro-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Ensure the book itself has a slight scale-up animation when it appears */
.modal-box.book-theme {
    transform: scale(0.95) translateY(10px);
    transition: transform 1.5s cubic-bezier(0.22, 1, 0.36, 1);
}

#intro-overlay.active .modal-box.book-theme {
    transform: scale(1) translateY(0);
}

#story-text-container {
    opacity: 1;
    transition: opacity 1s ease-in; /* Text fades in smoothly on the page */
}

#story-text-container.visible {
    opacity: 1;
}

/* Add a slight blur to the background during transitions to focus on the text */
#intro-overlay {
    background: rgba(0, 0, 0, 1);
    backdrop-filter: blur(5px);
    transition: opacity 0.8s ease-in-out, visibility 0.8s;
}

/* --- CINEMATIC CLASS SELECTION TRANSITION --- */
#overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 16, 0.98); 
    display: flex !important; /* Keep flex active for centering */
    align-items: center;
    justify-content: center;
    z-index: 999;
    
    /* The Magic Sauce: Start Hidden */
    opacity: 0;
    visibility: hidden;
    transition: opacity 1.5s ease-in-out, visibility 1.5s;
}

#overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Optional: Make the Class Selection Box slide up slightly as it fades in */
#overlay.active .modal-box {
    animation: fadeInUp 1.2s ease-out forwards;
}

/* --- TRAVEL OVERLAY --- */
#travel-overlay {
    position: fixed;
    inset: 0;
    z-index: 8000; /* Above everything */
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    transition: opacity 0.5s ease-in-out, visibility 0.5s;
    pointer-events: none;
}

#travel-overlay.travel-active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.travel-hidden {
    opacity: 0;
    visibility: hidden;
}

#travel-content {
    text-align: center;
    transform: translateY(20px);
    transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

#travel-overlay.travel-active #travel-content {
    transform: translateY(0);
}

/*#travel-icon-wrap {
    margin-bottom: 20px;
    filter: drop-shadow(0 0 20px var(--z-col));
    transform: scale(2);
}*/
#travel-icon-wrap {
    margin-bottom: 20px;
    filter: drop-shadow(0 0 20px var(--z-col));
    width:100%;
    height: 100%;
    max-width: 90%;
    max-width: 90%;
}

.travel-text {
    font-family: var(--font-head);
    font-size: 12px;
    letter-spacing: 4px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

#travel-loc-name {
    font-family: var(--font-head);
    font-size: 32px;
    color: #fff;
    margin: 0 0 20px 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Moving progress bar for the "loading" feel */
.travel-bar-track {
    width: 200px;
    height: 2px;
    background: rgba(255,255,255,0.1);
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.travel-bar-fill {
    position: absolute;
    height: 100%;
    width: 50%;
    background: var(--z-col);
    left: -50%;
    animation: travel-progress 1.2s infinite linear;
}

@keyframes travel-progress {
    0% { left: -50%; }
    100% { left: 100%; }
}


/* Container and Scroll Area */
#sanctuary-ui {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #0d0e12;
}

.sanc-scroll-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* Category Labels */
.sanc-section-label {
    font-size: 10px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 15px 0 8px 5px;
    border-bottom: 1px solid #222;
    padding-bottom: 4px;
}

/* The Shop Button (Minimalist) */
.sanc-row-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #16181d;
    border: 1px solid #2a2d35;
    border-radius: 6px;
    padding: 10px 15px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sanc-row-btn:hover:not(:disabled) {
    border-color: var(--accent-gold);
    background: #1c1f26;
}

.sanc-row-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}

/* Row Info (Shortened) */
.sanc-row-name {
    display: block;
    font-family: var(--font-head);
    font-size: 14px;
    color: #eee;
}

.sanc-row-desc {
    display: block;
    font-size: 10px;
    color: #666;
}

/* Price Tags */
.sanc-row-price {
    font-family: var(--font-head);
    font-size: 12px;
    color: var(--accent-gold);
    background: rgba(0,0,0,0.3);
    padding: 4px 8px;
    border-radius: 4px;
    min-width: 65px;
    text-align: center;
}

/* Footer (Ritual Buttons) */
.sanc-footer {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #08090b;
    border-top: 1px solid #222;
}

.sanc-footer .sanc-row-btn {
    flex: 1;
    flex-direction: column;
    padding: 12px 5px;
    margin-bottom: 0;
    text-align: center;
}

.sanc-footer .sanc-row-price {
    margin-top: 5px;
    background: transparent;
    font-size: 10px;
    border: 1px solid currentColor;
}

/* Sanctuary Layout */
#sanctuary-ui {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sanc-scroll-body {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
}

/* Section Labels */
.sanc-section-label {
    font-size: 9px;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 15px 0 6px 4px;
}

/* Grid for Relics */
.sanc-grid-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

/* Universal Button Tile Style */
.sanc-btn-tile, .sanc-ritual-tile {
    width: 100%;
    background: #111;
    border: 1px solid #222;
    border-radius: 4px;
    padding: 12px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.sanc-btn-tile:hover:not(:disabled) {
    background: #161616;
    border-color: #333;
}

/* Button Text Styling */
.sanc-row-name {
    font-family: var(--font-head);
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1.5px;
}

.sanc-row-price {
    font-size: 9px;
    color: var(--accent-gold);
    margin-top: 4px;
    opacity: 0.7;
}

/* Footer Rituals (Side-by-Side) */
.sanc-footer {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #08090b;
    border-top: 1px solid #1a1a1a;
}

.sanc-ritual-tile {
    flex: 1; /* Ensures buttons are exactly the same size */
    min-height: 55px;
    border-width: 2px; /* Makes rituals feel more significant */
}

/* Visual States */
.sanc-btn-tile:disabled, .sanc-ritual-tile:disabled {
    opacity: 0.3;
    filter: grayscale(1);
    cursor: not-allowed;
}

.legendary {
    border-color: var(--magic);
    background: rgba(197, 108, 240, 0.02);
}

/* Ensure uniformity in the footer */
.sanc-footer {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #08090b;
    border-top: 1px solid #1a1a1a;
}

.sanc-ritual-tile {
    flex: 1; /* Forces both buttons to occupy 50% width */
    /*height: 70px;*/ /* Uniform height */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #111;
    border: 2px solid #222;
    border-radius: 4px;
    padding: 5px;
}

.sanc-ritual-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px; /* Space between icon and name */
}

/* Specific button borders for rituals */
#btnRest { border-color: rgba(39, 174, 96, 0.3); }
#btn-retire { border-color: rgba(255, 92, 92, 0.3); }

/* Ensure icons don't break layout */
.sanc-icon-inline {
    display: inline-block;
    transform: scale(1.2); /* Make ritual icons slightly more prominent */
}

/* Shop Row Container */
.sanc-row-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #111;
    border: 1px solid #222;
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

/* Grouping Icon + Text on the Left */
.sanc-row-main {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.sanc-icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Vertical Text Stack in the Center */
.sanc-row-info {
    display: flex;
    flex-direction: column;
}

.sanc-row-name {
    font-family: var(--font-head);
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 1px;
    color: #fff;
}

.sanc-row-desc {
    font-size: 9px;
    color: #666;
    text-transform: uppercase;
    margin-top: 1px;
}

/* Price Locked to the Right */
.sanc-row-price {
    font-family: var(--font-head);
    font-size: 11px;
    color: var(--accent-gold);
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 8px;
    border-radius: 3px;
    min-width: 65px;
    text-align: center;
}

/* Ritual Footer Mirroring */
.sanc-footer {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #08090b;
    border-top: 1px solid #1a1a1a;
}

.sanc-ritual-tile {
    flex: 1;
    /*height: 60px;*/
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #111;
    border: 2px solid #222;
    border-radius: 4px;
}

.sprite-icon {
    image-rendering: pixelated; /* Keeps the pixel art sharp */
    background-repeat: no-repeat;
    flex-shrink: 0; /* Prevents icons from squishing in flexboxes */
}

/* If you use icons inside buttons or rows, ensure they center well */
.sanc-icon-box, .dock-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px; /* Minimum space for the icon */
}

/* style.css */
.amulet-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(238, 187, 77, 0.1);
    border-radius: 10%;
    border: 1px solid var(--accent-gold);
    box-shadow: 0 0 15px rgba(238, 187, 77, 0.2);
    position: relative;
    overflow: hidden; /* Clips any sprite misalignment */
}

/* Ensure the sprite within the circle remains crisp */
.amulet-circle .sprite-icon {
    transform: scale(1.2); /* Scales 32px to fit the 44px circle better */
    image-rendering: pixelated;
}
/* 1. THE OVERLAY (The background scroll container) */
#intro-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none; /* Controlled by active class */
    align-items: flex-start; /* Start at top so it can scroll down */
    justify-content: center;
    overflow-y: auto; /* THIS enables the "Bootstrap-style" scrolling */
    padding: 40px 20px; /* Padding so the "book" doesn't touch screen edges */
}

/* 2. THE GRIMOIRE (The Modal Box) */
.modal-box.book-theme {
    position: relative;
    background-color: #f4e4bc !important; /* Aged parchment color */
    background-image: 
        /* Subtle paper texture overlay */
        url('https://www.transparenttextures.com/patterns/p6.png'),
        radial-gradient(circle, rgba(0,0,0,0) 40%, rgba(139, 69, 19, 0.15) 100%) !important;
    
    /* Elegant Leather/Gold Border */
    border: 12px solid #3e2723 !important; 
    outline: 2px solid #eebb4d; /* Thin gold "inlay" */
    outline-offset: -8px;
    
    border-radius: 4px !important;
    box-shadow: 0 30px 60px rgba(0,0,0,0.8), inset 0 0 100px rgba(93, 64, 55, 0.2) !important;
    color: #2c0e0e !important;
    
    /* Layout Logic: Removed fixed heights */
    display: flex;
    flex-direction: column;
    width: 95%;
    max-width: 650px;
    height: auto !important; /* Allow it to grow with text */
    min-height: auto;
    padding: 60px 50px !important; /* Generous breathing room */
    margin: auto; /* Centers it in the scrollable overlay */
    overflow:initial;
}

/* 3. REMOVE INNER SCROLLING */
#story-text-container {
    overflow-y: visible !important; /* Text no longer scrolls inside */
    max-height: none !important;    /* No height limit */
    font-family: 'Crimson Pro', serif;
    /*font-size: 1.25rem !important;*/
    line-height: 1.7 !important;
    color: #3e2723 !important;
    margin-bottom: 30px;
}

/* The Big First Letter (Drop Cap) */
#story-text-container::first-letter {
    font-family: 'Cinzel', serif;
    font-size: 4rem;
    float: left;
    line-height: 0.8;
    margin-right: 10px;
    margin-top: 5px;
    color: #800000; /* Deep blood red */
    text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

/* Grimoire Action Button */
#modal-action-btn.confirm-btn {
    background: #3e2723 !important;
    color: #f4e4bc !important;
    border: 1px solid #eebb4d !important;
    font-family: 'Cinzel', serif;
    padding: 20px !important;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3) !important;
    transition: all 0.2s ease;
}

#modal-action-btn.confirm-btn:hover {
    background: #5d4037 !important;
    color: #fff !important;
    transform: translateY(-2px);
}

/* style.css */
#intro-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96); /* Darker, cinematic backdrop */
    backdrop-filter: blur(10px);
    z-index: 5000;
    display: none; /* Controlled by .active in JS */
    
    /* BOOTSTRAP BEHAVIOR: Overlay is the scroll container */
    overflow-y: scroll; 
    display: flex;
    flex-direction: column;
    align-items: center; /* Centers horizontally */
    justify-content: flex-start; /* Starts at the top for long content */
    padding: 60px 20px; /* Gives the book breathing room at top/bottom */
}

#intro-overlay.active {
    display: flex;
}

/* style.css */
.modal-box.book-theme {
    /* Layout: Grow with content */
    width: 95%;
    max-width: 650px !important;
    height: auto !important; 
    max-height: none !important;
    margin-bottom: 60px; /* Extra space at the bottom after the button */
    
    /* Visuals: Aged Parchment & Leather */
    background-color: #f4e4bc !important;
    background-image: radial-gradient(circle, rgba(0,0,0,0) 40%, rgba(139, 69, 19, 0.15) 100%) !important;
    border: 12px solid #3e2723 !important; /* Thick leather frame */
    outline: 2px solid #eebb4d; /* Gold inlay line */
    outline-offset: -8px;
    border-radius: 4px !important;
    padding: 60px 50px !important;
    color: #2c0e0e !important;
    box-shadow: 0 30px 60px rgba(0,0,0,0.8), inset 0 0 100px rgba(93, 64, 55, 0.2) !important;
}

/* Fix the text container so it doesn't have its own scrollbar */
#story-text-container {
    overflow: visible !important;
    max-height: none !important;
    font-family: 'Crimson Pro', serif;
    /*font-size: 1.25rem !important;*/
    line-height: 1.8 !important;
    margin-bottom: 40px;
}

/* Cinematic Drop Cap */
#story-text-container::first-letter {
    font-family: 'Cinzel', serif;
    font-size: 4rem;
    float: left;
    line-height: 0.8;
    margin-right: 12px;
    color: #800000; /* Deep crimson ink */
}

/* style.css */
#overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    backdrop-filter: blur(10px);
    z-index: 999;
    display: none; /* Controlled by .active */
    
    /* Full Page Scroll Behavior */
    overflow-y: auto; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; 
    padding: 60px 20px;
}

#overlay.active { display: flex; }

/* Apply Grimoire visuals to the selection box */
#overlay .modal-box.book-theme {
    width: 95%;
    max-width: 650px;
    height: auto !important;
    max-height: none !important;
    background-color: #f4e4bc !important;
    background-image: radial-gradient(circle, rgba(0,0,0,0) 40%, rgba(139, 69, 19, 0.15) 100%) !important;
    border: 12px solid #3e2723 !important;
    outline: 2px solid #eebb4d;
    outline-offset: -8px;
    padding: 50px 30px !important;
    color: #2c0e0e !important;
}

/* style.css additions */
.select-btn {
    display: flex !important;
    flex-direction: row;
    flex-wrap: wrap; /* Allows stacking on small screens */
}

.portrait-side {
    width: 140px; /* Reduced from 190px for better fit */
    min-height: 120px;
}

.content-side {
    flex: 1;
    min-width: 200px; /* Triggers the wrap on mobile */
}

@media (max-width: 800px) {
    .portrait-side {
        width: 100% !important; /* Spans full width on mobile */
        border-right: none !important;
        border-bottom: 2px solid #3e2723;
        padding: 20px 0;
        overflow: hidden;
    }
    
    .select-btn {
        box-shadow: 3px 3px 0px #3e2723 !important; /* Smaller shadow for mobile */
    }

    .book-theme h1 {
        font-size: 28px !important;
    }
    .modal-box, .modal-box.book-theme {
        padding:30px !important;
    }
    .portrait-side div div.sprite-icon{
        vertical-align: top !important;
        justify-content: top !important;
    }
    .portrait-side{
        vertical-align: top !important;
        justify-content: top !important;
    }
    
    #intro-overlay, #overlay {
        padding: 30px 0px; /* Gives the book breathing room at top/bottom */
    }
}
/* style.css */

/* The card container */
.select-btn {
    display: flex !important;
    flex-direction: row;
    min-height: 220px; /* Increased to fit tall 64px vertical sprites */
    align-items: stretch;
    background: #fffdf5 !important;
    border: 2px solid #3e2723 !important;
    border-radius: 4px;
    margin-bottom: 25px;
    padding: 0;
    overflow: hidden;
    box-shadow: 6px 6px 0px #3e2723;
    transition: transform 0.1s;
}

/* Narrow but tall pillar for the sprite */
.portrait-pillar {
    width: 110px;
    flex-shrink: 0;
    background: radial-gradient(circle at center, rgba(0,0,0,0.05) 0%, transparent 85%);
    display: flex;
    /* CHANGE THIS: */
    align-items: flex-start; 
    justify-content: center;
    border-right: 2px solid #3e2723;
    position: relative;
    overflow: hidden;
}


/* The text area */
.details-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents text from breaking layout */
}

/* Mobile Adjustments */
@media (max-width: 800px) {
    .select-btn {
        min-height: 180px; /* Slightly shorter on small phones */
    }
    .portrait-pillar {
        width: 85px; /* Even narrower on mobile */
    }
    .book-theme h1 {
        font-size: 26px !important;
        letter-spacing: 2px !important;
    }
    #title-screen-overlay {
    background-position: right !important;
}

.titleSubText{
    color:var(--text-muted) !important;
}
}

/* style.css */
.hero-portrait-mini {
    width: 100px;
    height: 150px;
    background: radial-gradient(circle at top, rgba(238, 187, 77, 0.15) 0%, transparent 80%);
    border: 1px solid #3a404a;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: flex-start; /* Align to top */
    justify-content: center;
    flex-shrink: 0;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}
.hero-portrait-mini .ui-static-icon {
    height: 130%;
}

.hero-portrait-mini .sprite-icon {
    transform: scale(1.8); /* Adjust this if the sprite looks too big/small */
    transform-origin: top;
}

/* style.css */

#nav-dock {
    height: 75px; /* Slightly increased for better breathing room */
    overflow: hidden;
}

.dock-item {
    padding-top: 5px;
    position: relative;
}

/* Target the sprites inside the dock items */
.dock-item .sprite-icon, 
.dock-item .pixel-icon {
    display: block;
    margin: 0 auto 2px;
    
    /* THE FIX: Scale based on original size */
    /* If it's a 32px icon, scale(0.8) makes it ~25px */
    /* If it's a 64px character, scale(0.4) makes it ~25px */
    transform: scale(0.8); 
    transform-origin: center;
    
    /* Ensure tall icons don't push text down */
    max-height: 32px; 
}

/* Specific fix for the Hero icon if it uses the 64px character sprite */
#nav-hero .sprite-icon {
    transform: scale(0.45); /* Scale down the large vertical sprite */
    margin-bottom: -15px;   /* Pull the text back up toward the icon */
    margin-top: -10px;      /* Center it vertically in the slot */
}

/* Adjust the icon container to ensure centering */
.dock-icon {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
}

#combat-controls-wrapper .btn-action .sprite-icon {
  scale: 0.5;
}

#resonance-wrapper {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; height: 56px;
}
.btn-resonance {

  display: flex; flex-shrink: 0;
  justify-content: center;
  vertical-align: middle;
}
#resonance-wrapper .btn-action {
  
  display: flex; flex-shrink: 0;
  justify-content: left;
  vertical-align: middle;
  align-items: left;
}

.res-icon {
  display: flex; flex-shrink: 0; vertical-align: middle; align-items: center;
  height:30px;
  width: 30px;
}
.btn-resonance {
    overflow: hidden;
}
.btn-resonance .res-icon {
  display: flex; flex-shrink: 0; vertical-align: middle; align-items: center;
  max-height:30px;
  max-width:30px;
  height:100%;
  width: 100%;
  flex:1;
}

.res-icon .sprite-icon{
  transform-origin: center;
}

/* --- TINTED RESONANCE BUTTONS USING VARIABLES --- */

/* MIGHT - Tinted with --fury */
#res-btn-dawn {
    border-color: var(--fury) !important;
    /* Mixes 15% of the fury variable with the dark background */
    background: linear-gradient(135deg, color-mix(in srgb, var(--fury), transparent 85%) 0%, #121418 100%) !important;
    box-shadow: 0 4px 0 #2a150e, 0 0 10px rgba(255, 159, 26, 0.1);
}

/* POISE - Tinted with Light Grey */
#res-btn-twilight {
    border-color: #dcdde1 !important;
    background: linear-gradient(135deg, color-mix(in srgb, #dcdde1, transparent 90%) 0%, #121418 100%) !important;
    box-shadow: 0 4px 0 #1e2124;
}

/* ARTS - Tinted with --magic */
#res-btn-eclipse {
    border-color: var(--magic) !important;
    background: linear-gradient(135deg, color-mix(in srgb, var(--magic), transparent 85%) 0%, #121418 100%) !important;
    box-shadow: 0 4px 0 #1a0e21, 0 0 10px rgba(197, 108, 240, 0.1);
}

/* --- PRIMARY COMMAND ENHANCEMENTS --- */

/* Targets only the Amulet, Strike, and Skill buttons */
#command-crest .btn-action {
    background: linear-gradient(135deg, #2d343e 0%, #121418 100%) !important;
    border: 1px solid #636e72 !important; /* Brighter border than standard */
    box-shadow: 0 4px 0 #0a0b0d, 0 0 8px rgba(238, 187, 77, 0.1); /* Subtle gold bloom */
}

/* Make the Icon Well stand out on primary buttons */
#command-crest .btn-icon-well {
    background: rgba(238, 187, 77, 0.05); /* Very slight gold tint */
    border-right: 1px solid rgba(238, 187, 77, 0.2);
}

/* Hover state for primary actions */
#command-crest .btn-action:hover:not(:disabled) {
    border-color: var(--accent-gold) !important;
    box-shadow: 0 4px 0 #0a0b0d, 0 0 15px rgba(238, 187, 77, 0.3);
}

/* Active "Pressed" state */
#command-crest .btn-action:active:not(:disabled) {
    background: #121418 !important;
    transform: translateY(3px);
    box-shadow: 0 1px 0 #000;
}

/* Ensure the Hero Card has relative positioning so the absolute button knows where to stay */
#card-hero {
    position: relative; /* REQUIRED */
    overflow: visible !important; /* Allows the button to peek outside the card boundaries */
}

#btn-salve-hero {
    position: absolute; /* Keep absolute */
    /* Move it to the far right, outside the main meter area */
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    
    /* Styling to make it look like a distinct side-tab */
    width: 46px;
    height: 46px;
    background: #121418;
    border: 2px solid var(--safe);
    border-radius: 8px 8px 8px 8px; /* Rounded on the left, squarer on the right */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100; /* Ensures it stays above the health bars */
    box-shadow: -4px 0 10px rgba(0,0,0,0.5);
}

/* Adjust the icon and text inside */
#btn-salve-hero span:first-child {
    font-size: 18px;
    margin-bottom: -2px;
}

#pot-count {
    font-size: 11px;
    font-weight: bold;
    color: var(--safe);
}
#card-hero {
    padding-right: 55px !important; /* Creates a "dead zone" on the right for the potion button */
}
#resonance-wrapper .sprite-icon {
    transform: scale(0.7); /* Shrink icons slightly to fit the shorter buttons */
    transform-origin: center;
}

#resonance-wrapper .btn-resonance {
    min-width: 0; /* Prevents text from forcing the button to grow wide */
}

/* style.css */



/* Sidebar Specific: Scale down for the 3 vertical resonance buttons */
#resonance-wrapper .ui-static-icon {
    /*height: 100%;*/ /* Smaller height to fit the sidebar rows */
    flex-shrink:0;
    
}

/* Main Action Grid: Ensure icons don't squash text */
#command-crest .ui-static-icon {
    margin-right: 10px;
    flex-shrink: 0;
}

/* style.css */

.portrait-pillar {
    width: 110px;
    flex-shrink: 0;
    display: flex;
    /* Changing from flex-start to stretch ensures children fill the height */
    align-items: stretch !important; 
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: #000; /* Backdrop for any transparent areas */
}

.portrait-pillar .ui-static-icon {
    /* Force the image to ignore the base 32px size */
    width: 100% !important;
    height: 100% !important;
    
    /* Cover ensures the entire pillar is filled, cropping the sides if needed */
    object-fit: cover !important;
    
    /* Center the character in the pillar */
    object-position: center top !important; 
    
    /* Keep your retro pixels sharp */
    image-rendering: pixelated;
}
.location-card .ui-static-icon {
    /* Force the image to ignore the base 32px size */
    width: 100% !important;
    height: 100% !important;
    
    /* Cover ensures the entire pillar is filled, cropping the sides if needed */
    object-fit: cover !important;
    
    /* Center the character in the pillar */
    object-position: center top !important; 
    
    /* Keep your retro pixels sharp */
    image-rendering: pixelated;
}


.ui-static-icon {
    height: 100%;
    width: auto;
    object-fit: contain;
    image-rendering: pixelated; /* Keeps your 32x32 tiles crisp */
    vertical-align: middle;
}

.map-icon-wrap {
    font-size: 20px; 
    margin-right: 12px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    padding: 4px;
}

.map-icon-wrap .ui-static-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.btn-dashboard {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 6px 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 0;
}

.btn-dashboard:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #555;
}

.dash-icon {
    font-size: 1.4rem;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.btn-dashboard:active .dash-icon {
    transform: scale(0.9);
}

.dash-label {
    font-family: 'Crimson Pro', serif;
    font-size: 8px;
    font-weight: bold;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Specific styling for the Magic/Lore button */
.btn-dashboard[style*="--btn-color"] .dash-label {
    color: var(--magic);
    opacity: 0.8;
}

.dashboard-container {
}
.dashboard-container .btn-dashboard .dash-icon {
    height: 50px;
}

#settings-overlay .btn-action {
    display: flex;
    align-items: center;    /* Vertically centers the text relative to the image */
    justify-content: flex-start; /* Ensures content starts from the left */
    padding: 0;             /* Remove default padding to let panels fill the space */
    overflow: hidden;       /* Keeps the image corners from spilling out */
    text-align: left;
    gap: 15px;              /* Space between the image and the text */
}

/* This styles the 'left panel' (the image) */
#settings-overlay .ui-static-icon {
    height: 50px;           /* Fixed height */
    width: 50px;            /* Fixed width to make it a square panel */
    object-fit: contain;    /* Ensures pixel art isn't distorted */
    background: rgba(0, 0, 0, 0.2); /* Subtle background to distinguish the panel */
    border-right: 1px solid rgba(255, 255, 255, 0.1); /* Vertical divider line */
    /*padding: 5px;*/
    flex-shrink: 0;         /* Prevents the image from squishing */
}

/* Optional: If you want the text to have a bit of padding from the right edge */
#settings-overlay .btn-action span, 
#settings-overlay .btn-action {
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* 1. Base Styles (Hidden by default for larger screens) */
#nav-dock {
    display: none; 
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px; /* Adjust height as needed */
    background-color: #1a1a1a; /* Dark RPG-style background */
    border-top: 2px solid #444;
    z-index: 1000;
    box-sizing: border-box;
}

/* 2. Responsive Trigger (Show only on smaller screens) */
@media screen and (max-width: 768px) {
    #nav-dock {
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 5px 0;
    }
}

/* 3. Button Styling (The Container) */
.dock-item {
    background: none;
    border: none;
    color: #ccc;
    display: flex;
    flex-direction: column; /* Stacks icon on top of text */
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-family: 'Georgia', serif; /* Or your preferred font */
    cursor: pointer;
    width: 100%;
    transition: transform 0.1s ease;
}

/* 4. Icon Styling (Handling the non-transparent squares) */
#nav-dock .ui-static-icon, #nav-dock .dock-icon {
    width: 32px;  /* Control icon size */
    height: 32px;
    margin-bottom: 4px;
    border-radius: 4px; /* Softens the square edges */
    border: 1px solid #555; /* Makes the non-transparent block look like a framed tile */
    object-fit: contain;
    background-color: #000; /* Optional: provides a consistent backing for the icons */
}

/* 5. Active and Hover States */
.dock-item.active {
    color: #ffd700; /* Gold color for active state */
}

.dock-item.active img, .dock-item.active .dock-icon {
    border-color: #ffd700;
    box-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.dock-item:active {
    transform: scale(0.95);
}

/* Container remains flex to put buttons side-by-side */
.sanc-footer {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
}

/* The Button: Forced into 2 strict columns */
.sanc-ritual-tile {
    flex: 1;
    display: grid !important; /* Force Grid */
    grid-template-columns: 46px 1fr; /* Column 1 is icon, Column 2 is text */
    align-items: center;
    
    height: 50px;
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 0;
    margin: 0;
    cursor: pointer;
    overflow: visible; /* Allows the pulse shadow to be seen */
    box-sizing: border-box;
}

/* Column 1: The Icon Socket - UPDATED to fill */
.sanc-ritual-tile span[id^="icon-"] {
    grid-column: 1;
    height: 100%;
    width: 100%; /* Ensure it fills the 46px grid column */
    background: #111;
    display: flex;
    overflow: hidden; /* Clips the image to the border-radius of the button */
    border-right: 1px solid #444;
    border-radius: 6px 0 0 6px; /* Matches the left side of the button */
}

/* The Square Icon - UPDATED to fill the span */
.sanc-ritual-tile .sanc-icon-inline {
    width: 100% !important;
    height: 100% !important;
    display: block;
    
    /* 'cover' ensures the square tile fills the area without distortion */
    /* 'pixelated' keeps your tile art from looking blurry when stretched */
    object-fit: cover !important; 
    image-rendering: pixelated; 
}


/* Column 2: The Text */
.sanc-row-name {
    grid-column: 2; /* Stay in second column */
    margin: 0 !important;
    padding: 0 5px !important;
    text-align: center;
    
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    white-space: nowrap; /* Prevents wrapping */
    display: block;      /* Ensures it fills the grid cell */
}

/* Branding */
#btnRest { border-left: 4px solid var(--safe); }
#btn-retire { border-left: 4px solid var(--danger); }

/* THE PULSE: Enhanced visibility */
#btn-retire {
    /* Increased the spread and opacity so you can actually see it */
    animation: shadow-breathe 2.5s infinite ease-in-out;
}

@keyframes shadow-breathe {
    0% { 
        box-shadow: 0 0 0px rgba(0, 0, 0, 0); 
    }
    50% { 
        /* The 3rd value (15px) is the blur, the 4th (4px) is the spread */
        box-shadow: 0 0 15px 4px rgba(255, 0, 0, 0.35); 
    }
    100% { 
        box-shadow: 0 0 0px rgba(0, 0, 0, 0); 
    }
}

/* 1. The Container Row */
.sanc-row-btn {
    display: grid;
    grid-template-columns: 60px 1fr auto; /* [Icon] [Name/Desc] [Price] */
    align-items: center;
    width: 100%;
    min-height: 64px;
    padding: 8px;
    margin-bottom: 8px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-align: left; /* Reset button default */
}

/* 2. The Icon Container (The Socket) */
.sanc-row-content {
    display: contents; /* Allows children to participate in the grid above */
}

.sanc-icon-box {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 48px;  /* Larger size for the list icon */
    height: 48px;
    background: #000;
    border: 1px solid #444;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

/* 3. The Icon Image (Solving the 'tiny' problem) */
.sanc-icon-inline {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    image-rendering: pixelated; /* Keeps pixel art sharp */
    display: block;
}

/* 4. Text Info Area */
.sanc-row-info {
    display: flex;
    flex-direction: column;
    padding-left: 12px;
    overflow: hidden;
}

.sanc-row-name {
    font-weight: bold;
    font-size: 14px;
    color: #eee;
    text-transform: uppercase;
}

.sanc-row-desc {
    font-size: 11px;
    color: #888;
    line-height: 1.2;
    margin-top: 2px;
}

/* 5. The Price Tag */
.sanc-row-price {
    font-weight: bold;
    font-size: 14px;
    color: #ffd700; /* Gold color */
    padding-left: 10px;
    white-space: nowrap;
}

/* 6. States and Special Effects */
.sanc-row-btn:disabled {
    opacity: 0.6;
    filter: grayscale(0.8);
    cursor: not-allowed;
}

.sanc-row-btn.legendary {
    border: 1px solid var(--magic);
    background: linear-gradient(90deg, #1a1a1a, #2a1a3a);
}

.sanc-row-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.sanc-section-label {
    padding: 10px 0 5px 5px;
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #666;
}
#btn-salve-hero .ui-static-icon {
    height: 30px;
}

/* Container - Already centers children, but let's be sure */
#travel-content {
    display: flex;
    flex-direction: column;
    align-items: center; /* This centers all children horizontally */
    text-align: center;
}

/* Fix for the Centering */
#travel-icon-wrap {
    display: inline-block; /* Forces the box to shrink to the image size */
    margin: 0 auto 25px auto; /* Centers the box itself */
    line-height: 0; /* Removes extra vertical space from images */
    
    /* Your Stylized Border */
    /*padding: 8px;*/
    background: #2a2118;
    border: 4px solid #5d4a37;
    box-shadow: 
        inset 0 0 0 2px #1a140f, 
        0 4px 10px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

#travel-icon-wrap .ui-static-icon {
    width: 100%; /* Doubled size */
    height: 100%;
    display: block; /* Removes bottom whitespace alignment */
    margin: 0 auto; /* Extra centering safety */
    image-rendering: pixelated; 
}

/* Add a shadow overlay to make the icon look "deep" in the frame */
#travel-icon-wrap::after {
    content: "";
    position: absolute;
    top: 8px; left: 8px; right: 8px; bottom: 8px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
    pointer-events: none;
}

/* Ensure the Boss Icon fills the frame exactly like the previous one */
.icon-preview {
    width: 100%;
    height: 100%;
    padding:25px;
    display: block;
    image-rendering: pixelated; /* Essential for your spider pixel art */
    object-fit: contain; /* Ensures the spider isn't stretched if the aspect ratio differs */
}

/* Boss Variant: You can add this class to the #travel-icon-wrap in your HTML 
   if you want a different "danger" feel for bosses */
.boss-frame {
    border-color: #8b0000 !important; /* Deep blood red border */
    background: #1a0f0f !important; /* Darker, reddish-black background */
    box-shadow: 
        inset 0 0 0 2px #330000, 
        0 0 20px rgba(139, 0, 0, 0.5); /* Red outer glow */
}

/* Base Card Style (for context) */
.location-card {
    position: relative;
    background: #1a140f;
    border: 1px solid #3d3024;
    transition: all 0.3s ease;
    margin-bottom: 8px;
    overflow: hidden;
}

/* THE ACTIVE STATE */
.location-card.active {
    background: #2a2118; /* Slightly lighter background */
    border: 1px solid var(--accent-gold, #d4af37);
    box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.1), 0 0 10px rgba(0, 0, 0, 0.5);
    transform: scale(1.02); /* Slight pop out effect */
    z-index: 2; /* Ensure glow/shadow sits above neighbors */
}

/* The "You Are Here" Indicator */
.location-card.active::before {
    content: "CURRENT LOCATION";
    position: absolute;
    top: 0;
    right: 0;
    background: var(--accent-gold, #d4af37);
    color: #000;
    font-size: 8px;
    font-weight: bold;
    padding: 2px 8px;
    border-bottom-left-radius: 4px;
    letter-spacing: 1px;
}

/* Animated Border Glow */
.location-card.active::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border: 2px solid var(--accent-gold, #d4af37);
    animation: pulse-border 2s infinite;
    pointer-events: none;
}

@keyframes pulse-border {
    0% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.2; transform: scale(1.01); }
    100% { opacity: 0.5; transform: scale(1); }
}

/* Enhancing the icon of the active location */
.location-card.active .map-icon-wrapper {
    background: radial-gradient(circle, rgba(212, 175, 55, 0.2) 0%, transparent 70%);
    filter: drop-shadow(0 0 5px #d4af37);
}

.float-txt {
    position: absolute;
    top: 40%;
    left: 50%;
    pointer-events: none;
    font-weight: 800;
    z-index: 100;
    /* We use 'forwards' to keep the end state of the animation */
    animation: floatArc 2.5s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes floatArc {
    0% {
        opacity: 0;
        margin-top: 0;
    }
    10% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        /* This creates the upward movement */
        margin-top: -120px; 
        /* The 'transform' from JS handles the horizontal drift */
    }
}

/* Specific styling for the target types */
.float-enemy {
    text-shadow: 2px 2px 0px #000;
}

.float-player {
    text-shadow: 2px 2px 0px #000;
    /* Optional: maybe player damage is always a specific font style? */
}

/* --- GRIMOIRE STYLE SUMMARY (INK & PARCHMENT) --- */

.skim-container {
    /* Slightly darker parchment tint to look like an indented box */
    background: rgba(62, 39, 35, 0.05); 
    /* Elegant double border typical of old books */
    border: 1px solid rgba(93, 64, 55, 0.3);
    border-left: 4px solid #800000; /* Deep Crimson Accent */
    
    padding: 15px 20px;
    margin-bottom: 25px;
    border-radius: 2px;
    
    /* Typography */
    font-family: 'Crimson Pro', serif;
    color: #3e2723; /* Matching your book text color */
    box-shadow: inset 0 0 10px rgba(0,0,0,0.02);
}

.skim-summary {
    font-size: 0.85rem;
    line-height: 1.4;
    font-style: italic;
    margin-bottom: 8px;
    opacity: 0.9;
}

/* Label for "Next Objective" */
.skim-next {
    display: block;
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    font-weight: bold;
    color: #800000; /* Crimson Ink */
    border-top: 1px dashed rgba(93, 64, 55, 0.2);
    padding-top: 8px;
    margin-top: 8px;
}

/* The actual location text */
.skim-next b {
    color: #2c0e0e;
    font-size: 0.85rem;
    margin-left: 5px;
}

/* The divider between skim and full story */
.story-divider {
    border: 0;
    height: 1px;
    background: linear-gradient(to right, rgba(93, 64, 55, 0.3), transparent);
    margin: 25px 0;
}

/* NEW SCOPED DROP CAP */
/* This ignores the summary and only targets the actual lore paragraphs */
.lore-content p:first-of-type::first-letter {
    font-family: 'Cinzel', serif;
    font-size: 3.8rem;
    float: left;
    line-height: 0.8;
    margin-right: 12px;
    margin-top: 5px;
    color: #800000;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

/* Ensure the summary box never accidentally triggers a drop cap */
.skim-container::first-letter {
    font-size: inherit !important;
    float: none !important;
    color: inherit !important;
}

.skim-container {
    display: flex;
    flex-direction: column;
    justify-content: center; /* Centers the summary vertically if it's the only item */
    min-height: 50px; 
}
