:root {
    --bg-page: #0a0b16; /* Deep dark blue */
    --panel-wood: #2e2231;
    --panel-wood-dark: #221825;
    --gold: #dfbd83;
    --gold-dim: #977d54;
    --text-light: #e4e6eb;
    --text-blue: #94b9ff;
    --slot-bg: rgba(0,0,0,0.2);
    --slot-border: rgba(223, 189, 131, 0.3);
    --font-heading: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-body: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: radial-gradient(circle at top center, #1c203b 0%, #0a0b16 100%);
    color: var(--text-light);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background-attachment: fixed;
    padding: 30px;
}

.app-container {
    max-width: 1000px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 25px;
    margin-bottom: 10px;
    text-align: center;
}

.header-text h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--gold);
    text-shadow: 0 2px 10px rgba(223, 189, 131, 0.3);
    letter-spacing: 2px;
}

.header-text p {
    color: var(--text-blue);
    font-size: 0.95rem;
    margin-top: 5px;
}

.key-legend {
    display: flex;
    gap: 30px;
    justify-content: center;
    margin-top: 35px;
    margin-bottom: 25px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.legend-key {
    color: #fff;
    font-weight: bold;
    font-size: 1.8rem;
}
.dash {
    color: #555;
    font-size: 1.2rem;
}
.legend-box {
    width: 44px;
    height: 44px;
    border: 1px solid var(--slot-border);
    background: var(--slot-bg);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
}
.legend-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Panels */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.dota-panel {
    background: var(--panel-wood);
    border: 2px solid var(--gold-dim);
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6), inset 0 0 30px rgba(0,0,0,0.5);
    padding: 25px;
    background-image: repeating-linear-gradient(
        0deg,
        rgba(0,0,0, 0.05) 0px,
        rgba(0,0,0, 0.05) 1px,
        transparent 1px,
        transparent 15px
    );
}

.panel-title {
    font-family: var(--font-heading);
    color: var(--text-light);
    text-align: center;
    font-size: 1.2rem;
    letter-spacing: 1.5px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 15px;
}

.inventory-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.inventory-cauldron {
    height: 160px;
    filter: drop-shadow(0 0 20px rgba(138, 255, 128, 0.4));
    transform: translateY(-10px);
}

/* Inventory Grid */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(10, 55px);
    gap: 8px;
    justify-content: center;
}

.slot {
    width: 55px;
    height: 55px;
    border: 1px solid var(--slot-border);
    background: var(--slot-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.1s;
    border-radius: 4px;
}

.slot:hover {
    border-color: var(--gold);
    background: rgba(255,255,255,0.05);
}

.slot.active {
    border-color: var(--gold);
    background: rgba(223, 189, 131, 0.15);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

.slot.filled {
    background: transparent;
    border-color: transparent;
}
.slot.filled.active {
    border-color: var(--gold);
}

.slot img {
    width: 80%;
    height: 80%;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.8));
    pointer-events: none;
}

/* Clear Button */
.clear-btn {
    background: rgba(255, 85, 85, 0.05);
    border: 1px solid rgba(255, 85, 85, 0.4);
    color: #ff5555;
    padding: 10px 15px;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}
.clear-btn:hover {
    background: rgba(255, 85, 85, 0.15);
    border-color: #ff5555;
    box-shadow: 0 0 15px rgba(255, 85, 85, 0.4);
    color: #fff;
}

/* Trades */
.trades-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.trade-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.2);
}
.trade-row:nth-child(even) { background: rgba(0,0,0,0.15); }
.trade-row:nth-child(odd) { background: rgba(0,0,0,0.05); }

.trade-side {
    display: flex;
    gap: 4px;
    align-items: center;
}
.give-side { justify-content: flex-end; }
.get-side { justify-content: flex-start; }

.trade-arrow {
    width: 30px;
    height: 30px;
    background: #3b2c3a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 15px;
    color: var(--gold);
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    border: 1px solid #5a4b5d;
}

/* Interactive Candies */
.trade-candy-slot, .add-candy-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--slot-bg);
    border: 1px solid var(--slot-border);
    border-radius: 4px;
    transition: 0.2s;
}

.trade-candy-slot:hover {
    border-color: #ff5555;
    background: rgba(255,0,0,0.2);
}

.trade-candy-slot.filled {
    background: transparent;
    border-color: transparent;
}

.trade-candy-slot.filled:hover {
    border-color: #ff5555;
    background: rgba(255,0,0,0.2);
}

