body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', 'Noto Sans SC', 'Microsoft YaHei', 'SimHei', Arial, sans-serif;
  height: 100vh;
  overflow: hidden;
  background: black;
  color: white;
}
#background {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: url('images/bg.png') no-repeat center center fixed;
  background-size: cover;
  z-index: -1;
  transition: background-image 0.8s cubic-bezier(0.77,0,0.175,1);
}
#video-bg {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  object-fit: cover;
  z-index: -1;
  background: black;
}
#video-bg.hidden { display: none !important; }

/* Neon Password Section */
#password-container {
  position: absolute; 
  top: 50%; 
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: transparent; 
  padding: 0; 
  border: none; 
  box-shadow: none;
}
#password-container h2 {
  font-size: 2em;
  font-weight: bold;
  margin-bottom: 28px;
  color: #fff;
  text-shadow:
    0 0 8px #fff,
    0 0 16px #e0e0e0,
    0 0 32px #fff,
    1px 1px 2px #333;
  letter-spacing: 1px;
  transition: color 0.3s;
}
#password-container input[type="text"] {
  padding: 13px 26px;
  font-size: 1.2em;
  background: transparent;
  border: 2px solid #fff;
  border-radius: 30px;   /* fully rounded like the button */
  outline: none;
  color: #fff;
  text-align: center;
  margin-right: 0;
  box-shadow: 0 0 12px #fff6, 0 0 2px #fff9;
  transition: border-color 0.3s, box-shadow 0.3s;
  text-shadow:
    0 0 4px #fff,
    0 0 12px #fff,
    0 0 24px #e0e0e0;
}
#password-container input[type="text"]:focus {
  border: 2.5px solid #fff;
  box-shadow: 0 0 18px #fff, 0 0 36px #fff9;
}
#input-format-tip {
  color: #fff;
  font-size: 1.05em;
  margin-top: 8px;
  text-shadow:
    0 0 8px #fff,
    0 0 14px #fff,
    0 0 34px #e0e0e0;
  letter-spacing: 2px;
  font-weight: bold;
  font-family: inherit;
  user-select: none;
  opacity: 0.93;

}
#error-message { 
  color: #ff3939; 
  margin-top: 16px; 
  font-size: 1em;
  text-shadow: 0 0 8px #fff3, 0 0 14px #ffdddd;
}

/* Overlay Rectangle (Menu) */
#overlay {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  display: flex; gap: 60px; opacity: 0; pointer-events: none;
  transition: opacity 1.1s cubic-bezier(0.77,0,0.175,1); z-index: 1;
}
#overlay.visible { opacity: 1; pointer-events: auto; }
.card {
  width: 320px; height: 480px;
  background-size: cover; background-position: center;
  border: none; border-radius: 30px; box-shadow: none;
  position: relative; overflow: hidden;
  transition: transform 0.3s; cursor: pointer;
}

/* Minimal Music Player */
#music-player {
  position: fixed;
  top: 30px;
  left: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0;
  min-width: unset;
  z-index: 9999;
  user-select: none;
  transition: none;
}
#music-player .progress-container {
  width: 235px;
  margin: 0 0 6px 0;
  height: 22px;
  position: relative;
  display: flex;
  align-items: center;
}
#progress-bar {
  width: 100%;
  background: transparent;
  height: 4px;
  border-radius: 8px;
  outline: none;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  accent-color: #111;
  cursor: pointer;
  position: relative;
  top: 0;
}
#progress-bar::-webkit-slider-runnable-track {
  background: #111;
  height: 4px;
  border-radius: 8px;
}
#progress-bar::-ms-fill-lower, #progress-bar::-ms-fill-upper {
  background: #111;
}
#progress-bar::-moz-range-track {
  background: #111;
  height: 4px;
  border-radius: 8px;
}
#progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  background: #111;
  border: 0;
  border-radius: 50%;
  margin-top: -6.5px; /* 17/2 - 4/2 = 6.5, to center on 4px bar */
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: background 0.18s;
}
#progress-bar::-moz-range-thumb {
  width: 17px;
  height: 17px;
  background: #111;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: background 0.18s;
}
#progress-bar {
  padding: 0;
  border: none;
}
#progress-bar::-ms-thumb {
  width: 17px;
  height: 17px;
  background: #111;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: background 0.18s;
}
#progress-bar:focus {
  outline: none;
  box-shadow: none;
}
#progress-bar::-moz-focus-outer {
  border: 0;
}
#progress-bar::-webkit-slider-thumb:hover,
#progress-bar::-moz-range-thumb:hover,
#progress-bar::-ms-thumb:hover {
  background: #222;
}
#music-player .music-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  width: 100%;
  justify-content: center;
  margin: 0;
}
#music-player .music-controls button {
  background: none;
  border: none;
  padding: 0 14px;
  border-radius: 50%;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  box-shadow: none;
  min-width: 44px; min-height: 44px;
}
#music-player .music-controls button:active {
  background: #eee;
}
#music-player .music-controls svg {
  display: block;
}
#music-player .music-controls svg polygon,
#music-player .music-controls svg rect {
  fill: #111;
}
#music-player .music-controls button:focus {
  outline: none;
  box-shadow: none;
}
#music-player.bare {
  background: none !important;
  box-shadow: none !important;
  border: none !important;
}
#music-player.hidden { display: none !important; }

