/* ============================================
       MCU Watch Tracker — Cinematic Dark Mode
       ============================================ */
    :root {
      --marvel-red: #E23636;
      --doomsday-gold: #D4A843;
      --surface-dark: #050508;
      --surface: #0a0a12;
      --surface-light: #10101e;
      --surface-card: #14142a;
      --surface-hover: #1e1e3a;
      --text-primary: #f0f0f5;
      --text-secondary: #8888a8;
      --border-subtle: rgba(255, 255, 255, 0.06);
      --glass-bg: rgba(5, 5, 10, 0.82);
      --glass-border: rgba(255, 255, 255, 0.07);
    }

    *,
    *::before,
    *::after {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    html {
      scroll-behavior: smooth;
      -webkit-font-smoothing: antialiased;
    }

    body {
      font-family: 'Inter', system-ui, sans-serif;
      background-color: var(--surface-dark);
      color: var(--text-primary);
      min-height: 100vh;
      overflow-x: hidden;
    }

    ::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }

    ::-webkit-scrollbar-track {
      background: var(--surface-dark);
    }

    ::-webkit-scrollbar-thumb {
      background: var(--surface-card);
      border-radius: 3px;
    }

    ::-webkit-scrollbar-thumb:hover {
      background: var(--surface-hover);
    }

    body::before {
      content: '';
      position: fixed;
      inset: 0;
      pointer-events: none;
      z-index: 0;
      background: radial-gradient(ellipse at 20% 0%, rgba(226, 54, 54, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(212, 168, 67, 0.03) 0%, transparent 60%);
    }

    .glass-header {
      background: var(--glass-bg);
      backdrop-filter: blur(24px) saturate(1.2);
      -webkit-backdrop-filter: blur(24px) saturate(1.2);
      border-bottom: 1px solid var(--glass-border);
    }

    .progress-bar-track {
      background: var(--surface-light);
      border-radius: 999px;
      overflow: hidden;
      height: 8px;
    }

    .progress-bar-fill {
      height: 100%;
      border-radius: 999px;
      background: linear-gradient(90deg, var(--marvel-red), var(--doomsday-gold));
      transition: width 0.7s cubic-bezier(0.23, 1, 0.32, 1);
      position: relative;
      min-width: 0;
    }

    .progress-bar-fill::after {
      content: '';
      position: absolute;
      inset: 0;
      background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.25) 50%, transparent 100%);
      animation: shimmer 2.5s ease-in-out infinite;
    }

    @keyframes shimmer {
      0% {
        transform: translateX(-100%);
      }

      100% {
        transform: translateX(200%);
      }
    }

    .category-tabs {
      display: flex;
      gap: 0.5rem;
      overflow-x: auto;
      scrollbar-width: none;
      -ms-overflow-style: none;
      padding: 0.25rem 0;
    }

    .category-tabs::-webkit-scrollbar {
      display: none;
    }

    .category-tabs button {
      flex-shrink: 0;
      padding: 0.5rem 1.25rem;
      border-radius: 9999px;
      font-size: 0.8rem;
      font-weight: 600;
      color: rgba(255, 255, 255, 0.45);
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid rgba(255, 255, 255, 0.06);
      transition: all 0.25s ease;
      cursor: pointer;
      font-family: inherit;
      white-space: nowrap;
    }

    .category-tabs button:hover {
      color: rgba(255, 255, 255, 0.7);
      background: rgba(255, 255, 255, 0.08);
    }

    .category-tabs button.active {
      color: #fff;
      background: rgba(226, 54, 54, 0.15);
      border-color: rgba(226, 54, 54, 0.35);
      box-shadow: 0 0 16px rgba(226, 54, 54, 0.12);
    }

    /* Movie Cards */
    .movie-card {
      background: var(--surface-card);
      border: 1px solid var(--border-subtle);
      border-radius: 14px;
      overflow: hidden;
      transition: transform 0.45s cubic-bezier(0.23, 1, 0.32, 1), border-color 0.35s ease, box-shadow 0.45s ease;
      position: relative;
      will-change: transform;
    }

    .movie-card:hover {
      transform: translateY(-8px) scale(1.015);
      border-color: rgba(226, 54, 54, 0.25);
      box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45), 0 0 40px rgba(226, 54, 54, 0.08);
    }

    .movie-card.is-watched {
      opacity: 0.45;
      filter: saturate(0.2) brightness(0.85);
    }

    .movie-card.is-watched:hover {
      opacity: 0.75;
      filter: saturate(0.5) brightness(0.95);
    }

    .poster-wrap {
      position: relative;
      width: 100%;
      aspect-ratio: 2/3;
      overflow: hidden;
      background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    }

    .poster-wrap img {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: transform 0.55s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.4s ease;
      opacity: 0;
      z-index: 1;
    }

    .poster-wrap img.loaded {
      opacity: 1;
    }

    .movie-card:hover .poster-wrap img.loaded {
      transform: scale(1.06);
    }

    .poster-fallback {
      position: absolute;
      inset: 0;
      z-index: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      text-align: center;
      padding: 2rem 1.2rem;
      background: linear-gradient(135deg, #1a1a2e 0%, #0d1b3e 40%, #1a0a0a 100%);
    }

    .poster-fallback .fb-icon {
      width: 44px;
      height: 44px;
      margin-bottom: 14px;
      opacity: 0.3;
      color: var(--marvel-red);
    }

    .poster-fallback .fb-title {
      font-size: 0.92rem;
      font-weight: 700;
      color: var(--text-primary);
      line-height: 1.35;
    }

    .poster-fallback .fb-year {
      font-size: 0.78rem;
      color: var(--text-secondary);
      margin-top: 6px;
    }

    .type-badge {
      position: absolute;
      top: 10px;
      right: 10px;
      padding: 3px 9px;
      border-radius: 6px;
      font-size: 0.6rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      z-index: 5;
      pointer-events: none;
    }

    .type-badge.movie {
      background: rgba(226, 54, 54, 0.88);
      color: #fff;
    }

    .type-badge.series {
      background: rgba(139, 92, 246, 0.88);
      color: #fff;
    }

    .order-badge {
      position: absolute;
      top: 10px;
      left: 10px;
      width: 28px;
      height: 28px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.68rem;
      font-weight: 800;
      background: rgba(0, 0, 0, 0.65);
      backdrop-filter: blur(6px);
      border: 1px solid rgba(255, 255, 255, 0.1);
      color: var(--text-primary);
      z-index: 5;
      pointer-events: none;
    }

    .cat-badge {
      display: inline-flex;
      align-items: center;
      padding: 2px 8px;
      border-radius: 999px;
      font-size: 0.58rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }

    .cat-badge.cat-infinity {
      background: rgba(99, 102, 241, 0.12);
      color: #818cf8;
      border: 1px solid rgba(99, 102, 241, 0.18);
    }

    .cat-badge.cat-multiverse {
      background: rgba(239, 68, 68, 0.10);
      color: #f87171;
      border: 1px solid rgba(239, 68, 68, 0.15);
    }

    .cat-badge.cat-television {
      background: rgba(16, 185, 129, 0.10);
      color: #34d399;
      border: 1px solid rgba(16, 185, 129, 0.15);
    }

    .cat-badge.cat-legacy {
      background: rgba(245, 158, 11, 0.10);
      color: #fbbf24;
      border: 1px solid rgba(245, 158, 11, 0.15);
    }

    .watched-stamp {
      position: absolute;
      inset: 0;
      background: rgba(5, 5, 10, 0.55);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 4;
      pointer-events: none;
    }

    .watched-stamp svg {
      width: 52px;
      height: 52px;
      color: var(--marvel-red);
      filter: drop-shadow(0 0 14px rgba(226, 54, 54, 0.45));
    }

    .watch-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      width: 100%;
      padding: 10px 14px;
      border-radius: 10px;
      font-size: 0.82rem;
      font-weight: 600;
      cursor: pointer;
      border: 1px solid var(--border-subtle);
      background: var(--surface);
      color: var(--text-secondary);
      transition: all 0.3s ease;
      font-family: inherit;
    }

    .watch-btn:hover {
      border-color: var(--marvel-red);
      color: var(--marvel-red);
      background: rgba(226, 54, 54, 0.06);
    }

    .watch-btn.is-on {
      background: linear-gradient(135deg, rgba(226, 54, 54, 0.12), rgba(212, 168, 67, 0.08));
      border-color: var(--marvel-red);
      color: var(--marvel-red);
    }

    .trailer-btn {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 5px 12px;
      border-radius: 8px;
      font-size: 0.75rem;
      font-weight: 500;
      background: transparent;
      border: 1px solid var(--border-subtle);
      color: var(--text-secondary);
      cursor: pointer;
      transition: all 0.3s ease;
      font-family: inherit;
    }

    .trailer-btn:hover {
      border-color: var(--doomsday-gold);
      color: var(--doomsday-gold);
      background: rgba(212, 168, 67, 0.06);
    }

    .platform-pill {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 4px 10px;
      border-radius: 7px;
      font-size: 0.68rem;
      font-weight: 600;
      background: rgba(226, 54, 54, 0.08);
      color: var(--marvel-red);
      border: 1px solid rgba(226, 54, 54, 0.15);
    }

    .sort-toggle {
      display: inline-flex;
      background: var(--surface);
      border-radius: 12px;
      padding: 4px;
      border: 1px solid var(--border-subtle);
    }

    .sort-toggle button {
      padding: 9px 16px;
      border-radius: 9px;
      font-size: 0.82rem;
      font-weight: 500;
      color: var(--text-secondary);
      background: transparent;
      border: none;
      cursor: pointer;
      transition: all 0.3s ease;
      white-space: nowrap;
      font-family: inherit;
    }

    .sort-toggle button.active {
      background: var(--marvel-red);
      color: #fff;
      box-shadow: 0 2px 12px rgba(226, 54, 54, 0.35);
    }

    .sort-toggle button:not(.active):hover {
      color: var(--text-primary);
    }

    .pacing-card {
      background: linear-gradient(135deg, rgba(226, 54, 54, 0.05), rgba(212, 168, 67, 0.03));
      border: 1px solid rgba(226, 54, 54, 0.1);
      border-radius: 16px;
    }

    .analytics-row {
      border-top: 1px solid rgba(255, 255, 255, 0.05);
      margin-top: 1.5rem;
      padding-top: 1.25rem;
    }

    .stat-val {
      font-size: 2rem;
      font-weight: 800;
      background: linear-gradient(135deg, var(--marvel-red), var(--doomsday-gold));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      line-height: 1.1;
    }

    .stat-val.small {
      font-size: 1.25rem;
    }

    .stat-lbl {
      font-size: 0.7rem;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      margin-top: 4px;
      font-weight: 600;
    }

    .modal-overlay {
      position: fixed;
      inset: 0;
      z-index: 1000;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(0, 0, 0, 0.88);
      backdrop-filter: blur(12px);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.35s ease;
    }

    .modal-overlay.active {
      opacity: 1;
      pointer-events: all;
    }

    .modal-frame, .details-frame {
      width: 92%;
      max-width: 960px;
      border-radius: 14px;
      overflow: hidden;
      box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
      transform: scale(0.88);
      transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    }

    .modal-frame { aspect-ratio: 16/9; }
    
    .modal-overlay.active .modal-frame,
    .modal-overlay.active .details-frame {
      transform: scale(1);
    }

    .modal-frame iframe {
      width: 100%;
      height: 100%;
      border: none;
    }

    @keyframes checkPop {
      0% {
        transform: scale(0) rotate(-20deg);
      }

      60% {
        transform: scale(1.25) rotate(5deg);
      }

      100% {
        transform: scale(1) rotate(0);
      }
    }

    .check-pop {
      animation: checkPop 0.45s cubic-bezier(0.23, 1, 0.32, 1);
    }

    @keyframes fadeInUp {
      from {
        opacity: 0;
        transform: translateY(24px);
      }

      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .fade-in-up {
      animation: fadeInUp 0.5s ease forwards;
      opacity: 0;
    }

    select {
      appearance: none;
      -webkit-appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238888a8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 14px center;
      padding-right: 40px !important;
    }

    input[type="date"] {
      color-scheme: dark;
    }

    /* Schedule Timeline */
    .timeline {
      position: relative;
      border-left: 2px solid rgba(226, 54, 54, 0.2);
      margin-left: 1rem;
      padding-left: 2rem;
      list-style: none;
    }

    .timeline-item {
      position: relative;
      margin-bottom: 2rem;
    }

    .timeline-item::before {
      content: '';
      position: absolute;
      left: -2.4rem;
      top: 0.2rem;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: var(--surface-dark);
      border: 2px solid var(--doomsday-gold);
      box-shadow: 0 0 10px rgba(212, 168, 67, 0.4);
    }

    .timeline-date {
      font-size: 0.85rem;
      color: var(--marvel-red);
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 0.25rem;
    }

    .timeline-title {
      font-size: 1.15rem;
      font-weight: 800;
      color: #fff;
    }

    .timeline-meta {
      font-size: 0.8rem;
      color: var(--text-secondary);
      margin-top: 0.25rem;
    }

    @media (max-width: 640px) {
      .stat-val {
        font-size: 1.5rem;
      }

      .sort-toggle button {
        padding: 7px 12px;
        font-size: 0.75rem;
      }

      .movie-card:hover {
        transform: translateY(-4px) scale(1.01);
      }
    }

    .line-clamp-2 {
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .install-btn {
      display: none;
      /* hidden by default until PWA event fires */
      background: linear-gradient(135deg, rgba(226, 54, 54, 0.15), rgba(212, 168, 67, 0.1));
      border: 1px solid rgba(226, 54, 54, 0.3);
      color: #fff;
      font-size: 0.75rem;
      font-weight: 600;
      padding: 6px 12px;
      border-radius: 8px;
      cursor: pointer;
      transition: all 0.2s;
    }

    .install-btn.visible {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .install-btn:hover {
      border-color: var(--marvel-red);
      box-shadow: 0 0 10px rgba(226, 54, 54, 0.3);
    }
