/* --- CSS Variables & Global Base Styles --- */
:root {
  --bg-color: #000;
  --primary-color: #fff;
  --header-bg: rgba(0, 0, 0, 0.85);
  --static-duration: 0.3s;
  font-size: clamp(16px, 1.5vw, 20px);
}

/* Reset and Base */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg-color);
  color: var(--primary-color);
  font-family: 'Merova', sans-serif;
  overflow: hidden;
  -webkit-touch-callout: none; /* Prevent callout to copy image, etc when tap to hold */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS Safari */
  -webkit-text-size-adjust: 100%; /* Prevent automatic text size adjustment on orientation change */
}

/* --- Skip Link --- */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary-color);
  color: var(--bg-color);
  padding: 8px 16px;
  z-index: 1000;
  transition: top 0.3s;
}
.skip-link:focus {
  top: 0;
}

/* --- Back to Top Button --- */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--primary-color);
  color: var(--bg-color);
  border: none;
  padding: 10px;
  font-size: 1.5rem;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  z-index: 400;
  transition: opacity 0.3s;
}

/* --- Import Merova Font --- */
@font-face {
  font-family: 'Merova';
  src: url('visuals/Merova.otf') format('opentype');
  font-display: swap;
}

/* --- Optimize Animations --- */
.landing-name,
#staticOverlay,
.channel-number-overlay {
  will-change: transform, opacity;
}

/* --- Static Overlay --- */
#staticOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 2px,
    transparent 3px
  );
  opacity: 0;
  z-index: 150;
  pointer-events: none;
}

/* --- Fixed Header (Hidden Initially) --- */
#header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 5000; /* Increased z-index to ensure it's always visible */
  background-color: var(--header-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px; /* Increased padding for larger header */
  height: 50px; /* Increased height to accommodate larger font */
  opacity: 0; /* Initially hidden */
  transition: opacity 0.5s;
}
.header-name {
  font-size: 1.8rem;
  text-align: left;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-top: 10px; /* Add some space from top of header */
  font-family: 'Merova', sans-serif;
}
.menu-button {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(232, 230, 225, 0.72);
  color: var(--primary-color);
  padding: 8px 18px;
  cursor: pointer;
  position: fixed !important;
  top: 10px !important;
  right: 20px !important;
  z-index: 999999 !important;
  opacity: 0;
  display: none;
  transition: opacity 0.3s ease, border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease;
  letter-spacing: 0.08em;
  font-weight: 400;
  text-transform: uppercase;
  font-size: 1.05rem;
  font-family: 'Merova', sans-serif;
  border-radius: 0;
  box-shadow: none;
}

.menu-button:focus-visible,
.channel-button:focus-visible,
.close-guide:focus-visible,
.close-modal:focus-visible,
.back-to-top:focus-visible {
  outline: 1px solid rgba(201, 169, 97, 0.86);
  outline-offset: 2px;
  box-shadow: none;
}

/* Menu visibility utility classes */
.menu-visible {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* Hide the persistent guide button while the guide itself is open. */
.tv-guide-active .menu-button {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* --- Landing Overlay --- */
#landing {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
}
.power-button {
  width: 100px;
  height: 100px;
  cursor: pointer;
  margin-bottom: 10px;
  position: relative;
  border-radius: 50%;
  background-color: #111;
}
.power-button::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 0, 0, 0.3);
  filter: blur(10px);
  pointer-events: none;
  animation: pulsate 1.5s infinite;
}
@keyframes pulsate {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
  50% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
}
.power-icon {
  width: 100%;
  height: 100%;
  display: block;
}
.power-icon path,
.power-icon line {
  stroke: red;
  stroke-width: 8;
}
.landing-name {
  font-size: 4rem;
  color: var(--primary-color);
  opacity: 0;
  width: 0;
  max-width: min(92vw, 1160px);
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
  letter-spacing: 0.2em;
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow: 0 0 28px rgba(255, 255, 255, 0.12);
}
.landing-subtitle {
  font-size: 1.2rem;
  color: var(--primary-color);
  margin-top: 5px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.landing-subtitle .subtitle-item {
  display: inline-block;
  opacity: 0;
  margin-right: 10px;
}

/* --- Main Content (Scrollable) --- */
#mainContent {
  display: none;
  overflow-y: auto;
  scroll-snap-type: y proximity;
  scroll-behavior: smooth;
  height: 100svh;
  padding-top: 60px; /* Prevents content from hiding behind the fixed header */
  overscroll-behavior-y: contain;
}

