:root {
    --ds-red: #8a0303;
    --ds-red-bright: #ff1a1a;
    --ds-black: #0a0a0a;
    --ds-dark-grey: #141414;
    --ds-panel-grey: #1c1c1c;
    --ds-border: #333333;
    --ds-gold: #c5a059;
    --ds-gold-dim: #8a6e36;
    --ds-text-main: #dcdcdc;
    --ds-text-muted: #888;
    --er-blue: #3a4a63;
    --er-gold: #d4af37;
}

/* RESET & BASE */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background-color: var(--ds-black); color: var(--ds-text-main); font-family: 'Cinzel', serif; }

.dsfg-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Cinzel', serif;
    overflow-x: hidden;
}

/* --- LAYOUT GRID (Desktop Sticky) --- */
.dsfg-layout-grid {
    display: grid;
    grid-template-columns: 1fr; /* Mobile default: Stacked */
    gap: 40px;
}

@media (min-width: 992px) {
    .dsfg-layout-grid {
        grid-template-columns: 1.2fr 1fr; /* Desktop: Preview wider, Controls narrow */
        align-items: start;
    }
    
    /* Left Column (Sticky) */
    .dsfg-left-col {
        position: sticky;
        top: 20px;
        display: flex;
        flex-direction: column;
        gap: 20px;
        max-height: 95vh;
        overflow-y: auto; /* Allow scroll if unicode gets too long */
        padding-right: 5px;
    }

    /* Custom scrollbar for sticky column */
    .dsfg-left-col::-webkit-scrollbar { width: 6px; }
    .dsfg-left-col::-webkit-scrollbar-track { background: var(--ds-dark-grey); }
    .dsfg-left-col::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

    /* Right Column (Normal Scroll) */
    .dsfg-right-col {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
}

/* --- HEADER --- */
header {
    text-align: center;
    padding: 20px;
    background: var(--ds-panel-grey);
    border: 1px solid var(--ds-border);
    border-bottom: 2px solid var(--ds-gold);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

header h2 {
    color: var(--ds-gold);
    font-size: 2rem;
    letter-spacing: 2px;
    margin-bottom: 5px;
    text-shadow: 0 0 15px rgba(197, 160, 89, 0.2);
}

header .subtitle {
    font-family: 'MedievalSharp', cursive;
    color: var(--ds-text-muted);
    font-size: 0.9rem;
}

/* --- PREVIEW SECTION --- */
.preview-section {
    width: 100%;
    background: var(--ds-panel-grey);
    border: 1px solid var(--ds-border);
    padding: 10px;
    position: relative;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.8);
}

#preview-canvas, #preview-canvas-er {
    width: 100%;
    aspect-ratio: 16/9;
    position: relative;
    overflow: hidden;
    background-color: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px solid #222;
}

.preview-bg-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; }
.preview-bg { width: 100%; height: 100%; object-fit: cover; object-position: center; opacity: 0.6; transition: opacity 0.3s; }
.overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 1; pointer-events: none; }
.preview-content { z-index: 10; text-align: center; width: 90%; position: relative; pointer-events: none; }

