/* ===================================
   CineVault - Premium Streaming UI
   Mobile & Desktop Optimized
   =================================== */

/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
  /* Colors */
  --bg-primary: #07090f;
  --bg-secondary: #0d1117;
  --bg-tertiary: #131926;
  --bg-elevated: #1a2236;
  --border-color: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.15);

  /* Accent Colors */
  --gold: #f5c842;
  --gold-dark: #e8a020;
  --gold-light: #f7d77a;
  --gold-bg: rgba(245, 200, 66, 0.12);
  --gold-border: rgba(245, 200, 66, 0.3);

  --blue: #4f8ef7;
  --blue-bg: rgba(79, 142, 247, 0.15);
  --blue-border: rgba(79, 142, 247, 0.3);

  --green: #3dd68c;
  --green-bg: rgba(61, 214, 140, 0.15);
  --green-border: rgba(61, 214, 140, 0.3);

  --red: #f75252;

  /* Text Colors */
  --text-primary: #eef0f8;
  --text-secondary: #a0aec0;
  --text-muted: #5a6a8a;

  /* Typography */
  --font-display: 'Syne', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-Index Layers */
  --z-base: 1;
  --z-overlay: 100;
  --z-modal: 200;
  --z-player: 300;
  --z-ad: 9999;
  --z-toast: 10000;

  /* Safe Areas */
  --safe-area-top: env(safe-area-inset-top, 0);
  --safe-area-bottom: env(safe-area-inset-bottom, 0);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

/* Noise Texture Overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
  opacity: 0.5;
}

/* Focus Styles for Accessibility */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

button {
  cursor: pointer;
  font-family: inherit;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===== APP CONTAINER ===== */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  z-index: var(--z-base);
}

/* ===== LOADING SCREEN ===== */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  z-index: var(--z-modal);
  transition: opacity var(--transition-normal);
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 14px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 1px;
}

/* ===== TOP BAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg) var(--space-sm);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.logo {
  font-family: var(--font-display);
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 1px;
}

.logo span {
  color: var(--text-primary);
  font-weight: 400;
}

.topbar-actions {
  display: flex;
  gap: var(--space-sm);
}

.icon-btn {
  width: 40px;
  height: 40px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.icon-btn:active, .icon-btn.active {
  color: var(--gold);
  background: var(--gold-bg);
  border-color: var(--gold-border);
}

/* ===== MAIN TABS ===== */
.main-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xs);
  padding: 0 var(--space-lg) var(--space-md);
  flex-shrink: 0;
}

.mtab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.mtab svg {
  width: 20px;
  height: 20px;
}

.mtab:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.mtab.active {
  background: var(--gold-bg);
  border-color: var(--gold-border);
  color: var(--gold);
  font-weight: 600;
}

/* ===== FILTER PILLS ===== */
.pills {
  display: flex;
  gap: var(--space-sm);
  padding: 0 var(--space-lg) var(--space-md);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}

.pills::-webkit-scrollbar {
  display: none;
}

.pill {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pill:hover {
  border-color: var(--border-hover);
  color: var(--text-secondary);
}

.pill.active {
  background: var(--gold);
  color: var(--bg-primary);
  border-color: var(--gold);
  font-weight: 600;
}

/* ===== MAIN SCROLL AREA ===== */
.main-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-tertiary) transparent;
}

.main-scroll::-webkit-scrollbar {
  width: 6px;
}

.main-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.main-scroll::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

.main-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== SECTIONS ===== */
.section {
  padding: var(--space-lg) 0 0;
}

.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  margin-bottom: var(--space-md);
}

