:root {
  --bg: #08080c;
  --surface: #14141d;
  --surface-2: #1d1d2a;
  --accent: #ff2d55;
  --accent-glow: rgba(255, 45, 85, 0.35);
  --text: #ffffff;
  --muted: #a1a1b5;
  --ad-bar-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

/* Main App Shell: Full-viewport vertical column (Stage + Wide Ad Dock) */
.app-shell {
  width: 100%;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

/* Vertical 9:16 Stage */
.stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  background: #000;
  overflow: hidden;
}

.reel-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
}

.hidden-prefetch {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Top Bar */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: max(14px, env(safe-area-inset-top)) 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0) 100%);
  z-index: 10;
  pointer-events: none;
}

.brand-pill,
.ep-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(12, 12, 18, 0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.ep-pill {
  cursor: pointer;
}

/* Center Tap Indicator */
.tap-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  z-index: 12;
  pointer-events: none;
  animation: popFade 0.55s ease forwards;
}

@keyframes popFade {
  0% { opacity: 0.95; transform: translate(-50%, -50%) scale(0.85); }
  50% { opacity: 0.95; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); }
}

/* Loading & Tap-to-Start Overlays */
.loading-overlay,
.start-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 12, 0.62);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 14;
  border: none;
  color: #fff;
  cursor: pointer;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

.start-play-circle {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 8px 28px var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  padding-left: 4px;
}

.start-label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Right-Side Reels Action Rail */
.side-rail {
  position: absolute;
  right: 10px;
  bottom: 84px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 11;
}

.rail-btn {
  background: rgba(12, 12, 18, 0.56);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  width: 54px;
  padding: 9px 4px;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.rail-btn:active {
  transform: scale(0.92);
  background: rgba(255, 45, 85, 0.35);
}

.rail-icon {
  font-size: 19px;
  line-height: 1;
}

.rail-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

/* Bottom Meta & 60s Progress Bar */
.bottom-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 14px 10px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
  z-index: 9;
  pointer-events: none;
}

.meta-text {
  padding-right: 68px;
  margin-bottom: 10px;
}

.series-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.episode-subtitle {
  margin-top: 3px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
}

.progress-track {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s linear;
}

/* Persistent Wide Clickable On-Screen Ad Bar */
.wide-ad-dock {
  flex: 0 0 var(--ad-bar-height);
  width: 100%;
  height: var(--ad-bar-height);
  background: #101018;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
  overflow: hidden;
}

.wide-ad-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Full-Screen Post-Episode Ad Banner Gate (5s Skip / 15s Auto-Next) */
.ad-gate {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 14, 0.96);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.ad-gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
}

.ad-gate-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ad-tag {
  background: #f59e0b;
  color: #111;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.06em;
}

.ad-upnext {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.ad-timer-bar {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.ad-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), #ff7a45);
  transition: width 1s linear;
}

.ad-gate-slot {
  width: 100%;
  min-height: 270px;
  background: #0c0c14;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-iframe-interstitial {
  width: 100%;
  height: 270px;
  border: 0;
  display: block;
}

.ad-gate-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.ad-auto-text {
  font-size: 12px;
  color: var(--muted);
}

.ad-auto-text strong {
  color: #fff;
}

.skip-btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 20px var(--accent-glow);
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.skip-btn:disabled {
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
}

.skip-btn:not(:disabled):active {
  transform: scale(0.97);
}

/* Slide-Up Drawers (Episodes & Series) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.drawer-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 70dvh;
  background: var(--surface);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header h2 {
  font-size: 17px;
  font-weight: 700;
}

.drawer-close {
  background: var(--surface-2);
  color: #fff;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
}

.episodes-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  overflow-y: auto;
  padding-bottom: 12px;
}

.ep-cell {
  padding: 12px 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface-2);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.ep-cell.active {
  background: var(--accent);
  border-color: var(--accent);
}

.series-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-bottom: 12px;
}

.series-item {
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface-2);
  color: #fff;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.series-item.active {
  border-color: var(--accent);
  background: rgba(255, 45, 85, 0.16);
}

.series-item-title {
  font-size: 15px;
  font-weight: 700;
}

.series-item-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