.trade-candy-slot img {
    width: 85%;
    height: 85%;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.6));
}

.add-candy-btn {
    border-style: dashed;
    color: var(--gold-dim);
    font-size: 1.4rem;
}
.add-candy-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(223, 189, 131, 0.1);
}

/* Target Inputs */
.target-inputs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 25px;
    min-height: 40px;
}

/* Buttons */
.calculate-btn {
    width: 100%;
    background: linear-gradient(to bottom, #2b2238, #18131f);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    padding: 15px;
    font-size: 1.1rem;
    font-family: var(--font-heading);
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 4px;
    transition: 0.2s;
    margin-bottom: 20px;
}
.calculate-btn:hover {
    background: linear-gradient(to bottom, #3b2f4a, #221b2b);
    border-color: var(--gold);
    color: #fff;
    box-shadow: 0 0 15px rgba(223, 189, 131, 0.3);
}

/* Results */
.results-container {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    padding: 15px;
    border: 1px solid rgba(255,255,255,0.05);
    min-height: 100px;
}

.placeholder-text {
    text-align: center;
    color: #888;
    font-style: italic;
    margin-top: 10px;
}

.path-step {
    background: rgba(0,0,0,0.3);
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 4px;
    border-left: 3px solid var(--gold);
}
.path-step-title {
    color: var(--gold);
    font-size: 0.85rem;
    margin-bottom: 8px;
    font-weight: bold;
}
.path-step-details {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}
.candy-mini-list {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    max-width: 150px;
}
.candy-mini-list img {
    width: 22px;
    height: 22px;
}

.error-msg {
    color: #ff5555;
    text-align: center;
    font-weight: bold;
    padding: 10px;
}

/* Popup */
.candy-popup {
    position: absolute;
    background: #1c151e;
    border: 1px solid var(--gold-dim);
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.9);
    z-index: 1000;
}
.popup-candy {
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--slot-border);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: 0.1s;
}
.popup-candy:hover {
    border-color: var(--gold);
    background: rgba(255,255,255,0.05);
}
.popup-candy img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.popup-candy-row {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--slot-border);
    border-radius: 4px;
    cursor: pointer;
    transition: 0.1s;
    margin-bottom: 4px;
}
.popup-candy-row:last-child {
    margin-bottom: 0;
}
.popup-candy-row:hover {
    border-color: var(--gold);
    background: rgba(255,255,255,0.05);
}
.popup-candy-row img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Footer */
.footer-credit {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 25px;
    color: #888;
    font-size: 0.95rem;
    line-height: 1.6;
}

.footer-credit a {
    color: var(--gold);
    text-decoration: none;
    font-weight: bold;
    transition: 0.2s;
}

.footer-credit a:hover {
    color: #fff;
    text-shadow: 0 0 5px var(--gold);
}

.tg-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.9rem;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .app-header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .header-text h1 {
        font-size: 1.8rem;
    }

    .bottom-sections {
        grid-template-columns: 1fr;
    }
    
    .inventory-wrapper {
        flex-direction: column;
        gap: 15px;
        justify-content: center;
    }
    
    .inventory-cauldron {
        height: 100px;
        transform: none;
    }
    
    .inventory-grid {
        grid-template-columns: repeat(10, 8.5vw);
        gap: 1vw;
        justify-content: center;
    }
    
    .slot {
        width: 8.5vw;
        height: 8.5vw;
    }
    
    .dota-panel {
        padding: 15px;
    }
}

/* Custom Recipes */
.custom-recipe-panel {
    margin-top: 20px;
}
.custom-recipe-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
.custom-recipe-row {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.15);
    padding: 10px 15px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.2);
    width: 100%;
    max-width: 450px;
    justify-content: space-between;
}
.custom-recipe-block {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--slot-border);
    border-radius: 4px;
    cursor: pointer;
    transition: 0.1s;
    min-height: 48px;
}
.custom-recipe-block:hover {
    border-color: var(--gold);
    background: rgba(255,255,255,0.05);
}
.dropdown-icon {
    color: var(--gold-dim);
    font-size: 1.2rem;
    margin-left: 8px;
}
.clear-popup-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 85, 85, 0.1);
    border: 1px solid rgba(255, 85, 85, 0.4);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #ff5555;
    font-weight: bold;
    transition: 0.1s;
}
.clear-popup-btn:hover {
    background: rgba(255, 85, 85, 0.3);
    border-color: #ff5555;
    transform: scale(1.1);
}