.sec-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.sec-more {
  font-size: 13px;
  color: var(--gold);
  background: none;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.sec-more:hover {
  opacity: 0.8;
}

/* ===== HORIZONTAL SCROLL ROW ===== */
.hrow {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  padding: 0 var(--space-lg) var(--space-sm);
  scrollbar-width: none;
}

.hrow::-webkit-scrollbar {
  display: none;
}

/* ===== CARDS ===== */
.card {
  flex-shrink: 0;
  width: 120px;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

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

.card:active {
  transform: scale(0.95);
}

.card-poster {
  width: 120px;
  height: 180px;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  background: var(--bg-tertiary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

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

.card-score {
  position: absolute;
  bottom: var(--space-sm);
  left: var(--space-sm);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-sm);
  padding: 3px var(--space-sm);
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 2px;
}

.card-wl {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.card-wl:hover {
  background: rgba(0, 0, 0, 0.9);
  color: var(--gold);
}

.card-wl.on {
  color: var(--gold);
}

.card-name {
  font-size: 12px;
  font-weight: 500;
  margin-top: var(--space-sm);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== GRID ===== */
.grid-wrap {
  padding: var(--space-lg) var(--space-lg) calc(var(--space-xl) + var(--safe-area-bottom));
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--space-md);
}

@media (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-lg);
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

.gcell {
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.gcell:hover {
  transform: translateY(-4px);
}

.gcell:active {
  transform: scale(0.95);
}

.gcell-img {
  aspect-ratio: 2/3;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-tertiary);
  position: relative;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.gcell-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.gcell-img img.loaded {
  opacity: 1;
}

.gcell-score {
  position: absolute;
  bottom: var(--space-sm);
  right: var(--space-sm);
  background: rgba(0, 0, 0, 0.8);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--gold);
}

.gcell-ep {
  position: absolute;
  bottom: var(--space-sm);
  left: var(--space-sm);
  background: var(--blue);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 600;
  color: white;
}

.gcell-name {
  font-size: 12px;
  font-weight: 500;
  margin-top: var(--space-sm);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ===== BOTTOM NAVIGATION ===== */
.bottomnav {
  display: flex;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  padding-bottom: max(var(--space-md), var(--safe-area-bottom));
  position: relative;
  z-index: 10;
}

.bnav {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--space-sm) 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  transition: color var(--transition-fast);
}

.bnav svg {
  width: 22px;
  height: 22px;
}

.bnav:hover {
  color: var(--text-secondary);
}

.bnav.active {
  color: var(--gold);
}

/* ===== SEARCH OVERLAY ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: none;
  flex-direction: column;
  z-index: var(--z-overlay);
}

.overlay.open {
  display: flex;
  animation: slideInRight var(--transition-normal);
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--border-color);
}

.search-input-wrap input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
}

.search-input-wrap input::placeholder {
  color: var(--text-muted);
}

.search-cancel {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  padding: var(--space-sm);
}

.search-type-row {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.stype-btn {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.stype-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-secondary);
}

.stype-btn.active {
  background: var(--gold);
  color: var(--bg-primary);
  border-color: var(--gold);
  font-weight: 600;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.search-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-muted);
  gap: var(--space-md);
  font-size: 14px;
}

/* ===== WATCHLIST PAGE ===== */
.overlay-page {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: none;
  flex-direction: column;
  z-index: var(--z-overlay);
}

.overlay-page.open {
  display: flex;
  animation: slideInRight var(--transition-normal);
}

.wl-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.wl-heading {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  flex: 1;
}

.wl-badge {
  background: var(--gold);
  color: var(--bg-primary);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.wl-content {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.wl-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  color: var(--text-muted);
}

.wl-empty svg {
  opacity: 0.2;
}

/* ===== DETAIL PANEL ===== */
.detail-panel {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  overflow-y: auto;
  scrollbar-width: thin;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  z-index: var(--z-modal);
}

.detail-panel.open {
  transform: translateX(0);
}

.dp-backdrop {
  position: relative;
  width: 100%;
  height: clamp(220px, 40vh, 320px);
  flex-shrink: 0;
}

.dp-backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.dp-backdrop img.loaded {
  opacity: 1;
}

.dp-back-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(7, 9, 15, 0.25) 0%, var(--bg-primary) 100%);
}

.dp-close, .dp-wl-btn {
  position: absolute;
  top: var(--space-md);
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.dp-close:hover, .dp-wl-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.dp-close {
  left: var(--space-md);
}

.dp-wl-btn {
  right: var(--space-md);
}

.dp-wl-btn.on {
  color: var(--gold);
}

.dp-body {
  padding: 0 var(--space-lg) calc(80px + var(--safe-area-bottom));
}

.dp-type-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: var(--space-sm);
}

.dp-type-movie {
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid var(--gold-border);
}

.dp-type-tv {
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid var(--blue-border);
}

.dp-type-anime {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.dp-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 6vw, 36px);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: var(--space-md);
}

.dp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.dp-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.dp-chip.gold {
  color: var(--gold);
  background: var(--gold-bg);
  border-color: rgba(245, 200, 66, 0.2);
}

.genres-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.g-tag {
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-muted);
}

.dp-overview {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
}

.watch-btn {
  width: 100%;
  padding: var(--space-md);
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  box-shadow: 0 8px 30px rgba(245, 200, 66, 0.3);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.watch-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(245, 200, 66, 0.4);
}

.watch-btn:active {
  transform: translateY(0);
}

/* ===== EPISODE PICKER ===== */
.ep-picker {
  margin-bottom: var(--space-xl);
}

.ep-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  gap: var(--space-md);
}

