<p class="viewport">Viewport height: <span class="c-viewport__height" id="vpHeight"></span>px
</p>
<div class="overlay">
  <div class="modal">
    <h2>Modal Title</h2>
    <p>Gingerbread soufflé brownie pie marzipan. Gummies pie pudding icing chocolate cake apple pie chocolate bar. Sweet marzipan powder lollipop gummi bears chupa chups jelly beans marshmallow.</p>
    <button>Okay</button>
  </div>
</div>

html {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.viewport {
  position: absolute;
  z-index: 10;
  font-size: 75%;
  padding: 5px;
  color: grey;
  background: white;
  top: 0;
  left: calc(50% - 70px);
  border-radius: 11px;
  box-shadow: 1px 1px 5px 0px rgba(0,0,0,0.25);
}

.overlay {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
}

.modal {
  max-width: 30em;
  width: 100%;
  margin: 1em auto;
  background: #fff;
  text-align: center;
  padding: 1em;
}

@media (min-height: 400px) and (min-width: 500px) {
  .modal {
    position: absolute;
    left: 50%;
    top: 2em;
    top: 50%;
    transform: translate(-50%, -50%);
  }
}