:root {
  color-scheme: dark;
  --black: #000000;
  --white: #ffffff;
  --red: #ff0000;
  --green: #00ff00;
  --yellow: #ffff00;
  --blue: #0000ff;
  --cyan: #00ffff;
  --magenta: #ff00ff;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  background: #050505;
  color: var(--white);
  font-family: "Courier New", Consolas, monospace;
  letter-spacing: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

.seo-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.noscript-summary {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  align-content: center;
  gap: 1rem;
  padding: 2rem;
  background: #000;
  color: #fff;
  font: 20px/1.4 "Courier New", Consolas, monospace;
}

.set {
  width: min(100vw, calc(100svh * 4 / 3), 960px);
  padding: 0;
}

@supports (height: 100dvh) {
  body {
    min-height: 100dvh;
  }

  .set {
    width: min(100vw, calc(100dvh * 4 / 3), 960px);
  }
}

.screen {
  position: relative;
  overflow: hidden;
  min-height: auto;
  max-height: none;
  margin: 0 auto;
  width: 100%;
  padding: 0;
  background: var(--black);
  border: 0;
  box-shadow: 0 0 0 1px #000;
  image-rendering: pixelated;
}

.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(#ffffff0a 50%, transparent 50%) 0 0 / 100% 2px,
    linear-gradient(90deg, transparent 0 18%, #0003 18% 20%, transparent 20% 52%, #fff1 52% 54%, transparent 54% 100%) 0 0 / 12px 100%,
    radial-gradient(ellipse at center, transparent 56%, #0005 84%, #000b 100%);
  mix-blend-mode: screen;
  opacity: .5;
  z-index: 3;
}

.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 18px #000;
  z-index: 4;
}

.command,
.page {
  position: relative;
  z-index: 1;
}

.teletext-viewport {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  background: var(--black);
}

.teletext-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: var(--black);
}

.page {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: repeat(24, 1fr);
  width: 100%;
  height: 100%;
  background: var(--black);
  border: 0;
  overflow: hidden;
  font-family: "Courier New", Consolas, monospace;
  font-size: clamp(10px, 2.34vw, 29px);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 1px currentColor;
  opacity: 0;
}

.tt-row {
  display: grid;
  grid-template-columns: repeat(40, 1fr);
  height: 100%;
  white-space: pre;
  overflow: hidden;
  letter-spacing: 0;
}

.tt-row[role="button"] {
  cursor: pointer;
}

.tt-row[role="button"]:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: -3px;
}

.tt-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 100%;
  transform: scaleX(1.16);
  transform-origin: center;
}

.fg-k { color: var(--black); }
.fg-w { color: var(--white); }
.fg-r { color: var(--red); }
.fg-g { color: var(--green); }
.fg-y { color: var(--yellow); }
.fg-b { color: var(--blue); }
.fg-c { color: var(--cyan); }
.fg-m { color: var(--magenta); }

.bg-k { background: var(--black); }
.bg-w { background: var(--white); }
.bg-r { background: var(--red); }
.bg-g { background: var(--green); }
.bg-y { background: var(--yellow); }
.bg-b { background: var(--blue); }
.bg-c { background: var(--cyan); }
.bg-m { background: var(--magenta); }

.flash {
  animation: none;
}

.command {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 720px) {
  .set {
    width: min(100vw, calc(100svh * 4 / 3));
    padding: 0;
  }

  .screen {
    width: 100%;
    min-height: auto;
    max-height: none;
    aspect-ratio: auto;
    padding: 0;
  }

  @supports (height: 100dvh) {
    .set {
      width: min(100vw, calc(100dvh * 4 / 3));
    }
  }

  .page {
    font-size: clamp(7px, 3.22vw, 13px);
  }

  .tt-cell {
    transform: scaleX(1);
  }
}