/* Text Styles */
.main-text { font-size: 2.5rem; line-height: 1.1; margin-bottom: 10px; text-transform: uppercase; transition: all 0.2s; }
.sub-text { font-size: 1rem; color: #ccc; opacity: 0.8; font-family: 'Cinzel', serif; }

/* UI Elements */
.ui-element { position: absolute; z-index: 20; display: none; }
.ui-element.active { display: flex; align-items: center; }

.boss-hp-bar {
    bottom: 10%; left: 50%; transform: translateX(-50%);
    width: 90%; max-width: 500px; height: 16px;
    background: #222; border: 1px solid #000; box-shadow: 0 2px 10px #000;
}
.boss-name-tag {
    position: absolute; top: -25px; left: 0;
    color: #fff; font-family: 'Uncial Antiqua', cursive; font-size: 1rem;
    text-shadow: 1px 1px 2px #000; white-space: nowrap;
}
.boss-hp-fill { width: 60%; height: 100%; background: linear-gradient(90deg, #500, #f00); }

.soul-counter {
    top: 15px; right: 15px;
    background: rgba(0,0,0,0.8); border: 1px solid var(--ds-gold);
    color: var(--ds-gold); padding: 4px 10px;
    font-size: 1rem; gap: 8px;
}

/* --- CONTROLS (Right Column) --- */

/* Tabs */
.game-tabs {
    display: flex; gap: 0; background: var(--ds-panel-grey);
    border: 1px solid var(--ds-border); border-radius: 4px; overflow: hidden;
}
.game-tab {
    flex: 1; padding: 12px; text-align: center;
    background: var(--ds-dark-grey); color: var(--ds-text-muted);
    cursor: pointer; border: none; outline: none;
    font-family: 'Cinzel', serif; font-weight: 700; letter-spacing: 1px;
    transition: all 0.3s;
}
.game-tab:hover { background: #252525; color: #fff; }
.game-tab.active {
    color: #fff;
    border-bottom: 3px solid;
}
/* Active Colors set via JS mostly, but default: */
.game-tab.active:first-child { background: var(--ds-red); border-color: #ff4444; }
.game-tab.active:last-child { background: var(--er-blue); border-color: #5a6a83; }

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

/* Control Group Card */
.control-group {
    background: var(--ds-panel-grey);
    border: 1px solid var(--ds-border);
    padding: 20px;
    border-radius: 2px;
    margin-bottom: 20px;
}

.group-title {
    color: var(--ds-gold); font-size: 0.85rem;
    text-transform: uppercase; letter-spacing: 1.5px;
    margin-bottom: 15px; display: flex; align-items: center; gap: 8px;
    border-bottom: 1px solid #333; padding-bottom: 8px;
}

.control-row { margin-bottom: 15px; }
.control-row:last-child { margin-bottom: 0; }
label { display: block; font-size: 0.8rem; color: var(--ds-text-muted); margin-bottom: 6px; }

/* Inputs */
input[type="text"], input[type="number"] {
    width: 100%; background: var(--ds-black); border: 1px solid #444;
    color: #fff; padding: 10px; font-family: 'Cinzel', serif;
    outline: none; transition: border 0.2s;
}
input[type="text"]:focus { border-color: var(--ds-gold); }

/* Range */
.full-range { width: 100%; accent-color: var(--ds-gold); cursor: pointer; }

/* Buttons Grids */
.btn-grid { display: grid; gap: 8px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Buttons */
button {
    background: var(--ds-black); border: 1px solid #444;
    color: var(--ds-text-muted); padding: 10px;
    cursor: pointer; font-family: 'Cinzel', serif; font-size: 0.8rem;
    transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 5px;
}
button:hover { background: #252525; color: #fff; border-color: #666; }
button.active { background: var(--ds-red); color: #fff; border-color: #ff4444; box-shadow: 0 0 8px rgba(138,3,3,0.4); }

/* Specific Button Types */
.preset-btn { flex-direction: column; height: auto; padding: 12px 5px; text-align: center; }
.preset-btn span { font-family: 'Uncial Antiqua', cursive; font-size: 1.1rem; color: var(--ds-gold); display: block; margin-bottom: 2px; }
.elden-btn.active { background: var(--er-blue); border-color: #5a6a83; box-shadow: 0 0 8px rgba(58,74,99,0.4); }

/* Color Picker */
.color-picker-container { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
input[type="color"] {
    width: 35px; height: 35px; border: 1px solid #444; background: #000;
    cursor: pointer; padding: 0;
}

/* Background Grid */
.bg-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 10px; }
.bg-option {
    height: 40px; border: 1px solid #444; background-size: cover;
    background-position: center; cursor: pointer; position: relative;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; color: #888; background-color: #000;
}
.bg-option.selected { border: 2px solid var(--ds-gold); box-shadow: 0 0 5px rgba(197, 160, 89, 0.4); }

/* Upload */
.upload-btn {
    display: inline-block; width: auto; padding: 8px 15px;
    background: #222; border: 1px dashed #555; color: #aaa;
    font-size: 0.8rem; margin-bottom: 10px;
}
#bg-upload, #bg-upload-er { display: none; }
.upload-btn:hover { color: #fff; border-color: var(--ds-gold); }

/* Unicode Card */
.unicode-card { padding: 15px; }
.unicode-styles {
    display: grid; grid-template-columns: 1fr; gap: 8px;
    max-height: 200px; overflow-y: auto; padding-right: 5px;
}
.style-card {
    background: var(--ds-black); border: 1px solid #333; padding: 8px;
    display: flex; justify-content: space-between; align-items: center;
}
.style-preview { font-size: 1rem; color: var(--ds-gold); font-family: 'Courier New', monospace; }
.style-name { font-size: 0.7rem; color: #666; margin-right: auto; margin-left: 10px; }
.copy-btn { background: transparent; border: none; color: #666; padding: 5px; }
.copy-btn:hover { color: #fff; background: transparent; }

/* Download Button */
.download-btn {
    width: 100%; padding: 18px;
    background: linear-gradient(180deg, #2a2a2a, #000);
    border: 1px solid var(--ds-gold); color: var(--ds-gold);
    font-size: 1.1rem; font-weight: bold; text-transform: uppercase;
    letter-spacing: 2px; box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    transition: transform 0.2s;
}
.download-btn:hover {
    background: linear-gradient(180deg, #3a3a3a, #111);
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(197, 160, 89, 0.2);
}

/* --- EFFECTS --- */
.effect-blood { color: var(--ds-red); text-shadow: 0 0 8px var(--ds-red), 0 0 15px #500; }
.effect-gold { color: var(--ds-gold); text-shadow: 0 0 8px var(--ds-gold), 0 0 15px rgba(197,160,89,0.5); }
.effect-white { color: #fff; text-shadow: 2px 2px 0 #000; }
.effect-dark { color: #000; text-shadow: 0 0 2px #fff; background: rgba(255,255,255,0.1); padding: 0 5px; }
.effect-glitch { animation: glitch 1s infinite; }
.effect-er { color: var(--er-gold); text-shadow: 0 0 8px var(--er-gold); }

@keyframes glitch {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
    100% { transform: translate(0); }
}

/* --- FONTS --- */
.font-undead { font-family: 'Uncial Antiqua', cursive !important; font-weight: 700; }
.font-hollow { font-family: 'MedievalSharp', cursive !important; }
.font-abyss { font-family: 'Cinzel', serif !important; font-weight: 700; }
.font-glitch { font-family: 'Rubik Glitch', cursive !important; }
.font-fell { font-family: 'Cormorant Garamond', serif !important; font-weight: 700; }
.font-cormorant { font-family: 'Cormorant Garamond', serif !important; }
.font-antiqua { font-family: 'Crimson Text', serif !important; }
.font-playfair { font-family: 'Playfair Display', serif !important; font-weight: 700; }

/* --- MOBILE TWEAKS --- */
@media (max-width: 600px) {
    .dsfg-container { padding: 10px; }
    header h2 { font-size: 1.5rem; }
    .grid-4 { grid-template-columns: 1fr 1fr; } /* 4 columns to 2 on mobile */
    .bg-grid { grid-template-columns: repeat(3, 1fr); }
    .dsfg-layout-grid { gap: 20px; }
    .main-text { font-size: 1.8rem; }
    .dsfg-left-col { position: static; } /* No sticky on mobile */
}

/* --- NOTIFICATION --- */
.download-notification {
    position: fixed; top: 20px; right: 20px;
    background: var(--ds-panel-grey); border-left: 4px solid var(--ds-gold);
    padding: 15px 25px; box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    z-index: 1000; display: none; transform: translateX(50px);
    transition: all 0.3s ease;
}
.download-notification.show { display: block; transform: translateX(0); }
.download-notification h3 { color: var(--ds-gold); font-size: 1rem; display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.download-notification p { font-size: 0.85rem; color: #aaa; margin: 0; }

/* Utility */
.hidden { display: none !important; }
.ornament { display: none; } /* Removed for cleaner look */
.material-icons { font-size: 1.1rem; vertical-align: middle; }