/* Retro monospace HUD */
@font-face {
  font-family: 'VCR';
  src: url('https://fonts.googleapis.com/css2?family=VT323&display=swap');
}

:root {
  --green: #a9ff8c;
  --flicker: 0.15s;
  --scanline-opacity: 0.15;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background:#000; overflow:hidden; font-family: 'VT323', monospace; }

#video-container {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#player {
  width: 1280px;
  height: 720px;
  object-fit: cover;
  filter: contrast(1.2) brightness(0.9) saturate(1.1);
  transition: opacity 0.3s ease-out, transform 0.2s ease-out, filter 0.2s ease-out;
  /* Optimize video rendering */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  will-change: transform;
  /* Performance optimization - fixed size */
  max-width: 1280px;
  max-height: 720px;
}

/* Responsive scaling for different screen sizes */
@media (min-width: 1920px) {
  #player {
    transform: scale(1.5);
  }
}

@media (min-width: 2560px) {
  #player {
    transform: scale(2);
  }
}

@media (max-width: 1366px) {
  #player {
    transform: scale(1);
  }
}

/* Top display elements */
#top-display {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 1001;
  pointer-events: none;
}

#data-display {
  position: absolute;
  top: 1rem;
  left: 1rem;
  padding: .25rem .5rem;
  font: 14px 'VT323', monospace;
  color: var(--green);
  letter-spacing: 1px;
  z-index: 1001;
}

#tape-counter {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: .25rem .5rem;
  font: 14px 'VT323', monospace;
  color: var(--green);
  letter-spacing: 1px;
  z-index: 1001;
}

/* CRT scanlines & slight chromatic shift */
#player::after { content:''; } /* Safari quirk */
body::before,
body::after {
  content:'';
  position:fixed; inset:0; pointer-events:none;
}
body::before {             /* horizontal scanlines */
  background: repeating-linear-gradient(
      0deg, rgba(0,0,0,0) 0 1px, rgba(0,0,0,.15) 2px 3px);
  mix-blend-mode: overlay;
}
body::after {              /* subtle color bleed */
  background: rgba(255,0,0,.02);
  filter: blur(1px);
  mix-blend-mode: screen;
}

/* VHS flicker keyframe */
@keyframes flick {
  0%, 100% { transform:translate(0); }
  50% { transform:translateX(-0.5px); }
}

@keyframes scanlines {
  0% { transform: translateY(0); }
  100% { transform: translateY(100vh); }
}

@keyframes chromatic {
  0% { transform: translateX(0); }
  50% { transform: translateX(1px); }
  100% { transform: translateX(0); }
}

@keyframes tracking {
  0% { transform: translateY(0); }
  50% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

#crt { 
  position:fixed; inset:0; z-index:999; opacity:.03;
  animation: flick var(--flicker) steps(2) infinite; 
}

/* Enhanced scanlines */
body::before {             /* horizontal scanlines */
  background: repeating-linear-gradient(
      0deg, rgba(0,0,0,0) 0 1px, rgba(0,0,0,var(--scanline-opacity)) 2px 3px);
  mix-blend-mode: overlay;
  animation: scanlines 0.1s linear infinite;
}

body::after {              /* subtle color bleed */
  background: rgba(255,0,0,.02);
  filter: blur(1px);
  mix-blend-mode: screen;
  animation: chromatic 0.3s ease-in-out infinite;
}

/* Datestamp */
#datestamp {
  position:absolute; bottom:1rem; left:1rem; padding:.25rem .5rem;
  font: 14px 'VT323', monospace; color:var(--green); background:#0009;
  letter-spacing:1px; border:1px solid var(--green);
  text-shadow:0 0 4px var(--green);
  animation: tracking 0.5s ease-in-out infinite;
  z-index: 1001;
}

/* Additional VHS effects */
.vhs-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 998;
  background: 
    linear-gradient(90deg, transparent 0%, rgba(0,0,0,0.1) 50%, transparent 100%),
    radial-gradient(circle at 50% 50%, transparent 0%, rgba(0,0,0,0.05) 100%);
  mix-blend-mode: multiply;
}

/* Loading indicator */
#loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'VT323', monospace;
  color: var(--green);
  font-size: 1.5rem;
  text-shadow: 0 0 10px var(--green);
  z-index: 1002;
  animation: flicker 0.5s infinite;
  display: block;
}

#loading.hidden {
  display: none;
}

/* Start overlay */
#start-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 1003;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.5s ease-out;
}

#start-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.start-content {
  text-align: center;
  color: var(--green);
  font-family: 'VT323', monospace;
}

.start-content h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
  text-shadow: 0 0 20px var(--green);
  animation: flicker 0.5s infinite;
}

.start-content p {
  font-size: 1.5rem;
  margin-bottom: 2rem;
  opacity: 0.8;
}

.start-content small {
  font-size: 0.8rem;
  opacity: 0.6;
  display: block;
}