/* GLOBAL RESET */
*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  background-color: #000;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0; padding: 0;
  width: 100vw; 
  height: 100dvh; /* Dynamic Height for Mobile */
  overflow: hidden; 
  overscroll-behavior: none;
  font-family: system-ui, -apple-system, sans-serif;
  color: #f5f5f7; background: #000;
  touch-action: none; 
}

#bg {
  position: fixed;
  top: -10vh; left: -10vw;
  width: 120vw; height: 120vh; 
  z-index: 0; pointer-events: none;
  background: #000;
  transform: scale(1.01);
}

.ui {
  position: fixed; left: 0; right: 0;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
  z-index: 10; pointer-events: none;
}

a { color: inherit; text-decoration: none; pointer-events: auto; transition: opacity 0.2s; }
a:hover { opacity: 0.7; }

/* NAV */
.ui-top { top: 0; display: flex; justify-content: space-between; align-items: center; }
.logo a { font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.8rem; }
.nav a { margin-left: 1.5rem; font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; }
.nav a { position: relative; }
.nav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -0.35rem; height: 1px; opacity: 0; transform: scaleX(0.6); transform-origin: center; background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.7), rgba(255,255,255,0)); transition: opacity 150ms ease-out, transform 150ms ease-out; }
.nav a:hover::after { opacity: 1; transform: scaleX(1); }

/* BOTTOM UI (CENTERED) */
.ui-bottom { 
  bottom: 0; 
  display: flex; flex-direction: column; 
  align-items: center; /* CENTER EVERYTHING */
  gap: 1rem; 
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); 
}

.panel { pointer-events: auto; background: rgba(12, 12, 14, 0.45); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 1rem; padding: 1rem; box-shadow: 0 8px 32px rgba(0,0,0,0.6); }

/* Footer Meta */
.panel.meta p { margin: 0.25rem 0; font-size: 0.8rem; text-align: center; }

/* TERMINAL BROADCAST UI */
.broadcast-panel {
  pointer-events: auto; 
  position: relative; width: 100%; max-width: 320px;
  background: rgba(0, 0, 0, 0.9); 
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px; padding: 12px; font-family: "Courier New", Courier, monospace;
  box-shadow: 0 8px 30px rgba(0,0,0,0.9);
  z-index: 50;
  display: none; opacity: 0; transform: translateY(10px);
  transition: all 0.3s ease;
}
.broadcast-panel.active { display: block; animation: slideUp 0.3s forwards; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.terminal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px dashed rgba(255,255,255,0.2); padding-bottom: 8px; margin-bottom: 8px; font-size: 0.7rem; color: #0f0; letter-spacing: 0.1em; }
.blink { animation: blinker 1.5s linear infinite; color: red; margin-right: 6px; }
@keyframes blinker { 50% { opacity: 0; } }
#close-broadcast { background: none; border: none; color: #fff; cursor: pointer; padding: 4px; }

.terminal-screen { display: flex; flex-direction: column; gap: 6px; }
.track-meta { font-size: 0.75rem; color: #eee; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label { color: rgba(255,255,255,0.5); margin-right: 6px; }
.terminal-controls { display: flex; align-items: center; gap: 1rem; margin-top: 8px; border-top: 1px dashed rgba(255,255,255,0.2); padding-top: 8px; }
.terminal-controls button { background: none; border: 1px solid rgba(255,255,255,0.3); color: #fff; font-family: inherit; font-size: 0.7rem; padding: 4px 10px; cursor: pointer; }
.terminal-controls button:hover { background: #fff; color: #000; }
#term-vol { width: 60px; height: 2px; -webkit-appearance: none; background: #555; cursor: pointer; }
#term-vol::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; background: #fff; border-radius: 50%; cursor: pointer; }

/* OS WINDOWS (TV) */
.os-window {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.95);
  width: 90%; max-width: 800px; background: rgba(12, 12, 14, 0.95);
  backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 16px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.8); z-index: 100;
  display: flex; flex-direction: column; opacity: 0; pointer-events: none;
  transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}
.os-window.active { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }
.window-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.window-header h3 { margin: 0; font-size: 0.8rem; letter-spacing: 0.1em; color: #fff; }
.header-controls { display: flex; gap: 1rem; align-items: center; }
.close-window { background: none; border: none; color: #fff; font-size: 1.2rem; cursor: pointer; opacity: 0.5; }
.close-window:hover { opacity: 1; }
.window-content.no-padding { padding: 0; background: #000; overflow: hidden; border-radius: 0 0 16px 16px; }
.tv-container { position: relative; width: 100%; padding-bottom: 56.25%; background: #000; }
.tv-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.tiny-note { padding: 1rem; text-align: center; color: rgba(255,255,255,0.4); margin: 0; font-size: 0.7rem; }
.tiny-note a { text-decoration: underline; }
.icon-btn { background: none; border: 1px solid rgba(255,255,255,0.2); color: #fff; padding: 4px 8px; border-radius: 4px; font-size: 0.7rem; cursor: pointer; letter-spacing: 0.1em; transition: all 0.2s; }
.icon-btn:hover { background: #fff; color: #000; }

/* INSTALL TOAST */
.install-toast {
  position: fixed;
  bottom: 2rem; 
  right: 1.5rem; 
  transform: translateX(120%); 
  width: auto; max-width: 280px;
  background: rgba(20, 20, 22, 0.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1); box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  z-index: 200; opacity: 0; pointer-events: none;
  transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
  border-radius: 12px; padding: 12px 16px;
}
.install-toast.show { transform: translateX(0); opacity: 1; pointer-events: auto; }
.install-content { display: flex; align-items: center; gap: 12px; }
.install-icon { width: 36px; height: 36px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.install-text h3 { margin: 0; font-size: 0.85rem; font-weight: 600; color: #fff; }
.install-text p { margin: 2px 0 0 0; font-size: 0.7rem; color: rgba(255,255,255,0.7); white-space: nowrap; }
.close-btn { background: none; border: none; color: rgba(255,255,255,0.5); margin-left: auto; font-size: 1.1rem; padding: 4px; cursor: pointer; }

/* Mobile Adjustments */
@media (max-width: 600px) {
  .ui { padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
  .ui-bottom { 
    position: fixed; bottom: 0; width: 100%;
    align-items: center; /* Center footer */
    gap: 1rem; 
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); 
  }
  .logo a { font-size: 0.7rem; }
  .nav a { margin-left: 0.8rem; font-size: 0.65rem; }
  .panel.meta { display: block; }

  /* Mobile Toast */
  .install-toast { 
    right: 50%; transform: translateX(50%) translateY(100%); 
    bottom: 5rem;
  }
  .install-toast.show { transform: translateX(50%) translateY(0); }
  
  .os-window { width: 100%; height: 100%; border-radius: 0; top: 0; left: 0; transform: none; }
  .os-window.active { transform: none; }
  .window-content.no-padding { border-radius: 0; flex-grow: 1; justify-content: center; }
}