:root {
  color-scheme: dark;
  --paper: #c4beb2;
  --blood: #d24a4a;
  --dim: #8d877f;
  --black: #000;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--black);
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  background: var(--black);
  color: var(--paper);
  font-family: "Courier New", Courier, monospace;
  letter-spacing: 0.04em;
  overscroll-behavior: none;
}

button,
input,
a {
  font-family: inherit;
  letter-spacing: inherit;
  touch-action: manipulation;
}

button,
input {
  background: transparent;
  color: inherit;
  border: none;
  border-radius: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 1px dashed #6a3030;
  outline-offset: 4px;
}

::selection {
  background: #4a1010;
  color: #f0ebe3;
}

#noise {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  image-rendering: pixelated;
}

#scanlines {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.32) 0 1px,
    transparent 1px 3px
  );
  opacity: 0;
}

body.on #scanlines {
  opacity: 0.45;
}

body.live #scanlines {
  animation: scan 9s linear infinite;
}

#vignette {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.78) 100%);
  opacity: 0;
}

body.on #vignette {
  opacity: 1;
}

#flicker-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background: #000;
  opacity: 0;
}

body.live.flicker #flicker-layer {
  animation: flickoverlay 0.28s linear;
}

body.live.intense #flicker-layer {
  animation: intenseflick 1.5s linear forwards;
}

body.live.intense #tears {
  opacity: 0.8;
}

body.live.intense #stage {
  animation: roll 0.45s linear infinite;
}

body.live.intense .line,
body.live.intense .word {
  text-shadow: 3px 0 rgba(140, 0, 0, 0.9), -3px 0 rgba(0, 80, 90, 0.8);
}

#tears {
  position: fixed;
  inset: 0;
  z-index: 66;
  pointer-events: none;
  opacity: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 6px,
    rgba(255, 255, 255, 0.045) 6px 7px,
    transparent 7px 11px,
    rgba(0, 0, 0, 0.55) 11px 16px,
    rgba(120, 20, 20, 0.16) 16px 17px
  );
  background-size: 100% 140px;
}

#tears.on {
  animation: tearflash 0.18s steps(2, end);
}

#figure {
  position: fixed;
  z-index: 42;
  width: min(46vw, 220px);
  height: min(70vh, 420px);
  opacity: 0;
  pointer-events: none;
}

#figure.show {
  opacity: 1;
}

#figure::before {
  content: "";
  position: absolute;
  inset: -14%;
  background: radial-gradient(circle at 50% 38%, rgba(120, 120, 120, 0.38), rgba(0, 0, 0, 0) 68%);
  z-index: -1;
}

#figure svg,
#closeup svg,
.silhouette svg {
  width: 100%;
  height: 100%;
  display: block;
}

#figure.flip svg {
  transform: scaleX(-1);
}

#closeup {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  background: transparent;
}

#closeup.show {
  opacity: 1;
  background: radial-gradient(circle at 50% 42%, rgba(72, 72, 72, 0.55), rgba(0, 0, 0, 0.15) 58%, rgba(0, 0, 0, 0.82) 100%);
}

#closeup svg {
  width: auto;
  height: 108vh;
  filter: blur(0.4px);
}

#stage {
  position: relative;
  z-index: 10;
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(7vh, env(safe-area-inset-top)) max(6vw, env(safe-area-inset-right))
    max(12vh, calc(env(safe-area-inset-bottom) + 3.2rem)) max(6vw, env(safe-area-inset-left));
  scrollbar-width: thin;
  scrollbar-color: #3a1515 #000;
}

#stage::-webkit-scrollbar {
  width: 8px;
}

#stage::-webkit-scrollbar-thumb {
  background: #3a1515;
}

#stage::-webkit-scrollbar-track {
  background: #000;
}

body.blackout #noise,
body.blackout #scanlines,
body.blackout #vignette,
body.blackout #figure,
body.blackout #tears,
body.blackout #closeup,
body.blackout #idle {
  opacity: 0 !important;
}

body.blackout #stage {
  visibility: hidden;
  opacity: 0 !important;
  pointer-events: none;
}

body.live.power-on #noise {
  animation: poweron 0.5s ease-out;
}

