:root {
  color-scheme: dark;
  --chrome: #0f172a;
  --bg: #070a12;
  --panel: #0f172a;
  --panel-2: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #8b5cf6;
  --accent-glow: rgba(139, 92, 246, 0.35);
  --cyan: #06b6d4;
  --mint: #10b981;
  --line: rgba(255, 255, 255, 0.08);
  --radius: 12px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  max-width: 100vw;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 5%, rgba(139, 92, 246, 0.18), transparent 32%),
    radial-gradient(circle at 12% 20%, rgba(6, 182, 212, 0.12), transparent 28%),
    linear-gradient(180deg, #0b1120 0%, #070a12 40%, #05070e 100%);
}

button {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(6px + env(safe-area-inset-top)) 6px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

#homeScreen.screen.is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100%;
}

/* Compact, perfectly filling video grid (8 videos per page) */
.video-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 6px;
  align-content: start;
  flex: 1;
  margin-bottom: 8px;
}

.video-grid.watched-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 4px;
}

.watched-grid .video-card {
  border-radius: 6px;
}

.watched-grid .card-info {
  padding: 2px 4px 4px;
}

.watched-grid .video-card-title {
  font-size: 0.62rem;
  line-height: 1.15;
  -webkit-line-clamp: 1;
}

.watched-grid .duration-badge {
  font-size: 0.52rem;
  padding: 1px 3px;
  bottom: 2px;
  right: 2px;
}

.watched-grid .view-badge {
  font-size: 0.52rem;
  padding: 1px 3px;
  bottom: 2px;
  left: 2px;
}

.watched-grid .view-badge svg {
  width: 7px;
  height: 7px;
}

.video-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.18s ease, box-shadow 0.18s ease;
  user-select: none;
}

.video-card:active {
  transform: scale(0.97);
}

.video-card:hover {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.2);
}

.poster-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #1e293b;
  overflow: hidden;
}

.poster-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

.video-card:hover .poster-wrap img {
  transform: scale(1.05);
}

.duration-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  padding: 1px 4px;
  font-size: 0.62rem;
  font-weight: 700;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  border-radius: 3px;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.view-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 1px 4px;
  font-size: 0.60rem;
  font-weight: 600;
  color: #f1f5f9;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  border-radius: 3px;
  line-height: 1.2;
}

.view-badge svg {
  width: 9px;
  height: 9px;
  fill: currentColor;
}

.card-info {
  padding: 4px 6px 6px;
}

.video-card-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.22;
  color: #f1f5f9;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Pagination Buttons (8 videos per page) */
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
  padding: 8px 0 6px;
}

.pager-button {
  min-width: 32px;
  min-height: 32px;
  padding: 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #cbd5e1;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.pager-button:hover:not(:disabled) {
  background: #334155;
  color: #ffffff;
}

.pager-button.is-active {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.pager-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Fluid Player Streaming Screen */
.player-screen {
  padding: 10px 0;
  animation: fadeIn 0.2s ease-out;
}

.player-header {
  margin-bottom: 12px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 0.86rem;
  font-weight: 700;
  color: #cbd5e1;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.back-btn:hover {
  background: #334155;
  color: #ffffff;
}

.back-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.player-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.fluid_button_download,
.fluid_button_theatre,
.fluid_button_theatre_collapse,
.fluid_button_miniplayer,
.fluid_button_pip {
  display: none !important;
}

.player-details {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}

.player-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  color: #f1f5f9;
}

.player-watched-note {
  margin: 6px 0 0;
  padding: 6px 8px;
  font-size: 0.68rem;
  line-height: 1.35;
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.6);
  border-left: 3px solid #8b5cf6;
  border-radius: 4px;
}

.player-watched-note strong {
  color: #c4b5fd;
}

/* In-Player Banner / Social Ad Box */
.player-banner-box {
  margin-top: 10px;
}

.social-banner-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(99, 102, 241, 0.16));
  border: 1px solid rgba(139, 92, 246, 0.45);
  border-radius: 10px;
  text-decoration: none;
  color: #ffffff;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.social-banner-btn:active {
  transform: scale(0.98);
}

.social-banner-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.social-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.social-banner-text strong {
  font-size: 0.80rem;
  font-weight: 700;
  color: #ffffff;
}

.social-banner-text small {
  font-size: 0.68rem;
  color: #cbd5e1;
}

.social-banner-action {
  font-size: 0.74rem;
  font-weight: 700;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.35);
  padding: 4px 10px;
  border-radius: 6px;
}

/* Fallback Unlocked Screen */
.unlocked-screen {
  padding: 20px 0;
}

.unlock-card {
  padding: 30px 18px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  text-align: center;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
}

.success-pill {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 20px;
  margin-bottom: 14px;
}

.unlock-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #a78bfa;
}

.unlock-icon svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.unlock-card h2 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  font-weight: 800;
  color: #ffffff;
}

.unlock-card p {
  margin: 0 0 20px;
  font-size: 0.9rem;
  color: #94a3b8;
}

.delivery-card {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 15px 16px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(139, 92, 246, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
}

.delivery-card:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(139, 92, 246, 0.5);
}

.delivery-card:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.delivery-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  margin-right: 12px;
  flex-shrink: 0;
}

.delivery-icon svg {
  width: 18px;
  height: 18px;
  fill: #ffffff;
}

.delivery-copy {
  flex: 1;
}

.delivery-copy strong {
  display: block;
  font-size: 0.94rem;
  font-weight: 700;
}

.delivery-copy small {
  display: block;
  font-size: 0.76rem;
  opacity: 0.85;
  margin-top: 2px;
}

.delivery-chevron {
  width: 18px;
  height: 18px;
  fill: #ffffff;
  opacity: 0.8;
}

.text-button {
  padding: 8px 16px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #94a3b8;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color 0.15s ease;
}

.text-button:hover {
  color: #f8fafc;
}

.error-text {
  margin-top: 12px;
  font-size: 0.82rem;
  color: #f87171;
}

/* Ad Loading Overlay */
.ad-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 10, 18, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.2s ease-out;
}

.ad-loading-overlay[hidden] {
  display: none !important;
}

.ad-loading-card {
  width: 100%;
  max-width: 330px;
  padding: 28px 20px;
  border-radius: 16px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.7);
}

.ad-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border: 3.5px solid rgba(139, 92, 246, 0.2);
  border-top-color: #8b5cf6;
  border-right-color: #06b6d4;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.ad-loading-card h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #f8fafc;
}

.ad-loading-card p {
  margin: 0 0 12px;
  font-size: 0.86rem;
  color: #94a3b8;
  line-height: 1.4;
}

.ad-skip-hint {
  display: inline-block;
  padding: 5px 12px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}


/* Watched Video Dimming & Badge */
.video-card.is-watched {
  opacity: 0.52;
  filter: saturate(0.7);
}

.video-card.is-watched:hover,
.video-card.is-watched:active {
  opacity: 0.88;
  filter: saturate(1);
}

.watched-tag {
  position: absolute;
  bottom: 4px;
  left: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  font-size: 0.60rem;
  font-weight: 600;
  color: #10b981;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(16, 185, 129, 0.4);
  backdrop-filter: blur(4px);
  border-radius: 3px;
  line-height: 1.2;
  z-index: 2;
}
