#suggestedVideo, #suggestedPlaylist, #suggestedVideo2, #suggestedVideo3, #testCanvas, #suggestedYoutube,
    #ytInput, #startBtn, #randomizeBtn, #autoGlitchBtn, #continualRandomizeBtn,
    #sliderContainer, #wired-btn,
  #suggestedMoonlight{
        opacity: 0.2;
        transition: opacity 0.2s ease-in-out;
    }

    #suggestedVideo:hover, #suggestedPlaylist:hover, #suggestedVideo2:hover, #suggestedVideo3:hover, #testCanvas:hover, #suggestedYoutube:hover,
    #suggestedMoonlight:hover,
    #ytInput:hover, #startBtn:hover, #randomizeBtn:hover, #autoGlitchBtn:hover, #continualRandomizeBtn:hover,
    #sliderContainer:hover, #wired-btn:hover {
        opacity: 1;
    }

    html, body {
      margin: 0; padding: 0; overflow: hidden;
      background: black;
      transition: transform 0.1s ease-in-out;
      height: 100%; width: 100%;
      cursor: crosshair;
    }
    canvas {
      position: absolute;
      top: 0; left: 0;
      width: 100vw; height: 100vh;
    }
    #glitchCanvas { z-index: 0; }
    #ytFrame {
      filter: brightness(0.9) contrast(1.1); /* Slightly crush blacks and pop whites for a more analog feel */
      position: absolute;
      top: 0; left: 0;
      width: 100vw; height: 100vh;
      z-index: 1;
      border: none;
    }

   #suggestedVideo, #suggestedPlaylist, #suggestedVideo2, #suggestedVideo3, #testCanvas, #suggestedYoutube,
  #suggestedMoonlight{
      font-family: Impact, 'Arial Black', 'Franklin Gothic Heavy', sans-serif;
      text-align: center;
      color: white;
      cursor: pointer;
      z-index: 5;
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      width: 100%;
      -webkit-user-select: none; /* Safari */
      -ms-user-select: none; /* IE 10+ and Edge */
      user-select: none; /* Standard syntax */
    }

    /*
    /=============================================
    |                                             |
    |   HERE ARE THE LAYOUT PERCENTAGES FOR THE   |
    |           SUGGESTED VIDEO LINKS             |
    |                                             |
    \=============================================/ 
    */
    #suggestedVideo {
      top: 0%;
    }

    #suggestedVideo3 {
      top: 5%;
    }

    #suggestedVideo2 {
      top: 10%;
    }

    #suggestedYoutube {
      top: 15%;
    }

    #suggestedPlaylist {
      top: 20%;
    }

    #suggestedMoonlight {
      top: 25%;
    }
    
    #testCanvas {
      bottom: 35%;
    }

    input, button {
      position: absolute;
      font-family: monospace;
      font-size: 14px;
      padding: 10px 16px;
      color: white;
      background: rgba(0, 0, 0, 0.6);
      border: 1px solid white;
      z-index: 5;
      transition: all 0.2s ease-in-out;
    }
    button:active {
      transform: scale(0.95) rotate(-1deg);
      background: rgba(255, 0, 255, 0.3);
      box-shadow: 0 0 8px white;
    }
    #ytInput {
      top: 40%; left: 50%; transform: translate(-50%, -50%);
      width: 320px;
    }
    #startBtn {
      top: 50%; left: 50%; transform: translate(-50%, -50%);
    }
    #randomizeBtn { top: 60px; right: 20px; display: none; z-index: 10; }
    #autoGlitchBtn { top: 20px; right: 20px; display: none; z-index: 10; }
    #continualRandomizeBtn { top: 100px; right: 20px; display: none; z-index: 10; width: 230px; }
    #aiWarpBtn { top: 156px; right: 20px; display: none; z-index: 10; width: 230px; }

    /* New slider container */
    #sliderContainer {
      position: absolute;
      top: 85px;
      left: 20px;
      z-index: 10;
      background: rgba(0,0,0,0.5);
      padding: 10px;
      border: 1px solid white;
      border-radius: 5px;
      display: none; /* Hidden until start */
    }
    .slider-group {
      display: flex;
      align-items: center;
      margin-bottom: 5px;
    }
    .slider-group label {
      font-family: monospace;
      font-size: 12px;
      color: white;
      width: 120px; /* Align sliders */
    }
    .slider-group input[type="range"] {
        margin-left: 120px;
    }

    .lock-button {
      font-family: monospace;
      font-size: 11px;
      color: white;
      background: black;
      border: 1px solid white;
      margin-left: 230%;
      cursor: pointer;
      padding: 4px 8px;
    }

    .lock-button.locked {
      color: black;
      background: white;
    }

    /* Notification style */
    .notification {
      position: fixed;
      top: 20px;
      left: 50%;
      transform: translateX(-50%);
      background-color: rgba(0, 255, 13, 0.8);
      color: black;
      padding: 10px 20px;
      border-radius: 5px;
      z-index: 100;
      font-family: monospace;
      opacity: 0;
      transition: opacity 0.5s ease-in-out;
      pointer-events: none;
    }

    /* --- Wired Button CRT Styles --- */
    .wired-button {
      font-family: 'Courier New', Courier, monospace;
      text-decoration: none;
      color: #00ffff;
      background: rgba(0, 20, 20, 0.5); /* More faded background */
      border: 2px solid #00ffff;
      border-radius: 8px;
      cursor: pointer;
      overflow: hidden; /* Keep scanlines inside */
      box-shadow: 0 0 10px rgba(0, 255, 255, 0.5),
                  0 0 20px rgba(0, 255, 255, 0.3),
                  inset 0 0 15px rgba(0, 255, 255, 0.2);
      text-shadow: 0 0 4px #00ffff, 0 0 8px #00ffff;
      animation: crt-flicker 0.2s infinite;
      transition: all 0.2s ease;
    }

    .wired-button:hover {
        background: rgba(0, 40, 40, 0.7);
        box-shadow: 0 0 15px rgba(0, 255, 255, 0.8),
                    0 0 30px rgba(0, 255, 255, 0.5),
                    inset 0 0 20px rgba(0, 255, 255, 0.3);
    }

    .wired-button::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(to bottom, rgba(255,255,255,0.15) 50%, rgba(0,0,0,0.3) 50%);
      background-size: 100% var(--scanline-thickness, 4px);
      opacity: 0.6;
      animation: scanline-move var(--scanline-speed, 4s) linear infinite;
      pointer-events: none;
    }

    #wired-btn {
      position: absolute;
      top: 20px;
      left: 20px;
      padding: 15px 30px;
      font-size: 1.5em;
      z-index: 20; /* Ensure it's on top */
    }

    @keyframes crt-flicker {
      0%, 100% { opacity: 0.9; }
      50% { opacity: 1; }
    }

    @keyframes scanline-move {
      from { background-position: 0 0; }
      to { background-position: 0 -8px; } /* Faster movement */
    }

    /* --- UI Toggle Tab Styles (CRT Themed) --- */
    #ui-toggle-tab {
      position: fixed;
      right: -145px; /* Start mostly hidden, adjust based on final width */
      top: 50%;
      transform: translateY(-50%);
      z-index: 9999;
      transition: right 0.3s ease-in-out, opacity 0.2s ease-in-out;
      cursor: pointer;
      opacity: 0.4; /* More visible when collapsed */
    }

    #ui-toggle-tab:hover {
      right: 0;
      opacity: 1;
    }

    #toggle-ui-btn {
      /* Inherit wired-button styles */
      font-family: 'Courier New', Courier, monospace;
      text-decoration: none;
      color: #00ffff;
      background: rgba(0, 20, 20, 0.7);
      border: 2px solid #00ffff;
      border-right: none; /* Hide the border that's off-screen */
      border-radius: 8px 0 0 8px; /* Round corners on the visible side */
      box-shadow: 0 0 10px rgba(0, 255, 255, 0.5),
                  0 0 20px rgba(0, 255, 255, 0.3),
                  inset 0 0 15px rgba(0, 255, 255, 0.2);
      text-shadow: 0 0 4px #00ffff, 0 0 8px #00ffff;
      animation: crt-flicker 0.2s infinite;
      padding: 10px 16px;
      font-size: 14px;
      white-space: nowrap; /* Prevent text wrapping */
      position: relative; /* For scanline pseudo-element */
      overflow: hidden;
    }


