:root {
  --teletext-green: #0f0;
  --teletext-blue: #00f;
  --bar-height: 40px;
  --control-height: calc(var(--bar-height) - 8px);
  --control-border: 2px;
  --control-inner-height: calc(var(--control-height) - (var(--control-border) * 2));
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: #000;
  color: #fff;
  font-family: "VT323", monospace;
  font-size: clamp(22px, 2.2vw, 30px);
  text-shadow: 0 0 3px #fff, 0 0 8px #1a1a1a;
}

body::before {
  content: "";
  position: fixed;
  pointer-events: none;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  opacity: 0.16;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.4) 2.5px,
    rgba(0, 0, 0, 0.55) 4px
  );
  mix-blend-mode: multiply;
}

.screen,
.screen-header,
.brand-bar,
.content-box {
  animation: crt-flicker 1.1s infinite steps(2);
}

@keyframes crt-flicker {
  0% {
    opacity: 1;
  }
  99% {
    opacity: 0.98;
  }
  100% {
    opacity: 1;
  }
}

.screen {
  width: 100%;
  margin: 0;
  padding: 8px 12px 4px 12px;
  height: 100dvh;
  min-height: 100vh;
  max-height: 100dvh;
  box-sizing: border-box;
  background: #000;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.screen-header {
  display: flex;
  align-items: center;
  background: var(--teletext-blue);
  padding: 0 16px;
  margin: 0 0 6px;
  height: var(--bar-height);
  box-sizing: border-box;
  flex: 0 0 auto;
  border-bottom: 2px double #fff;
  border-radius: 0;
  letter-spacing: 2px;
  column-gap: 12px;
}

.screen-header > * {
  display: none;
}

.brand-bar {
  background: #f00;
  height: var(--bar-height);
  margin: 0 0 6px;
  border-bottom: 2px double #fff;
  box-sizing: border-box;
}

.channel-label,
.screen-title {
  color: #fff;
  font-family: inherit;
  text-shadow: 0 0 2px var(--teletext-blue), 0 0 8px #fff;
  font-size: 1.15em;
  display: flex;
  align-items: center;
  height: auto;
  line-height: 1;
}

.channel-label {
  font-size: 1.15em;
  text-align: left;
  flex: 1 1 0;
}

.screen-title {
  text-align: center;
  font-size: 1.65em;
  justify-content: center;
  flex: 1 1 0;
}

.header-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  height: 100%;
  align-self: center;
  flex: 1 1 0;
  justify-content: flex-end;
}

.nav-btn:hover,
.go-btn:hover {
  background: var(--teletext-green);
  color: #000;
}

.nav-btn {
  background: #000;
  color: #fff;
  border: 2px double var(--teletext-green);
  font-family: inherit;
  font-size: 1em;
  padding: 0 8px;
  border-radius: 0;
  cursor: pointer;
  text-shadow: 0 0 4px var(--teletext-green), 0 0 2px #fff2;
  height: var(--control-height);
  min-height: var(--control-height);
  line-height: var(--control-inner-height);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
  align-self: center;
}

.nav-link {
  min-width: var(--control-height);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.go-btn {
  background: #000;
  color: #fff;
  font-family: inherit;
  font-size: 1em;
  width: 26px;
  cursor: pointer;
  box-sizing: border-box;
  outline: none;
  height: var(--control-height);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  line-height: var(--control-inner-height);
  align-self: center;
}

.search-container {
  display: inline-flex;
  border: 2px double var(--teletext-green);
  border-radius: 0;
  overflow: hidden;
  text-shadow: none;
  height: var(--control-height);
  align-items: center;
  background: #000;
  padding: 0;
  box-sizing: border-box;
  align-self: center;
}

.search-container input {
  width: 72px;
  background: #000;
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 1em;
  text-align: center;
  box-sizing: border-box;
  outline: none;
  height: var(--control-inner-height);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  line-height: var(--control-inner-height);
}

.content-area {
  flex: 1 1 auto;
  display: flex;
  margin: 0;
  min-height: 0;
  overflow: hidden;
}

.content-box {
  flex: 1;
  border: 2px double var(--teletext-green);
  margin: 8px 0 4px 0;
  background: #000;
  box-sizing: border-box;
  overflow: hidden;
  border-radius: 0;
  font-family: inherit;
  font-size: 1em;
  padding: 6px 28px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 0;
}

.teletext {
  margin: 0;
  white-space: pre;
  font-family: inherit;
  font-size: 1em;
  line-height: 1.1em;
  height: 100%;
  overflow: hidden;
  width: 100%;
  letter-spacing: 0;
  font-variant-ligatures: none;
  box-sizing: border-box;
}

.mobile-only {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.4em;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 3px #fff, 0 0 8px #1a1a1a;
}

@media (max-width: 800px) {
  .screen-header {
    gap: 6px;
  }
  .screen-title {
    font-size: 1.25em;
  }
  .search-container input {
    width: 54px;
  }
  .content-box {
    margin: 3px 3px;
  }
}

@media (max-width: 640px) {
  :root {
    --bar-height: 30px;
    --control-height: 18px;
  }
  body {
    font-size: clamp(16px, 3.8vw, 21px);
  }
  .screen {
    padding: 0;
  }
  .screen-header,
  .brand-bar {
    display: none;
  }
  .teletext {
    display: none;
  }
  .mobile-only {
    display: flex;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100svh;
    align-items: center;
    justify-content: center;
    background: #000;
    z-index: 2;
  }
}
