:root {
  --bg: #070a0f;
  --panel: rgba(18, 24, 33, 0.86);
  --panel-2: rgba(12, 16, 23, 0.72);
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-2: rgba(255, 255, 255, 0.14);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.62);
  --cyan: #3cf2ff;
  --amber: #ffb45b;
  --danger: #ff4d5f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  --radius: 18px;
  --radius-sm: 14px;
  --gap: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
    Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

body {
  overflow: hidden;
}

/* ── Player stage ── */
#player-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
}

#video-player {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0;
}

@media (max-width: 768px) {
  #video-player {
    width: 100vw;
    height: 100vh;
  }
}

.app {
  position: fixed;
  inset: 0;
}

.player-stage {
  position: fixed;
  inset: 0;
  background: radial-gradient(
      1200px 700px at 10% 0%,
      rgba(60, 242, 255, 0.12),
      transparent 60%
    ),
    radial-gradient(
      900px 500px at 100% 20%,
      rgba(255, 180, 91, 0.12),
      transparent 55%
    ),
    linear-gradient(
      180deg,
      rgba(0, 0, 0, 0.5),
      rgba(0, 0, 0, 0.1) 55%,
      rgba(0, 0, 0, 0.65)
    );
}

.player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.status {
  position: absolute;
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  bottom: calc(14px + var(--safe-bottom));
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.25;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  display: none;
}

.status.is-visible {
  display: block;
}

.status .ok {
  color: rgba(255, 255, 255, 0.85);
}

.status .warn {
  color: var(--amber);
}

.status .bad {
  color: var(--danger);
}

/* ── FAB ── */
.fab {
  position: fixed;
  top: calc(16px + var(--safe-top));
  right: calc(16px + var(--safe-right));
  width: 58px;
  height: 58px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 16, 23, 0.22);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 50;
}

.fab:active {
  transform: scale(0.98);
}

.fab-bars {
  width: 18px;
  height: 14px;
  display: grid;
  gap: 4px;
}

.fab-bars span {
  display: block;
  height: 2px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.92);
}

/* ── Menu ── */
.menu {
  position: fixed;
  width: min(380px, calc(100vw - 24px));
  height: min(72vh, 620px);
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
  z-index: 40;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  pointer-events: none;
  transition: opacity 160ms ease, transform 180ms ease;
}

.menu.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.menu-header {
  padding: 14px 14px 10px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0)
  );
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.brand-name {
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 14px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.menu-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tab {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 16, 23, 0.35);
  color: rgba(255, 255, 255, 0.84);
  border-radius: 999px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease,
    transform 140ms ease;
}

.tab:active {
  transform: scale(0.99);
}

.tab.is-active {
  border-color: rgba(60, 242, 255, 0.35);
  background: rgba(60, 242, 255, 0.12);
  color: rgba(255, 255, 255, 0.94);
}

.menu-body {
  position: relative;
  height: calc(100% - 96px);
}

.menu-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  color: rgba(255, 255, 255, 0.72);
}

.hidden {
  display: none !important;
}

#loading-indicator.hidden {
  display: none !important;
  pointer-events: none !important;
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-top-color: rgba(60, 242, 255, 0.95);
  animation: spin 800ms linear infinite;
  pointer-events: none;
}

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

/* ── Menu content – scrollable ── */
.menu-content {
  height: 100%;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scroll-behavior: smooth;
}

/* ── Channels header with sticky back ── */
.channels-header {
  position: sticky;
  top: -1px;
  z-index: 100;
  background: rgba(15, 15, 25, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  margin-bottom: 8px;
}

#back-btn {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 16, 23, 0.35);
  color: rgba(255, 255, 255, 0.86);
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 680;
  font-size: 13px;
  margin-top: 8px;
  transition: background 140ms ease, border-color 140ms ease;
}

#back-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(12, 16, 23, 0.5);
}

#back-btn:active {
  transform: scale(0.98);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 10px;
}

.section-title h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.86);
}

.section-title .chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 16, 23, 0.35);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.68);
}

.list {
  display: grid;
  gap: 10px;
}

.card {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-sm);
  padding: 12px;
  background: rgba(12, 16, 23, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  text-align: left;
  color: rgba(255, 255, 255, 0.9);
  transition: transform 130ms ease, border-color 130ms ease,
    background 130ms ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(12, 16, 23, 0.54);
}

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

.card.is-selected {
  border-color: rgba(60, 242, 255, 0.35);
  background: rgba(60, 242, 255, 0.08);
}

/* ── Neon border for selected channel ── */
.channel-item.active {
  border-radius: 14px;
  border: 2px solid white;
  animation: neonPulse 2s ease-in-out infinite;
  box-shadow: 0 0 8px white, 0 0 15px red, 0 0 25px lime, 0 0 35px white;
}

@keyframes neonPulse {
  0% {
    box-shadow: 0 0 5px white, 0 0 10px red, 0 0 20px lime;
  }
  50% {
    box-shadow: 0 0 10px white, 0 0 20px red, 0 0 35px lime;
  }
  100% {
    box-shadow: 0 0 5px white, 0 0 10px red, 0 0 20px lime;
  }
}

.card-img {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-main {
  min-width: 0;
}

.card-title {
  font-weight: 720;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sub {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fav-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 16, 23, 0.35);
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.fav-btn.is-on {
  border-color: rgba(255, 180, 91, 0.35);
  background: rgba(255, 180, 91, 0.12);
  color: rgba(255, 222, 175, 0.95);
}

.empty {
  padding: 18px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: rgba(12, 16, 23, 0.32);
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

/* ── Splash ── */
.splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 100;
  background: radial-gradient(
      1200px 800px at 30% 10%,
      rgba(60, 242, 255, 0.16),
      transparent 55%
    ),
    radial-gradient(
      1000px 700px at 80% 30%,
      rgba(255, 180, 91, 0.14),
      transparent 58%
    ),
    linear-gradient(180deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.88));
}

.splash-inner {
  display: grid;
  place-items: center;
  gap: 18px;
  padding: 24px;
}

.splash-logo {
  width: min(220px, 64vw);
  height: auto;
  filter: drop-shadow(0 20px 55px rgba(0, 0, 0, 0.65));
}

.splash-title {
  font-weight: 900;
  font-size: 26px;
  letter-spacing: 0.2em;
}

.splash-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.splash-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  animation: pulse 1.1s ease-in-out infinite;
}

.splash-dot:nth-child(2) {
  animation-delay: 0.12s;
}

.splash-dot:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes pulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  50% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.splash.is-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
}

@media (max-width: 520px) {
  .menu {
    height: min(78vh, 680px);
  }
}

/* ── Menu scroll & overflow ── */
#menu,
#side-menu {
  position: fixed;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#menu-overlay {
  pointer-events: none;
}

#menu-overlay.active {
  pointer-events: auto;
}