/* --- Preset Dropdown Menu Styles --- */
/* --- Preset Dropdown Menu Styles (inspired by double-oh-six.html) --- */
#preset-toggle-btn {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9991; /* Above the dropdown container */
  font-family: 'Share Tech Mono', 'Consolas', monospace;
  font-size: 0.9rem; /* Slimmer */
  padding: 5px 15px; /* Slimmer */
  border-radius: 0 0 8px 8px; /* from preset-toggle-btn */
  font-weight: normal; /* Slimmer */
  cursor: pointer;
  display: none; /* Hidden until playback starts */
  opacity: 0.5;
  overflow: hidden; /* Keep scanlines inside */
  position: relative; /* For scanline pseudo-element */
  color: #00ffff;
  background: rgba(0, 20, 20, 0.5);
  border: 2px solid #00ffff;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.5), 0 0 20px rgba(0, 255, 255, 0.3), inset 0 0 15px rgba(0, 255, 255, 0.2);
  text-shadow: 0 0 4px #00ffff, 0 0 8px #00ffff;
  animation: crt-flicker 0.2s infinite;
  transition: all 0.2s ease;
}

#preset-toggle-btn:hover {
  background: #39ffff;
  box-shadow: 0 2px 15px rgba(0, 255, 247, 0.8);
}

