/* --- General Styles --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    margin: 0;
    padding: 20px;
    background-color: #1e2a38;
    color: #e0e0e0;
}
.container {
    max-width: 1200px;
    margin: auto;
}
header h1 {
    text-align: center;
    color: #ffc107;
    margin-bottom: 2rem;
}
section {
    background-color: #2c3e50;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
h2 {
    margin-top: 0;
    color: #ffc107;
    border-bottom: 1px solid #4a617a;
    padding-bottom: 0.5rem;
}

/* --- Main Layout --- */
.calculator-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}
.tree-panel {
    width: 100%;
    max-width: 900px;
}
.controls-panel {
    width: 100%;
    max-width: 900px;
    display: flex;
    gap: 1.5rem;
}
.controls-panel section {
    flex: 1;
    margin-bottom: 0;
}

/* --- Tree Panel --- */
#tree-background {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #273444;
    border-radius: 10px;
    border: 2px solid #4a617a;
    padding: 30px;
    box-sizing: border-box;
}
#items-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* --- Item Node Styles --- */
.item-node {
    position: absolute;
    width: 80px;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: 12px;
}
.item-image {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    cursor: help;
    display: block;
    margin-left: auto;
    margin-right: auto;
}
.item-node input {
    width: 60px;
    padding: 5px;
    border-radius: 5px;
    border: 2px solid #4a617a;
    background-color: #1e2a38;
    color: #e0e0e0;
    text-align: center;
    font-weight: bold;
    -moz-appearance: textfield;
}
.item-node input::-webkit-outer-spin-button,
.item-node input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* --- Item State Styles (Capped & Warning) --- */
.item-node.capped .item-image {
    filter: grayscale(50%);
}
.item-node.capped input {
    background-color: #ffc107;
    color: #1e2a38;
    border-color: #e0a800;
}
.item-node.warning input {
    border-color: #e74c3c;
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.7);
}


/* --- Controls Panel --- */
.controls-panel input[type="number"] {
    width: 80px;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #4a617a;
    background-color: #1e2a38;
    color: #e0e0e0;
}
#results-section strong,
#results-section span,
#goal-section strong {
    color: #ffffff;
}

/* --- XP Bar --- */
.xp-bar-container {
    width: 100%;
    background-color: #1e2a38;
    border-radius: 5px;
    height: 10px;
    margin-top: 5px;
}
#xp-bar {
    height: 100%;
    width: 0%;
    background-color: #00b894;
    border-radius: 5px;
    transition: width 0.3s ease-in-out;
}

/* --- Buttons --- */
button, .button-like-label {
    padding: 10px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
    text-align: center;
}
button:hover, .button-like-label:hover {
    background-color: #0056b3;
}
input[type="file"] {
    display: none;
}

/* ==========================================================================
   Mobile & Tablet Styles
   ========================================================================== */

/* Hide mobile list by default */
#mobile-items-container {
    display: none;
}

@media (max-width: 800px) {
    /* Swap visibility: hide tree, show list */
    .tree-panel {
        display: none;
    }
    #mobile-items-container {
        display: block;
        width: 100%;
        max-width: 900px;
    }

    /* Stack control panels vertically */
    .controls-panel {
        flex-direction: column;
    }

    /* Styles for each row in the mobile list */
    .mobile-item-row {
        display: flex;
        align-items: center;
        padding: 10px;
        background-color: #2c3e50;
        border-radius: 6px;
        margin-bottom: 8px;
        border: 2px solid transparent;
        transition: border-color 0.3s;
    }
    .mobile-item-row .item-image {
        width: 32px;
        height: 32px;
        margin-right: 15px;
        margin-bottom: 0;
    }
    .mobile-item-label {
        flex-grow: 1;
        font-weight: bold;
        color: #ffffff;
    }
    .mobile-item-row input {
        width: 60px;
        padding: 5px;
        border-radius: 5px;
        border: 2px solid #4a617a;
        background-color: #1e2a38;
        color: #e0e0e0;
        text-align: center;
        font-weight: bold;
    }

    /* State styles for the mobile list */
    .mobile-item-row.capped {
        border-color: #ffc107;
    }
    .mobile-item-row.warning {
        border-color: #e74c3c;
    }
}