/* --- Channel Sections --- */
.channel-section {
  height: 100vh;
  min-height: 100svh;
  padding: 80px 50px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  position: relative;
  background: transparent;
  text-align: center;
}

/* Section 4 - contain absolute positioned children */
#section4 {
  overflow: hidden;
}

/* Section 5 (Sensibility) - grow to fit tall asymmetric grid */
#section5 {
  height: auto;
  min-height: 100vh;
}

/* Section 6 (UATP Archive) - long channel, snaps on entry then releases for reading */
#section6 {
  scroll-snap-align: start;
  height: auto;
  min-height: 100vh;
}

.channel-buttons {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  z-index: 10;
}
.channel-button {
  padding: 12px 20px;
  background: transparent;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
  /* Enhanced touch target for mobile */
  min-width: 44px;
  min-height: 44px;
}
.channel-button:hover,
.channel-button:active {
  background: var(--primary-color);
  color: var(--bg-color);
  transform: scale(1.05);
  box-shadow: 0 0 10px var(--primary-color);
}
.channel-number-overlay {
  position: fixed;
  bottom: 10px;
  right: 10px;
  font-size: 2.5rem;
  color: var(--primary-color);
  opacity: 0.9;
  z-index: 9995;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
  display: none;
  padding: 0;
  margin: 0;
  line-height: 1;
}