.screen {
  width: min(100%, 42rem);
  margin: 0 auto;
  min-height: 62vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.screen.center {
  text-align: center;
  align-items: center;
}

.copy,
.lines {
  width: 100%;
}

.line {
  margin: 0.38rem 0;
  line-height: 1.65;
  letter-spacing: 0.06em;
  overflow-wrap: break-word;
}

body.live .line {
  text-shadow: 0 0 8px rgba(120, 20, 20, 0.28);
}

body.see-you-on #stage .line,
.line.vanished {
  opacity: 0;
}

.see-you,
.ghost-line {
  position: fixed;
  z-index: 76;
  margin: 0;
  max-width: 86vw;
  color: var(--paper);
  letter-spacing: 0.14em;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(120, 0, 0, 0.45);
}

.see-you {
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
}

.linkish,
.recording,
.recording:visited {
  color: var(--blood);
  text-decoration: none;
  letter-spacing: 0.14em;
  margin-top: 1.7rem;
}

.linkish {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.2rem;
  background: none;
  border: none;
}

body.live .linkish,
body.live .recording {
  animation: textflicker 3.4s infinite;
}

.linkish:hover,
.linkish:focus-visible,
.recording:hover,
.recording:focus-visible {
  color: #f0d2d2;
  animation: none;
}

.tv,
.player {
  display: block;
  width: min(100%, 440px);
  margin: 1.15rem auto;
  background: #050505;
  border: 12px solid #121212;
  box-shadow: 0 0 0 1px #2a1212;
  text-align: left;
}

.tube {
  position: relative;
  height: min(34vh, 250px);
  min-height: 150px;
  background: #1a1a1a;
  overflow: hidden;
}

.player .tube {
  height: min(38vh, 280px);
}

.snow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  image-rendering: pixelated;
  opacity: 0.8;
}

.tube::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.38) 0 1px,
    transparent 1px 3px
  );
}

.tube::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  box-shadow: inset 0 0 36px 10px rgba(0, 0, 0, 0.65);
}

.silhouette {
  position: absolute;
  left: 50%;
  bottom: 0;
  height: 96%;
  z-index: 2;
  transform: translateX(-50%);
  pointer-events: none;
}

.silhouette .shift {
  height: 100%;
}

.silhouette svg {
  height: 100%;
  width: auto;
  filter: blur(0.5px);
}

body.live .tv .silhouette {
  animation: sway 8s ease-in-out infinite;
}

.tv-label,
.player-bar {
  color: #7a3030;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
}

.tv-label {
  text-align: center;
  padding: 0.4rem 0 0.2rem;
}

.player-bar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid #2a1212;
}

.rec-dot {
  color: #a32020;
  margin-right: 0.35rem;
}

body.live .rec-dot {
  animation: blink 1.6s steps(1, end) infinite;
}

.track {
  height: 10px;
  border-top: 1px solid #2a1212;
  background: repeating-linear-gradient(90deg, #140606 0 10px, #6a1818 10px 11px, #140606 11px 18px);
  background-size: 48px 10px;
}

body.live .track {
  animation: crawl 0.8s linear infinite;
}

.word {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 1rem;
  text-align: center;
  color: #d9d3c7;
  letter-spacing: 0.12em;
  text-shadow: 2px 0 rgba(120, 0, 0, 0.8), -2px 0 rgba(0, 60, 70, 0.7);
  z-index: 6;
}

body.live .word.pop {
  animation: wordpop 0.15s linear;
}

.file {
  border-top: 1px solid #4a1818;
  border-left: 1px solid #2a1010;
  border-right: 1px solid #3a1414;
  border-bottom: 1px solid #5a2020;
  padding: 1rem 1rem 1.15rem;
  background: rgba(18, 0, 0, 0.35);
  margin-bottom: 1.15rem;
}

.file .line {
  color: #b7b1a6;
}

.meta {
  color: #7a4038;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  margin: 0.15rem 0;
}

.file-rule {
  height: 1px;
  background: #3a1515;
  margin: 0.7rem 0 0.9rem;
}

.initial {
  color: #e25a5a;
  font-weight: 700;
}

.screen.center .answer-form {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.field {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1.15rem;
}

.prompt {
  color: var(--blood);
}

.answer-form input {
  width: min(18rem, 72vw);
  min-height: 44px;
  border-bottom: 1px solid #6a2424;
  padding: 0.2rem 0.1rem;
  text-align: left;
  color: var(--paper);
  font-size: max(16px, 1em);
  caret-color: var(--blood);
  caret-shape: block;
}

.pending {
  visibility: hidden;
}

.feedback {
  color: var(--blood);
  margin-top: 1rem;
}

.feedback p {
  margin: 0.2rem 0;
}

.hint {
  min-height: 1.5em;
  margin: 0.8rem 0 0;
  color: #8a3a3a;
  letter-spacing: 0.08em;
  opacity: 0;
  transition: opacity 2.6s linear;
}

.hint.on {
  opacity: 1;
}

body.calm .hint {
  transition: none;
}

#idle {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: max(4.4rem, calc(env(safe-area-inset-bottom) + 3.4rem));
  z-index: 76;
  margin: 0;
  text-align: center;
  color: #8a3a3a;
  letter-spacing: 0.12em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 4s linear;
}

#idle.on {
  opacity: 1;
}

