:root {
  color-scheme: dark;
  --halloween-orange: #ff6b35;
  --halloween-purple: #4a148c;
  --halloween-black: #1a1a1a;
  --halloween-gold: #ffa000;
  --video-overlay: rgba(15, 15, 19, 0.7);
}

.video-background { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -2; overflow: hidden; background: #000; }
.video-background video { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  filter: brightness(0.5) contrast(1.5) saturate(1.4); 
  opacity: 1;
  transition: opacity 0.8s ease-in-out; 
  will-change: opacity; 
  transform: translateZ(0); 
  backface-visibility: hidden; 
  contain: layout style paint; 
}
.video-background.static-bg { 
  background: linear-gradient(135deg, rgba(30, 13, 46, 0.8) 0%, rgba(15, 15, 19, 0.9) 100%),
              url('assets/videos/halloween-background-1-poster.jpg') center/cover no-repeat;
  filter: brightness(0.5) contrast(1.5) saturate(1.4);
}

.audio-control { position: fixed; top: 20px; right: 20px; z-index: 1000; opacity: 0.8; transition: opacity 0.3s ease; }
.audio-control:hover { opacity: 1; }
.audio-toggle { background: rgba(26, 26, 26, 0.9); border: 2px solid var(--halloween-orange); border-radius: 25px; padding: 8px 16px; color: var(--halloween-orange); font-family: 'Inter', system-ui, sans-serif; font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.3s ease; backdrop-filter: blur(10px); box-shadow: 0 4px 15px rgba(255, 107, 53, 0.2); }
.audio-toggle:hover { background: rgba(255, 107, 53, 0.1); border-color: var(--halloween-gold); color: var(--halloween-gold); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255, 107, 53, 0.3); }
.audio-toggle.audio-enabled { background: rgba(255, 107, 53, 0.2); border-color: var(--halloween-gold); color: var(--halloween-gold); }

.hidden { display: none !important; }
.show-block { display: block !important; }
.show-flex { display: flex !important; }
.badge-large { font-size: 2.5rem; }
.state-message { text-align: center; padding: 2rem; opacity: 0.7; }
.state-message .icon-lg { font-size: 2rem; margin-bottom: 1rem; }
.state-message .title-sm { margin: 0 0 0.5rem 0; font-size: 1.1rem; }
.state-message .desc { margin: 0; font-size: 0.9rem; color: rgba(248,247,255,0.6); }
.full-span-center { grid-column: 1 / -1; text-align: center; padding: 2rem; }
.centered-flex { display: flex; justify-content: center; align-items: center; text-align: center; }
.muted { opacity: 0.75; }
.entry-number-hint { color: rgba(248, 247, 255, 0.6); font-size: 0.8em; font-weight: normal; }

.content-overlay { position: relative; z-index: 1; background: var(--video-overlay); min-height: 100vh; backdrop-filter: blur(1px); display: flex; flex-direction: column; align-items: center; width: 100%; }

