.upgrade-line {
    font-family: monospace;
    color: lime;
    font-size: 13px;
    margin-bottom: 0.5rem;
}

#worker_coins {
    .auto-upgrade {
        text-transform: none;
        text-align: end;
        width: 160px;
        border-bottom: 0;
        color: #00ff66;
        text-decoration: none;
        font-weight: bold;
    }

    .auto-upgrade:hover {
        background-color: rgba(0, 255, 100, 0.1);
        cursor: pointer;
    }
}

.upgrade-terminal {
    .big-button {
        margin-left: 0;
        margin-bottom: 0;
    }
    padding-bottom: 0;
}

.upgrade-button {
    color: black;
    font-family: monospace;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}

:root {
    --purchaseable-color: #4CAF50;
    --purchaseable-color-hover: #5CBF60;
    --unavailable-color: #666;
}

.upgrade-buttons-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: flex-start;
}

/* Target the forms created by button_to */
.upgrade-buttons-group form {
    flex: 1;
    min-width: 0;
    max-width: 150px;
    display: flex;
}

.upgrade-buttons-group .upgrade-button {
    background: var(--purchaseable-color);
    border: 1px solid #45a049;
    border-radius: 4px;
    color: white;
    font-family: monospace;
    font-size: 12px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upgrade-buttons-group .upgrade-button:hover:not([disabled]):not(.unavailable) {
    background: var(--purchaseable-color-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.upgrade-buttons-group .upgrade-button[disabled],
.upgrade-buttons-group .upgrade-button.insufficient-funds,
.upgrade-buttons-group .upgrade-button.unavailable {
    background: var(--unavailable-color);
    border-color: #555;
    color: #DDD;
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.upgrade-buttons-group .upgrade-button[disabled]:hover,
.upgrade-buttons-group .upgrade-button.insufficient-funds:hover,
.upgrade-buttons-group .upgrade-button.unavailable:hover {
    transform: none;
    box-shadow: none;
}

/* Sortable upgrades styles */
.sortable-upgrades-hint {
    color: #888;
    font-family: monospace;
    font-size: 11px;
    margin-bottom: 1rem;
    text-align: center;
    padding: 0.5rem;
    background: rgba(0, 255, 0, 0.05);
    border: 1px dashed #333;
    border-radius: 4px;
}

.upgrade-item {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #333;
    border-radius: 6px;
    transition: all 0.2s ease;
    position: relative;
    /* Removed touch-action: none to allow scrolling outside drag handle */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none; /* Prevents text selection on mobile */
}

.upgrade-item:hover {
    background: rgba(0, 255, 0, 0.05);
    border-color: #555;
}

.upgrade-item.drag-over {
    background: rgba(0, 255, 0, 0.1);
    border-color: lime;
    transform: scale(1.02);
}

/* SortableJS specific classes */
.upgrade-item.sortable-ghost {
    opacity: 0.4;
    background: rgba(0, 255, 0, 0.1);
    border-color: lime;
    transform: scale(0.98);
}

.upgrade-item.sortable-chosen {
    background: rgba(0, 255, 0, 0.05);
    border-color: #555;
}

.upgrade-item.sortable-drag {
    opacity: 0.8;
    transform: rotate(2deg);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.drag-handle {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 16px;
    height: 16px;
    cursor: move;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition: all 0.2s ease;
    z-index: 10;
    touch-action: none; /* Prevents scrolling only when touching the drag handle */
}

.drag-handle:hover {
    color: lime;
    background: rgba(0, 255, 0, 0.1);
}

.drag-handle svg {
    width: 12px;
    height: 12px;
}

.upgrade-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    margin-left: 20px; /* Make room for drag handle */
    font-family: monospace;
    color: lime;
}

.upgrade-name {
    font-weight: bold;
    margin-right: 0.5rem;
}

.upgrade-value {
    color: #ccc;
    margin-left: auto;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .upgrade-buttons-group {
        flex-direction: column;
        align-items: stretch;
    }

    .upgrade-buttons-group form {
        max-width: none;
        width: 100%;
    }

    .upgrade-buttons-group .upgrade-button {
        max-width: none;
        width: 100%;
    }

    .upgrade-header {
        flex-wrap: wrap;
    }

    .upgrade-value {
        margin-left: 0;
        margin-top: 0.25rem;
        flex-basis: 100%;
    }

    /* Enhanced mobile drag and drop */
    .upgrade-item {
        padding: 1rem; /* Larger touch target */
        margin-bottom: 1.25rem; /* More space between items */
    }

    .drag-handle {
        top: 6px;
        left: 6px;
        width: 20px;
        height: 20px;
    }

    .drag-handle svg {
        width: 14px;
        height: 14px;
    }

    .upgrade-header {
        margin-left: 28px; /* More room for larger mobile drag handle */
    }

    .upgrade-item.dragging {
        transform: rotate(1deg) scale(1.02); /* Less rotation on mobile */
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4); /* More prominent shadow */
    }

    .upgrade-item.drag-over {
        transform: scale(1.03); /* Slightly more scale for better feedback */
        border-color: lime;
        background: rgba(0, 255, 0, 0.15); /* More visible feedback */
    }

    .sortable-upgrades-hint {
        font-size: 14px; /* Larger hint text on mobile */
        margin-bottom: 1.5rem;
    }
}