.hidden { display: none !important; }

#letter-view {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  display: flex; justify-content: center; align-items: flex-start; z-index: 2;
}
#scrolling-text {
  width: 90vw; max-width: 1200px; max-height: 90vh;
  overflow-y: auto; margin: 0 auto; padding: 32px 16px 0 16px;
  scrollbar-width: none; background: none; box-shadow: none;
}
#scrolling-text::-webkit-scrollbar { width: 0px; background: transparent; }
#scrolling-text::-webkit-scrollbar-thumb { background: transparent; }

.neon-text {
  color: #fff;
  font-weight: bold;
  font-family: inherit;
  text-shadow:
    0 0 8px #fff,
    0 0 18px #f3f3f3,
    0 0 34px #e0e0e0,
    1px 1px 2px #333;
  font-size: 2.1em;
  line-height: 2.5;
  text-align: left;
  white-space: pre-wrap;
  opacity: 0;
  transition: opacity 2s cubic-bezier(0.77,0,0.175,1);
  margin: 0; padding: 0; letter-spacing: normal;
}
.neon-text.visible { opacity: 1; }

#second-view {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  display: flex; justify-content: center; align-items: flex-start; z-index: 2;
}
#vertical-float-container, #credits-float-container {
  position: fixed;
  width: 100vw; height: 100vh; top: 0; left: 0;
  overflow: visible;
  pointer-events: none; z-index: 3;
}
.credits-float-text {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(100vh);
  color: #fff;
  font-weight: bold;
  text-shadow:
    0 0 8px #fff,
    0 0 18px #f3f3f3,
    0 0 34px #e0e0e0,
    1px 1px 2px #333;
  font-size: 2.1em;
  line-height: 2.8;
  opacity: 0;
  white-space: pre-line;
  transition:
    opacity 1.2s cubic-bezier(0.77,0,0.175,1),
    transform 18s linear;
  width: 80vw;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  user-select: none;
  z-index: 2;
  margin-bottom: 80px;
}

#back-btn {
  position: fixed; bottom: 38px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,0.82); color: #222; border: none;
  border-radius: 50px; padding: 8px 28px; font-size: 1.2em;
  z-index: 999;
  cursor: pointer;
}

@media (max-width: 700px) {
  #scrolling-text,
  .credits-float-text {
    font-size: 1.08em !important;
    width: 92vw;
    max-width: 99vw;
  }
  #letter-view,
  #second-view { align-items: flex-start; }
  #music-player { top: 14px; left: 7px;}
}

document.addEventListener('visibilitychange', function() {
  // If tab is hidden, stop credits (or pause as needed)
  if (document.hidden) {
    stopCredits(); // Use your function to stop/clear all text/timeouts
  } else {
    // If on second rectangle page, restart the credits
    const secondView = document.getElementById("second-view");
    if (!secondView.classList.contains("hidden")) {
      startCredits();
    }
  }
});