#preset-toggle-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.15) 50%, rgba(0,0,0,0.3) 50%);
  background-size: 100% var(--scanline-thickness, 4px);
  opacity: 0.6;
  animation: scanline-move var(--scanline-speed, 4s) linear infinite;
  pointer-events: none;
}

#preset-dropdown-container { /* This is the actual dropdown panel */
  position: fixed;
  top: 0;
  left: 50%; /* Center horizontally */
  transform: translateX(-50%); /* Center horizontally */
  width: 90%; /* Constrain width */
  max-width: 600px; /* Max width to prevent it from being too wide */
  height: 0; /* Initially closed */
  overflow: hidden; /* Keep scanlines inside */
  background-color: rgba(10, 26, 35, 0.5); /* Dark, 50% transparent background */
  border-bottom: 2px solid #00fff7;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.5), 0 0 20px rgba(0, 255, 255, 0.3), inset 0 0 15px rgba(0, 255, 255, 0.2);
  z-index: 9990; /* Below the toggle button */
  transition: height 0.4s ease-in-out, opacity 0.4s ease-in-out;
  display: none; /* Hidden initially, will be shown by JS */
  flex-direction: column; /* To stack preset-bar and current-preset-display */
  justify-content: center;
  align-items: center;
  padding-top: 30px; /* Adjust for slimmer toggle button */
  box-sizing: border-box;
  opacity: 0; /* Initially hidden for transition */
}

#preset-dropdown-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.15) 50%, rgba(0,0,0,0.3) 50%);
  background-size: 100% var(--scanline-thickness, 4px);
  opacity: 0.6;
  animation: scanline-move var(--scanline-speed, 4s) linear infinite; /* Scanline effect */
  pointer-events: none;
}

