:root {
  --bg-primary: #0a0a0c;
  --bg-secondary: #141418;
  --bg-surface: #1e1e24;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --danger: #ef4444;
  --border: rgba(255, 255, 255, 0.08);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-family);
  overflow: hidden;
  user-select: none;
}

.embed-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  max-width: 100%;
  background-color: var(--bg-primary);
}

/* Header */
.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 16px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-text {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.9rem;
  color: #fff;
}

.badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge.movi { color: #60a5fa; border-color: rgba(96, 165, 250, 0.3); }
.badge.torrent { color: #34d399; border-color: rgba(52, 211, 153, 0.3); }

.metadata-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.metadata-summary h1 {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
}

.episode-badge {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

/* Viewport & 16:9 Canvas */
.player-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: calc(100% - 96px);
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.player-mount video {
  width: 100%;
  height: 100%;
  max-height: 100%;
  outline: none;
  object-fit: contain;
}

/* Overlays */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 12, 0.94);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
  transition: opacity 0.2s ease;
}

.overlay.hidden {
  display: none !important;
  opacity: 0;
}

.overlay.active {
  display: flex !important;
  opacity: 1;
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

#loading-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Error UI */
.error-box {
  max-width: 420px;
  text-align: center;
}

.error-icon {
  width: 48px;
  height: 48px;
  color: var(--danger);
  margin-bottom: 12px;
}

.error-box h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.error-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

/* Torrent File Selector Modal */
.selector-box {
  width: 100%;
  max-width: 500px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  max-height: 80%;
  display: flex;
  flex-direction: column;
}

.selector-box h3 {
  font-size: 0.9rem;
  margin-bottom: 12px;
  color: var(--text-main);
}

.file-list {
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}

.file-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
}

.file-size {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: 12px;
}

/* Bottom Controls */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 16px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 10;
}

.nav-cluster, .action-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-cluster {
  flex: 1;
  text-align: center;
  padding: 0 16px;
}

.status-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.control-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.control-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.control-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.control-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.control-btn.primary:hover {
  background: var(--accent-hover);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .desktop-only { display: none; }
  .player-header { padding: 0 12px; }
  .player-controls { padding: 0 12px; }
}
/* Server & Subserver Selectors */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.server-control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.server-label {
  font-size: 0.75rem;
  color: #8a8a93;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.server-select {
  background: #18181c;
  color: #ededed;
  border: 1px solid #2e2e36;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.server-select:hover,
.server-select:focus {
  border-color: #646cff;
  background: #202026;
}

/* Turnstile widget positioning inside loading overlay */
.turnstile-box {
  margin-top: 16px;
  min-height: 65px;
  display: flex;
  justify-content: center;
  align-items: center;
}
