body {
  margin: 0;
  overflow: hidden;
  background-color: #000;
  color: #fff;
  font-family: 'Helvetica Neue', sans-serif;
}

canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1; /* Keep the canvas in the background */
}

#welcome-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: #000; /* Fallback color */
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), 
    url('/~sbyteme/public/images/main-menu-background.PNG'); 
  background-size: cover;
  background-position: center;
  
  text-align: center;
  z-index: 10;
  overflow: hidden;
  animation: screen-wobble 5s infinite; 
}

body::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 0, 0, 0.15),
        rgba(0, 255, 255, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1001; 
    animation: glitch-lines 1.5s infinite;
}

/* Disable glitch effect when game is active */
body.game-active::after {
    display: none;
}


#welcome-screen::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
   background-repeat: repeat;
  opacity: 0.15;
  animation: noiseMove 0.25s steps(4) infinite, noiseFlicker 3s infinite;
  pointer-events: none;
  z-index: 11;
}

/* Keyframes */
@keyframes noiseMove {
  0% { background-position: 0 0; }
  100% { background-position: 100% 100%; }
}

@keyframes noiseFlicker {
  0%, 19%, 21%, 100% { opacity: 0.15; }
  20% { opacity: 0.25; }
  50% { opacity: 0.1; }
  70% { opacity: 0.2; }
}

@keyframes glitch-lines {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(100%);
    }
}

@keyframes screen-wobble {
    0%, 100% {
        transform: translateX(0) scale(1);
    }
    25% {
        transform: translateX(-5px) scale(1.02);
    }
    50% {
        transform: translateX(5px) scale(1.02);
    }
    75% {
        transform: translateX(-5px) scale(1.02);
    }
}


.title-container {
  margin-bottom: 50px;
}

/* Glitchy Title Effect */
.glitch {
  font-family: 'Creepster', cursive;
  font-size: 6em;
  color: rgb(255, 255, 255);
  position: relative;
  text-shadow: 2px 2px rgb(0, 0, 0), -2px -2px rgb(0, 0, 0);
  animation: glitch 1s infinite;
  z-index: 12;
}

.glitch:before,
.glitch:after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  clip: rect(0, 900px, 0, 0);
  z-index: 12;
}

.glitch:before {
  left: 2px;
  text-shadow: -2px 0 rgb(0, 0, 0);
  animation: glitch-anim-1 2s infinite linear alternate-reverse;
}

.glitch:after {
  left: -2px;
  text-shadow: -2px 0 rgb(0, 0, 0);
  animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

@keyframes glitch {
  0% { transform: skewX(0); }
  5% { transform: skewX(0.5deg); }
  10% { transform: skewX(-0.5deg); }
  15% { transform: skewX(0.5deg); }
  20% { transform: skewX(0); }
  100% { transform: skewX(0); }
}

@keyframes glitch-anim-1 {
  0% { clip: rect(42px, 9999px, 44px, 0); }
  5% { clip: rect(12px, 9999px, 59px, 0); }
  100% { clip: rect(98px, 9999px, 92px, 0); }
}

@keyframes glitch-anim-2 {
  0% { clip: rect(65px, 9999px, 100px, 0); }
  10% { clip: rect(79px, 9999px, 65px, 0); }
  100% { clip: rect(20px, 9999px, 45px, 0); }
}

/* Menu Buttons */
.menu-container {
  display: flex;
  flex-direction: column;
  z-index: 12;
}

.menu-btn {
  background: transparent;
  border: 2px solid #fff;
  color: #fff;
  font-size: 1.5em;
  padding: 10px 30px;
  margin: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 12;
}

.menu-btn:hover {
  background: #f00;
  color: #000;
  border-color: #f00;
  box-shadow: 0 0 20px #f00;
}

/* Loading Screen */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #050505; /* Very dark background */
  color: #fff;
  display: none; /* Initially hidden */
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 1000;
  cursor: none;
}

.mansion-outline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('/~sbyteme/public/images/haunted-house-loading-screen-test.png'); 
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.1;
    z-index: 1001;
}

#loading-container {
    position: relative;
    width: 80%;
    max-width: 600px;
    height: 15px;
    background-color: #1a1a1a;
    border: 1px solid #444;
    border-radius: 2px;
    overflow: visible; /* Allow monster to sit on top */
    z-index: 1002;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

#loading-bar {
    width: 0%;
    height: 100%;
    background-color: #ffffff;
    transition: width 0.3s ease-in-out;
    box-shadow: 0 0 15px #fff, 0 0 20px #fff;
}

#monster-icon {
    position: absolute;
    bottom: 100%; 
    left: 0;
    width: 48px; 
    height: 48px;
    background-size: cover;
    transform: translateX(-50%);
    transition: left 0.3s ease-in-out;
    animation: run-sprite 0.5s steps(4) infinite; 
}

#loading-text {
    position: relative;
    z-index: 1002;
    color: #aaa;
    font-size: 16px;
    font-family: 'Courier New', Courier, monospace;
    margin-top: 25px;
    text-shadow: 1px 1px 2px #000;
}

/* Keyframes for the monster running animation */
@keyframes run-sprite {
  from { background-position: 0 0; }
  to { background-position: -192px 0; } 
}