:root {
  color-scheme: dark;
  --page: #191919;
  --panel: #10100f;
  --paper: #f4f1ea;
  --gallery-paper: #f5f3ed;
  --ink: #121211;
  --red: #d7272a;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  margin: 0;
  background: var(--page);
}

body {
  color: var(--paper);
  font-family: "Courier New", Courier, monospace;
}

a {
  color: inherit;
  text-decoration: none;
}

.random-page {
  width: min(calc(100% - 90px), 1115px);
  min-height: 100vh;
  margin: 7px auto 25px;
  padding: 9px 0 42px;
  background: var(--panel);
}

.random-header {
  text-align: center;
}

.wordmark {
  display: inline-block;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1;
}

.random-nav {
  display: flex;
  justify-content: center;
  padding: 0;
  margin: 14px 0 0;
  list-style: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.random-nav li:not(:last-child)::after {
  padding: 0 10px;
  color: var(--paper);
  content: "|";
}

.random-nav a {
  color: var(--red);
}

.random-nav .is-current,
.random-nav a:hover,
.random-nav a:focus-visible {
  color: var(--paper);
  outline: none;
}

.random-stage {
  margin-top: 59px;
  padding: 0 14px 14px;
}

.random-gallery {
  display: grid;
  grid-auto-flow: dense;
  grid-auto-rows: 19px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
}

.gallery-item {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  background: #20201e;
  cursor: zoom-in;
}

.gallery-sentinel {
  grid-column: 1 / -1;
  height: 1px;
}

.gallery-item:nth-child(12n + 1) {
  grid-column: span 6;
  grid-row: span 20;
}

.gallery-item:nth-child(12n + 2),
.gallery-item:nth-child(12n + 3) {
  grid-column: span 6;
  grid-row: span 10;
}

.gallery-item:nth-child(12n + 4),
.gallery-item:nth-child(12n + 5),
.gallery-item:nth-child(12n + 6) {
  grid-column: span 4;
  grid-row: span 13;
}

.gallery-item:nth-child(12n + 7) {
  grid-column: span 7;
  grid-row: span 22;
}

.gallery-item:nth-child(12n + 8),
.gallery-item:nth-child(12n + 9) {
  grid-column: span 5;
  grid-row: span 11;
}

.gallery-item:nth-child(12n + 10) {
  grid-column: span 3;
  grid-row: span 16;
}

.gallery-item:nth-child(12n + 11) {
  grid-column: span 4;
  grid-row: span 16;
}

.gallery-item:nth-child(12n + 12) {
  grid-column: span 5;
  grid-row: span 16;
}

.gallery-item img,
.gallery-item video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms ease, filter 400ms ease;
}

.gallery-item:nth-child(5n + 2) img,
.gallery-item:nth-child(5n + 2) video,
.gallery-item:nth-child(7n + 3) img,
.gallery-item:nth-child(7n + 3) video {
  filter: saturate(0.82) contrast(1.04);
}

.gallery-item:hover img,
.gallery-item:hover video {
  filter: saturate(1.07) contrast(1.04);
  transform: scale(1.035);
}

.gallery-item:focus-visible {
  outline: 1px solid var(--paper);
  outline-offset: 3px;
}

body.is-lightbox-open {
  overflow: hidden;
}

.random-lightbox {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  padding: 24px 76px;
  place-items: center;
  background: rgba(6, 6, 6, 0.94);
}

.random-lightbox[hidden] {
  display: none;
}

.lightbox-figure {
  display: grid;
  width: 100%;
  height: 100%;
  margin: 0;
  place-items: center;
  cursor: grab;
  touch-action: pan-y;
}

.random-lightbox.is-dragging .lightbox-figure {
  cursor: grabbing;
  user-select: none;
}

.lightbox-figure > img,
.lightbox-figure > video {
  display: block;
  max-width: min(100%, 1200px);
  max-height: calc(100vh - 48px);
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
}

.lightbox-close,
.lightbox-control {
  position: absolute;
  z-index: 1;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(244, 241, 234, 0.45);
  border-radius: 50%;
  background: rgba(24, 24, 24, 0.78);
  color: var(--paper);
  cursor: pointer;
  font: 32px/1 Arial, sans-serif;
  transition: background-color 160ms ease, color 160ms ease;
}

.lightbox-close {
  top: 18px;
  right: 20px;
  padding-bottom: 3px;
}

.lightbox-previous {
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next {
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-close:hover,
.lightbox-close:focus-visible,
.lightbox-control:hover,
.lightbox-control:focus-visible {
  background: var(--paper);
  color: #121211;
  outline: none;
}

.lightbox-counter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  margin: 0;
  color: rgba(244, 241, 234, 0.82);
  font-size: 12px;
  transform: translateX(-50%);
}

@media (max-width: 780px) {
  .random-page {
    width: 100%;
    margin: 0;
    padding-top: 31px;
  }

  .wordmark {
    font-size: 18px;
  }

  .random-nav {
    margin-top: 16px;
    font-size: 11px;
  }

  .random-stage {
    margin-top: 45px;
    padding: 0 8px 8px;
  }

  .random-gallery {
    grid-auto-rows: 26vw;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .gallery-item:nth-child(n) {
    grid-column: span 1;
    grid-row: span 1;
  }

  .gallery-item:nth-child(6n + 1),
  .gallery-item:nth-child(6n + 4) {
    grid-column: span 2;
    grid-row: span 2;
  }

  .random-lightbox {
    padding: 18px 54px;
  }

  .lightbox-close,
  .lightbox-control {
    width: 34px;
    height: 34px;
    font-size: 29px;
  }

  .lightbox-close {
    top: 12px;
    right: 12px;
  }

  .lightbox-previous {
    left: 10px;
  }

  .lightbox-next {
    right: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-item img,
  .gallery-item video {
    transition: none;
  }
}
