.ol-custom-overviewmap,
.ol-custom-overviewmap.ol-uncollapsible {
  bottom: auto;
  left: auto;
  right: 0;
  top: 0;
}

.ol-custom-overviewmap:not(.ol-collapsed)  {
  border: 1px solid black;
}

.ol-custom-overviewmap .ol-overviewmap-map {
  border: none;
  width: 300px;
}

.ol-custom-overviewmap .ol-overviewmap-box {
  border: 2px solid red;
}

.ol-custom-overviewmap:not(.ol-collapsed) button{
  bottom: auto;
  left: auto;
  right: 1px;
  top: 1px;
}

.ol-rotate {
  top: 170px;
  right: 0;
}

.mapcontainer {
  position: relative;
}

div.ol-custom-overviewmap,
div.ol-custom-overviewmap.ol-uncollapsible {
  bottom: auto;
  left: auto;
  right: 0;
  top: 0;
}

div.ol-custom-overviewmap:not(.ol-collapsed)  {
  border: 1px solid black;
}

div.ol-custom-overviewmap div.ol-overviewmap-map {
  border: none;
  width: 300px;
}

div.ol-custom-overviewmap div.ol-overviewmap-box {
  border: 2px solid red;
}

div.ol-custom-overviewmap:not(.ol-collapsed) button{
  bottom: auto;
  left: auto;
  right: 1px;
  top: 1px;
}

div.ol-rotate {
  top: 170px;
  right: 0;
}

Update CSS to work outside the examples template
Update CSS to work outside the examples template

The existing CSS doesn't work in CodeSandBox etc where ol/ol.css is imported in the JavaScript