/* Grow with the window while the 2:1 canvas still fits on screen. */
.nw-header,
.nw {
  max-width: max(64rem, min(100%, calc((100vh - 9rem) * 2 + 2rem)));
}

.nw {
  margin: 0 auto;
  padding: 0 1rem 2rem;
  -webkit-user-select: none;
  user-select: none;
}

.nw-stage {
  position: relative;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}

.nw-stage canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1000 / 500;
  touch-action: manipulation;
}

/* Fullscreen: letterbox the canvas at its aspect ratio. */
.nw-stage:fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
}

.nw-stage:fullscreen canvas {
  width: min(100vw, 200vh);
}

.nw-hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.nw-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
  text-align: center;
  overflow-y: auto;
}

.nw-overlay.open {
  display: flex;
}

.nw-overlay h2 {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  margin: 0 0 0.25rem;
}

.nw-overlay p {
  margin: 0.25rem 0 0.75rem;
  color: #e7e5e4;
}

.nw-overlay .row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.nw-overlay button {
  font: inherit;
  padding: 0.5rem 1.1rem;
  font-weight: 600;
  background: #fff;
  color: #1c1917;
  border: 0;
  border-radius: 0.5rem;
  cursor: pointer;
}

.nw-overlay button.primary {
  background: var(--accent);
  color: #fff;
}

.nw-overlay .help {
  font-size: 0.85rem;
  color: #d6d3d1;
}

/* margin: auto centres the card but still lets a tall one scroll from the top. */
.nw-overlay > div {
  max-width: 40rem;
  margin: auto;
}

.nw-overlay .row.settings {
  margin-top: 0.75rem;
}

.nw-overlay button.small {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgb(255 255 255 / 0.15);
  color: #fff;
}

.nw-overlay button.small:hover {
  background: rgb(255 255 255 / 0.28);
}

/* End-of-run numbers. */
.nw-overlay .stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0.5rem auto 0.75rem;
  max-width: 30rem;
}

.nw-overlay .stats div {
  padding: 0.35rem 0.25rem;
  border-radius: 0.5rem;
  background: rgb(255 255 255 / 0.08);
}

.nw-overlay .stats b {
  display: block;
  font-size: 1.15rem;
  color: #fde68a;
}

.nw-overlay .stats span {
  font-size: 0.7rem;
  color: #d6d3d1;
}

.nw-overlay .memorial {
  font-size: 0.8rem;
  font-style: italic;
  color: #d6d3d1;
}

.nw-overlay .memorial span {
  color: #a8a29e;
}

/* The ending lets the dawn and the helicopter show through. */
.nw-overlay.ending > div {
  margin-bottom: 0;
}

.nw-overlay.ending {
  background: linear-gradient(rgb(0 0 0 / 0), rgb(0 0 0 / 0.35) 35%, rgb(0 0 0 / 0.75));
}

@media (max-width: 40rem) {
  .nw-overlay {
    padding: 0.5rem;
    font-size: 0.8rem;
  }

  .nw-overlay p {
    margin: 0.15rem 0 0.4rem;
  }

  .nw-overlay .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
