.tv-page {
  min-height: 100vh;
  background: transparent;
  padding-top: 24px;
}

.tv-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tv-header {
  margin-bottom: 1.5rem;
}

.tv-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.25rem;
}

.tv-subtitle {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.85rem;
}

.tv-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.filter-select {
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  min-width: 140px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none' stroke='%23fff' stroke-width='1.5' opacity='0.5'%3E%3Cpath d='M2.5 3.5l2.5 3 2.5-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2rem;
  transition: border-color 0.2s;
}

.filter-select:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.filter-select:focus {
  outline: none;
  border-color: rgba(255, 0, 102, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 0, 102, 0.08);
}

.filter-select option {
  background: #0a0e18;
  color: #fff;
}

.search-input {
  flex: 1;
  min-width: 160px;
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #fff;
  font-size: 0.85rem;
}

.search-input:focus {
  outline: none;
  border-color: rgba(255, 0, 102, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 0, 102, 0.08);
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.tv-stats {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.stat-item {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.8rem;
}

.stat-item strong {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
}

.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
}

.channel-card {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.04);
  contain: content;
}

.channel-card:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
  border-color: rgba(255, 0, 102, 0.15);
}

.channel-card:active {
  transform: scale(0.97);
}

.channel-logo-wrap {
  aspect-ratio: 16 / 9;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.04), transparent 50%),
    rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
}

.channel-logo {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.channel-logo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.2);
  text-align: center;
  padding: 0.3rem;
  word-break: break-word;
}

.channel-info {
  padding: 0.5rem 0.6rem 0.6rem;
  display: grid;
  gap: 0.15rem;
}

.channel-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.3);
}

.channel-quality {
  background: rgba(255, 0, 102, 0.15);
  color: rgba(255, 255, 255, 0.6);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.55rem;
  font-weight: 600;
}

.channels-sentinel {
  height: 1px;
  width: 100%;
}

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

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.06);
  border-top-color: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.no-channels {
  text-align: center;
  padding: 3rem 1rem;
  color: rgba(255, 255, 255, 0.3);
}

.no-channels svg {
  width: 40px;
  height: 40px;
  margin-bottom: 0.75rem;
  opacity: 0.2;
}

.no-channels p {
  font-size: 0.85rem;
}

.player-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.player-modal.active {
  display: flex;
}

.player-content {
  width: 100%;
  max-width: 1100px;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5);
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: rgba(255, 255, 255, 0.03);
}

.player-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.player-close {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

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

.player-sources {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.source-btn {
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.source-btn.active {
  background: rgba(255, 0, 102, 0.15);
  color: #fff;
  border-color: rgba(255, 0, 102, 0.3);
}

.source-btn:not(.active) {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.5);
  border-color: rgba(255, 255, 255, 0.06);
}

.source-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}

.player-iframe-wrap {
  width: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-iframe-wrap iframe {
  width: 100%;
  height: 75vh;
  border: none;
  display: block;
}

@media (max-width: 1023px) {
  .tv-container {
    padding: 0.75rem;
    padding-bottom: max(80px, env(safe-area-inset-bottom, 80px));
  }

  .tv-title {
    font-size: 1.15rem;
  }

  .tv-subtitle {
    font-size: 0.78rem;
  }

  .tv-filters {
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
  }

  .filter-select,
  .search-input {
    width: 100%;
    min-height: 38px;
    font-size: 0.82rem;
  }

  .channels-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }

  .channel-card {
    border-radius: 8px;
  }

  .channel-logo-wrap {
    padding: 0.4rem;
  }

  .channel-name {
    font-size: 0.68rem;
  }

  .channel-meta {
    font-size: 0.6rem;
  }

  .player-content {
    max-height: 100dvh;
  }

  .player-header {
    padding: 0.6rem 0.75rem;
  }

  .player-sources {
    padding: 0.6rem 0.75rem;
  }

  .player-modal {
    padding: 0;
    align-items: center;
  }

  .player-content {
    border-radius: 12px;
  }

  .player-iframe-wrap iframe {
    height: 60vh;
  }
}

@media (max-width: 560px) {
  .channels-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
