/* --- Base Styles --- */
html, body {
    margin: 0;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}
body {
    font-family: 'Oswald';
    background-color: #1c1c1c;
    color: #e8e8e8;
    font-size: 23px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100vh;
}
#topGradientBar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, .9) 0%, rgba(0, 0, 0, 0) 100%);
    z-index: 1000;
    pointer-events: none;
}
.layer-group {
    background: rgba(58, 58, 58, 0.8);
    padding: 10px 15px;
    border-radius: 12px;
    margin: 0 auto 15px auto;
    width: 98%;
    color: #e8e8e8;
    box-sizing: border-box;
}
.layer-group:last-child { margin-bottom: 5px; }
.layer-control {
    position: relative;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 5px 5px 5px;
    border-radius: 10px;
    border: 1px solid #999;
    font-size: 0.7em;
    color: #fff;
    flex: 1;
    min-width: 320px;
    max-width: 450px;
    height: fit-content;
}
#top-logo {
    display: block;
    width: 250px;
    margin-bottom: 10px;
    z-index: 1001;
}
#top-logo img { width: 100%; height: auto; }
.page-title {
    font-size: 1.5em;
    color: #e8e8e8;
    margin: 0 0 20px 0;
    font-weight: 400;
    letter-spacing: 1px;
}
#calculator-container {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1400px;
    align-items: flex-start;
}
.layer-group h3 { font-size: 1.2em; color: #f1c40f; margin: 0; }
.title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #000; 
}
#updatePricesButton {
    font-size: 0.7em;
    background-color: #f1c40f;
    color: black;
    padding: 2px 8px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    flex-shrink: 0;
}
.price-section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}
.price-section-header h4 { margin: 0; font-size: 1.1em; color: #fff; }
.price-line {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 15px;
}
.price-line .price-display { font-size: 1.2em; font-weight: bold; margin: 0; white-space: nowrap; }
.price-line .price-change-display { font-size: 1em; margin: 0; }
.price-change-display .price-change.positive { color: #4caf50; }
.price-change-display .price-change.negative { color: #f44336; }
.price-section .price-per-gram { font-size: 0.8em; color: #bbb; margin: 0 0 4px 0; }
.last-updated { font-size: 0.8em; color: #aaa; margin: 0 10px; text-align: center; white-space: nowrap; }
.chart-container { min-height: 150px; margin-top: 10px; }
.settings-inputs { display: flex; gap: 10px; justify-content: space-around; align-items: center; font-size: 0.85em; }
.section-divider {
    height: 1px;
    background-color: #000; 
    margin: 15px 5px;
    border: none;
}
.layer-group input[type="number"] {
    padding: 4px;
    border-radius: 4px;
    border: 1px solid #555;
    background-color: #2c2c2c;
    color: #e8e8e8;
    font-family: 'Oswald', sans-serif;
    font-size: 0.9em;
    text-align: center;
}
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* --- DESKTOP LAYOUT --- */
.purity-input, .coin-input { background: rgba(45, 45, 45, 0.7); padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; border: 1px solid #444; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.purity-input label, .coin-input label { font-size: 1em; font-weight: bold; color: #fff; line-height: 1.2; }
.purity-input label small, .coin-input label small { font-weight: normal; color: #bbb; font-size: 0.8em; margin-left: 5px; display: inline-block; }
.controls-wrapper { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.input-group { display: flex; align-items: center; gap: 5px; font-size: 0.9em; }
.purity-input .input-group input[type="number"] { width: 45px; }
.coin-input .input-group input[type="number"] { width: 45px; }
.placer-input .controls-wrapper { gap: 15px; }
.value-group { display: flex; flex-direction: column; align-items: flex-end; font-size: 0.9em; line-height: 1.1; }
.value-group strong { color: #f1c40f; font-size: 1.1em; }
.total-value { text-align: right; font-size: 1.1em; margin-top: 15px; font-weight: bold; }
.total-value span { color: #4caf50; }
.mobile-total { display: none; }

/* --- MOBILE RESPONSIVE STYLES --- */
@media screen and (max-width: 1024px) {
    #top-logo { position: relative; top: 0; left: 0; transform: none; width: 180px; margin-top: 0; }
    body { padding: 10px; font-size: 17px; } /* Lowered base font for mobile fit */
    .page-title { font-size: 1.2em; margin-bottom: 12px; }
    #calculator-container { flex-direction: column; width: 100%; max-width: 500px; gap: 10px; }
    .layer-control { width: 100%; max-width: none; font-size: 0.75em; }
    .chart-container { display: none; }
    .desktop-total { display: none; }
    .mobile-total { display: block; order: -1; text-align: center; margin: 0 0 10px 0; padding-bottom: 10px; border-bottom: 1px solid #000; font-size: 1.2em; }
    
    /* Ensure rows don't hide labels or values */
    .purity-input, .coin-input { 
        display: flex; 
        flex-direction: column; 
        align-items: stretch; 
        padding: 10px; 
    }
    .purity-input label, .coin-input label { 
        width: 100%; 
        white-space: normal; /* Allows price/gram to wrap if needed */
        margin-bottom: 8px;
        text-align: left;
    }
    .controls-wrapper { 
        width: 100%;
        justify-content: space-between; /* Input on left, Payout on right */
        gap: 5px;
    }
    .value-group { 
        flex-direction: row; 
        align-items: center; 
        gap: 5px;
    }
    .value-group span { 
        display: inline; /* Restore "Payout:" text on mobile */
        color: #bbb;
    }
    .value-group strong { font-size: 1.1em; }
    .layer-group input[type="number"] { width: 50px; padding: 6px; }

    /* Specific fix for Placer Gold row */
    .placer-input .controls-wrapper {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }
    .placer-input .value-group {
        width: 100%;
        justify-content: flex-end;
        border-top: 1px solid #444;
        padding-top: 5px;
        margin-top: 5px;
    }
}