body.voter-body { margin: 0; font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0f0f13; color: #f8f7ff; min-height: 100vh; overflow-x: hidden; }

.voter-app { width: min(100%, 480px); min-height: 100vh; display: flex; flex-direction: column; padding: 1.5rem 1.25rem 5.5rem; box-sizing: border-box; position: relative; }

.voter-header { text-align: center; margin-bottom: 1.5rem; }
.voter-title { font-size: clamp(1.8rem, 5vw, 2.35rem); font-weight: 700; margin: 0.5rem 0; }
.voter-subtitle { margin: 0; font-size: 0.95rem; color: rgba(248, 247, 255, 0.7); }

.category-grid { display: grid; gap: 1rem; flex: 1; grid-auto-rows: 1fr; align-content: stretch; align-items: stretch; }
.category-card { border: none; background: linear-gradient(135deg, rgba(255,111,0,0.16), rgba(255,111,0,0.06)); border-radius: 1.25rem; padding: 1.75rem 1.25rem; color: inherit; display: flex; flex-direction: column; justify-content: space-between; text-align: left; box-shadow: 0 18px 45px rgba(0,0,0,0.45); width: 100%; height: 100%; position: relative; pointer-events: none; }

.modal-backdrop { position: fixed; top:0; left:0; right:0; bottom:0; background: rgba(10,9,17,0.85); display:none; align-items:flex-start; justify-content:center; padding:1rem; margin:0; z-index:2000; box-sizing:border-box; overflow-y:auto; -webkit-overflow-scrolling:touch; overscroll-behavior:contain; transition: all .3s ease-in-out; }
.modal-backdrop.active { display:flex; background: rgba(8,7,15,0.85); }
.modal { width: min(480px, calc(100vw - 2rem)); height: min(760px, calc(100vh - 2rem)); transition: all 0.4s ease-out; }
/* Migrated from index.html inline styles */
    :root {
      color-scheme: dark;
      --halloween-orange: #ff6b35;
      --halloween-purple: #4a148c;
      --halloween-black: #1a1a1a;
      --halloween-gold: #ffa000;
      --video-overlay: rgba(15, 15, 19, 0.7);
    }

    /* Video Background System */
    .video-background {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -2;
      overflow: hidden;
    }

    .video-background video {
      width: 100%;
      height: 100%;
      object-fit: cover;
      filter: brightness(0.5) contrast(1.5) saturate(1.4); /* More pronounced background */
      transition: opacity 1s ease-in-out;
      /* Hardware acceleration optimizations - Phase 1 */
      will-change: transform, opacity;
      transform: translateZ(0);
      backface-visibility: hidden;
      contain: layout style paint;
    }

    /* Video Start Overlay for Autoplay Restrictions */
    .video-start-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(135deg, 
        rgba(26, 26, 26, 0.95) 0%, 
        rgba(74, 20, 140, 0.85) 50%, 
        rgba(255, 107, 53, 0.9) 100%);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: -1;
      backdrop-filter: blur(10px);
    }

    .video-start-content {
      text-align: center;
      color: white;
      max-width: 400px;
      padding: 2rem;
    }

    .video-start-icon {
      font-size: 4rem;
      margin-bottom: 1rem;
      animation: pulse 2s infinite;
    }

    .video-start-content h3 {
      font-size: 1.5rem;
      margin-bottom: 0.5rem;
      color: var(--halloween-gold);
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    }

    .video-start-content p {
      font-size: 1rem;
      margin-bottom: 1.5rem;
      opacity: 0.9;
    }

    .video-start-btn {
      background: linear-gradient(135deg, var(--halloween-orange) 0%, var(--halloween-gold) 100%);
      border: none;
      border-radius: 25px;
      padding: 0.75rem 2rem;
      color: white;
      font-weight: 600;
      font-size: 1rem;
      cursor: pointer;
      transition: all 0.3s ease;
      box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    .video-start-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
      background: linear-gradient(135deg, var(--halloween-gold) 0%, var(--halloween-orange) 100%);
    }

    @keyframes pulse {
      0%, 100% { transform: scale(1); }
      50% { transform: scale(1.1); }
    }

    /* Audio Control System */
    .audio-control {
      position: fixed;
      top: 20px;
      right: 20px;
      z-index: 1000;
      opacity: 0.8;
      transition: opacity 0.3s ease;
    }

    /* Ensure modal is above audio control when active */
    .modal-backdrop.active {
      z-index: 1200;
    }

    /* Create better contrast and visibility for background when modal is open */
    .modal-backdrop.active {
      background: rgba(10, 9, 17, 0.25);
    }

    .audio-control:hover {
      opacity: 1;
    }

    .audio-toggle {
      background: rgba(26, 26, 26, 0.9);
      border: 2px solid var(--halloween-orange);
      border-radius: 25px;
      padding: 8px 16px;
      color: var(--halloween-orange);
      font-family: 'Segoe UI', system-ui, sans-serif;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 8px;
      transition: all 0.3s ease;
      backdrop-filter: blur(10px);
      box-shadow: 0 4px 15px rgba(255, 107, 53, 0.2);
    }

    .audio-toggle:hover {
      background: rgba(255, 107, 53, 0.1);
      border-color: var(--halloween-gold);
      color: var(--halloween-gold);
      transform: translateY(-2px);
      box-shadow: 0 6px 20px rgba(255, 107, 53, 0.3);
    }

    .audio-toggle.audio-enabled {
      background: rgba(255, 107, 53, 0.2);
      border-color: var(--halloween-gold);
      color: var(--halloween-gold);
    }

    .audio-icon {
      font-size: 16px;
      line-height: 1;
    }

    .audio-text {
      font-size: 12px;
    }

    @media (max-width: 768px) {
      .audio-control {
        top: 15px;
        right: 15px;
      }
      
      .audio-toggle {
        padding: 6px 12px;
        font-size: 12px;
      }
      
      .audio-text {
        display: none;
      }
      
      .audio-icon {
        font-size: 18px;
      }
    }

    /* Intro Video Screen */
    .intro-screen {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 1000;
      background: #000;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 1;
      transition: opacity 0.5s ease-out;
    }

    .intro-screen.fade-out {
      opacity: 0;
      pointer-events: none;
    }

    .intro-video {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .intro-skip {
      position: absolute;
      bottom: 2rem;
      right: 2rem;
      z-index: 1001;
    }

    .skip-button {
      background: rgba(255, 107, 53, 0.9);
      color: white;
      border: 2px solid var(--halloween-orange);
      padding: 0.75rem 1.5rem;
      border-radius: 25px;
      font-family: 'Inter', sans-serif;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
      backdrop-filter: blur(10px);
    }

    .skip-button:hover {
      background: var(--halloween-orange);
      transform: translateY(-2px);
      box-shadow: 0 5px 15px rgba(255, 107, 53, 0.4);
    }

    /* Content Overlay */
    .content-overlay {
      position: relative;
      z-index: 1;
      background: var(--video-overlay);
      min-height: 100vh;
      backdrop-filter: blur(1px);
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 100%;
    }

    body.voter-body {
      margin: 0;
      font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      background: #0f0f13;
      color: #f8f7ff;
      min-height: 100vh;
      overflow-x: hidden;
    }

    .voter-app {
      width: min(100%, 480px);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      padding: 1.5rem 1.25rem 5.5rem;
      box-sizing: border-box;
      position: relative;
    }

    .voter-header {
      text-align: center;
      margin-bottom: 1.5rem;
    }

    .voter-title {
      font-size: clamp(1.8rem, 5vw, 2.35rem);
      font-weight: 700;
      margin: 0.5rem 0;
    }

    .voter-subtitle {
      margin: 0;
      font-size: 0.95rem;
      color: rgba(248, 247, 255, 0.7);
    }

    .category-grid {
      display: grid;
      gap: 1rem;
      flex: 1;
      grid-auto-rows: 1fr;
      align-content: stretch;
      align-items: stretch;
    }

    .category-grid > * {
      width: 100%;
    }

    .category-card-wrapper {
      width: 100%;
      height: 100%;
      cursor: pointer;
      user-select: none;
      -webkit-tap-highlight-color: rgba(255, 111, 0, 0.3);
      touch-action: pan-y;
      border-radius: 1.25rem;
      position: relative;
      transition: transform 0.25s ease, box-shadow 0.25s ease;
    }

    .category-card-wrapper:hover,
    .category-card-wrapper:focus,
    .category-card-wrapper.hover-active {
      transform: translateY(-4px);
      box-shadow: 0 22px 55px rgba(0, 0, 0, 0.6);
    }

    .category-card-wrapper:active {
      transform: translateY(-2px);
      box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    }

    .category-card {
      border: none;
      background: linear-gradient(135deg, rgba(255, 111, 0, 0.16), rgba(255, 111, 0, 0.06));
      border-radius: 1.25rem;
      padding: 1.75rem 1.25rem;
      color: inherit;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      text-align: left;
      box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
      width: 100%;
      height: 100%;
      position: relative;
      pointer-events: none; /* Let the wrapper handle all interactions */
    }

    .category-card:active,
    .category-card:focus-visible,
    .category-card:hover {
      transform: translateY(-4px);
      box-shadow: 0 22px 55px rgba(0, 0, 0, 0.6);
      animation: card-wiggle 0.25s ease-in-out 0s 2 alternate;
    }

    @keyframes card-wiggle {
      0% { transform: translateY(-4px) rotate(-1.4deg); }
      50% { transform: translateY(-4px) rotate(1.4deg); }
      100% { transform: translateY(-4px) rotate(-1.4deg); }
    }

    .category-card:active {
      transform: translateY(-2px);
      box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    }

    .category-card .category-label {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: clamp(1.25rem, 5vw, 1.6rem);
      font-weight: 600;
      gap: 0.75rem;
    }

    .category-meta {
      margin-top: 1.2rem;
      font-size: 0.85rem;
      color: rgba(248, 247, 255, 0.7);
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.5rem;
      min-height: 1.2rem;
    }

    .category-progress {
      font-weight: 500;
      text-align: right;
      white-space: nowrap;
      flex-shrink: 0;
      color: rgba(248, 247, 255, 0.7);
      background: none !important;
    }

    /* Style for voted status text */
    .category-progress.voted-status,
    .category-progress:has-text("Voted for") {
      color: #ff6b35 !important;
      font-weight: 600;
    }

    /* Voting Summary Styles */
    .voting-summary {
      margin-top: 2rem;
      padding: 1.5rem;
      background: linear-gradient(135deg, rgba(255, 111, 0, 0.08), rgba(255, 111, 0, 0.03));
      border-radius: 1rem;
      border: 1px solid rgba(255, 111, 0, 0.15);
      backdrop-filter: blur(10px);
    }

    .voting-summary-header {
      text-align: center;
      margin-bottom: 1.25rem;
    }

    .voting-summary-header h3 {
      margin: 0 0 0.5rem 0;
      font-size: 1.25rem;
      font-weight: 600;
      color: #ff6b35;
    }

    .voting-summary-header p {
      margin: 0;
      font-size: 0.9rem;
      color: rgba(248, 247, 255, 0.7);
    }

    .voting-summary-list {
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
    }

    .voting-summary-item {
      background: rgba(255, 255, 255, 0.02);
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: 0.75rem;
      padding: 1rem;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
    }

    .voting-summary-category {
      font-weight: 600;
      color: #ff6b35;
      font-size: 1rem;
    }

    .voting-summary-entry {
      font-size: 0.95rem;
      color: rgba(248, 247, 255, 0.9);
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }

    .voting-summary-details {
      font-size: 0.85rem;
      color: rgba(248, 247, 255, 0.6);
      font-style: italic;
    }

    .voting-summary-meta {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 0.8rem;
      color: rgba(248, 247, 255, 0.5);
      border-top: 1px solid rgba(255, 255, 255, 0.05);
      padding-top: 0.5rem;
      margin-top: 0.5rem;
    }

    .entry-badge {
      background: rgba(255, 107, 53, 0.2);
      color: #ff6b35;
      padding: 0.2rem 0.5rem;
      border-radius: 0.4rem;
      font-size: 0.8rem;
      font-weight: 600;
      margin-left: 0.5rem;
    }

    .modal-backdrop {
      position: fixed !important;
      top: 0 !important;
      left: 0 !important;
      right: 0 !important;
      bottom: 0 !important;
      background: rgba(10, 9, 17, 0.85); /* Darker background for better contrast */
      display: none;
      align-items: flex-start !important; /* Force top alignment */
      justify-content: center !important;
      padding: 1rem !important; /* Padding on all sides */
      margin: 0 !important; /* Remove any margin */
      z-index: 2000 !important; /* Much higher to ensure it's above everything */
      box-sizing: border-box;
      overflow-y: auto !important; /* Allow scrolling in backdrop */
      -webkit-overflow-scrolling: touch !important; /* Smooth iOS scrolling */
      overscroll-behavior: contain !important; /* Prevent bounce */
      /* Smooth transition for modal positioning */
      transition: all 0.3s ease-in-out;
    }

    .modal-backdrop.active {
      display: flex;
      background: rgba(8, 7, 15, 0.85); /* Darker background for immersive experience */
    }

    /* Enhanced modal experience - hide entire landing page content when modal is active */
    .modal-backdrop.active ~ .content-overlay {
      opacity: 0;
      transform: translateY(-30px) scale(0.95);
      transition: opacity 0.3s ease-out, transform 0.3s ease-out;
      pointer-events: none;
    }
    
    /* Smooth return animation when modal closes */
    .content-overlay {
      opacity: 1;
      transform: translateY(0) scale(1);
      transition: opacity 0.4s ease-in, transform 0.4s ease-in;
    }
    
    /* Immersive modal positioning - force to very top of screen */
    .modal-backdrop.active .modal {
      margin-top: 0 !important; /* Force at the very top */
      margin-bottom: auto !important;
      align-self: flex-start !important; /* Force top alignment */
      position: relative !important;
      top: 0 !important; /* Absolute top positioning */
      animation: slideInFromTop 0.4s ease-out;
    }
    
    @keyframes slideInFromTop {
      from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
      }
      to {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }
    
    /* Background video continues playing while content is hidden */
.modal-backdrop.active ~ .video-background {
  opacity: 1; /* Keep video background visible and playing */
}

    .modal {
      width: min(480px, calc(100vw - 2rem));
      height: min(760px, calc(100vh - 2rem));
      transition: all 0.4s ease-out; /* Smooth size transitions */
    }
    
    /* Enhanced modal size when in immersive mode - full screen usage */
    .modal-backdrop.active .modal {
      width: min(600px, calc(100vw - 1rem)); /* Wider for better image viewing */
      height: min(95vh, calc(100vh - 1rem)); /* Nearly full height since content is hidden */
      max-width: 480px;
      max-height: 760px;
      background: rgba(18, 18, 24, 0.95);
      border-radius: 1.5rem;
      border: 1px solid rgba(255, 255, 255, 0.12);
      box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
      display: flex;
      flex-direction: column;
      overflow: hidden; /* CONTAIN: Modal boundaries are fixed */
      position: relative;
      margin: auto;
    }

    .modal-header,
    .modal-footer {
      padding: 1.15rem 1.5rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
    }

    .modal-header-left {
      display: flex;
      align-items: center;
      gap: 0.75rem;
    }

    .modal-title {
      font-size: 1.1rem;
      font-weight: 600;
      margin: 0;
    }

    .view-toggle {
      display: flex;
      gap: 0.5rem;
      background: rgba(255, 255, 255, 0.08);
      border-radius: 0.75rem;
      padding: 0.25rem;
    }

    .view-btn {
      padding: 0.5rem 0.75rem !important;
      border-radius: 0.5rem !important;
      font-size: 0.9rem;
      transition: all 0.2s ease;
      border: none !important;
      background: transparent !important;
    }

    .view-btn.active {
      background: rgba(255, 111, 0, 0.2) !important;
      color: #ff6f00 !important;
    }

    .view-btn .icon {
      font-size: 0.85rem;
      font-weight: 500;
    }

.modal-body {
  flex: 1;
  min-height: 0; /* CRITICAL: Allow shrinking for scroll */
  max-height: 100%; /* CONSTRAIN: Force scrolling when content exceeds */
      overflow-y: scroll !important; /* FORCE SCROLLBAR: Always show scrollbar */
      overflow-x: hidden;
      position: relative;
      transition: opacity 0.2s ease;
      display: flex;
      flex-direction: column;
      -webkit-overflow-scrolling: touch !important;
      overscroll-behavior: contain !important;
      scrollbar-width: thin;
      scrollbar-color: rgba(255, 111, 0, 0.3) transparent; /* Halloween orange scrollbar */
    }

    .modal-body::-webkit-scrollbar {
      width: 8px;
    }

    .modal-body::-webkit-scrollbar-track {
      background: rgba(0, 0, 0, 0.1);
      border-radius: 4px;
    }

    .modal-body::-webkit-scrollbar-thumb {
      background: rgba(255, 111, 0, 0.3);
      border-radius: 4px;
    }

    .modal-body.view-switching {
      opacity: 0.8;
    }

    .carousel {
      display: flex;
      flex: 1;
      height: 100%;
      transition: transform 0.35s ease;
      min-height: 0;
      /* Use CSS custom property for CSP-compliant transforms */
      --carousel-offset: 0%;
      transform: translateX(var(--carousel-offset));
    }

    .carousel-card {
      min-width: 100%;
      padding: 0 1.5rem 1.5rem;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      height: 100%;
      gap: 1rem;
      opacity: 0.35;
      transform: scale(0.94);
      transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .carousel-card.active {
      opacity: 1;
      transform: scale(1);
    }

    .carousel-image {
      width: 100%;
      border-radius: 1.25rem;
      aspect-ratio: 4 / 3;
      object-fit: contain;
      object-position: center;
      box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
      background: linear-gradient(135deg, rgba(248, 250, 252, 0.95) 0%, rgba(241, 245, 249, 0.98) 100%);
      transition: all 0.3s ease;
    }

    /* Auto-fit carousel images based on orientation */
    .carousel-image.landscape {
      object-fit: cover !important;
      background: none !important;
    }

    .carousel-image.portrait {
      object-fit: contain !important;
      background: linear-gradient(135deg, rgba(248, 250, 252, 0.95) 0%, rgba(241, 245, 249, 0.98) 100%) !important;
    }

    .carousel-image.square {
      object-fit: cover !important;
      background: none !important;
    }

    /* Clickable image cursor */
    .clickable-image {
      cursor: pointer !important;
    }

    /* Force visible class for CSP-compliant navigation visibility */
    .force-visible {
      display: flex !important;
      visibility: visible !important;
      opacity: 1 !important;
      pointer-events: auto !important;
      position: relative !important;
      z-index: 1000 !important;
    }

    /* Generic helpers to replace inline styles */
    .opacity-0 { opacity: 0 !important; }
    .fade-in { opacity: 1 !important; transition: opacity 0.3s ease; }
    .bg-placeholder { background-color: #f0f0f0 !important; }
.thumb-highlight { box-shadow: 0 0 0 3px rgba(255, 111, 0, 0.5) !important; }

/* Loading skeleton for images */
.loading-skeleton {
  background-image: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
}

/* Fullscreen image overlay */
.fullscreen-image-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  transition: opacity 0.3s ease;
}

.fullscreen-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  z-index: 10001;
}

.fullscreen-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Connection indicator statuses */
.status-connected { background: #10b981 !important; opacity: 0.4 !important; }
.status-connecting { background: #f59e0b !important; opacity: 0.8 !important; animation: pulse 2s infinite; }
.status-disconnected { background: #ef4444 !important; opacity: 0.8 !important; animation: pulse 2s infinite; }

/* Connection indicator base */
#connection-indicator.connection-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #6b7280;
  z-index: 1000;
  transition: all 0.3s ease;
  opacity: 0.6;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

    /* Mobile responsive carousel images */
    @media (max-width: 768px) {
      .carousel-image {
        aspect-ratio: 3 / 2;
        max-height: 300px;
      }
      
      .carousel-image.portrait {
        aspect-ratio: 3 / 4;
        max-height: 400px;
      }
    }

    @media (max-width: 480px) {
      .carousel-image {
        aspect-ratio: 16 / 10;
        max-height: 250px;
      }
      
      .carousel-image.portrait {
        aspect-ratio: 4 / 5;
        max-height: 300px;
      }
    }

    .entry-info {
      display: flex;
      flex-direction: column;
      gap: 0.6rem;
    }

    .entry-info h3 {
      margin: 0;
      font-size: 1.25rem;
      font-weight: 600;
    }

    .entry-info p {
      margin: 0.4rem 0 0;
      color: rgba(248, 247, 255, 0.75);
      font-size: 0.9rem;
      line-height: 1.4;
    }

    .entry-meta {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin-top: 0.75rem;
      font-size: 0.85rem;
      color: rgba(248, 247, 255, 0.7);
    }

    .thumbnail-grid {
      padding: 1rem 1.5rem;
      display: grid;
      width: 100% !important; /* FULL WIDTH: Use all available modal space */
      box-sizing: border-box !important;
      /* Will be overridden by responsive rules below */
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); 
      grid-auto-rows: minmax(180px, max-content); /* Flexible rows */
      gap: 0.75rem; /* Comfortable gap */
      flex: 0 0 auto; /* NO FLEX: Let content determine height */
      overflow: visible; /* NO SCROLLING: Modal-body handles it */
      justify-items: stretch; /* Cards fill grid cells */
      align-items: stretch; /* Cards stretch to fill row height */
      /* Clean thumbnail grid - no debug borders */
    }

    /* Remove legacy style-attribute-based visibility hacks */

    .thumbnail-grid::-webkit-scrollbar {
      width: 6px;
    }

    .thumbnail-grid::-webkit-scrollbar-track {
      background: rgba(255, 255, 255, 0.05);
      border-radius: 3px;
    }

    .thumbnail-grid::-webkit-scrollbar-thumb {
      background: rgba(255, 111, 0, 0.3);
      border-radius: 3px;
    }

    .thumbnail-card {
      position: relative;
      border-radius: 1rem;
      overflow: hidden;
      background: rgba(255, 255, 255, 0.05);
      cursor: pointer;
      transition: all 0.25s ease;
      border: 2px solid transparent;
      display: flex;
      flex-direction: column;
      /* Let card size based on content - image will be fixed height */
      min-height: 180px;
      width: 100%;
    }

    .thumbnail-card:hover,
    .thumbnail-card:focus {
      transform: translateY(-2px);
      box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
      border-color: rgba(255, 111, 0, 0.3);
      outline: none;
    }

    .thumbnail-card:active {
      transform: translateY(0) scale(0.98);
      transition: transform 0.1s ease;
    }

    .thumbnail-card.selecting {
      animation: selectPulse 0.3s ease-out;
    }

    @keyframes selectPulse {
      0% { transform: scale(1); }
      50% { transform: scale(1.05); }
      100% { transform: scale(1); }
    }

    .thumbnail-card.selected {
      border-color: #ff6f00;
      box-shadow: 0 0 0 2px rgba(255, 111, 0, 0.2);
    }

    .thumbnail-card.voted {
      border-color: #10b981;
      box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    }

    /* ROBUST thumbnail card sizing that works with grid */
    .thumbnail-card {
      position: relative !important;
      border-radius: 1rem !important;
      overflow: hidden !important;
      background: rgba(255, 255, 255, 0.05) !important;
      cursor: pointer !important;
      transition: all 0.25s ease !important;
      border: 2px solid transparent !important;
      display: flex !important;
      flex-direction: column !important;
      height: 100% !important; /* Fill the entire grid cell */
      width: 100% !important;
      min-height: 0 !important; /* Allow grid to control minimum height */
      max-height: 100% !important; /* Stay within grid cell boundaries */
      box-sizing: border-box !important;
    }
    
    /* OVERRIDE JAVASCRIPT INLINE STYLES FOR RESPONSIVE GRID */
    .thumbnail-grid .thumbnail-card {
      width: 100% !important; /* OVERRIDE: Let grid control width, not JS */
      max-width: 100% !important;
      min-width: 0 !important;
      flex: 1 !important;
      box-sizing: border-box !important;
    }
    
    .thumbnail-grid .thumbnail-card .thumbnail-image,
    .thumbnail-card .thumbnail-image,
    img.thumbnail-image {
      width: 100% !important; /* OVERRIDE: Fill container, not fixed 120px */
      height: auto !important; /* DYNAMIC: Let aspect-ratio control height */
      max-width: 100% !important;
      min-width: 0 !important;
      aspect-ratio: 1 / 1 !important; /* Square aspect ratio for consistency */
      object-fit: cover !important;
      object-position: center !important;
      display: block !important;
      background: linear-gradient(135deg, rgba(248, 250, 252, 0.9) 0%, rgba(241, 245, 249, 0.95) 100%) !important;
      transition: all 0.3s ease !important;
      border-radius: 0.75rem 0.75rem 0 0 !important;
      flex-shrink: 0 !important;
      box-sizing: border-box !important;
    }

    /* Dynamic sizing based on image orientation */
    .thumbnail-image.landscape {
      height: auto;
      min-height: 80px;
      max-height: 140px;
      object-fit: cover !important;
      background: none !important;
    }

    .thumbnail-image.portrait {
      height: auto;
      min-height: 120px;
      max-height: 200px;
      object-fit: contain !important;
      background: linear-gradient(135deg, rgba(248, 250, 252, 0.9) 0%, rgba(241, 245, 249, 0.95) 100%) !important;
    }

    .thumbnail-image.square {
      height: auto;
      min-height: 100px;
      max-height: 160px;
      object-fit: cover !important;
      background: none !important;
    }

    /* Adaptive aspect ratio containers */
    .thumbnail-image.portrait {
      aspect-ratio: 3 / 4;
    }

    .thumbnail-image.landscape {
      aspect-ratio: 4 / 3;
    }

    .thumbnail-image.square {
      aspect-ratio: 1 / 1;
    }

    /* Container adaptations for different image types */
    .thumbnail-card.portrait-container {
      min-height: 160px;
    }

    .thumbnail-card.landscape-container {
      min-height: 120px;
    }

    .thumbnail-card.square-container {
      min-height: 140px;
    }

    .thumbnail-info {
      padding: 0.75rem !important; /* Comfortable padding */
      flex: 1 !important; /* Take remaining space in card */
      display: flex !important;
      flex-direction: column !important;
      justify-content: flex-start !important;
      min-height: 0 !important; /* Allow shrinking */
      overflow: hidden !important; /* Prevent text overflow */
    }

    .thumbnail-title {
      font-size: 0.85rem;
      font-weight: 600;
      margin: 0 0 0.25rem 0;
      line-height: 1.2;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .thumbnail-participant {
      font-size: 0.75rem;
      color: rgba(248, 247, 255, 0.7);
      margin: 0 0 0.5rem 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .thumbnail-votes {
      font-size: 0.7rem;
      color: rgba(248, 247, 255, 0.6);
      display: flex;
      align-items: center;
      gap: 0.25rem;
    }

    .thumbnail-badge {
      position: absolute;
      top: 0.5rem;
      right: 0.5rem;
      background: rgba(16, 185, 129, 0.9);
      color: white;
      font-size: 0.7rem;
      padding: 0.25rem 0.5rem;
      border-radius: 0.5rem;
      font-weight: 600;
      display: none;
    }

    .thumbnail-card.voted .thumbnail-badge {
      display: block;
    }

    .thumbnail-overlay {
      position: absolute;
      inset: 0;
      background: rgba(0, 0, 0, 0.6);
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity 0.2s ease;
      pointer-events: none;
    }

    .thumbnail-card:hover .thumbnail-overlay,
    .thumbnail-card:focus .thumbnail-overlay {
      opacity: 1;
    }

    .thumbnail-play-icon {
      color: white;
      font-size: 2rem;
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    }

    .modal-footer-content {
      width: 100%;
    }

    .instruction {
      margin: 0;
      font-size: 0.85rem;
      color: #ffa500; /* Halloween orange */
      text-align: left;
      font-weight: 500;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    }

    /* NATURAL MODAL ACTIONS: Clean and always visible */
    .modal-actions {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      gap: 1rem;
      padding: 0;
      margin: 0;
    }

    .modal-actions .btn {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.45rem;
      padding: 0.75rem 1rem;
      border: none;
      border-radius: 0.75rem;
      font-weight: 600;
      font-size: 0.9rem;
      cursor: pointer;
      transition: all 0.2s ease;
      position: relative;
      overflow: hidden;
    }

    /* Fixed width for vote button to prevent stretching */
    .modal-actions .btn.primary {
      flex: 0 0 auto;
      width: 180px;
      min-width: 180px;
      max-width: 180px;
    }

    .modal-actions .nav-btn {
      flex: 0 0 auto;
      min-width: 2.5rem;
      max-width: 2.8rem;
      height: 2.5rem;
      border-radius: 50%;
      padding: 0.5rem;
      font-size: 0.9rem;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
      transition: all 0.2s ease, transform 0.1s ease;
    }

    .modal-actions .nav-btn:hover {
      transform: translateY(-2px) scale(1.05);
      box-shadow: 0 5px 20px rgba(75, 0, 130, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }

    .modal-actions .nav-btn:active {
      transform: translateY(0) scale(0.95);
    }

    /* FIXED NAVIGATION BAR: Slideshow only, always visible at bottom */
    .fixed-navigation-bar {
      position: sticky;
      bottom: 0;
      left: 0;
      right: 0;
      background: rgba(18, 18, 24, 0.95);
      backdrop-filter: blur(12px);
      border-top: 1px solid rgba(255, 255, 255, 0.1);
      padding: 1rem;
      z-index: 1000;
      box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
      display: none; /* Hidden by default */
    }

    .fixed-navigation-bar.slideshow-active {
      display: block; /* Only show in slideshow view */
    }

    .nav-actions {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 1rem;
      max-width: 400px;
      margin: 0 auto;
    }

    /* Apply existing button styles to fixed navigation */
    .nav-actions .btn {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.45rem;
      padding: 0.75rem 1rem;
      border: none;
      border-radius: 0.75rem;
      font-weight: 600;
      font-size: 0.9rem;
      cursor: pointer;
      transition: all 0.2s ease;
      position: relative;
      overflow: hidden;
    }

    .nav-actions .btn.primary {
      flex: 0 0 auto;
      width: 180px;
      min-width: 180px;
      max-width: 180px;
    }

    .nav-actions .nav-btn {
      flex: 0 0 auto;
      min-width: 2.5rem;
      max-width: 2.8rem;
      height: 2.5rem;
      border-radius: 50%;
      padding: 0.5rem;
      font-size: 0.9rem;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
      transition: all 0.2s ease, transform 0.1s ease;
    }

    .nav-actions .nav-btn:hover {
      transform: translateY(-2px) scale(1.05);
      box-shadow: 0 5px 20px rgba(75, 0, 130, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }

    .nav-actions .nav-btn:active {
      transform: translateY(0) scale(0.95);
    }

    /* HALLOWEEN-THEMED PROFESSIONAL BUTTON STYLES */
    .btn.primary {
      background: linear-gradient(135deg, #ff6b00 0%, #ff8c00 50%, #ffa500 100%);
      color: #1a1a1a;
      font-weight: 700;
      box-shadow: 0 4px 20px rgba(255, 107, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
      border: 1px solid #ff8c00;
      text-shadow: none;
      position: relative;
      overflow: hidden;
    }



    .btn.primary:hover {
      background: linear-gradient(135deg, #ff8c00 0%, #ffa500 50%, #ffb84d 100%);
      box-shadow: 0 6px 25px rgba(255, 107, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
      transform: translateY(-2px);
      border-color: #ffa500;
    }

    .btn.primary:active {
      transform: translateY(0);
      box-shadow: 0 2px 10px rgba(255, 107, 0, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .btn.ghost {
      background: linear-gradient(135deg, rgba(75, 0, 130, 0.15) 0%, rgba(25, 25, 25, 0.2) 100%);
      color: #ff8c00;
      border: 1px solid rgba(255, 140, 0, 0.3);
      font-weight: 600;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
      backdrop-filter: blur(4px);
    }

    .btn.ghost:hover {
      background: linear-gradient(135deg, rgba(75, 0, 130, 0.25) 0%, rgba(25, 25, 25, 0.3) 100%);
      border-color: rgba(255, 140, 0, 0.5);
      color: #ffa500;
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    .btn.ghost:active {
      background: linear-gradient(135deg, rgba(75, 0, 130, 0.1) 0%, rgba(25, 25, 25, 0.15) 100%);
      transform: translateY(0);
      box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    }

    /* Halloween-themed navigation arrows */
    .btn.ghost.nav-btn {
      font-size: 1.2rem;
      font-weight: 700;
      color: #ff8c00;
      min-width: 3rem;
      border-radius: 50%;
      aspect-ratio: 1;
      padding: 0;
    }

    .btn.ghost.nav-btn:hover {
      color: #ffa500;
      background: radial-gradient(circle, rgba(75, 0, 130, 0.3) 0%, rgba(25, 25, 25, 0.4) 100%);
      border-color: #ffa500;
    }

    /* Modern minimal toast system */
    .toast-container {
      position: fixed;
      top: 1rem;
      left: 1rem;
      z-index: 1000;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      pointer-events: none;
    }

    .mini-toast {
      background: rgba(18, 18, 24, 0.95);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 8px;
      padding: 0.75rem 1rem;
      font-size: 0.8rem;
      font-weight: 500;
      color: #f8f7ff;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
      backdrop-filter: blur(8px);
      max-width: 300px;
      min-width: 200px;
      transform: translateX(-100%);
      opacity: 0;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      pointer-events: auto;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      position: relative;
      overflow: hidden;
    }

    .mini-toast.show {
      transform: translateX(0);
      opacity: 1;
    }

    .mini-toast.success {
      border-left: 3px solid #10b981;
    }

    .mini-toast.error {
      border-left: 3px solid #ef4444;
    }

    .mini-toast.warning {
      border-left: 3px solid #f59e0b;
    }

    .mini-toast.info {
      border-left: 3px solid #3b82f6;
    }

    .mini-toast.vote {
      border-left: 3px solid #ff6f00;
    }

    .toast-icon {
      font-size: 1rem;
      flex-shrink: 0;
    }

    .toast-message {
      flex: 1;
      line-height: 1.3;
    }

    .toast-progress {
      position: absolute;
      bottom: 0;
      left: 0;
      height: 2px;
      background: rgba(255, 255, 255, 0.3);
      transform-origin: left;
      animation: toast-progress 3s linear forwards;
    }

    @keyframes toast-progress {
      from { width: 100%; }
      to { width: 0%; }
    }

    .modern-loader {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      font-size: 0.9rem;
      opacity: 0.8;
    }

    .modern-spinner {
      width: 20px;
      height: 20px;
      border: 2px solid rgba(248, 247, 255, 0.2);
      border-top: 2px solid #ff6f00;
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }

    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }

    #connection-indicator {
      position: fixed !important;
      top: 20px !important;
      right: 20px !important;
      width: 12px !important;
      height: 12px !important;
      border-radius: 50% !important;
      z-index: 1000 !important;
      transition: all 0.3s ease !important;
      pointer-events: none !important;
    }

    @keyframes pulse {
      0%, 100% { transform: scale(1); opacity: 0.4; }
      50% { transform: scale(1.2); opacity: 0.8; }
    }

    @media (max-width: 480px) {
      .thumbnail-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); /* Mobile-optimized columns */
        grid-auto-rows: minmax(180px, max-content); /* Smaller mobile rows */
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        /* Clean mobile grid - no debug borders */
      }
      
      .thumbnail-image {
        height: 100px !important; /* Fixed mobile image height */
        min-height: 100px !important;
        max-height: 100px !important;
      }

      /* Mobile dynamic sizing */
      .thumbnail-image.landscape {
        min-height: 60px;
        max-height: 100px;
        aspect-ratio: 4 / 3;
        object-fit: cover !important;
        background: none !important;
      }

      .thumbnail-image.portrait {
        min-height: 80px;
        max-height: 140px;
        aspect-ratio: 3 / 4;
        object-fit: contain !important;
        background: linear-gradient(135deg, rgba(248, 250, 252, 0.9) 0%, rgba(241, 245, 249, 0.95) 100%) !important;
      }

      .thumbnail-image.square {
        min-height: 70px;
        max-height: 120px;
        aspect-ratio: 1 / 1;
        object-fit: cover !important;
        background: none !important;
      }
      
      .thumbnail-info {
        padding: 0.5rem;
      }
      
      .modal-header {
        padding: 1rem 1.25rem;
        flex-wrap: wrap;
        gap: 0.5rem;
      }
      
      .view-toggle {
        order: 3;
        width: 100%;
        justify-content: center;
      }
      
      .modal-header-left {
        flex: 1;
        min-width: 0;
      }
      
      .modal-title {
        font-size: 1rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }

    /* CONTAINER-AWARE RESPONSIVE THUMBNAIL GRID */
    
    /* DEFAULT: Auto-fit based on available space with minimum viable width */
    .thumbnail-grid {
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
      gap: 0.5rem !important;
    }
    
    /* WIDER MODAL: More space allows smaller minimum widths */
    @media (min-width: 600px) {
      .thumbnail-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
        gap: 0.75rem !important;
      }
      
      .modal {
        max-width: 550px !important; /* Wider modal for better grid */
      }
    }

    /* LARGE SCREENS: Even wider modal and more flexible grid */
    @media (min-width: 900px) {
      .modal {
        max-width: 650px !important; /* Much wider modal */
        width: min(650px, calc(100vw - 2rem)) !important;
      }
      
      .thumbnail-grid {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)) !important;
        gap: 1rem !important;
      }
    }

    /* RESPONSIVE THUMBNAIL IMAGE SIZING */
    @media (max-width: 400px) {
      .thumbnail-image {
        min-height: 80px !important; /* Smaller on very small screens */
      }
    }

    @media (min-width: 401px) and (max-width: 600px) {
      .thumbnail-image {
        min-height: 100px !important; /* Medium size for medium screens */
      }
    }

    @media (min-width: 601px) {
      .thumbnail-image {
        min-height: 120px !important; /* Larger size for bigger screens */
      }
    }

    /* Mobile Optimizations */
    @media (max-width: 768px) {
      .video-background video {
        filter: brightness(0.6) contrast(1.8) saturate(1.5) !important; /* Much more visible on mobile */
      }
      
      /* SCROLLABLE MODAL: Not full-screen, naturally scrollable */
      .modal-backdrop {
        padding: 1rem !important; /* Add padding for natural modal look */
        align-items: flex-start !important;
        overflow-y: auto !important; /* Allow backdrop to scroll */
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important; /* Prevent bounce */
      }
      
      .modal-backdrop.active .modal {
        margin-top: 1rem !important; /* Natural top margin */
        margin-bottom: 1rem !important; /* Natural bottom margin */
        top: auto !important; /* Not fixed to top */
        width: calc(100vw - 1rem) !important; /* Almost full width with minimal margins */
        height: auto !important; /* Natural height, not full screen */
        min-height: 70vh !important; /* OPTIMAL: Good height but leaves room for bottom */
        max-height: 85vh !important; /* SAFE: Ensures bottom border is always visible */
        max-width: 600px !important; /* Maximum width for readability */
        border-radius: 1rem !important; /* Rounded corners for modal look */
        border: 1px solid rgba(255, 255, 255, 0.1) !important; /* Subtle border */
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important; /* Prevent modal overflow, let body scroll */
        position: relative !important; /* Not fixed positioning */
      }

      .modal-backdrop.active .modal::-webkit-scrollbar {
        display: none !important; /* Hide visual scrollbar */
      }

      .modal-backdrop.active .modal .modal-header {
        flex-shrink: 0 !important; /* Header always visible */
        min-height: auto !important;
        padding: 0.75rem 1rem !important; /* Reduce header padding */
      }

      .modal-backdrop.active .modal .modal-body {
        flex: 1 !important; /* Take available space */
        overflow-y: auto !important; /* MODAL-BODY SCROLLS: Light blue area scrollable */
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important; /* Smooth iOS scrolling */
        overscroll-behavior: contain !important; /* Prevent bounce */
        padding: 0 !important; /* Remove padding that might interfere */
        margin: 0 !important; /* Remove margins */
        max-height: 70vh !important; /* SAFE: Ensures scrollable area fits with bottom visible */
        min-height: 50vh !important; /* FLEXIBLE: Allow content to determine height */
        border: 3px solid lightblue !important; /* DEBUG: Light blue scrollable area */
      }

      /* OLD NAVIGATION SECTION STYLES REMOVED - Using fixed navigation bar now */

      /* CAROUSEL: Dynamic height based on content */
      .carousel {
        min-height: 550px !important; /* HALVED: Reduced minimum height for more compact display */
        max-height: 60vh !important; /* HALVED: Reduced maximum height (half of 60vh) */
        padding-bottom: 0.01rem !important; /* REDUCED: Less bottom space for more compact height */
        overflow: visible !important; /* Don't clip content */
      }

      /* CAROUSEL CARDS: Ensure proper spacing and no clipping */
      .carousel-card {
        margin-bottom: 0.1rem !important; /* REDUCED: Less space between entries for compact height */
        padding: 0.15rem !important; /* REDUCED: Less internal padding for compact height */
        overflow: visible !important; /* Don't clip content */
      }

      /* ENTRY INFO: Dynamic height based on description length */
      .entry-info {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
        overflow: visible !important; /* Allow text to flow naturally */
      }

      .entry-info p {
        overflow: visible !important;
        white-space: normal !important; /* Allow text wrapping */
        word-wrap: break-word !important;
      }

      /* THUMBNAIL CARDS: Fully responsive to grid */
      .thumbnail-card {
        margin: 0 !important; /* REMOVE MARGINS: Let grid handle spacing */
        padding: 0 !important; /* REMOVE PADDING: Maximize available space */
        overflow: hidden !important; /* CONTAIN: Keep content within bounds */
        position: relative !important;
        z-index: 1 !important;
        width: 100% !important; /* FULL CELL WIDTH: Use all available grid space */
        height: 100% !important; /* MOBILE: Fill entire grid cell height */
        max-width: 100% !important; /* NEVER EXCEED: Grid cell boundaries */
        max-height: 100% !important; /* NEVER EXCEED: Grid cell height boundaries */
        min-width: 0 !important; /* FLEXIBLE: Allow shrinking if needed */
        min-height: 0 !important; /* FLEXIBLE: Allow shrinking within grid cell */
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important; /* STRETCH: Fill available width */
        border-radius: 0.75rem !important; /* ROUNDED CORNERS */
        background: rgba(255, 255, 255, 0.05) !important; /* SUBTLE BACKGROUND */
      }

      /* GRID-SPECIFIC THUMBNAIL STYLING */
      .thumbnail-grid .thumbnail-card {
        margin: 0 !important; /* NO MARGINS: Grid gap handles all spacing */
        justify-self: stretch !important; /* STRETCH: Fill entire grid cell width */
        align-self: stretch !important; /* STRETCH: Fill entire grid cell height */
      }

      /* REMOVE FIRST/LAST SPECIAL MARGINS - GRID HANDLES SPACING */
      .thumbnail-grid .thumbnail-card:first-child,
      .thumbnail-grid .thumbnail-card:last-child {
        margin: 0 !important; /* Grid padding handles edge spacing */
      }

      .carousel .carousel-card:first-child {
        margin-top: 1rem !important; /* Space at top */
      }

      .carousel .carousel-card:last-child {
        margin-bottom: 3rem !important; /* Extra space at bottom */
      }

      /* THUMBNAIL GRID: Mobile-specific adjustments */
      .thumbnail-grid {
        min-height: auto !important; /* DYNAMIC: Let content determine height */
        padding: 1rem !important; /* CONSISTENT: Padding around entire grid */
        /* Clean thumbnail grid on mobile */
        background: rgba(255, 165, 0, 0.1) !important; /* DEBUG: Orange tint */
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important; /* MOBILE: Smaller minimum for mobile screens */
        gap: 0.75rem !important; /* MOBILE: Tighter spacing for smaller screens */
        overflow: hidden !important; /* CONTAIN: Keep everything within bounds */
        width: 100% !important; /* Full width when no navigation */
        box-sizing: border-box !important;
      }

      /* FORCE HIDE THUMBNAIL GRID WHEN NOT IN USE */
      .thumbnail-grid[style*="display: none"] {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
      }

      /* OLD INSTRUCTION STYLES REMOVED - Fixed navigation doesn't need instruction text */

      .modal-backdrop.active .modal .modal-footer {
        flex-shrink: 0 !important; /* Always visible */
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important; /* Reduce gap to save space */
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0)) !important;
        background: linear-gradient(180deg, rgba(18, 18, 24, 0.92) 0%, rgba(10, 10, 15, 0.97) 100%) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        box-shadow: 0 -16px 30px rgba(0, 0, 0, 0.45) !important;
        min-height: auto !important; /* Don't force height */
        max-height: 25vh !important; /* Limit footer height to 25% of viewport */
        position: relative !important; /* Ensure proper positioning */
        z-index: 1000 !important; /* Ensure it's above other content */
        bottom: 0 !important; /* Stick to bottom */
      }

      .modal-footer-content {
        display: flex;
        flex-direction: column;
        gap: 0.5rem !important; /* Reduce gap to save space */
        width: 100%;
      }

      .modal-actions {
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0.5rem !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 10 !important;
        position: relative !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
      }

      .modal-actions .btn {
        min-height: 44px !important; /* Mobile-optimized height */
        font-size: 0.85rem !important; /* Compact mobile font */
        font-weight: 600 !important;
        padding: 0.5rem 0.75rem !important; /* Balanced mobile padding */
        min-width: 0 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        border-radius: 0.5rem !important; /* Smaller radius for mobile */
      }

      .modal-actions .nav-btn {
        flex: 0 0 auto !important;
        min-width: 36px !important;
        max-width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
        padding: 0.25rem !important;
        font-size: 0.8rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        visibility: visible !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
        transition: all 0.2s ease, transform 0.1s ease !important;
      }

      .modal-actions .nav-btn:active {
        transform: scale(0.9) !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) !important;
      }

      .carousel-card {
        padding: 0 1rem 1rem !important;
      }

      .entry-info {
        gap: 0.5rem;
      }

      .entry-meta {
        margin-top: 0.25rem;
      }
      
      .intro-skip {
        bottom: 1rem;
        right: 1rem;
      }
      
      .skip-button {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
      }

      /* Fixed Navigation Bar - Mobile */
      .fixed-navigation-bar {
        padding: 0.75rem 1rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
      }
      
      .nav-actions {
        gap: 0.75rem;
      }
      
      .nav-actions .btn {
        font-size: 0.9rem;
      }

      .nav-actions .nav-btn {
        min-width: 36px !important;
        max-width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
        padding: 0.25rem !important;
        font-size: 0.8rem !important;
      }

      .nav-actions .nav-btn:active {
        transform: scale(0.9) !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) !important;
      }
    }

    /* Consistent modal for all mobile devices */
    @media (max-width: 480px) {
      .modal-backdrop {
        padding: 0.5rem !important; /* Small padding for phones */
      }
      
      .modal-backdrop.active .modal {
        width: calc(100vw - 1rem) !important; /* Almost full width with safe margin */
        min-height: 75vh !important; /* OPTIMAL: Good height with room for bottom */
        max-height: 88vh !important; /* SAFE: Ensures modal fits in viewport completely */
        max-width: none !important; /* No max width constraint on phones */
        margin-bottom: 1rem !important; /* Ensure bottom border is visible */
      }
      
      .modal-backdrop.active .modal .modal-body {
        max-height: 75vh !important; /* SAFE: Ensures scrollable area fits with bottom visible */
        overflow-y: auto !important; /* MODAL-BODY SCROLLS: Consistent scrolling */
        overflow-x: hidden !important;
        min-height: 0 !important; /* Allow flex shrinking */
      }

      /* MOBILE THUMBNAIL GRID - Use dynamic system from above */
      .thumbnail-grid {
        grid-auto-rows: minmax(160px, max-content) !important; /* Mobile row height */
        padding: 0.75rem !important; /* Mobile padding */
        /* Clean mobile grid styling */
        overflow: visible !important; /* NO SCROLLING: Modal-body handles it */
        flex: 0 0 auto !important; /* Let content determine size */
      }

      .thumbnail-card {
        border-radius: 0.5rem !important; /* SMALLER RADIUS: Mobile appropriate */
      }

      /* MOBILE THUMBNAIL IMAGES */
      .thumbnail-grid .thumbnail-card .thumbnail-image {
        height: 90px !important; /* Mobile image height */
        border-radius: 0.5rem 0.5rem 0 0 !important; /* MATCH CARD RADIUS */
      }
    }
      
      .modal-backdrop.active .modal .modal-body {
        padding: 0 1rem calc(1.25rem + env(safe-area-inset-bottom, 0)) !important;
        overflow-y: auto !important; /* MODAL-BODY SCROLLS: Final mobile override */
        overflow-x: hidden !important;
      }
      
      .instruction {
        margin-bottom: 0 !important; /* Remove margin to save space */
        font-size: 0.8rem !important; /* Smaller font to save space */
        text-align: center !important;
        line-height: 1.2 !important; /* Tighter line height */
        padding: 0 !important; /* Remove any padding */
      }
      
      /* Prevent bounce scrolling on carousel and thumbnails */
      .carousel,
      .thumbnail-grid {
        overscroll-behavior: contain !important;
        -webkit-overflow-scrolling: touch !important;
      }

      /* TALL MOBILE SCREENS: Additional height optimization for screens > 900px height */
      @media (min-height: 900px) {
      .modal-backdrop.active .modal {
        min-height: 80vh !important; /* Good height on tall screens */
        max-height: 90vh !important; /* SAFE: Still leaves room for bottom border */
      }
      
      .modal-backdrop.active .modal .modal-body {
        max-height: 78vh !important; /* SAFE: Scrollable area with bottom border visible */
        min-height: 60vh !important; /* Flexible minimum height */
      }
    }

    /* Mobile styles continue */
      
      /* Lock body scroll when modal is active on mobile */
      body:has(.modal-backdrop.active) {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: none !important; /* Prevent bounce */
      }

    /* Reduced Motion Support */
    @media (prefers-reduced-motion: reduce) {
      .video-background video {
        display: none;
      }
      
      .intro-screen {
        background: linear-gradient(135deg, var(--halloween-purple) 0%, var(--halloween-black) 100%);
      }
      
      .intro-video {
        display: none;
      }
      
      .content-overlay {
        background: var(--halloween-black);
      }
    }

    /* High Performance Mode (slow connections) */
    .video-disabled .video-background,
    .video-disabled .intro-screen {
      display: none;
    }
    
    .video-disabled .content-overlay {
      background: linear-gradient(135deg, #1a0d2e 0%, #0f0f13 100%);
    }
  </style>
.modal-body.view-slideshow .thumbnail-grid { display: none !important; }
.modal-body.view-grid .carousel { display: none !important; }
