:root {
  --bg-color: #0a0a12;
  --card-bg: rgba(22, 18, 38, 0.7);
  --card-border: rgba(111, 99, 255, 0.2);
  --primary: #6f63ff;
  --primary-hover: #8377ff;
  --accent: #650ea0;
  --text-main: #f3f3f8;
  --text-muted: #9a9ab0;
  --danger: #ff4b6e;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(101, 14, 160, 0.22) 0%, transparent 45%),
    radial-gradient(circle at 85% 60%, rgba(111, 99, 255, 0.15) 0%, transparent 45%);
  background-attachment: fixed;
}

/* Header & Navigation */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 18, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: padding 0.3s ease;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-badge {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  padding: 0.4rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(111, 99, 255, 0.4);
}

.logo-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(to right, #ffffff, #e9d5ff, #c084fc);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-domain {
  color: #c084fc;
  font-weight: 300;
  font-size: 1.15rem;
  -webkit-text-fill-color: initial;
}

nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-btn:hover, 
.nav-btn.active {
  color: #fff;
  background: rgba(111, 99, 255, 0.15);
}

/* Main Container */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Search Section */
.search-container {
  max-width: 680px;
  margin: 1rem auto 2.5rem;
  position: relative;
}

.search-box {
  display: flex;
  align-items: center;
  background: rgba(22, 18, 38, 0.9);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 0.35rem 0.5rem 0.35rem 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(111, 99, 255, 0.3);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 1rem;
  width: 100%;
  padding: 0.6rem 0.4rem;
  font-family: inherit;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-btn {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none;
  color: #fff;
  padding: 0.7rem 1.2rem;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.search-btn:hover {
  transform: scale(1.02);
}

.direct-launch {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.direct-launch button {
  background: rgba(111, 99, 255, 0.1);
  border: 1px solid rgba(111, 99, 255, 0.2);
  color: var(--primary);
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.direct-launch button:hover {
  background: var(--primary);
  color: #fff;
}

/* Titles & Media Grid */
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-6px);
  border-color: var(--primary);
  box-shadow: 0 12px 30px rgba(111, 99, 255, 0.25);
}

.card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: #121020;
}

.card-body {
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.35rem;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-type {
  text-transform: uppercase;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
}

.card-rating {
  color: #ffd700;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

/* Modal Player */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 10, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: #0f0c1b;
  border: 1px solid var(--card-border);
  width: 100%;
  max-width: 950px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  position: relative;
}

.modal-header {
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.modal-close:hover {
  background: var(--danger);
}

.safeguard-bar {
  padding: 0.6rem 1.25rem;
  background: rgba(101, 14, 160, 0.25);
  border-bottom: 1px solid rgba(111, 99, 255, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #d1ccff;
  gap: 0.75rem;
}

.safeguard-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  white-space: nowrap;
}

.safeguard-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.player-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
}

.player-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.tv-controls {
  padding: 0.85rem 1.25rem;
  background: rgba(18, 14, 32, 0.8);
  display: flex;
  gap: 0.75rem;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
}

.tv-controls select {
  background: #181428;
  color: #fff;
  border: 1px solid var(--card-border);
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  outline: none;
  font-family: inherit;
  font-size: 0.85rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  header {
    padding: 0.75rem 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  nav {
    width: 100%;
    justify-content: space-between;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    -webkit-overflow-scrolling: touch;
  }

  .nav-btn {
    font-size: 0.82rem;
    padding: 0.4rem 0.6rem;
  }

  main {
    padding: 1rem 0.85rem;
  }

  .search-container {
    margin: 0.25rem auto 1.5rem;
  }

  .search-box input {
    font-size: 0.92rem;
  }

  .search-btn {
    padding: 0.6rem 0.9rem;
  }

  .search-btn span {
    display: none;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
    gap: 0.75rem;
  }

  .card-body {
    padding: 0.6rem;
  }

  .card-title {
    font-size: 0.82rem;
  }

  .card-meta {
    font-size: 0.7rem;
  }

  .modal {
    padding: 0.5rem;
  }

  .modal-content {
    border-radius: 12px;
    max-height: 94vh;
    overflow-y: auto;
  }

  .safeguard-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    text-align: center;
  }

  .safeguard-btn {
    width: 100%;
    padding: 0.45rem;
  }

  .tv-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .tv-controls select {
    width: 100%;
    padding: 0.65rem;
  }
}

@media (max-width: 360px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Genre Pills Horizontal Scroller */
.genre-container {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.2rem 0 1.5rem 0;
  margin-top: -1rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.genre-container::-webkit-scrollbar {
  display: none;
}

.genre-pill {
  background: rgba(22, 18, 38, 0.7);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.genre-pill:hover,
.genre-pill.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(111, 99, 255, 0.3);
}