.preset-bar { 
  display: flex; 
  position: relative; /* Establish a positioning context for absolute children */
  width: 100%;
  height: 100%;
} 
.preset-dropdown, .preset-name-input, .preset-save-btn, .preset-delete-btn, .preset-delete-all-btn, .preset-nav-btn { 
  font-family: 'Share Tech Mono', 'Consolas', monospace; 
  font-size: 0.9rem; /* Slimmer */
  border: 2px solid #00fff7; 
  border-radius: 4px;
  margin: 2px; /* Slimmer */
  padding: 4px 8px; /* Slimmer */
  outline: none; 
  transition: box-shadow 0.2s, border-color 0.2s, background 0.2s, color 0.2s; 
  box-shadow: 0 0 8px rgba(0, 255, 247, 0.6); 
  opacity: 1; /* Controls are now fully opaque, but their background is transparent */
  position: absolute; /* Use absolute positioning for precise control */
  color: #00fff7;
  background: rgba(16, 28, 34, 0.5);
  cursor: pointer;
}

 
.preset-dropdown:focus, .preset-name-input:focus, .preset-save-btn:focus, .preset-delete-btn:focus, .preset-delete-all-btn:focus, .preset-nav-btn:focus { 
  border-color: #fff; 
  box-shadow: 0 0 12px #00fff7cc; 
  opacity: 1; 
} 
 
.preset-save-btn { 
  cursor: pointer; 
  font-weight: bold;
  right: 0; /* Aligned to the far right */
  top: 0px;
  transform: translateX(0%); /* Adjust position with transform */
}

.preset-delete-btn {
  cursor: pointer; 
  font-weight: bold;
  right: 5%; /* Aligned to the right */
  top: 32px;
  transform: translateX(5%); /* Adjust position with transform */
  background: rgba(34, 16, 16, 0.5);
  color: #ff2a2a;
  border-color: #ff2a2a;
}

.preset-delete-all-btn {
  cursor: pointer;
  font-weight: bold;
  right: 0; /* Aligned to the far right */
  top: 32px;
  transform: translateX(0%);
  background: rgba(255, 0, 255, 0.5); /* Magenta */
  color: #ffffff;
  border-color: #ff00ff;
}
 
.preset-nav-btn { 
  width: 28px; /* Slimmer */
  height: 28px; /* Slimmer */
  background: #101c22; 
  color: #00fff7; 
  border: 2px solid #00fff7; 
  border-radius: 50%; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-size: 1rem; /* Slimmer */
  cursor: pointer;
  box-shadow: 0 0 8px #00fff799;
}

.preset-nav-btn.left {
  top: 30px;
  left: calc(50% - 150px); /* 150px to the left of center */
  transform: translateX(-50%);
}

.preset-nav-btn.right {
  top: 30px;
  left: calc(50% + 150px); /* 150px to the right of center */
  transform: translateX(-50%);
}
.preset-dropdown { 
  top: 0px; left: 66%; transform: translateX(-66%);
}

.preset-nav-btn:hover {
  background: #00fff7; 
  color: #101c22; 
  border-color: #fff; 
}

.preset-save-btn:hover, .preset-delete-btn:hover {
  background: #00fff7;
  color: #101c22;
  border-color: #fff;
}

.preset-delete-btn:hover {
    background: #ff2a2a;
    color: white;
}

.preset-delete-all-btn:hover {
    background: #ff00ff;
    color: black;
}