body.calm #idle {
  transition: none;
}

.osd {
  position: fixed;
  z-index: 90;
  bottom: max(8px, env(safe-area-inset-bottom));
  padding: 8px;
  color: var(--dim);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  background: none;
  border: none;
}

#calm {
  left: max(8px, env(safe-area-inset-left));
}

#mute {
  right: max(8px, env(safe-area-inset-right));
}

.osd:hover,
.osd:focus-visible {
  color: #d7d0c4;
}

.osd.is-on {
  color: var(--blood);
}

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

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 2rem;
  text-align: center;
  background: #000;
  color: var(--paper);
  letter-spacing: 0.12em;
}

@keyframes scan {
  from { background-position: 0 0; }
  to { background-position: 0 12px; }
}

@keyframes poweron {
  0% { transform: scaleY(0.004); filter: brightness(1.35); }
  40% { transform: scaleY(0.012); filter: brightness(1.15); }
  100% { transform: scaleY(1); filter: none; }
}

@keyframes flickoverlay {
  0%, 100% { opacity: 0; }
  20% { opacity: 0.55; }
  35% { opacity: 0.08; }
  62% { opacity: 0.72; }
  78% { opacity: 0.12; }
}

@keyframes intenseflick {
  0% { opacity: 0; }
  8% { opacity: 0.55; }
  14% { opacity: 0; }
  40% { opacity: 0.18; }
  48% { opacity: 0.68; }
  58% { opacity: 0; }
  78% { opacity: 0.42; }
  88%, 100% { opacity: 0; }
}

@keyframes tearflash {
  0% { opacity: 0.85; transform: translateY(0); }
  50% { opacity: 0.45; transform: translateY(7px); }
  100% { opacity: 0; }
}

@keyframes roll {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-5px, 1px); }
  50% { transform: translate(4px, -2px); }
  75% { transform: translate(-2px, 2px); }
  100% { transform: translate(0, 0); }
}

@keyframes textflicker {
  0%, 18%, 22%, 46%, 49%, 100% { opacity: 1; }
  20% { opacity: 0.25; }
  47% { opacity: 0.45; }
  80% { opacity: 0.8; }
}

@keyframes sway {
  0%, 100% { transform: translateX(-50%); }
  50% { transform: translateX(calc(-50% + 7px)); }
}

@keyframes blink {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: 0.15; }
}

@keyframes crawl {
  from { background-position: 0 0; }
  to { background-position: 48px 0; }
}

@keyframes wordpop {
  0% { transform: translateX(-6px); opacity: 0.35; }
  100% { transform: none; opacity: 1; }
}

@media (max-width: 640px) {
  html { font-size: 16px; }
  .tv,
  .player { border-width: 8px; }
  .tube,
  .player .tube {
    height: 28vh;
    min-height: 132px;
  }
}

@media (max-height: 700px) {
  .screen { min-height: 0; }
  .tube,
  .player .tube {
    height: 24vh;
    min-height: 112px;
  }
}