.ep-picker-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.sub-dub-toggle {
  display: flex;
  gap: var(--space-xs);
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-full);
}

.lang-btn {
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.lang-btn:hover {
  color: var(--text-secondary);
}

.lang-btn.active {
  background: var(--accent-primary);
  color: white;
}

.lang-btn:active {
  transform: scale(0.95);
}

.season-tabs {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
}

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

.s-tab {
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.s-tab:hover {
  border-color: var(--border-hover);
  color: var(--text-secondary);
}

.s-tab.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
  font-weight: 600;
}

.ep-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-sm);
}

@media (min-width: 480px) {
  .ep-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (min-width: 768px) {
  .ep-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

.ep-btn {
  aspect-ratio: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.ep-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
}

.ep-btn:active, .ep-btn.active {
  background: var(--gold);
  color: var(--bg-primary);
  border-color: var(--gold);
  font-weight: 700;
}

/* ===== PLAYER OVERLAY ===== */
.player-overlay {
  position: fixed;
  inset: 0;
  background: black;
  display: none;
  flex-direction: column;
  z-index: var(--z-player);
}

.player-overlay.open {
  display: flex;
}

.player-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.player-close {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.player-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.player-title {
  flex: 1;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-frame {
  flex: 1;
  width: 100%;
  border: none;
  display: block;
  background: black;
}

.player-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.player-loading .spinner {
  width: 60px;
  height: 60px;
}

/* ===== AD OVERLAY ===== */
#ad-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-xl);
  z-index: var(--z-ad);
}

#ad-overlay.hidden {
  display: none;
}

.ad-progress-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
}

.ad-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  transition: width 0.1s linear;
}

.ad-logo {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.ad-poster-wrap {
  position: relative;
  width: 160px;
  height: 240px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.ad-poster-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ad-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(245, 200, 66, 0.15), transparent);
}

.ad-timer-ring {
  position: relative;
  width: 80px;
  height: 80px;
}

.ad-timer-ring svg {
  transform: rotate(-90deg);
}

.ad-timer-ring circle {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
}

.ad-ring-bg {
  stroke: rgba(255, 255, 255, 0.1);
}

.ad-ring-fill {
  stroke: var(--gold);
  stroke-dasharray: 201;
  stroke-dashoffset: 201;
  transition: stroke-dashoffset 0.1s linear;
}

.ad-timer-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
}

.ad-label {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
  max-width: 280px;
}

.ad-auto-note {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--gold);
  opacity: 0.9;
}

.ad-continue {
  padding: var(--space-sm) var(--space-xl);
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: var(--bg-primary);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: none;
  transform: scale(0.9);
  box-shadow: 0 8px 30px rgba(245, 200, 66, 0.4);
}