.current-preset-display {
  position: absolute; /* Position relative to the container */
  top: 35px; /* Position from the top of the container */
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Courier New', Times, serif;
  color: crimson;
  text-shadow: 0 0 5px rgb(127, 255, 246);
  pointer-events: none;
  font-size: 1.15rem;
  text-align: center;
  /* display: none; */ /* Hidden by default - REMOVED FOR DEBUGGING */
  z-index: 1; /* On top of other elements in the container */
  opacity: 1;
}


    /* --- Mobile Responsiveness --- */
    @media (max-width: 768px) {
        html, body {
            width: 100%;
            height: 100%;
            overflow: auto;
            background: black;
        }

        canvas {
            width: 100vw;
            height: 100vh;
        }

        #ytInput {
            width: 80vw;
            max-width: 320px; /* Keep max size */
            font-size: 12px;
            transform: scale(1) translate(-150%, -150%);
        }
        #startBtn {
            font-size: 12px;
            padding: 8px 12px;
            transform: scale(0.33) translate(-150%, -150%);
        }
        #randomizeBtn, #autoGlitchBtn, #continualRandomizeBtn, #aiWarpBtn {
            width: auto; /* Fit content */
            max-width: 40vw; /* Prevent from being too wide */
            font-size: 10px;
            padding: 6px 8px;
            right: 5px;
            white-space: nowrap; /* Prevent line breaks */
            transform: scale(1);
            transform-origin: top right;
        }
        #continualRandomizeBtn, #aiWarpBtn {
            white-space: normal; /* Allow longer buttons to wrap */
            text-align: center;
        }
        #wired-btn {
            left: 5px;
            top: 5px;
            padding: 8px 10px;
            font-size: 0.8em;
            transform: scale(1);
            transform-origin: top left;
        }
        #sliderContainer {
            left: 5px;
            top: 60px; /* Adjust to be below wired-btn */
            width: calc(100vw - 10px);
            max-width: 320px;
            box-sizing: border-box;
            opacity: 0.4;
            transform: scale(0.33);
            transform-origin: top left;
        }
         #sliderContainer:hover {
            opacity: 1;
        }
        .slider-group {
            position: relative; /* For lock button positioning */
            flex-direction: column;
            align-items: flex-start;
            margin-bottom: 8px;
        }
        .slider-group label {
            width: 100%;
            margin-bottom: 4px;
            font-size: 11px;
        }
        .slider-group input[type="range"] {
            width: 100%;
            margin-left: 0;
        }
        .lock-button {
            position: relative;
            right: 5px;
            top: 5px;
            margin-left: 315px;
            margin-top: 0;
            padding: 2px 6px;
            font-size: 10px;
        }
        h2[id^="suggested"] {
            font-size: 0.7em;
            line-height: 1.4;
            transform: scale(0.33);
        }
        #testCanvas {
             font-size: 0.7em;
             transform: scale(0.33);
        }

        #ui-toggle-tab {
            top: 50%; /* Move from middle to bottom */
            right: 0px;
            bottom: 10px;
            transform: scale(1); /* Keep the user's explicit non-scaling for this element */
            transform-origin: bottom right; /* Adjust origin for new position */
            /* By REMOVING 'right: 20px', it will inherit 'right: -145px' from the desktop rule, making it correctly hidden by default */
        }
        #toggle-ui-btn {
            font-size: 12px;
            padding: 8px 12px;
        }
        
        #preset-dropdown-container {
            width: 98%; /* Take up more screen width */
            padding-top: 35px;
            box-sizing: border-box;
            transform: scale(0.33);
            transform-origin: top center;
        }
        .preset-bar {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
            gap: 5px;
            width: 100%;
            padding: 0 5px;
            box-sizing: border-box;
        }
        .preset-dropdown, .preset-name-input, .preset-save-btn, .preset-delete-btn, .preset-delete-all-btn, .preset-nav-btn {
            font-size: 0.8rem;
            padding: 4px;
            margin: 0;
            position: static;
            transform: none;
            width: 100%;
            box-sizing: border-box;
        }
        .current-preset-display {
             position: static;
             transform: none;
             order: -2; /* Move to the top */
             grid-column: 1 / -1; /* Span full width */
             text-align: center;
             margin-bottom: 5px;
             font-size: 1rem;
        }
        .preset-name-input {
            grid-column: 1 / -1; /* Span full width */
            order: -1;
        }
    }
  
  /* Class to hide UI elements */
  body.ui-hidden #suggestedVideo,
  body.ui-hidden #suggestedPlaylist,
  body.ui-hidden #suggestedVideo2,
  body.ui-hidden #suggestedVideo3,
  body.ui-hidden #testCanvas,
  body.ui-hidden #suggestedYoutube,
  body.ui-hidden #suggestedMoonlight,
  body.ui-hidden #ytInput,
  body.ui-hidden #startBtn,
  body.ui-hidden #randomizeBtn,
  body.ui-hidden #autoGlitchBtn,
  body.ui-hidden #continualRandomizeBtn,
  body.ui-hidden #sliderContainer,
  body.ui-hidden #wired-btn,
  body.ui-hidden #aiWarpBtn {
    display: none !important; /* Use !important to override existing display properties */
  }
  .background-svg {
    position: absolute;
    z-index: -1;
  }