You can get the applied custom properties only using getComputedStyle and getPropertyValue.
element.style[someProperty] and getComputedStyle(element)[someProperty] are not equivalent.
element.style gives you the property directly assigned to the element (not what is currently applied, which can be different).
And your :root { --dark-color: black; } is applied through the stylesheet and not at the element directly.
getComputedStyle returns a CSSStyleDeclaration where the values of the properties reflect the result of all applied rules. To get the correct custom property you need getComputedStyle, so you can't get rid of that.
For getComputedStyle(element).getPropertyValue(name) compared to getComputedStyle(element)[name] part.
The dot notation or array access is not possible for custom properties. That access is given by this part of the specification:
For each CSS property property that is a supported CSS property, the following partial interface applies where camel-cased attribute is obtained by running the CSS property to IDL attribute algorithm for property.
partial interface CSSStyleDeclaration {
[CEReactions] attribute [LegacyNullToEmptyString] CSSOMString
_camel_cased_attribute;
};
The camel-cased attribute attribute, on getting, must return the result of invoking getPropertyValue() with the argument being the result of running the IDL attribute to CSS property algorithm for camel-cased attribute.
And supported CSS property is specified as:
[…] The term supported CSS property* refers to a CSS property that the user agent implements, including any vendor-prefixed properties, but excluding custom properties. […]