<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>VHS Tape // The Backrooms analog horror experience</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Special+Elite&display=swap');
html, body {
margin:0; padding:0; overflow:hidden; height:100%;
background: #0a0a0a;
font-family: 'Special Elite', monospace, monospace;
color: #0ff;
user-select:none;
perspective: 1500px;
perspective-origin: center bottom;
}
#scene {
width: 100vmin;
height: 80vmin;
position: absolute;
left: 50%;
top: 50%;
transform-style: preserve-3d;
transform-origin: center center;
transform: translate(-50%, -50%) rotateX(15deg) rotateY(0deg) rotateZ(0deg);
filter: contrast(1.2) brightness(0.6);
border-radius:12px;
box-shadow:
inset 0 0 50px #0ff,
0 0 20px #0ff55;
background: radial-gradient(circle at center, #001f1f, #000000);
overflow: visible;
}
/* VHS tape container */
#vhs {
position: absolute;
width: 220px;
height: 120px;
top: 50%;
left: 50%;
transform-style: preserve-3d;
transform: translate(-50%, -50%) rotateY(25deg) rotateX(-10deg) translateZ(0);
filter: drop-shadow(0 0 6px #0ff);
cursor: grab;
user-select:none;
}
/* VHS simple box */
.vhs-body {
position: relative;
width: 220px;
height: 120px;
background:
linear-gradient(0deg, #111 5%, #222 20%, #111 50%, #111 55%, #222 65%, #111 95%);
border-radius: 6px;
box-shadow:
inset 0 2px 10px #0ff7,
0 0 10px #06f9,
inset 0 -10px 24px #022;
overflow: hidden;
transform-style: preserve-3d;
}
/* cassette front label */
.label {
position: absolute;
top: 15px;
left: 20px;
width: 180px;
height: 30px;
background: linear-gradient(110deg, #111, #004343);
border-radius: 4px;
box-shadow: inset 0 0 20px #0ff8;
color: #0ff;
font-size: 12px;
line-height: 1.1em;
text-align: center;
font-weight: 700;
letter-spacing: 0.12em;
user-select:none;
text-shadow: 0 0 6px #0ff;
font-family: 'Special Elite', monospace;
padding-top:2px;
transform: translateZ(5px);
}
/* cassette reels */
.reel {
position: absolute;
background: radial-gradient(circle closest-side, #0ff 80%, transparent 95%);
border-radius: 50%;
box-shadow:
inset 0 0 10px #0ff,
0 0 15px #0ffac;
width: 50px;
height: 50px;
top: 65px;
filter: drop-shadow(0 0 6px #0ff);
transform-style: preserve-3d;
overflow: hidden;
background-color: #042626;
}
.reel-left {
left: 25px;
}
.reel-right {
right: 25px;
}
/* inner reel holes simulate tape */
.reel .hole {
position: absolute;
width: 10px;
height: 10px;
background: #000;
border-radius: 50%;
top: 50%;
left: 50%;
margin: -5px 0 0 -5px;
box-shadow:
12px 0 0 #000,
-12px 0 0 #000,
0 12px 0 #000,
0 -12px 0 #000;
filter: drop-shadow(0 0 1px #0ff8);
}
/* VHS tape rectangle inside reel (simulate tape) */
.tape-strip {
position: absolute;
top: 70px;
left: 15px;
width: 190px;
height: 20px;
background: linear-gradient(90deg, #0ff, #044, #0ff, #044, #0ff);
border-radius: 4px;
box-shadow: 0 0 10px #0ff, inset 0 0 20px #0ffbb;
filter: drop-shadow(0 0 15px #0ff88);
transform-style: preserve-3d;
z-index: 20;
}
/* VHS tape window - "glass" covering reels */
.glass {
position: absolute;
width: 80px;
height: 80px;
background: rgba(10, 200, 200, 0.15);
border-radius: 12px;
top: 30px;
border: 1px solid #0ff3;
filter: drop-shadow(0 0 4px #0ff8);
box-shadow: inset 0 0 17px #0afe, 0 0 15px #0affe3aa;
cursor: default;
pointer-events:none;
transform-style: preserve-3d;
}
.glass-left { left: 15px; }
.glass-right { right: 15px; }
/* VHS side bevel */
#vhs::before {
content:'';
position: absolute;
top:0; left:0;
width: 220px; height: 120px;
border-radius: 6px;
pointer-events:none;
box-shadow: inset 2px 2px 6px #005050bb, inset -2px -2px 6px #002222bb;
transform-style: preserve-3d;
}
/* VHS flickering static on tape label */
@keyframes flicker-label {
0% { opacity: 1 }
15% { opacity: 0.8 }
30% { opacity: 1 }
50% { opacity: 0.6 }
70% { opacity: 1 }
85% { opacity: 0.65 }
100% { opacity: 1 }
}
.label::after {
content:"";
position: absolute;
inset: 2px;
pointer-events:none;
background: repeating-linear-gradient(
0deg,
rgba(0,255,255,0.07),
rgba(0,255,255,0.12) 1px,
rgba(0,255,255,0.07) 2px
);
opacity: 0.25;
filter: brightness(1.1);
animation: flicker-label 0.15s infinite alternate;
border-radius: 3px;
mix-blend-mode: screen;
}
/* Text Box styles (log content) */
#log {
position: absolute;
bottom: 10px;
left: 50%;
width: 90vmin;
max-width: 840px;
height: 35vmin;
background: #001818dd;
color: #0ff;
border: 2px solid #0ff;
border-radius: 8px;
padding: 1em 1.2em;
overflow-y: auto;
box-shadow: 0 0 15px #0ff99;
font-family: 'Special Elite', monospace;
font-size: 1.1em;
line-height: 1.3em;
user-select: text;
letter-spacing: 0.05em;
text-shadow:
0 0 5px #0ff;
filter: drop-shadow(0 0 28px #0ff88);
pointer-events: auto;
z-index: 10;
}
#log p {
margin-bottom: 0.5em;
}
#input-container {
position: absolute;
bottom: 5px;
left: 50%;
transform: translateX(-50%);
width: 90vmin;
max-width: 840px;
display: flex;
justify-content: center;
pointer-events: auto;
}
#input {
width: 100%;
padding: 0.6em 1em;
font-family: 'Special Elite', monospace;
font-size: 1.2em;
background: #022222cc;
border: 2px solid #0ff;
border-radius: 6px;
color: #0ff;
outline: none;
letter-spacing: 0.06em;
text-shadow:
0 0 2px #0ffaa;
caret-color: #0ff;
user-select: text;
box-shadow: 0 0 10px #0ff88;
}
#input::placeholder {
color: #0ffbb;
}
#input:disabled {
background: #002222aa;
border-color: #044;
color: #044;
cursor: not-allowed;
box-shadow: none;
}
/* VHS tape buttons and dials */
.button {
position: absolute;
background: #022;
border-radius: 3px;
box-shadow: inset 0 0 8px #0ff7, 0 0 10px #06ffcc44;
border: 1px solid #0cff;
cursor: pointer;
filter: drop-shadow(0 0 10px #0ff);
transition: background 0.3s, box-shadow 0.3s;
transform-style: preserve-3d;
}
.button:active {
background: #0ff;
box-shadow: inset 0 0 14px #0fff, 0 0 20px #0ff;
}
/* Track buttons */
#btn-play {
width: 25px; height: 15px;
bottom: 15px;
left: 30px;
clip-path: polygon(0% 0%, 100% 50%, 0% 100%);
background: #013030;
box-shadow: inset 0 0 20px #00ccaa, 0 0 12px #00ffaa;
border-radius: 3px 6px 6px 3px;
border-left: 1px solid #0ff;
cursor: pointer;
filter: drop-shadow(0 0 6px #0afa);
transition: filter 0.2s ease;
}
#btn-play:hover { filter: drop-shadow(0 0 15px #0cff); }
/* Stop button */
#btn-stop {
width: 15px; height: 15px;
bottom: 15px;
left: 70px;
background: #022;
border-radius: 3px;
border: 1px solid #0ff;
box-shadow: inset 0 0 12px #0ff7;
cursor: pointer;
filter: drop-shadow(0 0 6px #0afa);
transition: filter 0.2s ease;
}
#btn-stop:hover { filter: drop-shadow(0 0 15px #0cff); }
/* Rewind & Fast-forward */
#btn-rewind, #btn-ffw {
width: 20px; height: 15px;
bottom: 15px;
background: #014141;
border-radius: 3px;
border: 1px solid #0ff;
box-shadow: inset 0 0 15px #0ff8;
cursor: pointer;
filter: drop-shadow(0 0 8px #07aced);
transition: box-shadow 0.2s ease;
}
#btn-rewind {
left: 110px;
clip-path: polygon(100% 0, 0 50%, 100% 100%);
}
#btn-ffw {
left: 145px;
clip-path: polygon(0 0, 100% 50%, 0 100%);
}
#btn-rewind:hover, #btn-ffw:hover {
box-shadow: inset 0 0 25px #00ffee, 0 0 20px #07aced;
}
/* Tape spool rotation animations */
@keyframes reel-spin-forward {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg);}
}
@keyframes reel-spin-backward {
0% { transform: rotate(0deg); }
100% { transform: rotate(-360deg);}
}
/* Flickering VHS static overlay */
#vhs-static {
pointer-events:none;
position: absolute;
width: 220px;
height: 120px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotateY(25deg) rotateX(-10deg);
background:
repeating-radial-gradient(circle, rgba(0,255,255,0.08) 0 1px, transparent 2px 6px),
repeating-linear-gradient(0deg, rgba(0,255,255,0.04), transparent 1px),
linear-gradient(90deg, #06ff, #002020, #0cff);
mix-blend-mode: screen;
animation: staticGlitch 0.1s steps(8) infinite;
filter: brightness(0.8);
opacity: 0.4;
border-radius: 6px;
box-shadow: 0 0 10px #0ffbb inset;
z-index: 9;
}
@keyframes staticGlitch {
0% { background-position: 0 0, 0 0, 0 0; }
100% { background-position: 12px 12px, 0 20px, 10px 5px; }
}
/* Crackle overlay (simulate tape noise) */
#noise-overlay {
pointer-events:none;
position: fixed;
inset: 0;
background:
radial-gradient(circle at 20% 30%, #0ff05e40 4vmin, transparent 10vmin),
radial-gradient(circle at 80% 65%, #0ffcbc448 2vmin, transparent 11vmin);
mix-blend-mode: screen;
animation: noiseFlicker 0.12s infinite alternate;
z-index: 100;
filter: blur(0.8px);
opacity: 0.15;
}
@keyframes noiseFlicker {
0% { opacity: 0.12; }
100% {opacity: 0.18; }
}
/* Logo "Backrooms VHS" on side */
#vhs-side-label {
position: absolute;
width: 20px;
height: 120px;
right: -28px;
top: 0;
background: linear-gradient(0deg, #060, #012);
border-radius: 3px;
box-shadow: inset 0 0 15px #00ffaa88;
color: #0aeeaa;
font-weight: 900;
font-size: 10px;
padding: 7px 3px 2px 3px;
writing-mode: vertical-rl;
text-orientation: mixed;
text-shadow: 0 0 10px #0ff, 0 0 15px #0effff;
letter-spacing: 0.2em;
font-family: 'Special Elite', monospace;
user-select: none;
text-align: center;
line-height: 1.1em;
transform-style: preserve-3d;
pointer-events:none;
}
/* VHS tape tape reels spinning highlight */
.reel-inner-light {
position: absolute;
top: 10px;
left: 10px;
width: 30px;
height: 30px;
border-radius: 50%;
box-shadow:
0 0 20px #0effaa,
inset 0 0 15px #0affc9;
mix-blend-mode: screen;
filter: blur(1.2px);
opacity: 0.6;
pointer-events:none;
transform-style: preserve-3d;
animation-name: pulseLight;
animation-duration: 2.5s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
}
@keyframes pulseLight {
0%, 100% {opacity: 0.65;}
50% {opacity: 0.22;}
}
/* VHS glitch effect overlays (horizontal glitches) */
#glitch-layer {
position: absolute;
inset: 0;
pointer-events: none;
overflow: visible;
mix-blend-mode: screen;
background: black;
animation: glitchScan 4s infinite;
opacity: 0;
box-shadow:
0 0 40px 10px #0ff;
}
@keyframes glitchScan {
0%, 15%, 85%, 100% {opacity: 0;}
20%, 80% {opacity: 0.25;}
30%, 75% {opacity: 0.1;}
50% {opacity: 0.3;}
}
/* VHS tape text input label on log */
#input-label {
position: absolute;
bottom: 60px;
left: 50%;
transform: translateX(-50%);
color:#0ff;
font-size: 1em;
font-family: 'Special Elite', monospace;
user-select: none;
text-shadow: 0 0 8px #06ffeecc;
pointer-events:none;
letter-spacing: 0.12em;
filter: drop-shadow(0 0 6px #0affcc);
z-index: 11;
}
</style>
</head>
<body>
<div id="scene" role="main" aria-label="VHS tape player in the backrooms analog horror environment">
<div id="vhs" aria-label="VHS tape cassette, draggable and playable">
<div class="vhs-body" aria-hidden="true">
<div class="label">THE BACKROOMS <br> FRAGMENT: VHS ERRORS</div>
<div class="glass glass-left"></div>
<div class="glass glass-right"></div>
<div class="reel reel-left" aria-hidden="true">
<div class="hole"></div>
<div class="reel-inner-light"></div>
</div>
<div class="reel reel-right" aria-hidden="true">
<div class="hole"></div>
<div class="reel-inner-light"></div>
</div>
<div class="tape-strip" aria-hidden="true"></div>
<div id="btn-play" class="button" role="button" aria-label="Play tape" tabindex="0"></div>
<div id="btn-stop" class="button" role="button" aria-label="Stop tape" tabindex="0"></div>
<div id="btn-rewind" class="button" role="button" aria-label="Rewind tape" tabindex="0"></div>
<div id="btn-ffw" class="button" role="button" aria-label="Fast-forward tape" tabindex="0"></div>
</div>
<div id="vhs-side-label" aria-hidden="true">BACKROOMS VHS</div>
<div id="vhs-static" aria-hidden="true"></div>
<div id="glitch-layer" aria-hidden="true"></div>
</div>
<div id="noise-overlay" aria-hidden="true"></div>
<div id="log" aria-live="polite" aria-atomic="false" aria-label="Analog horror logs output"></div>
<div id="input-container">
<input type="text" id="input" placeholder="Type command... (try HELP)" aria-label="User input" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" />
</div>
<div id="input-label">> COMMAND INPUT</div>
</div>
<script>
(() => {
// Data: massive analog horror content for backrooms VHS
const logs = {
start: [
"SYSTEM BOOTING...",
"VHS DATAPACK: THE BACKROOMS FRAGMENT loaded.",
"ERROR: MIXED SIGNALS DETECTED.",
"",
"Type HELP for more info...",
""
],
help: [
"COMMANDS AVAILABLE:",
"HELP - show this message",
"PLAY LOG <id> - play audio log with id",
"SCAN AREA - scan current backrooms level",
"STATUS - system status report",
"REWIND - rewind tape",
"FASTFORWARD - fast forward tape",
"STOP - stop playback",
"EXIT - exit session"
],
status: [
"SYSTEM FUNCTIONALITY REPORT",
"Environment: Level 2 - Dimly Lit Office",
"Anomalies detected: Multiple - Increased frequency",
"Power supply: stable",
"Warning: Signal interference rising",
"Ambient audio: Static and whispers detected"
],
scanArea: [
"SCANNING CURRENT AREA...",
"Location: Backrooms Level 2, coordinates unknown",
"Audio anomalies detected nearby.",
"Visual static interference at perimeter edges.",
"Unidentified presence confirmed south quadrant.",
"Recommendation: Avoid sudden movements."
],
log01: [
"[LOG 01 BEGIN]",
"Static crackles.",
"\"We... should not have come here.\"",
"Distant whispering, unintelligible.",
"The walls bleed shadows.",
"The hum... will never stop.",
"[LOG END]"
],
log02: [
"[LOG 02 BEGIN]",
"Recording compromised by severe interference.",
"Muffled screams echo from corridor behind.",
"\"If you hear this, run.\"",
"...",
"[LOG END]"
],
log03: [
"[LOG 03 BEGIN]",
"Ambient noise: Hum of fluorescent lights.",
"Unknown figure moving camera, shaky vision.",
"\"I think it's watching...\"",
"Camera shakes violently, distorted faces flash.",
"Signal lost.",
"[LOG END]"
],
log04: [
"[LOG 04 BEGIN]",
"Distorted sirens and mechanical drones.",
"Entity voice: \"You can't leave... not now.\"",
"Static bursts, overlayed glitch noise.",
"Last recorded timestamp: 03:17",
"[LOG END]"
],
exit: [
"TERMINATING SESSION...",
"System powering down.",
"Remember: DO NOT TRUST THE LIGHTS.",
"End of transmission."
]
};
// State & elements
const vhs = document.getElementById('vhs');
const reelLeft = vhs.querySelector('.reel-left');
const reelRight = vhs.querySelector('.reel-right');
const btnPlay = document.getElementById('btn-play');
const btnStop = document.getElementById('btn-stop');
const btnRewind = document.getElementById('btn-rewind');
const btnFfw = document.getElementById('btn-ffw');
const logBox = document.getElementById('log');
const input = document.getElementById('input');
let playing = false;
let rewinding = false;
let forwarding = false;
let stopped = true;
let currentLogInterval = null;
let currentLogLines = [];
let currentLineIndex = 0;
// Audio Context
const AudioContext = window.AudioContext || window.webkitAudioContext;
const audioCtx = new AudioContext();
// Sound helper, beep with distortion noise (analog feel)
function playBeep(freq = 440, duration = 0.1, volume=0.15) {
const osc = audioCtx.createOscillator();
const gainNode = audioCtx.createGain();
const distortion = audioCtx.createWaveShaper();
// Simple distortion curve
const curve = new Float32Array(256);
for (let i=0; i<256; i++) {
const x = i*2/256 -1;
curve[i] = x < 0 ? -Math.pow(Math.abs(x), 0.7) : Math.pow(x, 0.7);
}
distortion.curve = curve;
distortion.oversample = '2x';
osc.type = 'square';
osc.frequency.value = freq;
gainNode.gain.setValueAtTime(volume, audioCtx.currentTime);
osc.connect(distortion);
distortion.connect(gainNode);
gainNode.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + duration);
return new Promise(resolve => {
osc.onended = resolve;
});
}
// Play tape noise (white noise crackle) for ambience
function playTapeNoise() {
const bufferSize = audioCtx.sampleRate * 0.5;
const noiseBuffer = audioCtx.createBuffer(1, bufferSize, audioCtx.sampleRate);
const output = noiseBuffer.getChannelData(0);
for (let i=0; i<bufferSize; i++) {
output[i] = (Math.random() * 2 - 1) * 0.2;
}
const noiseSource = audioCtx.createBufferSource();
noiseSource.buffer = noiseBuffer;
noiseSource.loop = true;
const gainNode = audioCtx.createGain();
gainNode.gain.setValueAtTime(0.08, audioCtx.currentTime);
noiseSource.connect(gainNode);
gainNode.connect(audioCtx.destination);
noiseSource.start();
return {noiseSource, gainNode};
}
// global tape noise
let tapeNoisePlaying = false;
let tapeNoiseNodes = null;
function startTapeNoise() {
if (!tapeNoisePlaying) {
tapeNoiseNodes = playTapeNoise();
tapeNoisePlaying = true;
}
}
function stopTapeNoise() {
if (tapeNoisePlaying && tapeNoiseNodes) {
tapeNoiseNodes.noiseSource.stop();
tapeNoiseNodes = null;
tapeNoisePlaying = false;
}
}
// Reel spin animation helpers
function startReelsSpin(forward=true) {
reelLeft.style.animation = forward ? 'reel-spin-forward 3s linear infinite' : 'reel-spin-backward 3s linear infinite';
reelRight.style.animation = forward ? 'reel-spin-forward 3s linear infinite' : 'reel-spin-backward 3s linear infinite';
}
function stopReelsSpin() {
reelLeft.style.animation = 'none';
reelRight.style.animation = 'none';
}
// Type out function animating text lines gradually
async function typeLines(lines, delayBetweenLines = 700) {
for (let line of lines) {
if(!playing) break;
appendLog(line);
await wait(delayBetweenLines + line.length * 50);
}
}
// Append text line and scroll down
function appendLog(line) {
const p = document.createElement('p');
p.textContent = line;
logBox.appendChild(p);
logBox.scrollTop = logBox.scrollHeight;
}
function clearLog() {
logBox.innerHTML = '';
}
// Wait utility
function wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// Play log by ID with audio and reel spinning
async function playLog(logId) {
// Stop any ongoing
stopTape();
const logContent = logs[`log${logId.padStart(2,'0')}`];
if(!logContent) {
appendLog(`ERROR: Log with ID '${logId}' not found.`);
return;
}
clearLog();
playing = true;
stopped = false;
startReelsSpin(true);
startTapeNoise();
appendLog(`[PLAYING LOG ${logId}]`);
await typeLines(logContent, 1200);
appendLog(`[END OF LOG ${logId}]`);
stopTape();
}
// Stop tape playing
function stopTape() {
playing = false;
stopped = true;
rewinding = false;
forwarding = false;
stopReelsSpin();
stopTapeNoise();
}
// Rewind / Forward simulated by quick log changing with effect + sound
async function rewindTape() {
if (stopped) {
appendLog("Tape is stopped. Play a log first.");
return;
}
rewinding = true;
forwarding = false;
startReelsSpin(false);
startTapeNoise();
appendLog("[REWINDING...]");
await playRewindForwardEffect('rewind');
rewinding = false;
stopTapeNoise();
stopReelsSpin();
}
async function fastForwardTape() {
if (stopped) {
appendLog("Tape is stopped. Play a log first.");
return;
}
forwarding = true;
rewinding = false;
startReelsSpin(true);
startTapeNoise();
appendLog("[FAST FORWARDING...]");
await playRewindForwardEffect('forward');
forwarding = false;
stopTapeNoise();
stopReelsSpin();
}
async function playRewindForwardEffect(mode) {
const flicker = document.getElementById('vhs-static');
const glitchLayer = document.getElementById('glitch-layer');
let count = 0;
while (count < 20) {
flicker.style.opacity = (Math.random() * 0.7 + 0.2).toFixed(2);
glitchLayer.style.opacity = (Math.random() * 0.2).toFixed(2);
await wait(80);
count++;
}
flicker.style.opacity = 0.4;
glitchLayer.style.opacity = 0;
}
// Process commands from user input
async function processCommand(inputText) {
if (!inputText.trim()) return;
if (playing) {
appendLog("> Tape is playing. Please STOP to enter commands.");
return;
}
let cmd = inputText.trim().toUpperCase();
appendLog(`> ${inputText}`);
switch (true) {
case cmd === 'HELP':
clearLog();
logs.help.forEach(l => appendLog(l));
break;
case cmd === 'STATUS':
clearLog();
logs.status.forEach(l => appendLog(l));
break;
case cmd === 'SCAN AREA':
clearLog();
logs.scanArea.forEach(l => appendLog(l));
break;
case cmd.match(/^PLAY LOG (\d+)$/)?.length > 0:
const id = cmd.match(/^PLAY LOG (\d+)$/)[1];
clearLog();
await playLog(id);
break;
case cmd === 'STOP':
stopTape();
appendLog("[PLAYBACK STOPPED]");
break;
case cmd === 'REWIND':
await rewindTape();
break;
case cmd === 'FASTFORWARD':
case cmd === 'FAST FORWARD':
await fastForwardTape();
break;
case cmd === 'EXIT':
clearLog();
logs.exit.forEach(l => appendLog(l));
stopTape();
input.disabled = true;
break;
default:
appendLog("ERROR: Command not recognized. Type HELP for commands.");
}
}
// Handle button clicks for tape control
btnPlay.addEventListener('click', async () => {
if(!playing && !stopped) {
appendLog("Tape is not stopped. Please STOP first.");
return;
}
// Default: play first log if no log playing
await playLog('01');
});
btnStop.addEventListener('click', () => {
stopTape();
appendLog("[PLAYBACK STOPPED]");
});
btnRewind.addEventListener('click', () => rewindTape());
btnFfw.addEventListener('click', () => fastForwardTape());
// Input enter key interaction
input.addEventListener('keydown', async e => {
if(e.key === 'Enter') {
e.preventDefault();
if(!input.value.trim()) return;
if(audioCtx.state === 'suspended') await audioCtx.resume();
await processCommand(input.value);
input.value = '';
}
});
// Init scene - show start logs
async function init() {
clearLog();
logs.start.forEach(l => appendLog(l));
input.focus();
}
// VHS drag mechanic 3D rotation
let dragging = false;
let lastX = 0;
let lastY = 0;
let rotY = 25;
let rotX = -10;
vhs.addEventListener('pointerdown', (e) => {
e.preventDefault();
dragging = true;
lastX = e.clientX;
lastY = e.clientY;
vhs.style.cursor = 'grabbing';
});
window.addEventListener('pointerup', () => {
dragging = false;
vhs.style.cursor = 'grab';
});
window.addEventListener('pointermove', (e) => {
if (!dragging) return;
const dx = e.clientX - lastX;
const dy = e.clientY - lastY;
lastX = e.clientX;
lastY = e.clientY;
rotY += dx * 0.5;
rotX += dy * 0.3;
rotX = Math.min(Math.max(rotX, -30), 30);
rotY = rotY % 360;
vhs.style.transform = `translate(-50%, -50%) rotateY(${rotY}deg) rotateX(${rotX}deg) translateZ(0)`;
});
// Accessibility focus on input on page click or tab
document.body.addEventListener('click', () => input.focus());
// Initialize
window.onload = init;
})();
</script>
</body>
</html>