/* --- TV Guide Overlay Menu --- */
.tv-guide {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: none;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 18px;
  padding: calc(34px + env(safe-area-inset-top, 0px)) clamp(18px, 4vw, 52px) calc(34px + env(safe-area-inset-bottom, 0px)) !important;
  background:
    radial-gradient(circle at 50% 0%, rgba(201, 169, 97, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(10, 10, 10, 0.98), rgba(5, 5, 5, 0.98)) !important;
  color: #e8e6e1 !important;
  font-family: 'Merova', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
  z-index: 10000000 !important;
  opacity: 0;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  transition: opacity 240ms ease;
}

.tv-guide-header {
  width: min(1040px, 100%) !important;
  padding: 0 0 18px !important;
  margin: 0 !important;
  border-bottom: 1px solid rgba(232, 230, 225, 0.14) !important;
  background: transparent !important;
  text-align: left !important;
  color: #e8e6e1 !important;
  text-shadow: none !important;
  font-weight: 400 !important;
}

.tv-guide-header .guide-kicker {
  margin: 0 0 8px;
  color: #c9a961;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  line-height: 1;
  text-transform: uppercase;
}

.tv-guide-header h2 {
  margin: 0;
  color: #e8e6e1;
  font-size: clamp(2rem, 5vw, 4.8rem);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: -0.045em;
}

.tv-guide-grid {
  width: min(1040px, 100%);
  margin: 0 auto;
  overflow: visible;
  flex-shrink: 0;
  border: 1px solid rgba(232, 230, 225, 0.10);
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: blur(14px);
}

.tv-guide-time-header {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 0;
  background: rgba(232, 230, 225, 0.035);
  border-bottom: 1px solid rgba(232, 230, 225, 0.10);
}

.time-slot-header {
  padding: 12px 14px;
  border-right: 1px solid rgba(232, 230, 225, 0.08);
  color: rgba(232, 230, 225, 0.54);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  line-height: 1;
  text-align: left;
  text-transform: uppercase;
}

.time-slot-header:last-child {
  border-right: none;
}

.tv-guide-channels {
  display: flex;
  flex-direction: column;
}

.tv-guide-channel {
  display: flex;
  flex-direction: column;
  padding: 0;
  border-bottom: 1px solid rgba(232, 230, 225, 0.09);
  cursor: pointer;
  transition: background-color 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.tv-guide-channel:hover,
.tv-guide-channel:focus-visible,
.tv-guide-channel.is-current {
  background-color: rgba(201, 169, 97, 0.08);
}

.tv-guide-channel.is-current {
  box-shadow: inset 3px 0 0 #c9a961;
}

.tv-guide-channel:focus-visible {
  outline: 1px solid rgba(201, 169, 97, 0.72);
  outline-offset: -1px;
}

.tv-guide-channel:last-child {
  border-bottom: none;
}

.channel-info {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 16px clamp(14px, 2vw, 22px) 8px;
  border-bottom: 1px solid rgba(232, 230, 225, 0.06);
}

.channel-number {
  width: 64px;
  flex: 0 0 64px;
  color: #c9a961;
  font-size: 0.76rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-shadow: none;
}

.channel-title {
  margin-left: 0;
  color: #e8e6e1;
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  font-weight: 400;
  letter-spacing: -0.018em;
}

.program-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px clamp(14px, 2vw, 22px) 16px calc(clamp(14px, 2vw, 22px) + 82px);
}

.program-item {
  min-height: 64px;
  margin: 0;
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: rgba(10, 10, 10, 0.38);
  border: 1px solid rgba(232, 230, 225, 0.08);
  border-left: 1px solid rgba(201, 169, 97, 0.50);
  border-radius: 0;
  box-shadow: none;
}

.program-title {
  margin: 0 0 10px;
  color: #f2eee6;
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.program-time {
  color: rgba(232, 230, 225, 0.52);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  line-height: 1.25;
  text-transform: uppercase;
}

.close-guide {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: clamp(16px, 3vw, 30px);
  z-index: 10000001 !important;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 16px;
  background: rgba(10, 10, 10, 0.72);
  border: 1px solid rgba(232, 230, 225, 0.62);
  border-radius: 0;
  color: #e8e6e1;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: border-color 180ms ease, color 180ms ease, background-color 180ms ease;
}

.close-guide:hover,
.close-guide:focus-visible {
  background: rgba(201, 169, 97, 0.10);
  border-color: #c9a961;
  color: #f7f2e8;
  outline: none;
  box-shadow: none;
}

.tv-guide-info {
  width: min(1040px, 100%);
  position: static;
  margin: 0 auto;
  padding: 16px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(232, 230, 225, 0.10);
  border-radius: 0;
  color: #e8e6e1;
  box-shadow: none;
}

.tv-guide-info h3 {
  margin: 0 0 8px;
  padding: 0;
  border: none;
  color: #c9a961;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
}

.tv-guide-info p {
  max-width: 580px;
  margin: 0;
  color: rgba(232, 230, 225, 0.72);
  font-size: clamp(0.95rem, 1.4vw, 1.05rem);
  line-height: 1.45;
}

.time-slot {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 6px;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  color: rgba(232, 230, 225, 0.54);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-align: right;
  text-transform: uppercase;
}

.time-indicator {
  color: #c9a961;
  font-weight: 400;
}

.date-display {
  opacity: 0.68;
}

@media (max-width: 760px) {
  .tv-guide {
    gap: 14px;
    padding: calc(72px + env(safe-area-inset-top, 0px)) 14px calc(28px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .tv-guide-time-header {
    display: none;
  }

  .channel-info {
    padding: 14px 14px 8px;
  }

  .program-grid {
    grid-template-columns: 1fr;
    padding: 8px 14px 14px;
  }

  .program-item {
    grid-column: 1 / -1 !important;
    min-height: 54px;
  }

  .tv-guide-info {
    flex-direction: column;
    gap: 14px;
  }

  .time-slot {
    align-items: flex-start;
    text-align: left;
  }
}

/* --- Modal Overlays & Boxes --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2200;
  padding: 20px;
  backdrop-filter: blur(5px);
  transition: opacity 0.5s;
}
.modal-box {
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #c9a961;
  color: #f0f0f0;
  padding: 30px;
  max-width: 90%;
  max-height: 90%;
  overflow-y: auto;
  position: relative;
  font-family: 'Merova', sans-serif;
  line-height: 1.6;
  border-radius: 5px;
  box-shadow: 0 0 30px rgba(201, 169, 97, 0.18);
  transition: all 0.2s ease;
}
.modal-content {
  margin: 20px 0;
}
.modal-content h1,
.modal-content h2,
.modal-content h3 {
  margin-bottom: 15px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.05em;
  text-shadow: 0 0 5px rgba(201, 169, 97, 0.28);
}
.modal-content p,
.modal-content ul {
  margin-bottom: 20px;
  font-size: 1rem;
  color: #e0e0e0;
}
.modal-content a {
  color: #c9a961;
  text-decoration: none;
  border-bottom: 1px dotted #c9a961;
  transition: color 0.3s ease;
}
.modal-content a:hover {
  color: #d4b978;
}
.close-modal {
  position: absolute;
  top: 10px;
  left: 10px; /* Move to left side to avoid conflict with guide button */
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #c9a961;
  color: #f0f0f0;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 3px;
  transition: all 0.2s ease;
  line-height: 1;
  z-index: 10; /* Ensure it's above other content */
}
.close-modal:hover {
  background: rgba(201, 169, 97, 0.16);
  box-shadow: 0 0 10px rgba(201, 169, 97, 0.28);
}

/* iPhone vertical-specific modal optimizations */
@supports (-webkit-touch-callout: none) and (max-width: 480px) and (orientation: portrait) {
  .modal-overlay {
    align-items: center;
    padding: 12px;
  }

  .modal-box {
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    max-height: 86vh;
    padding: 24px 18px;
    border: 1px solid rgba(201, 169, 97, 0.72);
    box-shadow: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .close-modal {
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.72);
    padding: 0;
    font-size: 1.2rem;
    border-radius: 0;
    border: 1px solid rgba(201, 169, 97, 0.72);
    height: 44px;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
  }
  
  /* Make content slightly larger for better readability */
  .modal-content p,
  .modal-content ul {
    font-size: 1.05rem;
    line-height: 1.5;
  }
  
  /* Add bottom padding for notched phones */
  .modal-content {
    padding-bottom: env(safe-area-inset-bottom, 20px);
  }
}


/* --- Utility Classes --- */
.hidden {
  display: none;
}

/* --- Responsive Mobile Enhancements --- */
@media (max-width: 600px) {
  .landing-name {
    width: auto;
    max-width: 92vw;
    margin: 0 auto;
    padding: 0 4vw;
    display: grid;
    gap: 0.08em;
    overflow: visible;
    white-space: normal;
    overflow-wrap: normal;
    line-height: 0.86;
    font-size: clamp(2.4rem, 13vw, 3.3rem);
    letter-spacing: 0.08em;
  }
  .landing-name .name-line {
    display: block;
  }
  .header-name {
    font-size: 1.06rem;
    margin-top: 0;
    letter-spacing: 0.035em;
  }
  .menu-button {
    padding: 5px 11px;
    font-size: 0.82rem;
    letter-spacing: 0.12em;
    min-width: 44px;
    min-height: 38px;
    top: 6px !important;
    right: 10px !important;
    border-width: 1px;
  }
  #header {
    height: 38px;
    padding: 0 12px;
    background-color: rgba(0, 0, 0, 0.72);
  }
  
  /* Channel section vertical optimization for mobile */
  .channel-section {
    padding: 30px 20px;
    min-height: 100vh;
    justify-content: center;
  }
  
  /* Optimize video background for vertical mobile */
  .video-background iframe {
    width: 100vw !important;
    height: 100vh !important;
    object-fit: cover;
  }
  
  /* Button layout for vertical mobile */
  .channel-buttons {
    flex-direction: column !important;
    gap: 25px !important;
    width: 90%; /* Wider buttons for easier tapping */
    max-width: 330px; /* Slightly wider for better usage of screen width */
  }
  
  .channel-button {
    padding: 15px 24px; /* Larger touch target on mobile */
    width: 100%; /* Full width buttons on mobile */
    min-height: 58px; /* Touch target without app-like bulk */
    margin: 2px 0;
    -webkit-tap-highlight-color: rgba(201, 169, 97, 0.18);
    font-size: 1rem;
    letter-spacing: 0.16em;
    border-width: 1px;
    border-radius: 0;
    background-color: rgba(0, 0, 0, 0.28);
    box-shadow: none;
    text-transform: uppercase;
  }
  
  /* iPhone vertical-specific button optimizations */
  @supports (-webkit-touch-callout: none) and (max-width: 480px) and (orientation: portrait) {
    .channel-buttons {
      /* Place buttons in bottom half of screen for better thumb reach */
      top: 55% !important;
      gap: 20px !important;
    }
    
    .channel-button {
      min-height: 58px;
      border-radius: 0;
      box-shadow: none;
      border-width: 1px;
      transition: transform 0.16s ease, background-color 0.16s ease, color 0.16s ease;
      background-color: rgba(0, 0, 0, 0.34);
    }
    
    .channel-button:active {
      transform: scale(0.985);
      background-color: rgba(201, 169, 97, 0.16);
    }
    
    /* Channel 4 specific button optimizations */
    .channel4-buttons {
      top: 55% !important;
    }
  }
  
  /* Channel 4 specific vertical layout */
  .channel4-buttons {
    flex-direction: column !important;
    gap: 25px !important;
    width: 85%;
    max-width: 300px;
  }
  
  /* Modal adjustments for mobile */
  .modal-box {
    max-width: 95%;
    max-height: 85vh;
    padding: 25px 18px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }
  
  .close-modal {
    top: 8px;
    right: 8px;
    font-size: 1.2rem;
    padding: 8px 10px;
    min-width: 44px; /* Larger touch target */
    min-height: 44px; /* Larger touch target */
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .modal-content h1 {
    font-size: 1.8rem;
  }
  
  .modal-content h2 {
    font-size: 1.5rem;
  }
  
  .modal-content h3 {
    font-size: 1.3rem;
  }
  
  .channel-number-overlay {
    font-size: clamp(1.45rem, 6.4vw, 1.95rem);
    bottom: calc(12px + env(safe-area-inset-bottom));
    right: 12px;
    opacity: 0.68;
  }
  
  /* Fix for iOS Safari */
  html, body {
    height: 100%;
    overflow: hidden; /* mainContent handles scrolling */
  }
  
  #mainContent {
    height: auto;
    min-height: -webkit-fill-available;
    min-height: 100%;
    height: 100%;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    padding-top: calc(44px + env(safe-area-inset-top, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  
  .channel-number-overlay {
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
  }

  .back-to-top {
    display: none !important;
  }
  
  /* Improve iOS modal behavior */
  .modal-box {
    -webkit-overflow-scrolling: touch;
    max-height: calc(86vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding: max(22px, env(safe-area-inset-top, 0px) + 18px) max(18px, env(safe-area-inset-right, 0px) + 14px) max(22px, env(safe-area-inset-bottom, 0px) + 18px) max(18px, env(safe-area-inset-left, 0px) + 14px);
  }
  
  /* iOS specific enhancements */
  @supports (-webkit-touch-callout: none) {
    body {
      overscroll-behavior-y: none;
    }

    #header {
      padding-top: env(safe-area-inset-top, 0px);
      height: calc(38px + env(safe-area-inset-top, 0px));
    }

    .menu-button {
      top: calc(6px + env(safe-area-inset-top, 0px)) !important;
      right: calc(10px + env(safe-area-inset-right, 0px)) !important;
    }
  }
}

/* --- 4K+ Display Optimization --- */
@media (min-width: 3840px) {
  .channel-section {
    padding: 120px 80px;
  }
  .channel-button {
    font-size: 2rem;
    padding: 20px 32px;
  }
}

/* --- Channel 1 Video Background --- */
.video-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  overflow: hidden;
  z-index: -1;
  background: #000000 url('visuals/static.gif') center center repeat; /* Fallback with static gif */
}
.video-background iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100vw, 177.78vh) !important;
  height: max(56.25vw, 100vh) !important;
  pointer-events: none;
  border: 0;
  object-fit: cover;
  transform: translate(-50%, -50%) scale(1.36) !important;
}

.video-background::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.52) 0%, rgba(0, 0, 0, 0.10) 15%, transparent 34%, transparent 62%, rgba(0, 0, 0, 0.34) 82%, rgba(0, 0, 0, 0.78) 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.028) 0, rgba(255, 255, 255, 0.028) 1px, transparent 1px, transparent 3px);
}

