:root {
  --dos-font: ui-monospace, "Courier New", monospace;
  --screen-ink: #fff;
  --screen-paper: #000;
  color-scheme: dark;
  color: var(--screen-ink);
  background: var(--screen-paper);
  font-family: system-ui, sans-serif;
}

:root[data-theme="light"] {
  --screen-ink: #000;
  --screen-paper: #fff;
  color-scheme: light;
}

body {
  margin: 0;
}

.counter-page {
  box-sizing: border-box;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  place-items: center;
  min-block-size: 100vh;
  min-block-size: 100svh;
  padding: 1rem clamp(1.25rem, 5vw, 4rem);
}

.lifetime {
  display: grid;
  grid-row: 2;
  justify-items: center;
  inline-size: 100%;
}

.hourglass {
  display: block;
  inline-size: min(100%, max(24rem, 42vw), 76vh);
  inline-size: min(100%, max(24rem, 42vw), 76svh);
  block-size: auto;
  image-rendering: pixelated;
}

@media (max-width: 40rem) and (orientation: portrait) {
  .counter-page,
  .lifetime {
    grid-template-columns: minmax(0, 1fr);
  }

  .lifetime {
    inline-size: 100vw;
    overflow: clip;
  }

  .hourglass {
    inline-size: min(114vw, 76vh);
    inline-size: min(114vw, 76svh);
  }

  .hourglass.is-tilted {
    transform: scale(0.85);
  }
}

.counter-page footer {
  grid-row: 3;
  align-self: end;
}

.counter-page footer,
.footer-actions,
.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 1.25rem;
}

.footer-links,
.command,
.legal-page {
  font-family: var(--dos-font);
  font-variant-ligatures: none;
  line-height: 1.25;
}

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

a::before {
  content: "[" / "";
}

a::after {
  content: "]" / "";
}

a:hover,
a:focus-visible,
.command:enabled:hover,
.command:focus-visible {
  color: var(--screen-paper);
  background: var(--screen-ink);
}

a:focus-visible,
.command:focus-visible {
  outline: 2px solid var(--screen-ink);
  outline-offset: 4px;
}

.footer-links a,
.command,
.close-view {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
}

.command {
  appearance: none;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font-size: inherit;
  cursor: pointer;
}

.command:disabled {
  opacity: 0.6;
  cursor: wait;
}

#grain-status {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.close-view::before,
.close-view::after {
  content: none;
}

.legal-page {
  max-inline-size: 80ch;
  margin-inline: auto;
  padding: clamp(1.25rem, 5vw, 4rem);
  overflow-wrap: anywhere;
}

.legal-page h1,
.legal-page h2,
.legal-page strong {
  font: inherit;
  text-transform: uppercase;
}

.legal-page h1 {
  margin-block: 0 1lh;
}

.legal-page h2 {
  margin-block: 1lh 0;
}

.legal-page p {
  margin-block: 0 1lh;
}

.legal-page address {
  font-style: normal;
}
