<div class="block"></div>

<div class="block block--gold"></div>
:root {
  --color: yellowgreen;
}

.block {
  width: 100px;
  height: 100px;
  background: var(--color);
}

.block--gold {
  // Это работает,
  // правый квадрат пожелтел
  --color: gold;
}



// Layout
BODY {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.