.ad-continue.show {
  display: block;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* ===== ADBLOCK WARNING ===== */
.adblock-warning {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.adblock-warning.hidden {
  display: none;
}

.adblock-content {
  text-align: center;
  max-width: 400px;
}

.adblock-icon {
  font-size: 64px;
  margin-bottom: var(--space-lg);
}

.adblock-content h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: var(--space-md);
}

.adblock-content p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  line-height: 1.5;
}

.adblock-note {
  font-size: 13px;
  color: var(--text-muted);
}

.adblock-btn {
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-xl);
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(245, 200, 66, 0.3);
  transition: transform var(--transition-fast);
}

.adblock-btn:hover {
  transform: translateY(-2px);
}

/* ===== FOOTER ===== */
.app-footer {
  padding: var(--space-md) var(--space-lg) calc(var(--space-md) + var(--safe-area-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.footer-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  margin: 0;
}

.footer-disclaimer::before {
  content: '';
  display: block;
  width: 40px;
  height: 1px;
  background: var(--border-color);
  margin: 0 auto var(--space-sm);
}

@keyframes popIn {
  to { transform: scale(1); }
}

/* ===== TOAST ===== */
#toast {
  position: fixed;
  bottom: calc(80px + var(--safe-area-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-lg);
  font-size: 13px;
  color: var(--text-primary);
  z-index: var(--z-toast);
  opacity: 0;
  transition: all var(--transition-normal);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== SKELETON LOADING ===== */
.skel {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-elevated) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: var(--radius-md);
}

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

/* ===== HERO SECTION ===== */
.hero {
  position: relative;
  width: 100%;
  height: clamp(200px, 35vh, 280px);
  overflow: hidden;
  flex-shrink: 0;
}

.hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.hero-img.loaded {
  opacity: 1;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(7, 9, 15, 0.2) 0%, rgba(7, 9, 15, 0.5) 40%, var(--bg-primary) 100%);
}

.hero-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-lg);
}

.hero-badge {
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: var(--space-xs);
  font-family: var(--font-display);
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: var(--space-md);
}

.hero-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.btn-gold {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(245, 200, 66, 0.35);
  transition: transform var(--transition-fast);
}

.btn-gold:hover {
  transform: translateY(-2px);
}

.btn-ghost {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Tablet */
@media (min-width: 768px) {
  :root {
    --space-xs: 6px;
    --space-sm: 10px;
    --space-md: 16px;
    --space-lg: 20px;
    --space-xl: 32px;
  }

  .main-tabs {
    max-width: 500px;
    margin: 0 auto;
  }

  .pills {
    justify-content: center;
  }

  .card {
    width: 140px;
  }

  .card-poster {
    width: 140px;
    height: 210px;
  }

  .detail-panel {
    max-width: 600px;
    margin: 0 auto;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .app-container {
    max-width: 1200px;
    margin: 0 auto;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
  }

  .topbar {
    padding: var(--space-lg) var(--space-xl) var(--space-md);
  }

  .logo {
    font-size: 28px;
  }

  .card {
    width: 160px;
  }

  .card-poster {
    width: 160px;
    height: 240px;
  }

  .grid-wrap {
    padding: var(--space-lg) var(--space-xl) var(--space-xl);
  }

  .detail-panel {
    max-width: 700px;
  }

  .player-overlay {
    max-width: 100vw;
  }

  .player-frame {
    max-width: 1200px;
    margin: 0 auto;
  }
}

/* Large Desktop */
@media (min-width: 1440px) {
  .app-container {
    max-width: 1400px;
  }
}

/* ===== UTILITY CLASSES ===== */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.center-spin {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

/* ===== PRINT STYLES ===== */
@media print {
  .topbar, .bottomnav, .main-tabs, .pills,
  #search-overlay, #watchlist-page,
  #player-overlay, #ad-overlay {
    display: none !important;
  }

  .detail-panel {
    transform: none !important;
  }
}
