* { margin: 0; padding: 0; }
:root {
  --mono: "Noto Sans Mono", "MS Gothic", "Hiragino Kaku Gothic ProN", "Yu Gothic", monospace;
  --crt-green: rgb(198, 248, 220);
}
html, body { overflow: hidden; background: #060604; width: 100%; height: 100%; }
canvas { display: block; background: #060604; }
#noise {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
  opacity: 0.09;
  mix-blend-mode: screen;
  background-repeat: repeat;
}
@media (max-width: 600px) {
  #noise { opacity: 0.07; }
}

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

/* ═══════════════════════════════════════════════════════════════
   PILL SELECTION OVERLAY
   ═══════════════════════════════════════════════════════════════ */
#pill-container {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 50%;
  display: flex;
  gap: 80px;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease-in;
}
#pill-container.visible {
  opacity: 1;
}
#pill-container.visible .pill {
  pointer-events: auto;
}
#pill-container.washing {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease-out;
}

.pill {
  width: 60px;
  height: 60px;
  cursor: pointer;
  image-rendering: auto;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.6));
  transition: transform 0.01s ease-out, filter 3.00s ease-out;
  user-select: none;
  -webkit-user-drag: none;
}
.pill:hover {
  transform: scale(1.50);
}
.pill.red:hover {
  filter: drop-shadow(0 0 7px rgba(255, 60, 60, 1.0));
}
.pill.blue:hover {
  filter: drop-shadow(0 0 7px rgba(60, 140, 255, 1.0));
}
.pill:active {
  transform: scale(0.95);
}

#terminal-stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;     /* high on the screen */
  justify-content: flex-start; /* left-aligned */
  padding: 11vh 0 0 8vw;
  box-sizing: border-box;
  z-index: 18;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease-in;
}
#terminal-stage.visible {
  opacity: 1;
}

#terminal-line {
  font-family: var(--mono);
  font-weight: 400;
  font-size: clamp(0.7rem, 1.7vw, 1.0rem);
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--crt-green);
  text-align: left;
  white-space: pre;            /* fixed left edge, no re-centering */
  text-shadow:
    0 0 9px rgba(0, 200, 0, 0.85),
    0 0 16px rgba(0, 180, 0, 0.20);
}

#terminal-cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  margin-left: 0.04em;
  background: var(--crt-green);
  vertical-align: text-bottom;
  box-shadow: 0 0 8px rgba(0, 200, 0, 0.75);
  animation: term-blink 1s steps(1) infinite;
}
@keyframes term-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   TV FRAME + VIDEO

   The canvas keeps rendering underneath — the PNG bezel has
   transparent regions, and the rain shows through them. The
   <video> sits inside the bezel cutout and is initially black/empty
   (it starts playing late in the wash).
   ═══════════════════════════════════════════════════════════════ */
#tv-stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 4vh, 30px);
  padding: 4vh 4vw;
  box-sizing: border-box;
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s ease-in;
}
#tv-stage.visible {
  opacity: 1;
  pointer-events: auto;
}

#tv-frame {
  position: relative;
  flex: 0 0 auto;
  width: min(90vw, calc(62vh * 4 / 3));
  aspect-ratio: 4 / 3;
  background: url('../img/tv_frame.png') center / contain no-repeat;
}

/* On phones the frame can take up more of the screen */
@media (max-width: 600px) {
  #tv-frame {
    width: min(135vw, calc(70vh * 4 / 3));
  }
}


#tv-video {
  position: absolute;
  top: 10.5%;
  left: 33.2%;
  width: 35.5%;
  height: 61.5%;
  object-fit: cover;
  background: transparent;
  opacity: 0;
  transition: opacity 0.6s ease-in;
}
#tv-video.playing {
  opacity: 1;
}

/* Shown only if the browser refused to start the video with sound —
   muted fallback kicked in, so tell the user and let them fix it. */
#sound-btn {
  position: absolute;
  left: 50%;
  bottom: 2%;
  transform: translateX(-50%);
  display: none;
  font-family: var(--mono);
  font-size: clamp(0.6rem, 2.6vw, 0.85rem);
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: var(--crt-green);
  text-shadow: 0 0 9px rgba(0, 200, 0, 0.85);
  background: rgba(2, 18, 6, 0.75);
  border: 1px solid rgba(0, 200, 0, 0.55);
  box-shadow: 0 0 10px rgba(0, 200, 0, 0.25);
  padding: 0.45em 0.9em;
  cursor: pointer;
}
#sound-btn.visible {
  display: block;
  animation: sound-blink 1.2s steps(1) infinite;
}
#sound-btn:hover {
  background: rgba(0, 60, 20, 0.85);
  animation: none;
}
@keyframes sound-blink {
  0%, 74%  { opacity: 1; }
  75%, 100% { opacity: 0.45; }
}

.tv-titles {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4em;
  pointer-events: none;
  width: 100%;
}

.tv-title-line {
  font-family: var(--mono);
  font-weight: 400;
  text-transform: uppercase;
  line-height: 1.25;
  color: var(--crt-green);
  text-shadow:
    0 0 13px rgba(0, 200, 0, 0.90),
    0 0 21px rgba(0, 180, 0, 0.22);
}
.tv-title-line.main {
  font-size: clamp(0.95rem, 4.6vw, 1.6rem);
  letter-spacing: 0.04em;
}
.tv-title-line.sub {
  font-size: clamp(0.7rem, 3.1vw, 1.05rem);
  letter-spacing: 0.08em;
}

.tv-title-line .pop-char {
  opacity: 0;
  transition: opacity 0.14s ease-out;
}

.tv-title-line a {
  color: inherit;
  pointer-events: auto;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.06em;
  transition: color 0.15s ease;
}
.tv-title-line a:hover {
  color: #eafff2;
}

@media (prefers-reduced-motion: reduce) {
  .tv-title-line { opacity: 0.95; }
}