.video-background::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: clamp(76px, 13vh, 142px);
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.78) 58%, #000 100%);
}

.youtube-chrome-veil {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.56), rgba(0, 0, 0, 0.20) 33%, transparent 58%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0, rgba(255, 255, 255, 0.045) 1px, transparent 1px, transparent 4px),
    rgba(0, 0, 0, 0.22);
  mix-blend-mode: multiply;
  transition: opacity 90ms linear;
}

.video-background.is-loop-handoff .youtube-chrome-veil {
  opacity: 1;
  animation: signal-handoff 420ms steps(2, end);
}

@keyframes signal-handoff {
  0% { transform: translate3d(0, 0, 0); filter: brightness(0.82) contrast(1.14); }
  33% { transform: translate3d(-1px, 0, 0); filter: brightness(0.68) contrast(1.24); }
  66% { transform: translate3d(1px, 0, 0); filter: brightness(0.76) contrast(1.18); }
  100% { transform: translate3d(0, 0, 0); filter: brightness(0.92) contrast(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .landing-name {
    opacity: 1;
    width: 100%;
  }
}
/* Battery-saving mode for mobile */
.video-background.battery-saving {
  background-size: cover;
  background-position: center center;
}
/* Responsive optimization for mobile */
@media (max-width: 768px) {
  .video-background {
    background-size: cover;
  }
  .video-background iframe {
    height: 100vh !important; /* Use viewport height on mobile */
  }
  
  /* === SAFE ADDITIVE MOBILE ENHANCEMENTS FOR CHANNEL 1 === */
  
  /* Enhanced power button for mobile (purely additive) */
  .power-button {
    /* Ensure minimum touch target size (44px) */
    min-width: 100px;
    min-height: 100px;
    /* Add touch-friendly styling without breaking existing styles */
    -webkit-tap-highlight-color: rgba(255, 0, 0, 0.3);
    touch-action: manipulation; /* Optimize for touch */
  }
  
  /* Enhanced channel buttons for mobile (builds on existing styles) */
  .channel-button {
    /* Ensure comfortable touch targets */
    min-height: 48px; /* Minimum recommended touch target */
    min-width: 48px;
    /* Add better visual feedback */
    -webkit-tap-highlight-color: rgba(201, 169, 97, 0.18);
    /* Optimize touch behavior */
    touch-action: manipulation;
    /* Add subtle mobile-specific styling */
    transition: transform 0.1s ease-out, box-shadow 0.2s ease-out;
  }
  
  .channel-button:active {
    /* Subtle press feedback for mobile */
    transform: scale(0.98);
  }
  
  /* Safe area insets for modern phones (additive only) */
  #section1 {
    /* Add safe area padding without disrupting existing layout */
    padding-top: max(env(safe-area-inset-top), 0px);
    padding-bottom: max(env(safe-area-inset-bottom), 0px);
    /* Ensure content is accessible on phones with notches */
    min-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  
  /* Enhanced header for mobile (purely additive) */
  #header {
    /* Add safe area top padding */
    padding-top: env(safe-area-inset-top, 0px);
    /* Ensure header works well on mobile */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px); /* Safari support */
  }
  
  /* Enhanced menu button for mobile (purely additive) */
  #menuButton {
    /* Ensure proper touch target size */
    min-width: 44px;
    min-height: 44px;
    /* Add safe area positioning */
    top: max(10px, env(safe-area-inset-top, 0px) + 10px);
    right: max(20px, env(safe-area-inset-right, 0px) + 20px);
    /* Optimize for touch */
    -webkit-tap-highlight-color: rgba(201, 169, 97, 0.18);
    touch-action: manipulation;
  }
  
  /* Enhanced landing experience for mobile (purely additive) */
  #landing {
    /* Add safe area handling for landing screen */
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* Ensure landing content is properly positioned on mobile */
    min-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  
  /* Enhanced landing typography for mobile (builds on existing) */
  .landing-name {
    /* Add better mobile text handling */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Ensure proper line breaks on mobile */
    word-wrap: break-word;
    hyphens: auto;
  }
  
  .landing-subtitle {
    /* Better mobile typography */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Add subtle spacing improvements for mobile */
    line-height: 1.4;
  }
}
